Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package hudson.plugins.collabnet.browser;
  
  import hudson.Extension;
 
 import java.net.URL;
 
 public class TeamForge extends SubversionRepositoryBrowser {
     private static Logger log = Logger.getLogger("TeamForge");
 
     private String collabneturl;
     private String username;
     private String password;
     private String project;
     private String repo;
     private boolean overrideAuth;
 
     private transient static TeamForgeShare.TeamForgeShareDescriptor 
         shareDescriptor = null;

    
DataBoundConstructor for building the object from form data.
 
     public TeamForge(String collabneturlString usernameString password
                      String projectString repoOverrideAuth override_auth
     { 
         if (override_auth != null) {
             this. = true;
             this. = override_auth.collabneturl;
             this. = override_auth.username;
             this. = override_auth.password;
         } else {
             if (collabneturl == null && username == null && password == null) {
                 this. = false;
             } else {
                 this. = true;
                 this. = CNHudsonUtil.sanitizeCollabNetUrl(collabneturl);
                 this. = username;
                 this. = password;
             }
         }
         this. = project;
         this. = repo;
     }
    
    
Simple constructors for rebuilding the object from config data.
 
     public TeamForge(String collabneturlString usernameString password
                      String projectString repoboolean overrideAuth) {
         this. = CNHudsonUtil.sanitizeCollabNetUrl(collabneturl);
         this. = username;
         this. = password;
         this. = project;
         this. = repo;
         this. = overrideAuth;
     }
 
     public TeamForge(String projectString repoboolean overrideAuth) {
         this(nullnullnullprojectrepooverrideAuth);
     }
 
     @Extension
     public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
 
     @Override
     public DescriptorImpl getDescriptor() {
         return ;
     }

    

Returns:
whether or not auth is overriden
 
     public boolean overrideAuth() {
         return this.;
     }

    

Returns:
the collabneturl for the CollabNet server.
 
     public String getCollabNetUrl() {
        if (this.overrideAuth()) {
            return this.;
        } else {
            return getTeamForgeShareDescriptor().getCollabNetUrl();
        }
    }

    

Returns:
the username used for logging in.
    public String getUsername() {
        if (this.overrideAuth()) {
            return this.;            
        } else {
            return getTeamForgeShareDescriptor().getUsername();
        }
    }

    

Returns:
the password used for logging in.
    public String getPassword() {
        if (this.overrideAuth()) {
            return this.;
        } else {
            return getTeamForgeShareDescriptor().getPassword();
        }
    }
    public String getProject() {
        return this.;
    }
    public String getRepo() {
        return this.;
    }

    

Returns:
the TeamForge share descriptor.
        getTeamForgeShareDescriptor() {
        if ( == null) {
             = TeamForgeShare.getTeamForgeShareDescriptor();
        }
        return ;
    }

    

Returns:
the list of all possible projects, given the login data.
    public String[] getProjects() {
        CollabNetApp cna = CNHudsonUtil.getCollabNetApp(this.getCollabNetUrl(),
                                                        this.getUsername(), 
                                                        this.getPassword());
        Collection<Stringprojects = ComboBoxUpdater.ProjectsUpdater
            .getProjectList(cna);
        CNHudsonUtil.logoff(cna);
        return projects.toArray(new String[0]);
    }

    

Returns:
the list of all possible repos, given the login and project.
    public String[] getRepos() {
        CollabNetApp cna = CNHudsonUtil.getCollabNetApp(this.getCollabNetUrl(),
                                                        this.getUsername(), 
                                                        this.getPassword());
        Collection<Stringrepos = ComboBoxUpdater.ReposUpdater
            .getRepoList(cnathis.getProject());
        CNHudsonUtil.logoff(cna);
        return repos.toArray(new String[0]);
    }
    public URL getFileLink(SubversionChangeLogSet.Path path
        throws IOException {
        StringBuffer link = getViewerUrlWithPath(path).append("&system=")
            .append(this.getSystemId()).append("&view=markup");
        return new URL(link.toString());
    }
    public URL getDiffLink(SubversionChangeLogSet.Path path
        throws IOException {
        int revision = path.getLogEntry().getRevision();
        int r1 = revision - 1;
        int r2 = revision
        
        StringBuffer link = getViewerUrlWithPath(path).append("&system=")
            .append(this.getSystemId()).append("&r1=").append(r1)
            .append("&r2=").append(r2);
        return new URL(link.toString());
    }
                                              path) {
        String[] urlParts = this.getViewerUrl().split("\\?");
        StringBuffer viewWithPath = new StringBuffer(urlParts[0])
            .append(path.getValue()).append("?").append(urlParts[1]);
        return viewWithPath;
    }
        throws IOException {
        int revision = changeSet.getRevision();
        StringBuffer link = new StringBuffer(this.getViewerUrl())
            .append("?view=revision&system=")
            .append(this.getSystemId()).append("&revision=").append(revision);
        return new URL(link.toString());
    }

    
Get the viewer url to display to the user.

Returns:
the viewer url
    private String getViewerUrl() {
        CollabNetApp cna = CNHudsonUtil.getCollabNetApp(this.getCollabNetUrl(), 
                                                        this.getUsername(), 
                                                        this.getPassword());
        return CNHudsonUtil.getScmViewerUrl(cnagetCollabNetUrl(), this.getProject(), 
                                            this.getRepo());
    }
    private String getSystemId() {
        CollabNetApp cna = CNHudsonUtil.getCollabNetApp(this.getCollabNetUrl(), 
                                                        this.getUsername(), 
                                                        this.getPassword());
        return CNHudsonUtil.getSystemId(cnathis.getProject(), 
                                        this.getRepo());
    }
    public static final class DescriptorImpl 
        extends Descriptor<RepositoryBrowser<?>> {
        public DescriptorImpl() {
            super(TeamForge.class);
        }
        public String getDisplayName() {
            return "Collabnet TeamForge";
        }

        

Returns:
the url that contains the help files.
        public static String getHelpUrl() {
            return "/plugin/collabnet/browser/";
        }

        

Returns:
a relative url to the main help file.
        @Override
        public String getHelpFile() {
            return getHelpUrl() + "help-main.html";
        }

        

Returns:
true if there is auth data that can be inherited.
        public boolean canInheritAuth() {
            return getTeamForgeShareDescriptor().useGlobal();
        }

        
Form validation for the CollabNet URL.

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

        
Form validation for username.

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

Parameters:
req contains parameters from the config.jelly.
        public FormValidation doPasswordCheck(StaplerRequest req) {
            return CNFormFieldValidator.loginCheck(req);
        }
        
        
Form validation for the project field.

Parameters:
req contains parameters from the config.jelly.
        public FormValidation doProjectCheck(StaplerRequest req) {
            return CNFormFieldValidator.projectCheck(req);
        }

        
Form validation for the repo field.

Parameters:
req contains parameters from the config.jelly.
Throws:
javax.servlet.ServletException
        public FormValidation doRepoCheck(StaplerRequest req) {
            return CNFormFieldValidator.repoCheck(req);
        }

        
Gets a list of projects to choose from and write them as a JSON string into the response data.

Parameters:
req contains parameters from the config.jelly.
rsp http response data.
Throws:
java.io.IOException
        public void doGetProjects(StaplerRequest reqStaplerResponse rsp
            throws IOException {
            new ComboBoxUpdater.ProjectsUpdater(reqrsp).update();
        }

        
Gets a list of repos to choose from and write them as a JSON string into the response data.

Parameters:
req contains parameters from the config.jelly.
rsp http response data.
Throws:
java.io.IOException
        public void doGetRepos(StaplerRequest reqStaplerResponse rsp
            throws IOException {
            new ComboBoxUpdater.ReposUpdater(reqrsp).update();
        }
    }
New to GrepCode? Check out our FAQ X