Example usage for java.text ParseException getMessage

List of usage examples for java.text ParseException getMessage

Introduction

In this page you can find the example usage for java.text ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.rogchen.common.xml.UtilDateTime.java

public static Date parseDate(String str) {
    try {//from  w w w.java 2  s . co  m
        return DateUtils.parseDate(str, PARSE_PATTERNS.toArray(new String[PARSE_PATTERNS.size()]));
    } catch (ParseException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException("?" + str, e);
    }
}

From source file:com.collabnet.ccf.core.ga.GenericArtifactHelper.java

/**
 * Parses an XML document that complies to the generic artifact schema and
 * represents it as a Java object/*  ww w. ja v  a  2s .c  o  m*/
 * 
 * @param document
 *            XML representation of the generic artifact
 * @return Java object representing the artifact
 * @throws GenericArtifactParsingException
 *             exception is thrown if XML document does not comply to the
 *             schema
 */
public static GenericArtifact createGenericArtifactJavaObject(Document document)
        throws GenericArtifactParsingException {
    GenericArtifact genericArtifact = new GenericArtifact();
    // TODO Parse the XML document and populate the Java objects
    // fetch the artifact-root-element
    Element root = getRootElement(document);
    // get and set attributes

    ArtifactActionValue artifactAction = translateAttributeValue(root, ARTIFACT_ACTION, artifactActionHashMap);
    genericArtifact.setArtifactAction(artifactAction);

    genericArtifact
            .setSourceArtifactLastModifiedDate(getAttributeValue(root, SOURCE_ARTIFACT_LAST_MODIFICATION_DATE));
    genericArtifact
            .setTargetArtifactLastModifiedDate(getAttributeValue(root, TARGET_ARTIFACT_LAST_MODIFICATION_DATE));
    // genericArtifact.setLastReadTransactionId(getAttributeValue(root,
    // ARTIFACT_LAST_READ_TRANSACTION_ID));
    genericArtifact.setErrorCode(getAttributeValue(root, ERROR_CODE));

    ArtifactModeValue artifactMode = translateAttributeValue(root, ARTIFACT_MODE, artifactModeHashMap);
    genericArtifact.setArtifactMode(artifactMode);

    ArtifactTypeValue artifactType = translateAttributeValue(root, ARTIFACT_TYPE, artifactTypeHashMap);
    genericArtifact.setArtifactType(artifactType);

    IncludesFieldMetaDataValue includesFieldMetaData = translateAttributeValue(root, INCLUDES_FIELD_META_DATA,
            includesFieldMetaDataHashMap);
    genericArtifact.setIncludesFieldMetaData(includesFieldMetaData);

    if (artifactType == GenericArtifact.ArtifactTypeValue.ATTACHMENT) {
        genericArtifact.setArtifactValue(getValue(root));
    }

    genericArtifact.setSourceArtifactVersion(getAttributeValue(root, SOURCE_ARTIFACT_VERSION));
    genericArtifact.setTargetArtifactVersion(getAttributeValue(root, TARGET_ARTIFACT_VERSION));
    genericArtifact.setConflictResolutionPriority(getAttributeValue(root, CONFLICT_RESOLUTION_PRIORITY));
    genericArtifact.setTransactionId(getAttributeValue(root, TRANSACTION_ID));
    // only read optional attributes if necessary
    if (artifactType == ArtifactTypeValue.DEPENDENCY || artifactType == ArtifactTypeValue.ATTACHMENT
            || artifactType == ArtifactTypeValue.PLAINARTIFACT) {
        genericArtifact.setDepParentSourceArtifactId(getAttributeValue(root, DEP_PARENT_SOURCE_ARTIFACT_ID));
        genericArtifact
                .setDepParentSourceRepositoryId(getAttributeValue(root, DEP_PARENT_SOURCE_REPOSITORY_ID));
        genericArtifact
                .setDepParentSourceRepositoryKind(getAttributeValue(root, DEP_PARENT_SOURCE_REPOSITORY_KIND));
        genericArtifact.setDepParentTargetArtifactId(getAttributeValue(root, DEP_PARENT_TARGET_ARTIFACT_ID));
        genericArtifact
                .setDepParentTargetRepositoryId(getAttributeValue(root, DEP_PARENT_TARGET_REPOSITORY_ID));
        genericArtifact
                .setDepParentTargetRepositoryKind(getAttributeValue(root, DEP_PARENT_TARGET_REPOSITORY_KIND));
    }

    // dependencies have even more optional attributes
    if (artifactType == ArtifactTypeValue.DEPENDENCY) {
        genericArtifact.setDepChildSourceArtifactId(getAttributeValue(root, DEP_CHILD_SOURCE_ARTIFACT_ID));
        genericArtifact.setDepChildSourceRepositoryId(getAttributeValue(root, DEP_CHILD_SOURCE_REPOSITORY_ID));
        genericArtifact
                .setDepChildSourceRepositoryKind(getAttributeValue(root, DEP_CHILD_SOURCE_REPOSITORY_KIND));
        genericArtifact.setDepChildTargetArtifactId(getAttributeValue(root, DEP_CHILD_TARGET_ARTIFACT_ID));
        genericArtifact.setDepChildTargetRepositoryId(getAttributeValue(root, DEP_CHILD_TARGET_REPOSITORY_ID));
        genericArtifact
                .setDepChildTargetRepositoryKind(getAttributeValue(root, DEP_CHILD_TARGET_REPOSITORY_KIND));
    }

    genericArtifact.setSourceArtifactId(getAttributeValue(root, SOURCE_ARTIFACT_ID));
    genericArtifact.setSourceRepositoryId(getAttributeValue(root, SOURCE_REPOSITORY_ID));
    genericArtifact.setSourceRepositoryKind(getAttributeValue(root, SOURCE_REPOSITORY_KIND));
    genericArtifact.setSourceSystemId(getAttributeValue(root, SOURCE_SYSTEM_ID));
    genericArtifact.setSourceSystemKind(getAttributeValue(root, SOURCE_SYSTEM_KIND));
    genericArtifact.setTargetArtifactId(getAttributeValue(root, TARGET_ARTIFACT_ID));
    genericArtifact.setTargetRepositoryId(getAttributeValue(root, TARGET_REPOSITORY_ID));
    genericArtifact.setTargetRepositoryKind(getAttributeValue(root, TARGET_REPOSITORY_KIND));
    genericArtifact.setTargetSystemId(getAttributeValue(root, TARGET_SYSTEM_ID));
    genericArtifact.setTargetSystemKind(getAttributeValue(root, TARGET_SYSTEM_KIND));
    genericArtifact.setSourceSystemTimezone(getAttributeValue(root, SOURCE_SYSTEM_TIMEZONE));
    genericArtifact.setTargetSystemTimezone(getAttributeValue(root, TARGET_SYSTEM_TIMEZONE));
    // genericArtifact.setSourceSystemEncoding(getAttributeValue(root,
    // SOURCE_SYSTEM_ENCODING));
    // genericArtifact.setTargetSystemEncoding(getAttributeValue(root,
    // TARGET_SYSTEM_ENCODING));

    // now add fields
    List<Element> fields = getAllFieldElements(root);
    for (Element field : fields) {
        GenericArtifactField.FieldActionValue fieldAction = translateAttributeValue(field, FIELD_ACTION,
                fieldActionHashMap);
        GenericArtifactField.FieldValueTypeValue fieldValueType = translateAttributeValue(field,
                FIELD_VALUE_TYPE, fieldValueTypeHashMap);
        String fieldName = getAttributeValue(field, FIELD_NAME);
        String fieldType = getAttributeValue(field, FIELD_TYPE);
        Boolean fieldValueIsNull = translateAttributeValue(field, FIELD_VALUE_IS_NULL, fieldValueIsNullHashMap);
        Boolean fieldValueHasChanged = translateAttributeValue(field, FIELD_VALUE_HAS_CHANGED,
                fieldValueHasChangedHashMap);
        String fieldValue = getValue(field);

        // we cannot change these two attributes later because this would
        // influence the indexing data structures for fast lookup
        GenericArtifactField genericArtifactField = genericArtifact.addNewField(fieldName, fieldType);
        genericArtifactField.setFieldAction(fieldAction);
        genericArtifactField.setFieldValueType(fieldValueType);
        genericArtifactField.setFieldValueHasChanged(fieldValueHasChanged);

        if (includesFieldMetaData.equals(GenericArtifact.IncludesFieldMetaDataValue.TRUE)) {
            String minOccurs = getAttributeValue(field, MIN_OCCURS);
            String maxOccurs = getAttributeValue(field, MAX_OCCURS);
            String nullValueSupported = getAttributeValue(field, NULL_VALUE_SUPPORTED);
            String alternativeFieldName = getAttributeValue(field, ALTERNATIVE_FIELD_NAME);

            genericArtifactField.setMinOccursValue(minOccurs);
            genericArtifactField.setMaxOccursValue(maxOccurs);
            genericArtifactField.setNullValueSupported(nullValueSupported);
            genericArtifactField.setAlternativeFieldName(alternativeFieldName);
        } else {
            // try to set alternativeFieldName if set
            String alternativeFieldName = getAttributeValueWithoutException(field, ALTERNATIVE_FIELD_NAME);
            if (alternativeFieldName != null) {
                genericArtifactField.setAlternativeFieldName(alternativeFieldName);
            }
        }

        try {
            convertFieldValue(genericArtifactField, fieldValueIsNull, fieldValueType, fieldValue);
        } catch (ParseException e) {
            throw new GenericArtifactParsingException(
                    "Value " + fieldValue + " for field-element with name " + fieldName + " and field type "
                            + fieldType + " was not convertible to an instance of value type " + fieldValueType
                            + " because: " + e.getMessage());
        }
    }

    // finally set reference to source XML document
    genericArtifact.setSourceDocument(document);
    return genericArtifact;
}

