Java 类hudson.model.ModelObject 实例源码

项目:browserstack-integration-plugin    文件:BrowserStackCredentials.java   
@CheckForNull
private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) {
    for (CredentialsStore store : CredentialsProvider.lookupStores(object)) {
        if (!store.hasPermission(CredentialsProvider.VIEW)) {
            continue;
        }
        ModelObject storeContext = store.getContext();
        for (Domain domain : store.getDomains()) {
            if (CredentialsMatchers.firstOrNull(store.getCredentials(domain), CredentialsMatchers.withId(value))
                    != null) {
                if (storeContext == context) {
                    return FormValidation.error("This ID is already in use");
                } else {
                    return FormValidation.warning("The ID ‘%s’ is already in use in %s", value,
                            storeContext instanceof Item
                                    ? ((Item) storeContext).getFullDisplayName()
                                    : storeContext.getDisplayName());
                }
            }
        }
    }
    return null;
}
项目:browserstack-integration-plugin    文件:BrowserStackCredentials.java   
public final FormValidation doCheckId(@QueryParameter String value, @AncestorInPath ModelObject context) {
    if (value.isEmpty()) {
        return FormValidation.ok();
    }
    if (!value.matches("[a-zA-Z0-9_.-]+")) { // anything else considered kosher?
        return FormValidation.error("Unacceptable characters");
    }
    FormValidation problem = checkForDuplicates(value, context, context);
    if (problem != null) {
        return problem;
    }
    if (!(context instanceof User)) {
        User me = User.current();
        if (me != null) {
            problem = checkForDuplicates(value, context, me);
            if (problem != null) {
                return problem;
            }
        }
    }
    if (!(context instanceof Jenkins)) {
        // CredentialsProvider.lookupStores(User) does not return SystemCredentialsProvider.
        Jenkins j = Jenkins.getInstance();
        if (j != null) {
            problem = checkForDuplicates(value, context, j);
            if (problem != null) {
                return problem;
            }
        }
    }
    return FormValidation.ok();
}
项目:browserstack-integration-plugin    文件:BrowserStackCredentials.java   
/**
 * @return always returns false since the scope of Local credentials are always Global.
 */
@SuppressWarnings("unused") // used by stapler
public boolean isScopeRelevant(ModelObject object) {
    return false;
}