List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:net.netheos.pcsapi.providers.dropbox.Dropbox.java
/** * Generates a CFile from its json representation * * @param jObj JSON object representing a CFile * @return the CFile object corresponding to the JSON object *//*from ww w. j av a2s . co m*/ private CFile parseCFile(JSONObject jObj) { CFile cfile; if (jObj.optBoolean("is_dir", false)) { cfile = new CFolder(new CPath(jObj.getString("path"))); } else { cfile = new CBlob(new CPath(jObj.getString("path")), jObj.getLong("bytes"), jObj.getString("mime_type")); String stringDate = jObj.getString("modified"); try { // stringDate looks like: "Fri, 07 Mar 2014 17:47:55 +0000" SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US); Date modified = sdf.parse(stringDate); cfile.setModificationDate(modified); } catch (ParseException ex) { throw new CStorageException( "Can't parse date modified: " + stringDate + " (" + ex.getMessage() + ")", ex); } } return cfile; }
From source file:org.b3log.solo.service.InitService.java
/** * Archive the create date with the specified article. * * @param article the specified article, for example, * <pre>/*from w w w. j a v a 2s .c o m*/ * { * ...., * "oId": "", * "articleCreateDate": java.util.Date, * .... * } * </pre> * @throws RepositoryException repository exception */ public void archiveDate(final JSONObject article) throws RepositoryException { final Date createDate = (Date) article.opt(Article.ARTICLE_CREATE_DATE); final String createDateString = ArchiveDate.DATE_FORMAT.format(createDate); final JSONObject archiveDate = new JSONObject(); try { archiveDate.put(ArchiveDate.ARCHIVE_TIME, ArchiveDate.DATE_FORMAT.parse(createDateString).getTime()); archiveDate.put(ArchiveDate.ARCHIVE_DATE_ARTICLE_COUNT, 1); archiveDate.put(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT, 1); archiveDateRepository.add(archiveDate); } catch (final ParseException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new RepositoryException(e); } final JSONObject archiveDateArticleRelation = new JSONObject(); archiveDateArticleRelation.put(ArchiveDate.ARCHIVE_DATE + "_" + Keys.OBJECT_ID, archiveDate.optString(Keys.OBJECT_ID)); archiveDateArticleRelation.put(Article.ARTICLE + "_" + Keys.OBJECT_ID, article.optString(Keys.OBJECT_ID)); archiveDateArticleRepository.add(archiveDateArticleRelation); }
From source file:com.neusoft.mid.clwapi.service.msg.MsgServiceImpl.java
/** * ???/* ww w . j av a 2 s .co m*/ * * @param token * ?. * @param eTag * * @return ???. */ @Override public Object getMsgMold(String token, String eTag) { // ?? boolean checkEtag = true; // ?ID String usrId = context.getHttpHeaders().getHeaderString(UserInfoKey.USR_ID); String plaETag = context.getHttpHeaders().getHeaderString(UserInfoKey.RULE_ETAG); logger.info("????"); logger.info("?ETag:" + eTag); logger.info("??ETag:" + plaETag); // ? Date dateTer = null; // ?? Date datePla = null; // ? if (eTag == null) { logger.error("If-None-Match"); throw new ApplicationException(ErrorConstant.ERROR10001, Response.Status.BAD_REQUEST); } if (!eTag.equals(HttpConstant.TIME_ZERO)) { try { dateTer = BeanUtil.checkTimeForm(eTag, HttpConstant.TIME_FORMAT); } catch (ParseException e) { logger.error("??" + e.getMessage()); throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST); } } else { // ??? checkEtag = false; } // ?? List<MsgMoldInfo> list = msgMapper.getMsgMoldInfoWithUsr(usrId); // ??? if (list == null || list.size() == 0) { logger.info("???"); return Response.notModified().build(); } else { // ?? String e = list.get(0).getEditT(); // ? if (!StringUtils.equals(e, plaETag)) { logger.info("?"); // ??ETag upUserETag(token, usrId, e); plaETag = e; } } // ?? try { datePla = BeanUtil.checkTimeForm(plaETag, HttpConstant.TIME_FORMAT); } catch (ParseException e) { logger.error("???" + e.getMessage()); throw new ApplicationException(ErrorConstant.ERROR90000, Response.Status.INTERNAL_SERVER_ERROR); } // ??NO_CONTENT if ((list == null || list.size() == 0) && !plaETag.equals(HttpConstant.ZERO)) { logger.info("??"); return Response.noContent().build(); } else if (checkEtag && dateTer.compareTo(datePla) == 0) { // ?? logger.info("???"); return Response.notModified().build(); } else if (checkEtag && dateTer.compareTo(datePla) > 0) { logger.error("???"); throw new ApplicationException(ErrorConstant.ERROR10103, Response.Status.BAD_REQUEST); } // ? List<MsgMoldInfo> temp = new ArrayList<MsgMoldInfo>(); // ???? Iterator<MsgMoldInfo> it = list.iterator(); while (it.hasNext()) { MsgMoldInfo iMsgMoldInfo = it.next(); // ?? if (iMsgMoldInfo.getDel().equals(HttpConstant.MSGMOLD_DEL_FALSE)) { temp.add(iMsgMoldInfo); } } FindMsgMoldResp iFindMsgMoldResp = new FindMsgMoldResp(); iFindMsgMoldResp.setEtag(plaETag); iFindMsgMoldResp.setList(temp); return JacksonUtils.toJsonRuntimeException(iFindMsgMoldResp); }
From source file:fr.paris.lutece.portal.service.admin.DefaultImportAdminUserService.java
/** * {@inheritDoc}//from www . java2s .co m */ @Override protected List<CSVMessageDescriptor> readLineOfCSVFile(String[] strLineDataArray, int nLineNumber, Locale locale, String strBaseUrl) { List<CSVMessageDescriptor> listMessages = new ArrayList<CSVMessageDescriptor>(); int nIndex = 0; String strAccessCode = strLineDataArray[nIndex++]; String strLastName = strLineDataArray[nIndex++]; String strFirstName = strLineDataArray[nIndex++]; String strEmail = strLineDataArray[nIndex++]; boolean bUpdateUser = getUpdateExistingUsers(); int nUserId = 0; if (bUpdateUser) { int nAccessCodeUserId = AdminUserHome.checkAccessCodeAlreadyInUse(strAccessCode); int nEmailUserId = AdminUserHome.checkEmailAlreadyInUse(strEmail); if (nAccessCodeUserId > 0) { nUserId = nAccessCodeUserId; } else if (nEmailUserId > 0) { nUserId = nEmailUserId; } bUpdateUser = nUserId > 0; } String strStatus = strLineDataArray[nIndex++]; int nStatus = 0; if (StringUtils.isNotEmpty(strStatus) && StringUtils.isNumeric(strStatus)) { nStatus = Integer.parseInt(strStatus); } else { Object[] args = { strLastName, strFirstName, nStatus }; String strMessage = I18nService.getLocalizedString(MESSAGE_NO_STATUS, args, locale); CSVMessageDescriptor message = new CSVMessageDescriptor(CSVMessageLevel.INFO, nLineNumber, strMessage); listMessages.add(message); } String strLocale = strLineDataArray[nIndex++]; String strLevelUser = strLineDataArray[nIndex++]; int nLevelUser = 3; if (StringUtils.isNotEmpty(strLevelUser) && StringUtils.isNumeric(strLevelUser)) { nLevelUser = Integer.parseInt(strLevelUser); } else { Object[] args = { strLastName, strFirstName, nLevelUser }; String strMessage = I18nService.getLocalizedString(MESSAGE_NO_LEVEL, args, locale); CSVMessageDescriptor message = new CSVMessageDescriptor(CSVMessageLevel.INFO, nLineNumber, strMessage); listMessages.add(message); } // We ignore the reset password attribute because we set it to true anyway. // String strResetPassword = strLineDataArray[nIndex++]; nIndex++; boolean bResetPassword = true; String strAccessibilityMode = strLineDataArray[nIndex++]; boolean bAccessibilityMode = Boolean.parseBoolean(strAccessibilityMode); // We ignore the password max valid date attribute because we changed the password. // String strPasswordMaxValidDate = strLineDataArray[nIndex++]; nIndex++; Timestamp passwordMaxValidDate = null; // We ignore the account max valid date attribute // String strAccountMaxValidDate = strLineDataArray[nIndex++]; nIndex++; Timestamp accountMaxValidDate = AdminUserService.getAccountMaxValidDate(); String strDateLastLogin = strLineDataArray[nIndex++]; Timestamp dateLastLogin = new Timestamp(AdminUser.DEFAULT_DATE_LAST_LOGIN.getTime()); if (StringUtils.isNotBlank(strDateLastLogin)) { DateFormat dateFormat = new SimpleDateFormat(); Date dateParsed; try { dateParsed = dateFormat.parse(strDateLastLogin); } catch (ParseException e) { AppLogService.error(e.getMessage(), e); dateParsed = null; } if (dateParsed != null) { dateLastLogin = new Timestamp(dateParsed.getTime()); } } AdminUser user = null; if (bUpdateUser) { user = AdminUserHome.findByPrimaryKey(nUserId); } else { user = new LuteceDefaultAdminUser(); } user.setAccessCode(strAccessCode); user.setLastName(strLastName); user.setFirstName(strFirstName); user.setEmail(strEmail); user.setStatus(nStatus); user.setUserLevel(nLevelUser); user.setLocale(new Locale(strLocale)); user.setAccessibilityMode(bAccessibilityMode); if (bUpdateUser) { user.setUserId(nUserId); // We update the user AdminUserHome.update(user); } else { // We create the user user.setPasswordReset(bResetPassword); user.setPasswordMaxValidDate(passwordMaxValidDate); user.setAccountMaxValidDate(accountMaxValidDate); user.setDateLastLogin(dateLastLogin); if (AdminAuthenticationService.getInstance().isDefaultModuleUsed()) { LuteceDefaultAdminUser defaultAdminUser = (LuteceDefaultAdminUser) user; String strPassword = AdminUserService.makePassword(); defaultAdminUser.setPassword(AdminUserService.encryptPassword(strPassword)); AdminUserHome.create(defaultAdminUser); AdminUserService.notifyUser(AppPathService.getProdUrl(strBaseUrl), user, strPassword, PROPERTY_MESSAGE_EMAIL_SUBJECT_NOTIFY_USER, TEMPLATE_NOTIFY_USER); } else { AdminUserHome.create(user); } } // We remove any previous right, roles, workgroup and attributes of the user AdminUserHome.removeAllRightsForUser(user.getUserId()); AdminUserHome.removeAllRolesForUser(user.getUserId()); AdminUserFieldFilter auFieldFilter = new AdminUserFieldFilter(); auFieldFilter.setIdUser(user.getUserId()); AdminUserFieldHome.removeByFilter(auFieldFilter); // We get every attribute, role, right and workgroup of the user Map<Integer, List<String>> mapAttributesValues = new HashMap<Integer, List<String>>(); List<String> listAdminRights = new ArrayList<String>(); List<String> listAdminRoles = new ArrayList<String>(); List<String> listAdminWorkgroups = new ArrayList<String>(); while (nIndex < strLineDataArray.length) { String strValue = strLineDataArray[nIndex]; if (StringUtils.isNotBlank(strValue) && (strValue.indexOf(getAttributesSeparator()) > 0)) { int nSeparatorIndex = strValue.indexOf(getAttributesSeparator()); String strLineId = strValue.substring(0, nSeparatorIndex); if (StringUtils.isNotBlank(strLineId)) { if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_RIGHT)) { listAdminRights.add(strValue.substring(nSeparatorIndex + 1)); } else if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_ROLE)) { listAdminRoles.add(strValue.substring(nSeparatorIndex + 1)); } else if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_WORKGROUP)) { listAdminWorkgroups.add(strValue.substring(nSeparatorIndex + 1)); } else { int nAttributeId = Integer.parseInt(strLineId); String strAttributeValue = strValue.substring(nSeparatorIndex + 1); List<String> listValues = mapAttributesValues.get(nAttributeId); if (listValues == null) { listValues = new ArrayList<String>(); } listValues.add(strAttributeValue); mapAttributesValues.put(nAttributeId, listValues); } } } nIndex++; } // We create rights for (String strRight : listAdminRights) { AdminUserHome.createRightForUser(user.getUserId(), strRight); } // We create roles for (String strRole : listAdminRoles) { AdminUserHome.createRoleForUser(user.getUserId(), strRole); } // We create workgroups for (String strWorkgoup : listAdminWorkgroups) { AdminWorkgroupHome.addUserForWorkgroup(user, strWorkgoup); } List<IAttribute> listAttributes = _attributeService.getAllAttributesWithoutFields(locale); Plugin pluginCore = PluginService.getCore(); // We save the attributes found for (IAttribute attribute : listAttributes) { if (attribute instanceof ISimpleValuesAttributes) { List<String> listValues = mapAttributesValues.get(attribute.getIdAttribute()); if ((listValues != null) && (listValues.size() > 0)) { int nIdField = 0; boolean bCoreAttribute = (attribute.getPlugin() == null) || StringUtils.equals(pluginCore.getName(), attribute.getPlugin().getName()); for (String strValue : listValues) { int nSeparatorIndex = strValue.indexOf(getAttributesSeparator()); if (nSeparatorIndex >= 0) { nIdField = 0; try { nIdField = Integer.parseInt(strValue.substring(0, nSeparatorIndex)); } catch (NumberFormatException e) { nIdField = 0; } strValue = strValue.substring(nSeparatorIndex + 1); } else { nIdField = 0; } String[] strValues = { strValue }; try { List<AdminUserField> listUserFields = ((ISimpleValuesAttributes) attribute) .getUserFieldsData(strValues, user); for (AdminUserField userField : listUserFields) { if (userField != null) { userField.getAttributeField().setIdField(nIdField); AdminUserFieldHome.create(userField); } } if (!bCoreAttribute) { for (AdminUserFieldListenerService adminUserFieldListenerService : SpringContextService .getBeansOfType(AdminUserFieldListenerService.class)) { adminUserFieldListenerService.doCreateUserFields(user, listUserFields, locale); } } } catch (Exception e) { AppLogService.error(e.getMessage(), e); String strErrorMessage = I18nService .getLocalizedString(MESSAGE_ERROR_IMPORTING_ATTRIBUTES, locale); CSVMessageDescriptor error = new CSVMessageDescriptor(CSVMessageLevel.ERROR, nLineNumber, strErrorMessage); listMessages.add(error); } } } } } return listMessages; }
From source file:edu.psu.iam.cpr.core.api.helper.FindPersonHelper.java
/** * Match a user's (partial) date of birth against the value stored in the CPR. * @param dob The (partial) DOB to be matched. * /*from w ww . j av a2 s.com*/ * @return true If the record in the CPR matches the input parameters; otherwise, false. * @throws GeneralDatabaseException * @throws CprException */ public boolean matchDOBInCPR(final String dob) throws CprException { LOG4J_LOGGER.debug("FPH: checking date of birth; personId = " + personId + ", dob = " + dob); if (personId < 0) { return false; } if (dob == null || "".equals(dob.trim())) { return false; } Date d; try { LOG4J_LOGGER.debug("FPH: ready for conversion of dob = " + dob + " to Date object"); d = parseDateString(dob, true); } catch (ParseException ex) { LOG4J_LOGGER.debug("FPH: parse exception = " + ex.getMessage()); return false; } Calendar inputCal = Calendar.getInstance(Locale.US); inputCal.setTime(d); DateOfBirthTable dobTable = new DateOfBirthTable(); LOG4J_LOGGER.debug("FPH: ready for conversion to retrieve date from DOB table"); dobTable.setReturnHistoryFlag(false); DateOfBirthReturn[] dobReturn = dobTable.getDateOfBirthForPersonId(db, personId); if (dobReturn.length == 0 || dobReturn[0].getDob() == null) { LOG4J_LOGGER.debug("FPH: no dob found"); return false; } String cprDOB = dobReturn[0].getDob(); LOG4J_LOGGER.debug("FPH: date of birth found " + cprDOB); try { final Date cprDate = parseDateString(cprDOB, true); final Calendar cprCal = convertDateToCalendar(cprDate, true); // if the exact dates match, return true if (dob.equals(cprDate)) { return true; } // check for a partial match int inputMonth = inputCal.get(Calendar.MONTH); int cprMonth = cprCal.get(Calendar.MONTH); int inputDay = inputCal.get(Calendar.DAY_OF_MONTH); int cprDay = cprCal.get(Calendar.DAY_OF_MONTH); int inputYear = inputCal.get(Calendar.YEAR); int cprYear = inputCal.get(Calendar.YEAR); if ((inputMonth == cprMonth && (inputDay == cprDay || inputYear == cprYear)) || (inputDay == cprDay && inputYear == cprYear)) { return true; } return false; } catch (Exception e) { return false; } }
From source file:org.kuali.kfs.module.tem.service.impl.TravelExpenseServiceImpl.java
/** * @see org.kuali.kfs.module.tem.service.TravelExpenseService#createHistoricalTravelExpense(org.kuali.kfs.module.tem.businessobject.CreditCardStagingData) *//*from ww w . j av a2 s.c o m*/ @Override public HistoricalTravelExpense createHistoricalTravelExpense(CreditCardStagingData creditCard) { HistoricalTravelExpense expense = new HistoricalTravelExpense(); try { expense.setImportDate(dateTimeService.convertToSqlDate(creditCard.getProcessingTimestamp())); } catch (ParseException e) { throw new RuntimeException("Unable to convert timestamp to date " + e.getMessage()); } CreditCardAgency ccAgency = creditCard.getCreditCardAgency(); expense.setCreditCardOrAgencyCode(ccAgency.getCreditCardOrAgencyCode()); expense.setTravelExpenseTypeCode(creditCard.getExpenseTypeCode()); expense.setDescription(creditCard.getExpenseTypeCode()); expense.setTravelCompany(creditCard.getMerchantName()); expense.setAmount(creditCard.getTransactionAmount()); expense.setTransactionPostingDate(creditCard.getTransactionDate()); expense.setCreditCardStagingDataId(creditCard.getId()); expense.setProfileId(creditCard.getTemProfileId()); expense.setLocation(creditCard.getLocation()); expense.setReconciled(ReconciledCodes.UNRECONCILED); return expense; }
From source file:org.kuali.kfs.module.tem.service.impl.TravelExpenseServiceImpl.java
@Override public HistoricalTravelExpense createHistoricalTravelExpense(AgencyStagingData agency) { HistoricalTravelExpense expense = new HistoricalTravelExpense(); try {/*from w ww .j av a 2 s . co m*/ expense.setImportDate(dateTimeService.convertToSqlDate(agency.getProcessingTimestamp())); } catch (ParseException e) { throw new RuntimeException("Unable to convert timestamp to date " + e.getMessage()); } CreditCardAgency ccAgency = agency.getCreditCardAgency(); expense.setCreditCardAgency(ccAgency); expense.setCreditCardOrAgencyCode(ccAgency.getCreditCardOrAgencyCode()); final ExpenseType expenseType = getDefaultExpenseTypeForCategory(agency.getExpenseTypeCategory()); if (expenseType != null) { expense.setTravelExpenseTypeCode(expenseType.getCode()); } expense.setTravelCompany(agency.getMerchantName()); expense.setAmount(agency.getTripExpenseAmount()); expense.setTransactionPostingDate(agency.getTransactionPostingDate()); expense.setAgencyStagingDataId(agency.getId()); expense.setTripId(agency.getTripId()); expense.setProfileId(agency.getTemProfileId()); expense.setReconciled(ReconciledCodes.UNRECONCILED); return expense; }
From source file:org.kuali.kra.committee.print.ScheduleXmlStream.java
public ScheduleMasterData setScheduleMasterData(CommitteeSchedule scheduleDetailsBean, ScheduleMasterData currentSchedule) { scheduleDetailsBean.refreshNonUpdateableReferences(); String committeeId = scheduleDetailsBean.getParentCommittee().getCommitteeId(); currentSchedule.setScheduleId(scheduleDetailsBean.getScheduleId()); currentSchedule.setCommitteeId(committeeId); currentSchedule.setCommitteeName(scheduleDetailsBean.getParentCommittee().getCommitteeName()); currentSchedule.setScheduleStatusCode(BigInteger.valueOf(scheduleDetailsBean.getScheduleStatusCode())); currentSchedule.setScheduleStatusDesc(scheduleDetailsBean.getScheduleStatus().getDescription()); if (scheduleDetailsBean.getScheduledDate() != null) { currentSchedule/*from w w w . ja v a 2s. c o m*/ .setScheduledDate(getDateTimeService().getCalendar(scheduleDetailsBean.getScheduledDate())); } else { currentSchedule.setScheduledDate(getDateTimeService().getCurrentCalendar()); } try { if (scheduleDetailsBean.getTime() != null) { Date date; date = getDateTimeService().convertToSqlDate(scheduleDetailsBean.getTime()); currentSchedule.setScheduledTime(getDateTimeService().getCalendar(date)); } currentSchedule.setPlace(scheduleDetailsBean.getPlace()); if (scheduleDetailsBean.getProtocolSubDeadline() != null) { currentSchedule.setProtocolSubDeadline( getDateTimeService().getCalendar(scheduleDetailsBean.getProtocolSubDeadline())); } if (scheduleDetailsBean.getMeetingDate() != null) { currentSchedule .setMeetingDate(getDateTimeService().getCalendar(scheduleDetailsBean.getMeetingDate())); } if (scheduleDetailsBean.getStartTime() != null) { currentSchedule.setStartTime(getDateTimeService() .getCalendar(getDateTimeService().convertToSqlDate(scheduleDetailsBean.getStartTime()))); } if (scheduleDetailsBean.getEndTime() != null) { currentSchedule.setEndTime(getDateTimeService() .getCalendar(getDateTimeService().convertToSqlDate(scheduleDetailsBean.getEndTime()))); } if (scheduleDetailsBean.getAgendaProdRevDate() != null) { currentSchedule.setAgendaProdRevDate( getDateTimeService().getCalendar(scheduleDetailsBean.getAgendaProdRevDate())); } } catch (ParseException e) { LOG.error(e.getMessage(), e); } currentSchedule.setMaxProtocols(new BigInteger(String.valueOf(scheduleDetailsBean.getMaxProtocols()))); if (scheduleDetailsBean.getComments() != null) { currentSchedule.setComments(scheduleDetailsBean.getComments()); } return currentSchedule; }
From source file:com.snaplogic.snaps.uniteller.BaseService.java
@Override protected void process(Document document, String inputViewName) { try {//from www.j a va 2s . c o m AccountBean bean = account.connect(); String UFSConfigFilePath = urlEncoder.validateAndEncodeURI(bean.getConfigFilePath(), PATTERN, null) .toString(); String UFSSecurityFilePath = urlEncoder .validateAndEncodeURI(bean.getSecurityPermFilePath(), PATTERN, null).toString(); /* instantiating USFCreationClient */ Class<?> CustomUSFCreationClient = Class.forName(UFS_FOLIO_CREATION_CLIENT_PKG_URI); Constructor<?> constructor = CustomUSFCreationClient .getDeclaredConstructor(new Class[] { IUFSConfigMgr.class, IUFSSecurityMgr.class }); Object USFCreationClientObj = constructor.newInstance(CustomUFSConfigMgr.getInstance(UFSConfigFilePath), CustomUFSSecurityMgr.getInstance(UFSSecurityFilePath)); Method setAutoUpdatePsw = CustomUSFCreationClient.getDeclaredMethod("setAutoUpdatePsw", Boolean.TYPE); setAutoUpdatePsw.invoke(USFCreationClientObj, autoUpdatePsw); /* Preparing the request for USF */ Object data; if (document != null && (data = document.get()) != null) { if (data instanceof Map) { Map<String, Object> map = (Map<String, Object>) data; Class<?> UFSRequest = Class.forName(getUFSReqClassType()); Object UFSRequestObj = UFSRequest.newInstance(); Object inputFieldValue = null; Calendar cal = Calendar.getInstance(); for (Method method : UFSRequest.getDeclaredMethods()) { if (isSetter(method) && (inputFieldValue = map.get(method.getName().substring(3))) != null) { try { String paramType = method.getParameterTypes()[0].getName(); if (paramType.equalsIgnoreCase(String.class.getName())) { method.invoke(UFSRequest.cast(UFSRequestObj), String.valueOf(inputFieldValue)); } else if (paramType.equalsIgnoreCase(Double.class.getSimpleName())) { method.invoke(UFSRequest.cast(UFSRequestObj), Double.parseDouble(String.valueOf(inputFieldValue))); } else if (paramType.equalsIgnoreCase(INT)) { method.invoke(UFSRequest.cast(UFSRequestObj), Integer.parseInt(String.valueOf(inputFieldValue))); } else if (paramType.equalsIgnoreCase(Calendar.class.getName())) { try { cal.setTime(sdtf.parse(String.valueOf(inputFieldValue))); } catch (ParseException pe1) { try { cal.setTime(sdf.parse(String.valueOf(inputFieldValue))); } catch (ParseException pe) { writeToErrorView( String.format(DATE_PARSER_ERROR, DATETIME_FORMAT, DATE_FORMAT), pe.getMessage(), ERROR_RESOLUTION, pe); } } method.invoke(UFSRequest.cast(UFSRequestObj), cal); } } catch (IllegalArgumentException iae) { writeToErrorView(String.format(ILLEGAL_ARGS_EXE, method.getName()), iae.getMessage(), ERROR_RESOLUTION, iae); } catch (InvocationTargetException ite) { writeToErrorView(ite.getTargetException().getMessage(), ite.getMessage(), ERROR_RESOLUTION, ite); } } } /* Invoking the request over USFCreationClient */ Object UFSResponseObj = null; Method creationClientMethod = CustomUSFCreationClient .getMethod(getCamelCaseForMethod(resourceType), UFSRequest); try { UFSResponseObj = creationClientMethod.invoke(USFCreationClientObj, UFSRequest.cast(UFSRequestObj)); } catch (IllegalArgumentException iae) { writeToErrorView(String.format(ILLEGAL_ARGS_EXE, creationClientMethod.getName()), iae.getMessage(), ERROR_RESOLUTION, iae); } catch (InvocationTargetException ite) { writeToErrorView(ite.getTargetException().getMessage(), ite.getMessage(), ERROR_RESOLUTION, ite); } if (null != UFSResponseObj) { outputViews.write(documentUtility.newDocument(processResponseObj(UFSResponseObj))); counter.inc(); } } else { writeToErrorView(NO_DATA_ERRMSG, NO_DATA_WARNING, NO_DATA_REASON, NO_DATA_RESOLUTION); } } } catch (Exception ex) { writeToErrorView(ERRORMSG, ex.getMessage(), ERROR_RESOLUTION, ex); } }
From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java
private void updateAbsolute() { startDate = null;/*from ww w. j a va 2s. c o m*/ endDate = null; try { if (startTime.indexOf(",") == -1) { startDate = dateParser.parse(startTime); } else { startDate = dateTimeParser.parse(startTime); } if (endTime.indexOf(",") == -1) { endDate = dateParser.parse(endTime); } else { endDate = dateTimeParser.parse(endTime); } } catch (ParseException e) { throw new IllegalArgumentException("Bad format on startTime and/or endTime: " + e.getMessage()); } }