summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java87
1 files changed, 40 insertions, 47 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java b/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
index 8272c448..828834a2 100644
--- a/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
+++ b/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.jobs;
-
import java.util.Calendar;
import java.util.Enumeration;
import java.util.StringTokenizer;
@@ -28,33 +27,28 @@ import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.jobs.IJobCron;
import com.netscape.certsrv.logging.ILogger;
-
/**
* class representing one Job cron information
- * <p>here, an "item" refers to one of the 5 fields in a cron string;
- * "element" refers to any comma-deliminated element in an
- * "item"...which includes both numbers and '-' separated ranges.
- * A cron string in the configuration takes the following format:
- * <i>minute (0-59),
- * hour (0-23),
- * day of the month (1-31),
- * month of the year (1-12),
- * day of the week (0-6 with 0=Sunday)</i>
* <p>
- * e.g. jobsScheduler.job.rnJob1.cron=30 11,23 * * 1-5
- * In this example, the job "rnJob1" will be executed from Monday
- * through Friday, at 11:30am and 11:30pm.
+ * here, an "item" refers to one of the 5 fields in a cron string; "element"
+ * refers to any comma-deliminated element in an "item"...which includes both
+ * numbers and '-' separated ranges. A cron string in the configuration takes
+ * the following format: <i>minute (0-59), hour (0-23), day of the month (1-31),
+ * month of the year (1-12), day of the week (0-6 with 0=Sunday)</i>
* <p>
- *
+ * e.g. jobsScheduler.job.rnJob1.cron=30 11,23 * * 1-5 In this example, the job
+ * "rnJob1" will be executed from Monday through Friday, at 11:30am and 11:30pm.
+ * <p>
+ *
* @author cfu
* @version $Revision$, $Date$
*/
public class JobCron implements IJobCron {
/**
- * CRON_MINUTE, CRON_HOUR, CRON_DAY_OF_MONTH, CRON_MONTH_OF_YEAR,
- * and CRON_DAY_OF_WEEK are to be used in <b>getItem()</b> to
- * retrieve the corresponding <b>CronItem</b>
+ * CRON_MINUTE, CRON_HOUR, CRON_DAY_OF_MONTH, CRON_MONTH_OF_YEAR, and
+ * CRON_DAY_OF_WEEK are to be used in <b>getItem()</b> to retrieve the
+ * corresponding <b>CronItem</b>
*/
public static final String CRON_MINUTE = "minute";
public static final String CRON_HOUR = "hour";
@@ -72,7 +66,7 @@ public class JobCron implements IJobCron {
CronItem cDOW = null;
public JobCron(String cronString)
- throws EBaseException {
+ throws EBaseException {
mCronString = cronString;
// create all 5 items in the cron
@@ -84,9 +78,9 @@ public class JobCron implements IJobCron {
cronToVals(mCronString);
}
-
- private void cronToVals(String cronString)
- throws EBaseException {
+
+ private void cronToVals(String cronString)
+ throws EBaseException {
StringTokenizer st = new StringTokenizer(cronString);
String sMinute = null;
@@ -101,8 +95,8 @@ public class JobCron implements IJobCron {
cMinute.set(sMinute);
}
} catch (EBaseException e) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("CMSCORE_JOBS_INVALID_MIN", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("CMSCORE_JOBS_INVALID_MIN", e.toString()));
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_JOB_CRON"));
}
@@ -118,7 +112,7 @@ public class JobCron implements IJobCron {
if (st.hasMoreTokens()) {
sDayOMonth = st.nextToken();
- // cDOM.set(sDayOMonth);
+ // cDOM.set(sDayOMonth);
}
try {
@@ -133,24 +127,22 @@ public class JobCron implements IJobCron {
if (st.hasMoreTokens()) {
sDayOWeek = st.nextToken();
- // cDOW.set(sDayOWeek);
+ // cDOW.set(sDayOWeek);
}
/**
- * day-of-month or day-of-week, or both?
- * if only one of them is '*', the non '*' one prevails,
- * the '*' one will remain empty (no elements)
+ * day-of-month or day-of-week, or both? if only one of them is '*', the
+ * non '*' one prevails, the '*' one will remain empty (no elements)
*/
// day-of-week
- if ((sDayOMonth!= null) && sDayOMonth.equals(CronItem.ALL) && (sDayOWeek!= null) && !sDayOWeek.equals(CronItem.ALL)) {
+ if ((sDayOMonth != null) && sDayOMonth.equals(CronItem.ALL) && (sDayOWeek != null) && !sDayOWeek.equals(CronItem.ALL)) {
try {
cDOW.set(sDayOWeek);
} catch (EBaseException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_JOBS_INVALID_DAY_OF_WEEK", e.toString()));
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_JOB_CRON"));
}
- } else
- if ((sDayOMonth!= null) && !sDayOMonth.equals(CronItem.ALL) && (sDayOWeek!= null) && sDayOWeek.equals(CronItem.ALL)) {
+ } else if ((sDayOMonth != null) && !sDayOMonth.equals(CronItem.ALL) && (sDayOWeek != null) && sDayOWeek.equals(CronItem.ALL)) {
try {
cDOM.set(sDayOMonth);
} catch (EBaseException e) {
@@ -159,7 +151,7 @@ public class JobCron implements IJobCron {
}
} else { // if both '*', every day, if neither is '*', do both
try {
- if (sDayOWeek!= null) {
+ if (sDayOWeek != null) {
cDOW.set(sDayOWeek);
}
} catch (EBaseException e) {
@@ -179,10 +171,11 @@ public class JobCron implements IJobCron {
/**
* retrieves the cron item
- * @param item name of the item. must be one of the <b>CRON_*</b>
- * strings defined in this class
- * @return an instance of the CronItem class which represents the
- * requested cron item
+ *
+ * @param item name of the item. must be one of the <b>CRON_*</b> strings
+ * defined in this class
+ * @return an instance of the CronItem class which represents the requested
+ * cron item
*/
public CronItem getItem(String item) {
if (item.equals(CRON_MINUTE)) {
@@ -204,10 +197,11 @@ public class JobCron implements IJobCron {
/**
* Does the element fit any element in the item
+ *
* @param element the element of "now" in cron format
* @param item the item consists of a vector of elements
- * @return boolean (true/false) on whether the element is one of
- * the elements in the item
+ * @return boolean (true/false) on whether the element is one of the
+ * elements in the item
*/
boolean isElement(int element, Vector<CronRange> item) {
// loop through all of the elements of an item
@@ -221,7 +215,7 @@ public class JobCron implements IJobCron {
}
} else { // is a range
if ((element >= cElement.getBegin()) &&
- (element <= cElement.getEnd())) {
+ (element <= cElement.getEnd())) {
return true;
}
}
@@ -231,11 +225,10 @@ public class JobCron implements IJobCron {
}
/**
- * convert the day of the week representation from Calendar to
- * cron
+ * convert the day of the week representation from Calendar to cron
+ *
* @param time the Calendar value represents a moment of time
- * @return an integer value that represents a cron Day-Of-Week
- * element
+ * @return an integer value that represents a cron Day-Of-Week element
*/
public int DOW_cal2cron(Calendar time) {
int calDow = time.get(Calendar.DAY_OF_WEEK);
@@ -280,9 +273,9 @@ public class JobCron implements IJobCron {
/**
* convert the month of year representation from Calendar to cron
+ *
* @param time the Calendar value represents a moment of time
- * @return an integer value that represents a cron Month-Of-Year
- * element
+ * @return an integer value that represents a cron Month-Of-Year element
*/
public int MOY_cal2cron(Calendar time) {
int calMoy = time.get(Calendar.MONTH);
@@ -352,6 +345,6 @@ public class JobCron implements IJobCron {
if (mLogger == null)
return;
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- level, msg);
+ level, msg);
}
}