Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package hudson.plugins.collabnet.share;
  
  import hudson.Extension;
  import hudson.model.Job;
  
 
 
 
The TeamForgeShare descriptor holds global data to be shared with other extension points. It's not really a JobProperty, and it'd be neater to define it's own ExtensionPoint class, but the Hudson configure page does not show global.jelly for arbitrary extension types.
 
 public class TeamForgeShare extends JobProperty<Job<?, ?>> {

    
 
     @Override
         return (TeamForgeShareDescriptor)Hudson.getInstance().
             getDescriptor(getClass());
     }

    
Static version of the above getDescriptor method. The above can't be static because it's inherited.
 
         return (TeamForgeShareDescriptor)Hudson.getInstance().
             getDescriptor(TeamForgeShare.class);
     }
 
     @Extension
     public static final class TeamForgeShareDescriptor 
         extends JobPropertyDescriptor {
         private static Logger log = Logger.getLogger("TeamForgeShareDescriptor");
         private String collabNetUrl = null;
         private String username = null;
         private String password = null;
         private boolean useGlobal = false;
     
         public TeamForgeShareDescriptor() {
             super(TeamForgeShare.class);
             load();
         }
 
         @Override
         public String getDisplayName() {
             return "Global CollabNet Teamforge Configuration";
         }

        
This should never show up in any jobs since it's only for global configuration.
 
         @Override
         public boolean isApplicable(Class<? extends JobjobType) {
             return false;
         }
     
         @Override
         public boolean configure(StaplerRequest staplerRequestJSONObject jsonthrows FormException {
             if (json.has("useglobal")) {
                 this. = true;
                 JSONObject config = json.getJSONObject("useglobal");
                  = CNHudsonUtil.sanitizeCollabNetUrl(config.getString("collabneturl"));
                  = config.getString("username");
                  = config.getString("password");
             } else {
                 this. = false;
                  = null;
                  = null;
                  = null;
             }
             save();
             return true
         }
 
         public boolean useGlobal() {
             return this.;
         }
 
         public String getCollabNetUrl() {
             return this.;
         }
        
        public String getUsername() {
            return this.;
        }
        
        public String getPassword() {
            return this.;
        }
        
        
Form validation for the CollabNet URL.

Parameters:
value url
        public FormValidation doCollabNetUrlCheck(@QueryParameter String value) {
            return CNFormFieldValidator.soapUrlCheck(value);
        }

        
Form validation for username.

Parameters:
value
name of field
        public FormValidation doRequiredCheck(
                @QueryParameter String value, @QueryParameter String name) {
            return CNFormFieldValidator.requiredCheck(valuename);
        }
        
        
Check that a password is present and allows login.

Parameters:
req StaplerRequest which contains parameters from the config.jelly.
        public FormValidation doPasswordCheck(StaplerRequest req) {
            return CNFormFieldValidator.loginCheck(req);
        }
        
    }
New to GrepCode? Check out our FAQ X