package org.jenkinsci.plugins.p4.browsers; import hudson.Extension; import hudson.Util; import hudson.model.Descriptor; import hudson.scm.RepositoryBrowser; import hudson.util.FormValidation; import java.io.IOException; import java.net.URL; import javax.servlet.ServletException; import net.sf.json.JSONObject; import org.jenkinsci.plugins.p4.changes.P4ChangeEntry; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import com.perforce.p4java.core.IJob; import com.perforce.p4java.core.file.FileAction; import com.perforce.p4java.core.file.IFileSpec; public class P4WebBrowser extends P4Browser { private static final long serialVersionUID = 1L; public final URL url; // 'ac' stands for action and corresponds to a unique screen in P4Web public final String p4FileEnd = "?ac=22"; // file contents screen public final String p4DiffEnd = "?ac=19"; // file comparison screen public final String p4ChangeEnd = "?ac=10"; // change list content screen public final String p4JobEnd = "?ac=111"; // job content screen public final String p4LabelEnd = "?ac=16"; // label content screen @DataBoundConstructor public P4WebBrowser(URL url) { this.url = normalizeToEndWithSlash(url); } @Override public URL getChangeSetLink(P4ChangeEntry changeSet) throws IOException { return new URL(url.toString() + changeSet.getId() + p4ChangeEnd); } public URL getLabelSetLink(P4ChangeEntry changeSet) throws IOException { return new URL(url.toString() + changeSet.getId() + p4LabelEnd); } @Override public URL getDiffLink(IFileSpec file) throws Exception { if (file.getAction() != FileAction.EDIT && file.getAction() != FileAction.INTEGRATE) { return null; } int r = file.getEndRevision(); if (r <= 1) { return null; } return new URL(url.toString() + file.getDepotPathString() + p4DiffEnd + "&rev1=" + (r - 1) + "&rev2=" + (r)); } @Override public URL getFileLink(IFileSpec file) throws Exception { return new URL(url.toString() + file.getDepotPathString() + p4FileEnd); } @Override public URL getJobLink(String job) throws Exception { return new URL(url.toString() + job + p4JobEnd); } @Extension public static class DescriptorImpl extends Descriptor<RepositoryBrowser<?>> { @Override public String getDisplayName() { return "P4Web browser"; } public FormValidation doCheck(@QueryParameter final String value) throws IOException, ServletException { String url = Util.fixEmpty(value); if (url == null) { return FormValidation.ok(); } if (!url.startsWith("http://") && !url.startsWith("https://")) { return FormValidation .errorWithMarkup("The URL should contain <tt>http://</tt> or <tt>https://</tt>"); } return FormValidation.ok(); } @Override public P4WebBrowser newInstance(StaplerRequest req, JSONObject formData) throws FormException { return req.bindParameters(P4WebBrowser.class, "p4web."); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19599 | mparfianowicz | "Forking branch Main of p4-jenkins to mparfianowicz-p4jenkins." | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/browsers/P4WebBrowser.java | |||||
#3 | 19581 | Paul Allen | Minor fixes to satisfy FindBugs Analysis. | ||
#2 | 16409 | Paul Allen |
Use Fix records for Job information. 'p4 fixes' is lighter and still provides enough useful data. Includes jelly fix and extra job data in changelog.xml. |
||
#1 | 9690 | Paul Allen |
[Branching using p4-jenkins] Release 1.0.1 |
||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4/browsers/P4WebBrowser.java | |||||
#1 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4_client/browsers/P4WebBrowser.java | |||||
#1 | 9127 | Paul Allen |
Added Browser support for P4Web. - Includes fix for move/add and move/delete icons when browsing change lists. |