Skip to content

Commit

Permalink
[JENKINS-42877] Use class instead of interface for common Jelly files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evaristo Gutiérrez committed Apr 20, 2017
1 parent 199b408 commit 5f2811c
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 13 deletions.
Expand Up @@ -99,7 +99,7 @@ public String getIconUrl(String rootUrl) {
*/
@Restricted(NoExternalUse.class)
public Class getJellyFilesClass() {
return ConfigFilesUIContract.class;
return ConfigFilesUI.class;
}

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ public void doShow(StaplerRequest req, StaplerResponse rsp, @QueryParameter("id"
Config config = store.getById(confgiId);
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.getView(ConfigFilesUIContract.class, "show.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "show.jelly").forward(req, rsp);

}

Expand All @@ -179,7 +179,7 @@ public void doEditConfig(StaplerRequest req, StaplerResponse rsp, @QueryParamete
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.setAttribute("provider", config.getProvider());
req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "edit.jelly").forward(req, rsp);
}

/**
Expand Down Expand Up @@ -209,7 +209,7 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
checkPermission(Hudson.ADMINISTER);
req.setAttribute("providers", ConfigProvider.all());
req.setAttribute("configId", configId);
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "selectprovider.jelly").forward(req, rsp);
return;
}

Expand All @@ -229,14 +229,14 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
config.setProviderId(provider.getProviderId());
req.setAttribute("config", config);

req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "edit.jelly").forward(req, rsp);
}

public void doSelectProvider(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(Hudson.ADMINISTER);
req.setAttribute("providers", ConfigProvider.all());
req.setAttribute("configId", UUID.randomUUID().toString());
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "selectprovider.jelly").forward(req, rsp);
}

private void checkPermission(Permission permission) {
Expand Down
@@ -0,0 +1,8 @@
package org.jenkinsci.plugins.configfiles;

/**
* Blank class just to define a common place where to serve the views for Config Files
*
*/
public class ConfigFilesUI {
}
Expand Up @@ -4,7 +4,6 @@
import hudson.Extension;
import hudson.Util;
import hudson.model.Action;
import hudson.model.Hudson;
import hudson.model.Job;
import hudson.security.Permission;
import hudson.util.FormValidation;
Expand All @@ -17,6 +16,7 @@
import org.jenkinsci.plugins.configfiles.ConfigFilesManagement;
import org.jenkinsci.plugins.configfiles.ConfigFilesUIContract;
import org.jenkinsci.plugins.configfiles.Messages;
import org.jenkinsci.plugins.configfiles.ConfigFilesUI;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.*;
Expand Down Expand Up @@ -58,7 +58,7 @@ public String getIconUrl(String rootUrl) {
*/
@Restricted(NoExternalUse.class)
public Class getJellyFilesClass() {
return ConfigFilesUIContract.class;
return ConfigFilesUI.class;
}

@Override
Expand Down Expand Up @@ -136,7 +136,7 @@ public void doShow(StaplerRequest req, StaplerResponse rsp, @QueryParameter("id"
Config config = getStore().getById(confgiId);
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.getView(ConfigFilesUIContract.class, "show.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "show.jelly").forward(req, rsp);
}

@Override
Expand All @@ -146,7 +146,7 @@ public void doEditConfig(StaplerRequest req, StaplerResponse rsp, @QueryParamete
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.setAttribute("provider", config.getProvider());
req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "edit.jelly").forward(req, rsp);
}


Expand All @@ -166,7 +166,7 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
checkPermission(Job.CONFIGURE);
req.setAttribute("providers", getProviders());
req.setAttribute("configId", configId);
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "selectprovider.jelly").forward(req, rsp);
return;
}

Expand All @@ -186,15 +186,15 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
config.setProviderId(provider.getProviderId());
req.setAttribute("config", config);

req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "edit.jelly").forward(req, rsp);
}

@Override
public void doSelectProvider(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {;
checkPermission(Job.CONFIGURE);
req.setAttribute("providers", getProviders());
req.setAttribute("configId", UUID.randomUUID().toString());
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUI.class, "selectprovider.jelly").forward(req, rsp);
}

@Override
Expand Down

0 comments on commit 5f2811c

Please sign in to comment.