From source file:com.rogchen.common.xml.UtilDateTime.java

public static Date parseDate(String str, String dateFromat) {
    Set<String> patterns = Sets.newHashSet();
    patterns.addAll(PARSE_PATTERNS);//w w w  .j ava2s  .c  om
    patterns.add(dateFromat);
    try {
        return DateUtils.parseDate(str, patterns.toArray(new String[patterns.size()]));
    } catch (ParseException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException("?" + str, e);
    }
}

From source file:com.bittorrent.mpetazzoni.client.ConnectionHandler.java

/**
 * Accept the next incoming connection.//from   www. ja va  2 s  .  com
 *
 * <p>
 * When a new peer connects to this service, wait for it to send its
 * handshake. We then parse and check that the handshake advertises the
 * torrent hash we expect, then reply with our own handshake.
 * </p>
 *
 * <p>
 * If everything goes according to plan, notify the
 * <code>IncomingConnectionListener</code>s with the connected socket and
 * the parsed peer ID.
 * </p>
 *
 * @param client The accepted client's socket channel.
 */
private void accept(SocketChannel client) throws IOException, SocketTimeoutException {
    try {
        logger.debug("New incoming connection, waiting for handshake...");
        Handshake hs = this.validateHandshake(client, null);
        int sent = this.sendHandshake(client);
        logger.trace("Replied to {} with handshake ({} bytes).", this.socketRepr(client), sent);

        // Go to non-blocking mode for peer interaction
        client.configureBlocking(false);
        client.socket().setSoTimeout(CLIENT_KEEP_ALIVE_MINUTES * 60 * 1000);
        this.fireNewPeerConnection(client, hs.getPeerId());
    } catch (ParseException pe) {
        logger.info("Invalid handshake from {}: {}", this.socketRepr(client), pe.getMessage());
        IOUtils.closeQuietly(client);
    } catch (IOException ioe) {
        logger.warn("An error occured while reading an incoming " + "handshake: {}", ioe.getMessage());
        if (client.isConnected()) {
            IOUtils.closeQuietly(client);
        }
    }
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractSystemHealthController.java

@RequestMapping(value = "/update_maintenance_schedule", method = RequestMethod.POST)
public String updateMaintenanceSchedule(@ModelAttribute("serviceNotificationForm") ServiceNotificationForm form,
        ModelMap map) {// w w  w .j  a  va2 s. c  o  m
    logger.debug("###Entering in updateMaintenanceSchedule() method @POST");
    User currentUser = getCurrentUser();
    ServiceNotification notification = form.getServiceNotification();
    String error = null;
    try {
        Date startDate = notification.getPlannedStart();
        if (StringUtils.isNotBlank(form.getStartDateString()) && StringUtils.isNotBlank(form.getDateFormat())) {
            startDate = DateUtils.getDateFormatter(form.getDateFormat()).parse(form.getStartDateString());
        }
        Date endDate = notification.getPlannedEnd();
        if (StringUtils.isNotBlank(form.getEndDateString()) && StringUtils.isNotBlank(form.getDateFormat())) {
            endDate = DateUtils.getDateFormatter(form.getDateFormat()).parse(form.getEndDateString());
        }
        notification.setPlannedStart(
                DateTimeUtils.getDateInSystemTZForRecording(startDate, DateTimeUtils.getTimeZone(currentUser)));
        notification.setPlannedEnd(
                DateTimeUtils.getDateInSystemTZForRecording(endDate, DateTimeUtils.getTimeZone(currentUser)));
        healthService.updateServiceNotification(notification);
    } catch (ParseException e) {
        logger.error("Error while updating Scheduled Maintenance", e);
        error = e.getMessage();
    }
    if (error != null) {
        map.addAttribute("error", error);
    } else {
        map.addAttribute("item", notification);
    }
    logger.debug("###Exiting updateMaintenanceSchedule() method @POST");
    return "system.health.maintenanceView";
}

From source file:com.basetechnology.s0.agentserver.AgentInstance.java

static public AgentInstance fromJson(AgentServer agentServer, User user, JSONObject agentJson,
        AgentDefinition agentDefinition, boolean update) throws AgentServerException, SymbolException,
        JSONException, ParseException, TokenizerException, ParserException {
    // Parse the JSON for the agent instance

    // If we have the user, ignore user from JSON
    if (user == null) {
        String userId = agentJson.optString("user");
        if (userId == null || userId.trim().length() == 0)
            throw new AgentServerException("Agent instance user id ('user') is missing");
        user = agentServer.getUser(userId);
        if (user == User.noUser)
            throw new AgentServerException("Agent instance user id does not exist: '" + userId + "'");
    }//from w w w. j ava2 s .co m

    // Parse the agent instance name
    String agentInstanceName = agentJson.optString("name");
    if (!update && (agentInstanceName == null || agentInstanceName.trim().length() == 0))
        throw new AgentServerException("Agent instance name ('name') is missing");

    // Parse the agent definition name - but ignore for update since it can't be changed
    if (!update) {
        String agentDefinitionName = agentJson.optString("definition");
        if (agentDefinitionName == null || agentDefinitionName.trim().length() == 0)
            throw new AgentServerException(
                    "Agent instance definition name ('definition') is missing for user '" + user.id + "'");

        // Check if referenced agent definition exists
        agentDefinition = agentServer.getAgentDefinition(user, agentDefinitionName);
        if (agentDefinition == null)
            throw new AgentServerException(
                    "Agent instance '" + agentInstanceName + "' references agent definition '"
                            + agentDefinitionName + "' which does not exist for user '" + user.id + "'");
    }

    // Parse the agent instance description
    String agentDescription = agentJson.optString("description", null);
    if (!update && (agentDescription == null || agentDescription.trim().length() == 0))
        agentDescription = "";

    // Parse the agent instance parameter values
    String invalidParameterNames = "";
    SymbolManager symbolManager = new SymbolManager();
    SymbolTable symbolTable = symbolManager.getSymbolTable("parameter_values");
    JSONObject parameterValuesJson = null;
    SymbolValues parameterValues = null;
    if (agentJson.has("parameter_values")) {
        // Parse the parameter values
        parameterValuesJson = agentJson.optJSONObject("parameter_values");
        parameterValues = SymbolValues.fromJson(symbolTable, parameterValuesJson);

        // Validate that they are all valid agent definition parameters
        Map<String, Value> treeMap = new TreeMap<String, Value>();
        for (Symbol symbol : parameterValues)
            treeMap.put(symbol.name, null);
        for (String parameterName : treeMap.keySet())
            if (!agentDefinition.parameters.containsKey(parameterName))
                invalidParameterNames += (invalidParameterNames.length() > 0 ? ", " : "") + parameterName;
        if (invalidParameterNames.length() > 0)
            throw new AgentServerException("Parameter names for agent instance " + agentInstanceName
                    + " are not defined for referenced agent definition " + agentDefinition.name + ": "
                    + invalidParameterNames);
    }

    String triggerInterval = JsonUtils.getString(agentJson, "trigger_interval",
            update ? null : AgentDefinition.DEFAULT_TRIGGER_INTERVAL_EXPRESSION);
    String reportingInterval = JsonUtils.getString(agentJson, "reporting_interval",
            update ? null : AgentDefinition.DEFAULT_REPORTING_INTERVAL_EXPRESSION);

    Boolean publicOutput = null;
    if (agentJson.has("public_output"))
        publicOutput = agentJson.optBoolean("public_output");
    else if (update)
        publicOutput = null;
    else
        publicOutput = false;

    int limitInstanceStatesStored = agentJson.optInt("limit_instance_states_stored", -1);

    Boolean enabled = null;
    if (agentJson.has("enabled"))
        enabled = agentJson.optBoolean("enabled");
    else if (update)
        enabled = null;
    else
        enabled = true;

    // Parse creation and modification timestamps
    String created = agentJson.optString("instantiated", null);
    long timeInstantiated = -1;
    try {
        timeInstantiated = created != null ? DateUtils.parseRfcString(created) : -1;
    } catch (ParseException e) {
        throw new AgentServerException("Unable to parse created date ('" + created + "') - " + e.getMessage());
    }
    String modified = agentJson.optString("updated", null);
    long timeUpdated = -1;
    try {
        timeUpdated = modified != null ? (modified.length() > 0 ? DateUtils.parseRfcString(modified) : 0) : -1;
    } catch (ParseException e) {
        throw new AgentServerException("Unable to parse updated date ('" + modified + "') - " + e.getMessage());
    }

    // Parse state history
    List<AgentState> state = null;
    if (agentJson.has("state")) {
        JSONArray stateHistoryJson = agentJson.optJSONArray("state");
        int numStates = stateHistoryJson.length();
        state = new ArrayList<AgentState>();
        for (int i = 0; i < numStates; i++) {
            JSONObject stateJson = stateHistoryJson.optJSONObject(i);
            AgentState newState = AgentState.fromJson(stateJson, symbolManager);
            state.add(newState);

        }
    }

    // Validate keys
    JsonUtils.validateKeys(agentJson, "Agent instance",
            new ArrayList<String>(Arrays.asList("user", "name", "definition", "description", "parameter_values",
                    "trigger_interval", "reporting_interval", "enabled", "instantiated", "updated", "state",
                    "status", "inputs_changed", "triggered", "outputs_changed", "public_output",
                    "limit_instance_states_stored")));

    AgentInstance agentInstance = new AgentInstance(user, agentDefinition, agentInstanceName, agentDescription,
            parameterValues, triggerInterval, reportingInterval, publicOutput, limitInstanceStatesStored,
            enabled, timeInstantiated, timeUpdated, state, update, false);

    // Return the new agent instance
    return agentInstance;
}

From source file:net.sourceforge.vulcan.web.struts.forms.SchedulerConfigForm.java

@Override
protected void customValidate(ActionMapping mapping, HttpServletRequest request, ActionErrors errors) {
    final String cronExpr = getSchedulerConfig().getCronExpression();

    if (!StringUtils.isBlank(cronExpr)) {
        try {//from ww  w.ja  v a2  s  .  co m
            new CronTrigger("test", "group", cronExpr).computeFirstFireTime(null);
            this.intervalMultiplier = "0";
            this.intervalScalar = "0";
        } catch (ParseException e) {
            errors.add("config.cronExpression", new ActionMessage("errors.cron.syntax"));
        } catch (NumberFormatException e) {
            errors.add("config.cronExpression", new ActionMessage("errors.cron.syntax"));
        } catch (UnsupportedOperationException e) {
            errors.add("config.cronExpression",
                    new ActionMessage("errors.cron.syntax.detailed", new String[] { e.getMessage() }));
        }
    }
}

From source file:org.libreplan.web.common.JobSchedulerController.java

/**
 * Sets the <code>cronExpressionTextBox</code> value from the <code>cronExpressionInputPopup</code>.
 */// www.  j  av a2  s. c o m
public void updateCronExpression() {
    String cronExpression = getCronExpressionString();
    try {
        // Check cron expression format
        new CronExpression(cronExpression);
    } catch (ParseException e) {
        LOG.info("Unable to parse cron expression", e);

        throw new WrongValueException(cronExpressionInputPopup,
                _("Unable to parse cron expression") + ":\n" + e.getMessage());
    }
    cronExpressionTextBox.setValue(cronExpression);
    cronExpressionInputPopup.close();
    Util.saveBindings(cronExpressionTextBox);
}

From source file:org.noorganization.instalistsynch.controller.synch.impl.UnitSynch.java

@Override
public void indexLocal(int _groupId, Date _lastIndexTime) {
    String lastIndexTime = ISO8601Utils.format(_lastIndexTime, false, TimeZone.getTimeZone("GMT+0000"));
    Cursor changeLog = mLocalLogController.getLogsSince(lastIndexTime, eModelType.UNIT);

    while (changeLog.moveToNext()) {
        int actionId = changeLog.getInt(changeLog.getColumnIndex(LogInfo.COLUMN.ACTION));
        eActionType actionType = eActionType.getTypeById(actionId);

        String uuid = changeLog.getString(changeLog.getColumnIndex(LogInfo.COLUMN.ITEM_UUID));
        if (uuid.contentEquals("-"))
            continue;

        List<ModelMapping> existingMappings = mMappingController.get(
                ModelMapping.COLUMN.CLIENT_SIDE_UUID + " = ? AND " + ModelMapping.COLUMN.GROUP_ID + " = ?",
                new String[] { uuid, String.valueOf(_groupId) });
        ModelMapping existingMapping = (existingMappings.size() == 0 ? null : existingMappings.get(0));

        if (actionType == null) {
            Log.w(TAG, "Changelog contains entry without action.");
            continue;
        }//from w w  w  . jav a 2s  . c  om

        switch (actionType) {
        case INSERT: {
            if (existingMapping == null) {
                ModelMapping newMapping = new ModelMapping(null, _groupId, null, uuid,
                        new Date(Constants.INITIAL_DATE), new Date(), false);
                mMappingController.insert(newMapping);
            }
            break;
        }
        case UPDATE: {
            if (existingMapping == null) {
                Log.e(TAG, "Changelog contains update, but mapping does not exist. " + "Ignoring.");
                continue;
            }
            try {
                Date clientDate = ISO8601Utils.parse(
                        changeLog.getString(changeLog.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)),
                        new ParsePosition(0));
                existingMapping.setLastClientChange(clientDate);
                mMappingController.update(existingMapping);
            } catch (ParseException e) {
                Log.e(TAG, "Change log contains invalid date: " + e.getMessage());
                continue;
            }
            break;
        }
        case DELETE: {
            if (existingMapping == null) {
                Log.e(TAG, "Changelog contains deletion, but mapping does not exist. " + "Ignoring.");
                continue;
            }
            try {
                Date clientDate = ISO8601Utils.parse(
                        changeLog.getString(changeLog.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)),
                        new ParsePosition(0));
                existingMapping.setLastClientChange(clientDate);
                existingMapping.setDeleted(true);
                mMappingController.update(existingMapping);
            } catch (ParseException e) {
                Log.e(TAG, "Change log contains invalid date: " + e.getMessage());
                continue;
            }
            break;
        }
        }
    }
    changeLog.close();
}

