summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java108
1 files changed, 54 insertions, 54 deletions
diff --git a/pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java b/pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java
index 4100b465..f5810a46 100644
--- a/pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java
+++ b/pki/base/common/src/com/netscape/cms/listeners/RequestInQListener.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.listeners;
+
import java.io.IOException;
import java.util.Hashtable;
@@ -38,6 +39,7 @@ import com.netscape.certsrv.request.RequestId;
import com.netscape.cms.profile.input.SubjectNameInput;
import com.netscape.cms.profile.input.SubmitterInfoInput;
+
/**
* a listener for every request gets into the request queue.
* <p>
@@ -52,7 +54,7 @@ import com.netscape.cms.profile.input.SubmitterInfoInput;
* <LI>$SenderEmail
* <LI>$RecipientEmail
* </UL>
- *
+ *
*/
public class RequestInQListener implements IRequestListener {
protected static final String PROP_ENABLED = "enabled";
@@ -87,8 +89,8 @@ public class RequestInQListener implements IRequestListener {
* initializes the listener from the configuration
*/
public void init(ISubsystem sub, IConfigStore config)
- throws EListenersException, EPropertyNotFound, EBaseException {
-
+ throws EListenersException, EPropertyNotFound, EBaseException {
+
mSubsystem = (ICertAuthority) sub;
mConfig = mSubsystem.getConfigStore();
@@ -99,13 +101,11 @@ public class RequestInQListener implements IRequestListener {
mSenderEmail = rq.getString(PROP_SENDER_EMAIL);
if (mSenderEmail == null) {
- throw new EListenersException(
- CMS.getLogMessage("NO_NOTIFY_SENDER_EMAIL_CONFIG_FOUND"));
+ throw new EListenersException(CMS.getLogMessage("NO_NOTIFY_SENDER_EMAIL_CONFIG_FOUND"));
}
mRecipientEmail = rq.getString(PROP_RECVR_EMAIL);
if (mRecipientEmail == null) {
- throw new EListenersException(
- CMS.getLogMessage("NO_NOTIFY_RECVR_EMAIL_CONFIG_FOUND"));
+ throw new EListenersException(CMS.getLogMessage("NO_NOTIFY_RECVR_EMAIL_CONFIG_FOUND"));
}
mEmailSubject = rq.getString(PROP_EMAIL_SUBJECT);
@@ -118,34 +118,32 @@ public class RequestInQListener implements IRequestListener {
// make available http host and port for forming url in templates
mHttpHost = CMS.getAgentHost();
mAgentPort = CMS.getAgentPort();
- if (mAgentPort == null)
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("LISTENERS_REQUEST_PORT_NOT_FOUND"));
+ if (mAgentPort == null)
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("LISTENERS_REQUEST_PORT_NOT_FOUND"));
else
CMS.debug("RequestInQuListener: agentport = " + mAgentPort);
- // register for this event listener
+ // register for this event listener
mSubsystem.registerPendingListener(this);
}
/**
* carries out the operation when the listener is triggered.
- *
* @param r IRequest structure holding the request information
* @see com.netscape.certsrv.request.IRequest
*/
public void accept(IRequest r) {
- if (mEnabled != true)
- return;
+ if (mEnabled != true) return;
- // regardless of type of request...notify for everything
- // no need for email resolver here...
+ // regardless of type of request...notify for everything
+ // no need for email resolver here...
IMailNotification mn = CMS.getMailNotification();
mn.setFrom(mSenderEmail);
mn.setTo(mRecipientEmail);
- mn.setSubject(mEmailSubject + " (request id: " + r.getRequestId() + ")");
+ mn.setSubject(mEmailSubject + " (request id: " +
+ r.getRequestId() + ")");
/*
* get form file from disk
@@ -157,11 +155,10 @@ public class RequestInQListener implements IRequestListener {
*/
if (template != null) {
if (!template.init()) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("LISTENERS_TEMPLATE_NOT_INIT"));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("LISTENERS_TEMPLATE_NOT_INIT"));
return;
}
-
+
buildContentParams(r);
IEmailFormProcessor et = CMS.getEmailFormProcessor();
String c = et.getEmailContent(template.toString(), mContentParams);
@@ -172,8 +169,8 @@ public class RequestInQListener implements IRequestListener {
mn.setContent(c);
} else {
// log and mail
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("LISTENERS_TEMPLATE_NOT_GET"));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("LISTENERS_TEMPLATE_NOT_GET"));
mn.setContent("Template not retrievable for Request in Queue notification");
}
@@ -181,77 +178,79 @@ public class RequestInQListener implements IRequestListener {
mn.sendNotification();
} catch (ENotificationException e) {
// already logged, lets audit
- mLogger.log(ILogger.EV_AUDIT, null, ILogger.S_OTHER,
- ILogger.LL_FAILURE,
- CMS.getLogMessage("OPERATION_ERROR", e.toString()));
-
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER, ILogger.LL_FAILURE,
- CMS.getLogMessage("LISTENERS_SEND_FAILED", e.toString()));
+ mLogger.log(ILogger.EV_AUDIT, null,
+ ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString()));
+
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE,
+ CMS.getLogMessage("LISTENERS_SEND_FAILED", e.toString()));
} catch (IOException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("LISTENERS_SEND_FAILED", e.toString()));
+ CMS.getLogMessage("LISTENERS_SEND_FAILED", e.toString()));
}
}
private void buildContentParams(IRequest r) {
mContentParams.clear();
- mContentParams.put(IEmailFormProcessor.TOKEN_ID, mConfig.getName());
+ mContentParams.put(IEmailFormProcessor.TOKEN_ID,
+ mConfig.getName());
Object val = null;
String profileId = r.getExtDataInString("profileId");
if (profileId == null) {
- val = r.getExtDataInString(IRequest.HTTP_PARAMS,
- "csrRequestorEmail");
+ val = r.getExtDataInString(IRequest.HTTP_PARAMS, "csrRequestorEmail");
} else {
- // use the submitter info if available, otherwise, use the
- // subject name input email
- val = r.getExtDataInString(SubmitterInfoInput.EMAIL);
+ // use the submitter info if available, otherwise, use the
+ // subject name input email
+ val = r.getExtDataInString(SubmitterInfoInput.EMAIL);
- if ((val == null) || (((String) val).compareTo("") == 0)) {
- val = r.getExtDataInString(SubjectNameInput.VAL_EMAIL);
- }
+ if ((val == null) || (((String) val).compareTo("") == 0)) {
+ val = r.getExtDataInString(SubjectNameInput.VAL_EMAIL);
+ }
}
if (val != null)
- mContentParams.put(IEmailFormProcessor.TOKEN_REQUESTOR_EMAIL, val);
+ mContentParams.put(IEmailFormProcessor.TOKEN_REQUESTOR_EMAIL,
+ val);
if (profileId == null) {
- val = r.getExtDataInString(IRequest.HTTP_PARAMS, IRequest.CERT_TYPE);
+ val = r.getExtDataInString(IRequest.HTTP_PARAMS, IRequest.CERT_TYPE);
} else {
- val = profileId;
+ val = profileId;
}
if (val != null) {
- mContentParams.put(IEmailFormProcessor.TOKEN_CERT_TYPE, val);
+ mContentParams.put(IEmailFormProcessor.TOKEN_CERT_TYPE,
+ val);
}
RequestId reqId = r.getRequestId();
mContentParams.put(IEmailFormProcessor.TOKEN_REQUEST_ID,
- (Object) reqId.toString());
+ (Object) reqId.toString());
mContentParams.put(IEmailFormProcessor.TOKEN_ID, mId);
val = r.getRequestType();
if (val != null)
- mContentParams.put(IEmailFormProcessor.TOKEN_REQUEST_TYPE, val);
+ mContentParams.put(IEmailFormProcessor.TOKEN_REQUEST_TYPE,
+ val);
mContentParams.put(IEmailFormProcessor.TOKEN_HTTP_HOST,
- (Object) mHttpHost);
+ (Object) mHttpHost);
mContentParams.put(IEmailFormProcessor.TOKEN_HTTP_PORT,
- (Object) mAgentPort);
+ (Object) mAgentPort);
mContentParams.put(IEmailFormProcessor.TOKEN_SENDER_EMAIL,
- (Object) mSenderEmail);
+ (Object) mSenderEmail);
mContentParams.put(IEmailFormProcessor.TOKEN_RECIPIENT_EMAIL,
- (Object) mRecipientEmail);
+ (Object) mRecipientEmail);
}
/**
* sets the configurable parameters
- *
- * @param name a String represents the name of the configuration parameter
- * to be set
+ * @param name a String represents the name of the configuration parameter to be set
* @param val a String containing the value to be set for name
*/
public void set(String name, String val) {
@@ -270,14 +269,15 @@ public class RequestInQListener implements IRequestListener {
} else if (name.equalsIgnoreCase(PROP_EMAIL_TEMPLATE)) {
mFormPath = val;
} else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("LISTENERS_CERT_ISSUED_SET"));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("LISTENERS_CERT_ISSUED_SET"));
}
}
private void log(int level, String msg) {
if (mLogger == null)
return;
- mLogger.log(ILogger.EV_SYSTEM, null, ILogger.S_OTHER, level, msg);
+ mLogger.log(ILogger.EV_SYSTEM, null, ILogger.S_OTHER,
+ level, msg);
}
}
+