summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.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/cmscore/notification/EmailFormProcessor.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/cmscore/notification/EmailFormProcessor.java')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java91
1 files changed, 51 insertions, 40 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java b/pki/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java
index a0e6bdb1..aa1fd15f 100644
--- a/pki/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java
+++ b/pki/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.notification;
+
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
@@ -26,12 +27,12 @@ import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.notification.IEmailFormProcessor;
+
/**
- * formulates the final email. Escape character '\' is understood. '$' is used
- * preceeding a token name. A token name should not be a substring of any other
- * token name
+ * formulates the final email. Escape character '\' is understood.
+ * '$' is used preceeding a token name. A token name should not be a
+ * substring of any other token name
* <p>
- *
* @author cfu
* @version $Revision$, $Date$
*/
@@ -47,14 +48,27 @@ public class EmailFormProcessor implements IEmailFormProcessor {
// stores all the available token keys; added so that we can
// parse strings to replace unresolvable token keys and replace
// them by the words "VALUE UNKNOWN"
- protected static String[] token_keys = { TOKEN_ID, TOKEN_SERIAL_NUM,
- TOKEN_HTTP_HOST, TOKEN_HTTP_PORT, TOKEN_ISSUER_DN,
- TOKEN_SUBJECT_DN, TOKEN_REQUESTOR_EMAIL, TOKEN_CERT_TYPE,
- TOKEN_REQUEST_TYPE, TOKEN_STATUS, TOKEN_NOT_AFTER,
- TOKEN_NOT_BEFORE, TOKEN_SENDER_EMAIL, TOKEN_RECIPIENT_EMAIL,
- TOKEN_SUMMARY_ITEM_LIST, TOKEN_SUMMARY_TOTAL_NUM,
- TOKEN_SUMMARY_SUCCESS_NUM, TOKEN_SUMMARY_FAILURE_NUM,
- TOKEN_EXECUTION_TIME };
+ protected static String[] token_keys = {
+ TOKEN_ID,
+ TOKEN_SERIAL_NUM,
+ TOKEN_HTTP_HOST,
+ TOKEN_HTTP_PORT,
+ TOKEN_ISSUER_DN,
+ TOKEN_SUBJECT_DN,
+ TOKEN_REQUESTOR_EMAIL,
+ TOKEN_CERT_TYPE,
+ TOKEN_REQUEST_TYPE,
+ TOKEN_STATUS,
+ TOKEN_NOT_AFTER,
+ TOKEN_NOT_BEFORE,
+ TOKEN_SENDER_EMAIL,
+ TOKEN_RECIPIENT_EMAIL,
+ TOKEN_SUMMARY_ITEM_LIST,
+ TOKEN_SUMMARY_TOTAL_NUM,
+ TOKEN_SUMMARY_SUCCESS_NUM,
+ TOKEN_SUMMARY_FAILURE_NUM,
+ TOKEN_EXECUTION_TIME
+ };
// stores the eventual content of the email
Vector mContent = new Vector();
@@ -64,29 +78,25 @@ public class EmailFormProcessor implements IEmailFormProcessor {
}
/*
- * takes the form template, parse and replace all $tokens with the right
- * values. It handles escape character '\'
- *
+ * takes the form template, parse and replace all $tokens with the
+ * right values. It handles escape character '\'
* @param form The locale specific form template,
- *
- * @param tok2vals a hashtable containing one to one mapping from $tokens
- * used by the admins in the form template to the real values corresponding
- * to the $tokens
- *
+ * @param tok2vals a hashtable containing one to one mapping
+ * from $tokens used by the admins in the form template to the real
+ * values corresponding to the $tokens
* @return mail content
*/
- public String getEmailContent(String form, Hashtable tok2vals) {
+ public String getEmailContent(String form,
+ Hashtable tok2vals) {
mTok2vals = tok2vals;
if (form == null) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("CMSCORE_NOTIFY_TEMPLATE_NULL"));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_NOTIFY_TEMPLATE_NULL"));
return null;
}
if (mTok2vals == null) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("CMSCORE_NOTIFY_TOKEN_NULL"));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_NOTIFY_TOKEN_NULL"));
return null;
}
@@ -94,11 +104,11 @@ public class EmailFormProcessor implements IEmailFormProcessor {
* first, take care of the escape characters '\'
*/
StringTokenizer es = new StringTokenizer(form, TOK_ESC);
-
+
if (es.hasMoreTokens() && !form.startsWith(TOK_ESC)) {
dollarProcess(es.nextToken());
}
-
+
// rest of them start with '\'
while (es.hasMoreTokens()) {
String t = es.nextToken();
@@ -130,16 +140,16 @@ public class EmailFormProcessor implements IEmailFormProcessor {
}
/*
- * all of the string tokens below begin with a '$' match it one by one
- * with the mTok2vals table
+ * all of the string tokens below begin with a '$'
+ * match it one by one with the mTok2vals table
*/
while (st.hasMoreTokens()) {
String t = st.nextToken();
/*
- * We don't know when a token ends. Compare with every token in the
- * table for the first match. Which means, a token name should not
- * be a substring of any token name
+ * We don't know when a token ends. Compare with every
+ * token in the table for the first match. Which means, a
+ * token name should not be a substring of any token name
*/
boolean matched = false;
String tok = null;
@@ -173,7 +183,7 @@ public class EmailFormProcessor implements IEmailFormProcessor {
matched = true;
// replaced! bail out.
- break;
+ break;
}
}
@@ -182,17 +192,17 @@ public class EmailFormProcessor implements IEmailFormProcessor {
// no match, put the token back, as is
// -- for bug 382162, don't remove the following line, in
- // case John changes his mind for the better
- // mContent.add(TOK_PREFIX+t);
+ // case John changes his mind for the better
+ // mContent.add(TOK_PREFIX+t);
int tl = token_keys.length;
for (int i = 0; i < token_keys.length; i++) {
if (t.startsWith(token_keys[i])) {
- // match, replace it with the TOK_VALUE_UNKNOWN
+ // match, replace it with the TOK_VALUE_UNKNOWN
mContent.add(TOK_VALUE_UNKNOWN);
-
+
// now, put the rest of the non-token string
- // in mContent
+ // in mContent
if (t.length() != token_keys[i].length()) {
mContent.add(t.substring(token_keys[i].length()));
}
@@ -236,7 +246,8 @@ public class EmailFormProcessor implements IEmailFormProcessor {
public void log(int level, String msg) {
if (mLogger == null)
return;
- mLogger.log(ILogger.EV_SYSTEM, null, ILogger.S_OTHER, level,
- "EmailFormProcessor: " + msg);
+ mLogger.log(ILogger.EV_SYSTEM, null, ILogger.S_OTHER,
+ level, "EmailFormProcessor: " + msg);
}
}
+