From source file:org.apache.nifi.web.dao.impl.StandardReportingTaskDAO.java

private List<String> validateProposedConfiguration(final ReportingTaskNode reportingTask,
        final ReportingTaskDTO reportingTaskDTO) {
    final List<String> validationErrors = new ArrayList<>();

    // get the current scheduling strategy
    SchedulingStrategy schedulingStrategy = reportingTask.getSchedulingStrategy();

    // validate the new scheduling strategy if appropriate
    if (isNotNull(reportingTaskDTO.getSchedulingStrategy())) {
        try {/*from   w  w  w . ja  v a2  s. c o  m*/
            // this will be the new scheduling strategy so use it
            schedulingStrategy = SchedulingStrategy.valueOf(reportingTaskDTO.getSchedulingStrategy());
        } catch (IllegalArgumentException iae) {
            validationErrors.add(String.format("Scheduling strategy: Value must be one of [%s]",
                    StringUtils.join(SchedulingStrategy.values(), ", ")));
        }
    }

    // validate the scheduling period based on the scheduling strategy
    if (isNotNull(reportingTaskDTO.getSchedulingPeriod())) {
        switch (schedulingStrategy) {
        case TIMER_DRIVEN:
            final Matcher schedulingMatcher = FormatUtils.TIME_DURATION_PATTERN
                    .matcher(reportingTaskDTO.getSchedulingPeriod());
            if (!schedulingMatcher.matches()) {
                validationErrors.add("Scheduling period is not a valid time duration (ie 30 sec, 5 min)");
            }
            break;
        case CRON_DRIVEN:
            try {
                new CronExpression(reportingTaskDTO.getSchedulingPeriod());
            } catch (final ParseException pe) {
                throw new IllegalArgumentException(
                        String.format("Scheduling Period '%s' is not a valid cron expression: %s",
                                reportingTaskDTO.getSchedulingPeriod(), pe.getMessage()));
            } catch (final Exception e) {
                throw new IllegalArgumentException("Scheduling Period is not a valid cron expression: "
                        + reportingTaskDTO.getSchedulingPeriod());
            }
            break;
        }
    }

    return validationErrors;
}