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 net.sf.json.JSONObject; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.changes.P4AffectedFile; import org.jenkinsci.plugins.p4.changes.P4ChangeEntry; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import javax.servlet.ServletException; import java.io.IOException; import java.net.URL; public class P4WebBrowser extends P4Browser { private static final long serialVersionUID = 1L; // '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(String url) { super(url); } @Override public URL getChangeSetLink(P4ChangeEntry changeSet) throws IOException { return new URL(getSafeUrl().toString() + changeSet.getId() + p4ChangeEnd); } public URL getLabelSetLink(P4ChangeEntry changeSet) throws IOException { return new URL(getSafeUrl().toString() + changeSet.getId() + p4LabelEnd); } @Override public URL getDiffLink(P4AffectedFile file, String change) throws Exception { if (!file.getAction().equalsIgnoreCase("edit")) { return null; } int rev = parseRevision(file); if(rev <= 1) { // nothing to diff return null; } return new URL(getSafeUrl().toString() + file.getPath() + p4DiffEnd + "&rev1=" + (rev - 1) + "&rev2=" + (rev)); } @Override public URL getFileLink(P4AffectedFile file) throws Exception { return new URL(getSafeUrl().toString() + file.getPath() + p4FileEnd); } @Override public URL getJobLink(String job) throws Exception { return new URL(getSafeUrl().toString() + job + p4JobEnd); } @Extension @Symbol("p4Web") 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 jsonObject) throws FormException { return (req == null) ? null : req.bindJSON(P4WebBrowser.class, jsonObject); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 24698 | Paul Allen | Fix for the revision number used by Swarm and other browsers. | ||
#8 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#7 | 22375 | Paul Allen | Add null check for findbugs. | ||
#6 | 22372 | Paul Allen |
Update Repository Browser for use with Pipeline. May fix the following: JENKINS-43069 JENKINS-37094 |
||
#5 | 22128 | Paul Allen |
Helix Graph support for Jenkins. JENKINS-40354 |
||
#4 | 21132 | Paul Allen | FindBugs: Null Pointer Checks | ||
#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. |