summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/jobs/UnpublishExpiredJob.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/jobs/UnpublishExpiredJob.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/jobs/UnpublishExpiredJob.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/jobs/UnpublishExpiredJob.java253
1 files changed, 138 insertions, 115 deletions
diff --git a/pki/base/common/src/com/netscape/cms/jobs/UnpublishExpiredJob.java b/pki/base/common/src/com/netscape/cms/jobs/UnpublishExpiredJob.java
index 0c53d551f..6a0a6d034 100644
--- a/pki/base/common/src/com/netscape/cms/jobs/UnpublishExpiredJob.java
+++ b/pki/base/common/src/com/netscape/cms/jobs/UnpublishExpiredJob.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.jobs;
+
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.util.Date;
@@ -45,41 +46,60 @@ import com.netscape.certsrv.request.IRequest;
import com.netscape.certsrv.request.IRequestQueue;
import com.netscape.certsrv.request.RequestId;
+
/**
- * a job for the Jobs Scheduler. This job checks in the internal ldap db for
- * certs that have expired and remove them from the ldap publishing directory.
+ * a job for the Jobs Scheduler. This job checks in the internal ldap
+ * db for certs that have expired and remove them from the ldap
+ * publishing directory.
* <p>
* the $TOKENS that are available for the this jobs's summary outer form are:<br>
* <UL>
- * $Status $InstanceID $SummaryItemList $SummaryTotalNum $SummaryTotalSuccess
- * $SummaryTotalfailure $ExecutionTime
+ * $Status
+ * $InstanceID
+ * $SummaryItemList
+ * $SummaryTotalNum
+ * $SummaryTotalSuccess
+ * $SummaryTotalfailure
+ * $ExecutionTime
* </UL>
* and for the inner list items:
* <UL>
- * $SerialNumber $IssuerDN $SubjectDN $NotAfter $NotBefore $RequestorEmail
+ * $SerialNumber
+ * $IssuerDN
+ * $SubjectDN
+ * $NotAfter
+ * $NotBefore
+ * $RequestorEmail
* $CertType
* </UL>
- *
+ *
* @version $Revision$, $Date$
*/
-public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
- IExtendedPluginInfo {
-
+public class UnpublishExpiredJob extends AJobBase
+ implements IJob, Runnable, IExtendedPluginInfo {
+
ICertificateAuthority mCa = null;
IRequestQueue mReqQ = null;
ICertificateRepository mRepository = null;
IPublisherProcessor mPublisherProcessor = null;
private boolean mSummary = false;
- /*
- * Holds configuration parameters accepted by this implementation. This list
- * is passed to the configuration console so configuration for instances of
- * this implementation can be configured through the console.
+ /* Holds configuration parameters accepted by this implementation.
+ * This list is passed to the configuration console so configuration
+ * for instances of this implementation can be configured through the
+ * console.
*/
- protected static String[] mConfigParams = new String[] { "enabled", "cron",
- "summary.enabled", "summary.emailSubject", "summary.emailTemplate",
- "summary.itemTemplate", "summary.senderEmail",
- "summary.recipientEmail" };
+ protected static String[] mConfigParams =
+ new String[] {
+ "enabled",
+ "cron",
+ "summary.enabled",
+ "summary.emailSubject",
+ "summary.emailTemplate",
+ "summary.itemTemplate",
+ "summary.senderEmail",
+ "summary.recipientEmail"
+ };
/* Vector of extendedPluginInfo strings */
protected static Vector mExtendedPluginInfo = null;
@@ -89,25 +109,26 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
public String[] getExtendedPluginInfo(Locale locale) {
String s[] = {
- IExtendedPluginInfo.HELP_TEXT
- + "; A job that checks for expired certificates in the "
- + "database, and removes them from the publishing "
- + "directory",
- "cron;string;Format: minute hour dayOfMonth month "
- + "dayOfWeek. Use '*' for 'every'. For dayOfWeek, 0 is Sunday",
- "summary.senderEmail;string;Specify the address to be used "
- + "as the email's 'sender'. Bounces go to this address.",
+ IExtendedPluginInfo.HELP_TEXT +
+ "; A job that checks for expired certificates in the " +
+ "database, and removes them from the publishing " +
+ "directory",
+ "cron;string;Format: minute hour dayOfMonth month " +
+ "dayOfWeek. Use '*' for 'every'. For dayOfWeek, 0 is Sunday",
+ "summary.senderEmail;string;Specify the address to be used " +
+ "as the email's 'sender'. Bounces go to this address.",
"summary.recipientEmail;string;Who should receive summaries",
"enabled;boolean;Enable this plugin",
- "summary.enabled;boolean;Enable the summary. You must enabled "
- + "this for the job to work.",
+ "summary.enabled;boolean;Enable the summary. You must enabled " +
+ "this for the job to work.",
"summary.emailSubject;string;Subject of summary email",
- "summary.emailTemplate;string;Fully qualified pathname of "
- + "template file of email to be sent",
- "summary.itemTemplate;string;Fully qualified pathname of "
- + "file containing template for each item",
- IExtendedPluginInfo.HELP_TOKEN
- + ";configuration-jobrules-unpublishexpiredjobs", };
+ "summary.emailTemplate;string;Fully qualified pathname of " +
+ "template file of email to be sent",
+ "summary.itemTemplate;string;Fully qualified pathname of " +
+ "file containing template for each item",
+ IExtendedPluginInfo.HELP_TOKEN +
+ ";configuration-jobrules-unpublishexpiredjobs",
+ };
return s;
}
@@ -115,13 +136,14 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
/**
* initialize from the configuration file
*/
- public void init(ISubsystem owner, String id, String implName,
- IConfigStore config) throws EBaseException {
+ public void init(ISubsystem owner, String id, String implName, IConfigStore config) throws
+ EBaseException {
mConfig = config;
mId = id;
mImplName = implName;
- mCa = (ICertificateAuthority) CMS.getSubsystem("ca");
+ mCa = (ICertificateAuthority)
+ CMS.getSubsystem("ca");
if (mCa == null) {
return;
}
@@ -129,13 +151,13 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
mReqQ = mCa.getRequestQueue();
mRepository = (ICertificateRepository) mCa.getCertificateRepository();
mPublisherProcessor = mCa.getPublisherProcessor();
-
+
// read from the configuration file
mCron = mConfig.getString(IJobCron.PROP_CRON);
if (mCron == null) {
return;
}
-
+
// parse cron string into a JobCron class
IJobsScheduler scheduler = (IJobsScheduler) owner;
@@ -157,14 +179,16 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
}
/**
- * look in the internal db for certificateRecords that are expired. remove
- * them from ldap publishing directory if remove successfully, mark
- * <i>false</i> on the <b>InLdapPublishDir</b> flag, else, if remove
- * unsuccessfully, log it
+ * look in the internal db for certificateRecords that are
+ * expired.
+ * remove them from ldap publishing directory
+ * if remove successfully, mark <i>false</i> on the
+ * <b>InLdapPublishDir</b> flag,
+ * else, if remove unsuccessfully, log it
*/
public void run() {
- // System.out.println("in ExpiredUnpublishJob "+
- // getId()+ " : run()");
+ // System.out.println("in ExpiredUnpublishJob "+
+ // getId()+ " : run()");
// get time now..."now" is before the loop
Date date = CMS.getCurrentDate();
long now = date.getTime();
@@ -172,11 +196,12 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
String nowString = dateFormat.format(date);
// form filter
- String filter = "(&(x509Cert.notAfter<=" + now
- + ")(!(x509Cert.notAfter=" + now + "))" + "(" + "certMetainfo="
- + ICertRecord.META_LDAPPUBLISH + ":true))";
+ String filter = "(&(x509Cert.notAfter<=" + now +
+ ")(!(x509Cert.notAfter=" + now + "))" +
+ "(" + "certMetainfo=" + ICertRecord.META_LDAPPUBLISH +
+ ":true))";
// a test for without CertRecord.META_LDAPPUBLISH
- // String filter = "(x509Cert.notAfter<="+ now +")";
+ //String filter = "(x509Cert.notAfter<="+ now +")";
Enumeration expired = null;
@@ -184,14 +209,13 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
expired = mRepository.findCertRecs(filter);
// bug 399150
/*
- * CertRecordList list = null; list =
- * mRepository.findCertRecordsInList(filter, null, "serialno", 5);
- * int size = list.getSize(); expired = list.getCertRecords(0, size
- * - 1);
+ CertRecordList list = null;
+ list = mRepository.findCertRecordsInList(filter, null, "serialno", 5);
+ int size = list.getSize();
+ expired = list.getCertRecords(0, size - 1);
*/
} catch (EBaseException e) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("OPERATION_ERROR", e.toString()));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString()));
}
int count = 0; // how many have been unpublished successfully
@@ -209,14 +233,13 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
while (expired != null && expired.hasMoreElements()) {
ICertRecord rec = (ICertRecord) expired.nextElement();
- if (rec == null)
- break;
+ if (rec == null) break;
X509CertImpl cert = rec.getCertificate();
if (mSummary == true)
buildItemParams(cert);
- // get request id from cert record MetaInfo
+ // get request id from cert record MetaInfo
MetaInfo minfo = null;
try {
@@ -225,39 +248,42 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
negCount += 1;
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_FAILURE);
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("JOBS_META_INFO_ERROR", cert
- .getSerialNumber().toString(16) + e.toString()));
+ STATUS_FAILURE);
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("JOBS_META_INFO_ERROR",
+ cert.getSerialNumber().toString(16) +
+ e.toString()));
}
String ridString = null;
try {
if (minfo != null)
- ridString = (String) minfo.get(ICertRecord.META_REQUEST_ID);
+ ridString = (String) minfo.get(ICertRecord.META_REQUEST_ID);
} catch (EBaseException e) {
negCount += 1;
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_FAILURE);
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("JOBS_META_REQUEST_ERROR", cert
- .getSerialNumber().toString(16) + e.toString()));
+ STATUS_FAILURE);
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("JOBS_META_REQUEST_ERROR",
+ cert.getSerialNumber().toString(16) +
+ e.toString()));
} catch (NullPointerException e) {
// no requestId in MetaInfo...skip to next record
negCount += 1;
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_FAILURE);
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("JOBS_META_REQUEST_ERROR", cert
- .getSerialNumber().toString(16) + e.toString()));
+ STATUS_FAILURE);
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("JOBS_META_REQUEST_ERROR",
+ cert.getSerialNumber().toString(16) +
+ e.toString()));
}
if (ridString != null) {
RequestId rid = new RequestId(ridString);
-
+
// get request from request id
IRequest req = null;
@@ -271,21 +297,19 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
negCount += 1;
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_FAILURE);
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage(
- "JOBS_FIND_REQUEST_ERROR",
- cert.getSerialNumber().toString(16)
- + e.toString()));
+ STATUS_FAILURE);
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("JOBS_FIND_REQUEST_ERROR",
+ cert.getSerialNumber().toString(16) +
+ e.toString()));
}
try {
- if ((mPublisherProcessor != null)
- && mPublisherProcessor.enabled()) {
- mPublisherProcessor.unpublishCert(
- (X509Certificate) cert, req);
+ if ((mPublisherProcessor != null) &&
+ mPublisherProcessor.enabled()) {
+ mPublisherProcessor.unpublishCert((X509Certificate) cert, req);
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_SUCCESS);
+ STATUS_SUCCESS);
count += 1;
} else {
negCount += 1;
@@ -294,23 +318,21 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
negCount += 1;
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_FAILURE);
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage(
- "JOBS_UNPUBLISH_ERROR",
- cert.getSerialNumber().toString(16)
- + e.toString()));
+ STATUS_FAILURE);
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("JOBS_UNPUBLISH_ERROR",
+ cert.getSerialNumber().toString(16) +
+ e.toString()));
}
} // ridString != null
else {
try {
- if ((mPublisherProcessor != null)
- && mPublisherProcessor.enabled()) {
- mPublisherProcessor.unpublishCert(
- (X509Certificate) cert, null);
+ if ((mPublisherProcessor != null) &&
+ mPublisherProcessor.enabled()) {
+ mPublisherProcessor.unpublishCert((X509Certificate) cert, null);
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_SUCCESS);
+ STATUS_SUCCESS);
count += 1;
} else {
negCount += 1;
@@ -319,12 +341,11 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
negCount += 1;
if (mSummary == true)
buildItemParams(IEmailFormProcessor.TOKEN_STATUS,
- STATUS_FAILURE);
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage(
- "JOBS_UNPUBLISH_ERROR",
- cert.getSerialNumber().toString(16)
- + e.toString()));
+ STATUS_FAILURE);
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("JOBS_UNPUBLISH_ERROR",
+ cert.getSerialNumber().toString(16) +
+ e.toString()));
}
} // ridString == null
@@ -333,8 +354,8 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
// if summary is enabled, form the item content
if (mSummary) {
- IEmailFormProcessor emailItemFormProcessor = CMS
- .getEmailFormProcessor();
+ IEmailFormProcessor emailItemFormProcessor =
+ CMS.getEmailFormProcessor();
String c = emailItemFormProcessor.getEmailContent(itemForm,
mItemParams);
@@ -349,35 +370,37 @@ public class UnpublishExpiredJob extends AJobBase implements IJob, Runnable,
// time for summary
if (mSummary == true) {
- buildContentParams(IEmailFormProcessor.TOKEN_ID, mId);
+ buildContentParams(IEmailFormProcessor.TOKEN_ID,
+ mId);
buildContentParams(IEmailFormProcessor.TOKEN_SUMMARY_ITEM_LIST,
- itemListContent);
+ itemListContent);
buildContentParams(IEmailFormProcessor.TOKEN_SUMMARY_TOTAL_NUM,
- String.valueOf(count + negCount));
+ String.valueOf(count + negCount));
buildContentParams(IEmailFormProcessor.TOKEN_SUMMARY_SUCCESS_NUM,
- String.valueOf(count));
+ String.valueOf(count));
buildContentParams(IEmailFormProcessor.TOKEN_SUMMARY_FAILURE_NUM,
- String.valueOf(negCount));
+ String.valueOf(negCount));
buildContentParams(IEmailFormProcessor.TOKEN_EXECUTION_TIME,
- nowString);
+ nowString);
- IEmailFormProcessor emailFormProcessor = CMS
- .getEmailFormProcessor();
- String mailContent = emailFormProcessor.getEmailContent(
- contentForm, mContentParams);
+ IEmailFormProcessor emailFormProcessor = CMS.getEmailFormProcessor();
+ String mailContent =
+ emailFormProcessor.getEmailContent(contentForm,
+ mContentParams);
mailSummary(mailContent);
}
}
/**
- * Returns a list of configuration parameter names. The list is passed to
- * the configuration console so instances of this implementation can be
- * configured through the console.
- *
+ * Returns a list of configuration parameter names.
+ * The list is passed to the configuration console so instances of
+ * this implementation can be configured through the console.
+ *
* @return String array of configuration parameter names.
*/
public String[] getConfigParams() {
return (mConfigParams);
}
}
+