summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2011-12-08 21:15:59 -0500
committerAde Lee <alee@redhat.com>2011-12-08 21:15:59 -0500
commit171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch)
tree1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java
parentadad2fcee8a29fdb82376fbce07dedb11fccc182 (diff)
downloadpki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz
pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz
pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java592
1 files changed, 317 insertions, 275 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java b/pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java
index a4b82b13a..7f18d94e5 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/admin/JobsAdminServlet.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.admin;
+
import java.io.IOException;
import java.util.Enumeration;
import java.util.Locale;
@@ -41,9 +42,10 @@ import com.netscape.certsrv.jobs.IJobsScheduler;
import com.netscape.certsrv.jobs.JobPlugin;
import com.netscape.certsrv.logging.ILogger;
+
/**
- * A class representing an administration servlet for the Jobs Scheduler and
- * it's scheduled jobs.
+ * A class representing an administration servlet for the
+ * Jobs Scheduler and it's scheduled jobs.
*
* @version $Revision$, $Date$
*/
@@ -73,23 +75,24 @@ public class JobsAdminServlet extends AdminServlet {
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
- mJobsSched = (IJobsScheduler) CMS.getSubsystem(CMS.SUBSYSTEM_JOBS);
+ mJobsSched = (IJobsScheduler)
+ CMS.getSubsystem(CMS.SUBSYSTEM_JOBS);
}
/**
* Returns serlvet information.
*/
- public String getServletInfo() {
- return INFO;
+ public String getServletInfo() {
+ return INFO;
}
- /**
- * retrieve extended plugin info such as brief description, type info from
- * jobs
+ /**
+ * retrieve extended plugin info such as brief description, type info
+ * from jobs
*/
private void getExtendedPluginInfo(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException,
- EBaseException {
+ HttpServletResponse resp) throws ServletException,
+ IOException, EBaseException {
String id = req.getParameter(Constants.RS_ID);
int colon = id.indexOf(':');
@@ -97,18 +100,18 @@ public class JobsAdminServlet extends AdminServlet {
String implType = id.substring(0, colon);
String implName = id.substring(colon + 1);
- NameValuePairs params = getExtendedPluginInfo(getLocale(req), implType,
- implName);
+ NameValuePairs params =
+ getExtendedPluginInfo(getLocale(req), implType, implName);
sendResponse(SUCCESS, null, params, resp);
}
- private NameValuePairs getExtendedPluginInfo(Locale locale,
- String implType, String implName) {
+ private NameValuePairs getExtendedPluginInfo(Locale locale, String implType, String implName) {
IExtendedPluginInfo ext_info = null;
Object impl = null;
- JobPlugin jp = (JobPlugin) mJobsSched.getPlugins().get(implName);
+ JobPlugin jp =
+ (JobPlugin) mJobsSched.getPlugins().get(implName);
if (jp != null)
impl = getClassByNameAsExtendedPluginInfo(jp.getClassPath());
@@ -123,8 +126,7 @@ public class JobsAdminServlet extends AdminServlet {
if (ext_info == null) {
nvps = new NameValuePairs();
} else {
- nvps = convertStringArrayToNVPairs(ext_info
- .getExtendedPluginInfo(locale));
+ nvps = convertStringArrayToNVPairs(ext_info.getExtendedPluginInfo(locale));
}
return nvps;
@@ -135,24 +137,25 @@ public class JobsAdminServlet extends AdminServlet {
* Serves HTTP admin request.
*/
public void service(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ throws ServletException, IOException {
super.service(req, resp);
String scope = req.getParameter(Constants.OP_SCOPE);
String op = req.getParameter(Constants.OP_TYPE);
if (op == null) {
- // System.out.println("SRVLT_INVALID_PROTOCOL");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_PROTOCOL"), null, resp);
+ //System.out.println("SRVLT_INVALID_PROTOCOL");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_PROTOCOL"),
+ null, resp);
return;
}
try {
super.authenticate(req);
} catch (IOException e) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_AUTHS_FAILED"), null, resp);
+ sendResponse(ERROR,CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHS_FAILED"),
+ null, resp);
return;
}
@@ -161,8 +164,9 @@ public class JobsAdminServlet extends AdminServlet {
if (op.equals(OpDef.OP_READ)) {
mOp = "read";
if ((mToken = super.authorize(req)) == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"),
+ null, resp);
return;
}
if (scope.equals(ScopeDef.SC_JOBS))
@@ -170,26 +174,27 @@ public class JobsAdminServlet extends AdminServlet {
else if (scope.equals(ScopeDef.SC_JOBS_IMPLS))
getConfig(req, resp);
else if (scope.equals(ScopeDef.SC_JOBS_INSTANCE))
- getInstConfig(req, resp);
+ getInstConfig(req, resp);
else if (scope.equals(ScopeDef.SC_EXTENDED_PLUGIN_INFO)) {
- try {
- getExtendedPluginInfo(req, resp);
- } catch (EBaseException e) {
- sendResponse(ERROR, e.toString(getLocale(req)), null,
- resp);
- return;
+ try {
+ getExtendedPluginInfo(req, resp);
+ } catch (EBaseException e) {
+ sendResponse(ERROR, e.toString(getLocale(req)), null, resp);
+ return;
}
} else {
- // System.out.println("SRVLT_INVALID_OP_SCOPE");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"), null, resp);
+ //System.out.println("SRVLT_INVALID_OP_SCOPE");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"),
+ null, resp);
return;
}
} else if (op.equals(OpDef.OP_MODIFY)) {
mOp = "modify";
if ((mToken = super.authorize(req)) == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"),
+ null, resp);
return;
}
if (scope.equals(ScopeDef.SC_JOBS)) {
@@ -197,15 +202,17 @@ public class JobsAdminServlet extends AdminServlet {
} else if (scope.equals(ScopeDef.SC_JOBS_INSTANCE)) {
modJobsInst(req, resp, scope);
} else {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"),
+ null, resp);
return;
}
} else if (op.equals(OpDef.OP_SEARCH)) {
mOp = "read";
if ((mToken = super.authorize(req)) == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"),
+ null, resp);
return;
}
if (scope.equals(ScopeDef.SC_JOBS_IMPLS))
@@ -213,16 +220,18 @@ public class JobsAdminServlet extends AdminServlet {
else if (scope.equals(ScopeDef.SC_JOBS_INSTANCE))
listJobsInsts(req, resp);
else {
- // System.out.println("SRVLT_INVALID_OP_SCOPE");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"), null, resp);
+ //System.out.println("SRVLT_INVALID_OP_SCOPE");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"),
+ null, resp);
return;
}
} else if (op.equals(OpDef.OP_ADD)) {
mOp = "modify";
if ((mToken = super.authorize(req)) == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"),
+ null, resp);
return;
}
if (scope.equals(ScopeDef.SC_JOBS_IMPLS))
@@ -230,16 +239,18 @@ public class JobsAdminServlet extends AdminServlet {
else if (scope.equals(ScopeDef.SC_JOBS_INSTANCE))
addJobsInst(req, resp, scope);
else {
- // System.out.println("SRVLT_INVALID_OP_SCOPE");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"), null, resp);
+ //System.out.println("SRVLT_INVALID_OP_SCOPE");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"),
+ null, resp);
return;
}
} else if (op.equals(OpDef.OP_DELETE)) {
mOp = "modify";
if ((mToken = super.authorize(req)) == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_AUTHZ_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_AUTHZ_FAILED"),
+ null, resp);
return;
}
if (scope.equals(ScopeDef.SC_JOBS_IMPLS))
@@ -247,54 +258,58 @@ public class JobsAdminServlet extends AdminServlet {
else if (scope.equals(ScopeDef.SC_JOBS_INSTANCE))
delJobsInst(req, resp, scope);
else {
- // System.out.println("SRVLT_INVALID_OP_SCOPE");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"), null, resp);
+ //System.out.println("SRVLT_INVALID_OP_SCOPE");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_OP_SCOPE"),
+ null, resp);
return;
}
} else {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_INVALID_OP_TYPE", op), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_INVALID_OP_TYPE", op),
+ null, resp);
return;
}
} catch (EBaseException e) {
sendResponse(ERROR, e.toString(getLocale(req)), null, resp);
return;
- }
+ }
}
- private synchronized void addJobPlugin(HttpServletRequest req,
- HttpServletResponse resp, String scope) throws ServletException,
- IOException, EBaseException {
+ private synchronized void addJobPlugin(HttpServletRequest req,
+ HttpServletResponse resp, String scope)
+ throws ServletException, IOException, EBaseException {
String id = req.getParameter(Constants.RS_ID);
if (id == null) {
- // System.out.println("SRVLT_NULL_RS_ID");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ //System.out.println("SRVLT_NULL_RS_ID");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
// is the job plugin id unique?
if (mJobsSched.getPlugins().containsKey((Object) id)) {
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ILL_JOB_PLUGIN_ID", id)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ILL_JOB_PLUGIN_ID", id)).toString(),
+ null, resp);
return;
}
String classPath = req.getParameter(Constants.PR_JOBS_CLASS);
if (classPath == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_NULL_CLASS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_NULL_CLASS"),
+ null, resp);
return;
}
- IConfigStore destStore = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
- IConfigStore instancesConfig = destStore.getSubStore(scope);
+ IConfigStore destStore =
+ mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
+ IConfigStore instancesConfig =
+ destStore.getSubStore(scope);
// Does the class exist?
Class newImpl = null;
@@ -302,25 +317,29 @@ public class JobsAdminServlet extends AdminServlet {
try {
newImpl = Class.forName(classPath);
} catch (ClassNotFoundException e) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_NO_CLASS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_NO_CLASS"),
+ null, resp);
return;
} catch (IllegalArgumentException e) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_NO_CLASS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_NO_CLASS"),
+ null, resp);
return;
}
// is the class an IJob?
try {
if (IJob.class.isAssignableFrom(newImpl) == false) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ILL_CLASS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ILL_CLASS"),
+ null, resp);
return;
}
} catch (NullPointerException e) { // unlikely, only if newImpl null.
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ILL_CLASS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ILL_CLASS"),
+ null, resp);
return;
}
@@ -332,9 +351,10 @@ public class JobsAdminServlet extends AdminServlet {
try {
mConfig.commit(true);
} catch (EBaseException e) {
- // System.out.println("SRVLT_FAIL_COMMIT");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_COMMIT_FAILED"), null, resp);
+ //System.out.println("SRVLT_FAIL_COMMIT");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_COMMIT_FAILED"),
+ null, resp);
return;
}
@@ -342,8 +362,8 @@ public class JobsAdminServlet extends AdminServlet {
JobPlugin plugin = new JobPlugin(id, classPath);
mJobsSched.getPlugins().put(id, plugin);
- mJobsSched.log(ILogger.LL_INFO,
- CMS.getLogMessage("ADMIN_SRVLT_JS_PLUGIN_ADD", id));
+ mJobsSched.log(ILogger.LL_INFO,
+ CMS.getLogMessage("ADMIN_SRVLT_JS_PLUGIN_ADD", id));
NameValuePairs params = new NameValuePairs();
@@ -351,22 +371,24 @@ public class JobsAdminServlet extends AdminServlet {
return;
}
- private synchronized void addJobsInst(HttpServletRequest req,
- HttpServletResponse resp, String scope) throws ServletException,
- IOException, EBaseException {
+ private synchronized void addJobsInst(HttpServletRequest req,
+ HttpServletResponse resp, String scope)
+ throws ServletException, IOException, EBaseException {
String id = req.getParameter(Constants.RS_ID);
if (id == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
// is the job instance id unique?
if (mJobsSched.getInstances().containsKey((Object) id)) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ILL_JOB_INST_ID"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ILL_JOB_INST_ID"),
+ null, resp);
return;
}
@@ -376,20 +398,22 @@ public class JobsAdminServlet extends AdminServlet {
String implname = req.getParameter(Constants.PR_JOBS_IMPL_NAME);
if (implname == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ADD_MISSING_PARAMS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ADD_MISSING_PARAMS"),
+ null, resp);
return;
}
// check if implementation exists.
- JobPlugin plugin = (JobPlugin) mJobsSched.getPlugins().get(implname);
+ JobPlugin plugin =
+ (JobPlugin) mJobsSched.getPlugins().get(implname);
if (plugin == null) {
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_JOB_PLUGIN_NOT_FOUND", id))
- .toString(), null, resp);
+ sendResponse(ERROR,
+ new
+ EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_JOB_PLUGIN_NOT_FOUND",
+ id)).toString(),
+ null, resp);
return;
}
@@ -398,8 +422,10 @@ public class JobsAdminServlet extends AdminServlet {
// are there, but not checking the values are valid
String[] configParams = mJobsSched.getConfigParams(implname);
- IConfigStore destStore = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
- IConfigStore instancesConfig = destStore.getSubStore(scope);
+ IConfigStore destStore =
+ mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
+ IConfigStore instancesConfig =
+ destStore.getSubStore(scope);
IConfigStore substore = instancesConfig.makeSubStore(id);
if (configParams != null) {
@@ -410,13 +436,11 @@ public class JobsAdminServlet extends AdminServlet {
if (val != null && !val.equals("")) {
substore.put(key, val);
} else if (!key.equals("profileId")) {
- sendResponse(
- ERROR,
- new EJobsException(
- CMS.getUserMessage(
- getLocale(req),
- "CMS_JOB_SRVLT_MISSING_INST_PARAM_VAL",
- key)).toString(), null, resp);
+ sendResponse(ERROR,
+ new
+ EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_MISSING_INST_PARAM_VAL",
+ key)).toString(),
+ null, resp);
return;
}
}
@@ -433,32 +457,29 @@ public class JobsAdminServlet extends AdminServlet {
} catch (ClassNotFoundException e) {
// cleanup
instancesConfig.removeSubStore(id);
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
+ null, resp);
return;
} catch (InstantiationException e) {
instancesConfig.removeSubStore(id);
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
+ null, resp);
return;
} catch (IllegalAccessException e) {
instancesConfig.removeSubStore(id);
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
+ null, resp);
return;
}
-
- IJobsScheduler scheduler = (IJobsScheduler) CMS
- .getSubsystem(CMS.SUBSYSTEM_JOBS);
+
+ IJobsScheduler scheduler = (IJobsScheduler)
+ CMS.getSubsystem(CMS.SUBSYSTEM_JOBS);
// initialize the job plugin
try {
@@ -476,16 +497,17 @@ public class JobsAdminServlet extends AdminServlet {
} catch (EBaseException e) {
// clean up.
instancesConfig.removeSubStore(id);
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_COMMIT_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_COMMIT_FAILED"),
+ null, resp);
return;
}
// inited and commited ok. now add manager instance to list.
mJobsSched.getInstances().put(id, jobsInst);
- mJobsSched.log(ILogger.LL_INFO,
- CMS.getLogMessage("ADMIN_SRVLT_JOB_INST_ADD", id));
+ mJobsSched.log(ILogger.LL_INFO,
+ CMS.getLogMessage("ADMIN_SRVLT_JOB_INST_ADD", id));
NameValuePairs params = new NameValuePairs();
@@ -494,93 +516,101 @@ public class JobsAdminServlet extends AdminServlet {
return;
}
- private synchronized void listJobPlugins(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException,
- EBaseException {
+ private synchronized void listJobPlugins(HttpServletRequest req,
+ HttpServletResponse resp) throws ServletException,
+ IOException, EBaseException {
NameValuePairs params = new NameValuePairs();
Enumeration e = mJobsSched.getPlugins().keys();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
- JobPlugin value = (JobPlugin) mJobsSched.getPlugins().get(name);
+ JobPlugin value = (JobPlugin)
+ mJobsSched.getPlugins().get(name);
params.add(name, value.getClassPath());
- // params.add(name, value.getClassPath()+EDIT);
+ // params.add(name, value.getClassPath()+EDIT);
}
sendResponse(SUCCESS, null, params, resp);
return;
}
- private synchronized void listJobsInsts(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException,
- EBaseException {
+ private synchronized void listJobsInsts(HttpServletRequest req,
+ HttpServletResponse resp) throws ServletException,
+ IOException, EBaseException {
NameValuePairs params = new NameValuePairs();
- for (Enumeration e = mJobsSched.getInstances().keys(); e
- .hasMoreElements();) {
+ for (Enumeration e = mJobsSched.getInstances().keys();
+ e.hasMoreElements();) {
String name = (String) e.nextElement();
- IJob value = (IJob) mJobsSched.getInstances().get((Object) name);
+ IJob value = (IJob)
+ mJobsSched.getInstances().get((Object) name);
- // params.add(name, value.getImplName());
- params.add(name, value.getImplName() + VISIBLE
- + (value.isEnabled() ? ENABLED : DISABLED));
+ // params.add(name, value.getImplName());
+ params.add(name, value.getImplName() + VISIBLE +
+ (value.isEnabled() ? ENABLED : DISABLED)
+ );
}
sendResponse(SUCCESS, null, params, resp);
return;
}
- private synchronized void delJobPlugin(HttpServletRequest req,
- HttpServletResponse resp, String scope) throws ServletException,
+ private synchronized void delJobPlugin(HttpServletRequest req,
+ HttpServletResponse resp, String scope) throws ServletException,
IOException, EBaseException {
NameValuePairs params = new NameValuePairs();
String id = req.getParameter(Constants.RS_ID);
if (id == null) {
- // System.out.println("SRVLT_NULL_RS_ID");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ //System.out.println("SRVLT_NULL_RS_ID");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
// does this job plugin exist?
if (mJobsSched.getPlugins().containsKey(id) == false) {
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_JOB_PLUGIN_NOT_FOUND", id))
- .toString(), null, resp);
+ sendResponse(ERROR,
+ new
+ EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_JOB_PLUGIN_NOT_FOUND",
+ id)).toString(),
+ null, resp);
return;
}
// first check if any instances from this job plugin
// DON'T remove job plugin if any instance
- for (Enumeration e = mJobsSched.getInstances().elements(); e
- .hasMoreElements();) {
+ for (Enumeration e = mJobsSched.getInstances().elements();
+ e.hasMoreElements();) {
IJob jobs = (IJob) e.nextElement();
if ((jobs.getImplName()).equals(id)) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_JOB_IN_USE"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_JOB_IN_USE"),
+ null, resp);
return;
}
}
-
+
// then delete this job plugin
mJobsSched.getPlugins().remove((Object) id);
- IConfigStore destStore = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
- IConfigStore instancesConfig = destStore.getSubStore(scope);
+ IConfigStore destStore =
+ mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
+ IConfigStore instancesConfig =
+ destStore.getSubStore(scope);
instancesConfig.removeSubStore(id);
// commiting
try {
mConfig.commit(true);
} catch (EBaseException e) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_COMMIT_FAILED"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_COMMIT_FAILED"),
+ null, resp);
return;
}
@@ -588,49 +618,52 @@ public class JobsAdminServlet extends AdminServlet {
return;
}
- private synchronized void delJobsInst(HttpServletRequest req,
- HttpServletResponse resp, String scope) throws ServletException,
+ private synchronized void delJobsInst(HttpServletRequest req,
+ HttpServletResponse resp, String scope) throws ServletException,
IOException, EBaseException {
NameValuePairs params = new NameValuePairs();
String id = req.getParameter(Constants.RS_ID);
if (id == null) {
- // System.out.println("SRVLT_NULL_RS_ID");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ //System.out.println("SRVLT_NULL_RS_ID");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
// does job plugin instance exist?
if (mJobsSched.getInstances().containsKey(id) == false) {
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_JOB_NOT_FOUND", id)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_JOB_NOT_FOUND",
+ id)).toString(),
+ null, resp);
return;
}
// only remove from memory
// cannot shutdown because we don't keep track of whether it's
- // being used.
+ // being used.
IJob jobInst = (IJob) mJobsSched.getInstances().get(id);
mJobsSched.getInstances().remove((Object) id);
// remove the configuration.
- IConfigStore destStore = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
- IConfigStore instancesConfig = destStore.getSubStore(scope);
+ IConfigStore destStore =
+ mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
+ IConfigStore instancesConfig =
+ destStore.getSubStore(scope);
instancesConfig.removeSubStore(id);
// commiting
try {
mConfig.commit(true);
} catch (EBaseException e) {
- // System.out.println("SRVLT_FAIL_COMMIT");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_COMMIT_FAILED"), null, resp);
+ //System.out.println("SRVLT_FAIL_COMMIT");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_COMMIT_FAILED"),
+ null, resp);
return;
}
@@ -639,23 +672,25 @@ public class JobsAdminServlet extends AdminServlet {
}
/**
- * used for getting the required configuration parameters (with possible
- * default values) for a particular job plugin implementation name specified
- * in the RS_ID. Actually, there is no logic in here to set any default
- * value here...there's no default value for any parameter in this job
- * scheduler subsystem at this point. Later, if we do have one (or some), it
- * can be added. The interface remains the same.
+ * used for getting the required configuration parameters (with
+ * possible default values) for a particular job plugin
+ * implementation name specified in the RS_ID. Actually, there is
+ * no logic in here to set any default value here...there's no
+ * default value for any parameter in this job scheduler subsystem
+ * at this point. Later, if we do have one (or some), it can be
+ * added. The interface remains the same.
*/
- private synchronized void getConfig(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException,
- EBaseException {
+ private synchronized void getConfig(HttpServletRequest req,
+ HttpServletResponse resp)
+ throws ServletException, IOException, EBaseException {
String implname = req.getParameter(Constants.RS_ID);
if (implname == null) {
- // System.out.println("SRVLT_NULL_RS_ID");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ //System.out.println("SRVLT_NULL_RS_ID");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
@@ -673,25 +708,25 @@ public class JobsAdminServlet extends AdminServlet {
return;
}
- private synchronized void getInstConfig(HttpServletRequest req,
- HttpServletResponse resp) throws ServletException, IOException,
- EBaseException {
+ private synchronized void getInstConfig(HttpServletRequest req,
+ HttpServletResponse resp) throws ServletException,
+ IOException, EBaseException {
String id = req.getParameter(Constants.RS_ID);
if (id == null) {
- // System.out.println("SRVLT_NULL_RS_ID");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ //System.out.println("SRVLT_NULL_RS_ID");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
// does job plugin instance exist?
if (mJobsSched.getInstances().containsKey(id) == false) {
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_JOB_NOT_FOUND", id)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_JOB_NOT_FOUND",
+ id)).toString(),
+ null, resp);
return;
}
@@ -722,30 +757,34 @@ public class JobsAdminServlet extends AdminServlet {
}
/**
- * Modify job plugin instance. This will actually create a new instance with
- * new configuration parameters and replace the old instance, if the new
- * instance created and initialized successfully. The old instance is left
- * running. so this is very expensive. Restart of server recommended.
+ * Modify job plugin instance.
+ * This will actually create a new instance with new configuration
+ * parameters and replace the old instance, if the new instance
+ * created and initialized successfully.
+ * The old instance is left running. so this is very expensive.
+ * Restart of server recommended.
*/
- private synchronized void modJobsInst(HttpServletRequest req,
- HttpServletResponse resp, String scope) throws ServletException,
- IOException, EBaseException {
+ private synchronized void modJobsInst(HttpServletRequest req,
+ HttpServletResponse resp, String scope)
+ throws ServletException, IOException, EBaseException {
// expensive operation.
String id = req.getParameter(Constants.RS_ID);
if (id == null) {
- // System.out.println("SRVLT_NULL_RS_ID");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_NULL_RS_ID"), null, resp);
+ //System.out.println("SRVLT_NULL_RS_ID");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_NULL_RS_ID"),
+ null, resp);
return;
}
// Does the job instance exist?
if (!mJobsSched.getInstances().containsKey((Object) id)) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ILL_JOB_INST_ID"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ILL_JOB_INST_ID"),
+ null, resp);
return;
}
@@ -753,26 +792,28 @@ public class JobsAdminServlet extends AdminServlet {
String implname = req.getParameter(Constants.PR_JOBS_IMPL_NAME);
if (implname == null) {
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_ADD_MISSING_PARAMS"), null, resp);
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_ADD_MISSING_PARAMS"),
+ null, resp);
return;
}
- // get plugin for implementation
- JobPlugin plugin = (JobPlugin) mJobsSched.getPlugins().get(implname);
+ // get plugin for implementation
+ JobPlugin plugin =
+ (JobPlugin) mJobsSched.getPlugins().get(implname);
if (plugin == null) {
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_SRVLT_JOB_PLUGIN_NOT_FOUND", id))
- .toString(), null, resp);
+ sendResponse(ERROR,
+ new EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_JOB_PLUGIN_NOT_FOUND",
+ id)).toString(),
+ null, resp);
return;
}
- // save old instance substore params in case new one fails.
+ // save old instance substore params in case new one fails.
- IJob oldinst = (IJob) mJobsSched.getInstances().get((Object) id);
+ IJob oldinst =
+ (IJob) mJobsSched.getInstances().get((Object) id);
IConfigStore oldConfig = oldinst.getConfigStore();
String[] oldConfigParms = oldinst.getConfigParams();
@@ -780,7 +821,7 @@ public class JobsAdminServlet extends AdminServlet {
// implName is always required so always include it it.
saveParams.add(IJobsScheduler.PROP_PLUGIN,
- (String) oldConfig.get(IJobsScheduler.PROP_PLUGIN));
+ (String) oldConfig.get(IJobsScheduler.PROP_PLUGIN));
if (oldConfigParms != null) {
for (int i = 0; i < oldConfigParms.length; i++) {
String key = oldConfigParms[i];
@@ -796,8 +837,10 @@ public class JobsAdminServlet extends AdminServlet {
// remove old substore.
- IConfigStore destStore = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
- IConfigStore instancesConfig = destStore.getSubStore(scope);
+ IConfigStore destStore =
+ mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
+ IConfigStore instancesConfig =
+ destStore.getSubStore(scope);
instancesConfig.removeSubStore(id);
@@ -817,13 +860,11 @@ public class JobsAdminServlet extends AdminServlet {
substore.put(key, val);
} else if (!key.equals("profileId")) {
restore(instancesConfig, id, saveParams);
- sendResponse(
- ERROR,
- new EJobsException(
- CMS.getUserMessage(
- getLocale(req),
- "CMS_JOB_SRVLT_MISSING_INST_PARAM_VAL",
- key)).toString(), null, resp);
+ sendResponse(ERROR,
+ new
+ EJobsException(CMS.getUserMessage(getLocale(req),"CMS_JOB_SRVLT_MISSING_INST_PARAM_VAL",
+ key)).toString(),
+ null, resp);
return;
}
}
@@ -838,34 +879,31 @@ public class JobsAdminServlet extends AdminServlet {
} catch (ClassNotFoundException e) {
// cleanup
restore(instancesConfig, id, saveParams);
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
+ null, resp);
return;
} catch (InstantiationException e) {
restore(instancesConfig, id, saveParams);
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
+ null, resp);
return;
} catch (IllegalAccessException e) {
restore(instancesConfig, id, saveParams);
- sendResponse(
- ERROR,
- new EJobsException(CMS.getUserMessage(getLocale(req),
- "CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
- null, resp);
+ sendResponse(ERROR,
+ new EJobsException(
+ CMS.getUserMessage(getLocale(req),"CMS_JOB_LOAD_CLASS_FAILED", className)).toString(),
+ null, resp);
return;
}
// initialize the job plugin
- IJobsScheduler scheduler = (IJobsScheduler) CMS
- .getSubsystem(CMS.SUBSYSTEM_JOBS);
+ IJobsScheduler scheduler = (IJobsScheduler)
+ CMS.getSubsystem(CMS.SUBSYSTEM_JOBS);
try {
newJobInst.init(scheduler, id, implname, substore);
@@ -881,16 +919,17 @@ public class JobsAdminServlet extends AdminServlet {
return;
}
- // initialized ok. commiting
+ // initialized ok. commiting
try {
mConfig.commit(true);
} catch (EBaseException e) {
// clean up.
restore(instancesConfig, id, saveParams);
- // System.out.println("SRVLT_FAIL_COMMIT");
- sendResponse(ERROR, CMS.getUserMessage(getLocale(req),
- "CMS_ADMIN_SRVLT_COMMIT_FAILED"), null, resp);
+ //System.out.println("SRVLT_FAIL_COMMIT");
+ sendResponse(ERROR,
+ CMS.getUserMessage(getLocale(req), "CMS_ADMIN_SRVLT_COMMIT_FAILED"),
+ null, resp);
return;
}
@@ -898,8 +937,8 @@ public class JobsAdminServlet extends AdminServlet {
mJobsSched.getInstances().put(id, newJobInst);
- mJobsSched.log(ILogger.LL_INFO,
- CMS.getLogMessage("ADMIN_SRVLT_JOB_INST_REP", id));
+ mJobsSched.log(ILogger.LL_INFO,
+ CMS.getLogMessage("ADMIN_SRVLT_JOB_INST_REP", id));
NameValuePairs params = new NameValuePairs();
@@ -907,24 +946,26 @@ public class JobsAdminServlet extends AdminServlet {
return;
}
- private void getSettings(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException, EBaseException {
+ private void getSettings(HttpServletRequest req,
+ HttpServletResponse resp) throws ServletException,
+ IOException, EBaseException {
NameValuePairs params = new NameValuePairs();
IConfigStore config = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
- params.add(Constants.PR_ENABLE,
- config.getString(IJobsScheduler.PROP_ENABLED, Constants.FALSE));
+ params.add(Constants.PR_ENABLE,
+ config.getString(IJobsScheduler.PROP_ENABLED,
+ Constants.FALSE));
// default 1 minute
- params.add(Constants.PR_JOBS_FREQUENCY,
- config.getString(IJobsScheduler.PROP_INTERVAL, "1"));
+ params.add(Constants.PR_JOBS_FREQUENCY,
+ config.getString(IJobsScheduler.PROP_INTERVAL, "1"));
- // System.out.println("Send: "+params.toString());
+ //System.out.println("Send: "+params.toString());
sendResponse(SUCCESS, null, params, resp);
}
private void setSettings(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException, EBaseException {
- // Save New Settings to the config file
+ throws ServletException, IOException, EBaseException {
+ //Save New Settings to the config file
IConfigStore config = mConfig.getSubStore(DestDef.DEST_JOBS_ADMIN);
String enabled = config.getString(IJobsScheduler.PROP_ENABLED);
@@ -937,13 +978,14 @@ public class JobsAdminServlet extends AdminServlet {
config.putString(IJobsScheduler.PROP_ENABLED, enabledSetTo);
}
- // set frequency
- String interval = req.getParameter(Constants.PR_JOBS_FREQUENCY);
+ //set frequency
+ String interval =
+ req.getParameter(Constants.PR_JOBS_FREQUENCY);
if (interval != null) {
config.putString(IJobsScheduler.PROP_INTERVAL, interval);
- mJobsSched.setInterval(config
- .getInteger(IJobsScheduler.PROP_INTERVAL));
+ mJobsSched.setInterval(
+ config.getInteger(IJobsScheduler.PROP_INTERVAL));
}
if (enabledChanged == true) {
@@ -957,8 +999,8 @@ public class JobsAdminServlet extends AdminServlet {
}
// convenience routine.
- private static void restore(IConfigStore store, String id,
- NameValuePairs saveParams) {
+ private static void restore(IConfigStore store,
+ String id, NameValuePairs saveParams) {
store.removeSubStore(id);
IConfigStore rstore = store.makeSubStore(id);
@@ -968,7 +1010,7 @@ public class JobsAdminServlet extends AdminServlet {
String key = (String) keys.nextElement();
String value = saveParams.getValue(key);
- if (!value.equals(""))
+ if (!value.equals(""))
rstore.put(key, value);
}
}