List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:com.neusoft.mid.clwapi.service.statistics.StatisticsServiceImpl.java
/** * ??./*from w w w. jav a 2s . c o m*/ * * @param token * ?. * @param VIN * VIN * @param month * ,?yyyymm LATEST_MONTH * @return ??. */ @Override public Response getCarReport(String token, String VIN, String month) { VIN = StringUtils.strip(VIN); month = StringUtils.strip(month); String epid = context.getHttpHeaders().getHeaderString(UserInfoKey.ENTERPRISE_ID); logger.info("?-?ID:" + epid + ",VIN:" + VIN + "," + month); if (CheckRequestParam.isEmpty(epid)) { logger.info("?--?ID"); throw new ApplicationException(ErrorConstant.ERROR90000, Response.Status.INTERNAL_SERVER_ERROR); } Date reportMonth; List<CarMonthData> infos; //? if (HttpConstant.LATEST_MONTH.equals(month)) { infos = stMapper.getValidCarReport(VIN); if (CheckRequestParam.isEmpty(infos)) { logger.info("?-VIN:" + VIN + "???"); return Response.status(Response.Status.NO_CONTENT).header(HttpHeaders.CACHE_CONTROL, "no-store") .header("Pragma", "no-cache").build(); } try { reportMonth = TimeUtil.parseStringToDate(infos.get(0).getDateTime(), HttpConstant.MONTH_FORMAT_1); } catch (ParseException e) { logger.error("?-yyyyMM?" + e.getMessage()); throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST); } } else { //? try { reportMonth = TimeUtil.parseStringToDate(month, HttpConstant.MONTH_FORMAT); } catch (ParseException e) { logger.error("?-yyyyMM?" + e.getMessage()); throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST); } if (reportMonth.after(TimeUtil.getLastMonthD())) { logger.info("?-??" + month + "?"); throw new ApplicationException(ErrorConstant.ERROR10004, Response.Status.BAD_REQUEST); } infos = stMapper.getCarMonthData(month, VIN); if (CheckRequestParam.isEmpty(infos)) { logger.info("?-VIN:" + VIN + "???"); return Response.status(Response.Status.NO_CONTENT).header(HttpHeaders.CACHE_CONTROL, "no-store") .header("Pragma", "no-cache").build(); } } CarStatReport statInfo = convertCarResp(infos, reportMonth); if (CheckRequestParam.isEmpty(statInfo)) { logger.info("?-VIN:" + VIN + "???"); return Response.status(Response.Status.NO_CONTENT).header(HttpHeaders.CACHE_CONTROL, "no-store") .header("Pragma", "no-cache").build(); } return Response.ok(JacksonUtils.toJsonRuntimeException(statInfo)) .header(HttpHeaders.CACHE_CONTROL, "no-store").header("Pragma", "no-cache").build(); }
From source file:org.jahia.services.content.rules.Service.java
public void scheduleAction(AddedNodeFact node, final String actionToExecute, final String cronExpression, KnowledgeHelper drools) throws SchedulerException, RepositoryException { try {/*from w w w . ja v a 2s .c o m*/ doScheduleAction(node, actionToExecute, getTrigger(node, cronExpression, null, null), drools); } catch (ParseException e) { logger.error(e.getMessage(), e); } }
From source file:co.adun.mvnejb3jpa.web.controller.InitiateLeadController.java
private List<LtLead> process(LeadModel model) throws BusinessException { List<LtLeadModel> ltLeadsModel = model.getLtLeadsModel(); List<LtLead> ltLeads = new ArrayList<LtLead>(); LtUser user = userService.getCurrentUser(WebSecurityContext.getUsername()); DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH); for (LtLeadModel ltLeadModel : ltLeadsModel) { LtLead ltLead = ltLeadModel.getLtLead(); if (ltLead != null && !StringUtils.isEmpty(ltLeadModel.getFormId())) { DateValueModel birthDateModel = ltLeadModel.getBirthDateModel(); if (!StringUtils.isEmpty(birthDateModel.getValue())) { Date date = null; try { date = dateFormat.parse(birthDateModel.getValue()); } catch (ParseException e) { logger.info(e.getMessage()); }//from w ww . j a v a 2 s . c o m ltLead.getLtSubject().setBirthDate(date); } DateValueModel entryDateModel = ltLeadModel.getEntryDateModel(); if (!StringUtils.isEmpty(entryDateModel.getValue())) { Date date = null; try { date = dateFormat.parse(entryDateModel.getValue()); } catch (ParseException e) { logger.info(e.getMessage()); } ltLead.getLtSubject().setEntryDate(date); } MissionCode missionCode = ltLead.getMissionCode(); // if Mission Box is selected by not Supervisor and Analyst, // assign // Lead to mission box boolean assignToSup = false; boolean assignToAna = false; logger.info("Calling leadService.save"); /* * If the Analyst is selected, the lead is assigned to the * analyst. If analyst is not selected and Supervisor is * selected, then the lead is assigned to the Supervisor */ // assign to supervisor, if it is selected ValueModel analystModel = ltLeadModel.getAnalystModel(); if (!StringUtils.isEmpty(analystModel.getValue())) { LtUser ltUserByLtAssignToUserId = new LtUser(); ltUserByLtAssignToUserId.setId(new Long(analystModel.getValue())); ltLead.setLtUserByLtAssignToUserId(ltUserByLtAssignToUserId); assignToAna = true; } ValueModel supervisorModel = ltLeadModel.getSupervisorModel(); logger.info("Supervisor model value=" + supervisorModel.getValue()); if (!assignToAna) { if (!StringUtils.isEmpty(supervisorModel.getValue())) { LtUser ltUserByLtAssignToUserId = new LtUser(); ltUserByLtAssignToUserId.setId(new Long(supervisorModel.getValue())); ltLead.setLtUserByLtAssignToUserId(ltUserByLtAssignToUserId); assignToSup = true; } } StatusCode statusCode = new StatusCode(); if (!assignToSup && !assignToAna) { // TODO refactor to Constants if (missionCode != null) { setMissionCodeToLead(missionCode, ltLead); } else { ltLead.setMissionCode(null); } // set Lead to unassigned status, when it is not assigned to // a // person statusCode.setId(100L); // Unassigned cod } // Lead is in assigned status, when is is assigned to a person if (assignToSup == true || assignToAna == true) { statusCode.setId(101L); // assigned code ltLead.setMissionCode(null); } ltLead.setStatusCode(statusCode); LeadGeneratedFromCode leadGeneratedFromCode = ltLead.getLeadGeneratedFromCode(); String abbreviation = leadGeneratedFromCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { leadGeneratedFromCode.setId(new Long(strings[0])); leadGeneratedFromCode.setAbbreviation(strings[1]); } } LeadTypeCode leadTypeCode = ltLead.getLeadTypeCode(); abbreviation = leadTypeCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { leadTypeCode.setId(new Long(strings[0])); leadTypeCode.setAbbreviation(strings[1]); } } Set<LtLeadSource> ltLeadSources = new HashSet<LtLeadSource>(); LtLeadSource ltLeadSource = ltLeadModel.getLtLeadSource(); ContactTypeCode contactTypeCode = ltLeadSource.getContactTypeCode(); abbreviation = contactTypeCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { contactTypeCode.setId(new Long(strings[0])); contactTypeCode.setAbbreviation(strings[1]); ltLeadSource.setLtLead(ltLead); ltLeadSources.add(ltLeadSource); } } ltLead.setLtLeadSources(ltLeadSources); Set<LtLeadComment> ltLeadComments = new HashSet<LtLeadComment>(); LtLeadComment ltLeadComment = ltLeadModel.getLtLeadComment(); if (ltLeadComment != null && !StringUtils.isEmpty(ltLeadComment.getLeadComment())) { ltLeadComments.add(ltLeadComment); } ltLead.setLtLeadComments(ltLeadComments); ClassAdmissionCode classAdmissionCode = ltLead.getLtSubject().getClassAdmissionCode(); abbreviation = classAdmissionCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { classAdmissionCode.setId(new Long(strings[0])); classAdmissionCode.setAbbreviation(strings[1]); } else { ltLead.getLtSubject().setClassAdmissionCode(null); } } else { ltLead.getLtSubject().setClassAdmissionCode(null); } CountryCode countryCode = ltLead.getLtSubject().getCountryCode(); abbreviation = countryCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { countryCode.setId(new Long(strings[0])); countryCode.setAbbreviation(strings[1]); } else { ltLead.getLtSubject().setCountryCode(null); } } else { ltLead.getLtSubject().setCountryCode(null); } GenderCode genderCode = ltLead.getLtSubject().getGenderCode(); abbreviation = genderCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { genderCode.setId(new Long(strings[0])); genderCode.setAbbreviation(strings[1]); } else { ltLead.getLtSubject().setGenderCode(null); } } else { ltLead.getLtSubject().setGenderCode(null); } Set<LtLeadSpecialProject> ltLeadSpecialProjects = new HashSet<LtLeadSpecialProject>(); for (LtLeadSpecialProject ltLeadSpecialProject : ltLeadModel.getLtLeadSpecialProjects()) { SpecialProjectCode specialProjectCode = ltLeadSpecialProject.getSpecialProjectCode(); abbreviation = specialProjectCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { specialProjectCode.setId(new Long(strings[0])); specialProjectCode.setAbbreviation(strings[1]); ltLeadSpecialProject.setLtLead(ltLead); ltLeadSpecialProjects.add(ltLeadSpecialProject); } } } ltLead.setLtLeadSpecialProjects(ltLeadSpecialProjects); Set<LtSubjectCitizenshipCountry> ltSubjectCitizenshipCountries = new HashSet<LtSubjectCitizenshipCountry>(); for (LtSubjectCitizenshipCountry ltSubjectCitizenshipCountry : ltLeadModel .getLtSubjectCitizenshipCountries()) { CountryCode cocCountryCode = ltSubjectCitizenshipCountry.getCountryCode(); abbreviation = cocCountryCode.getAbbreviation(); if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) { String[] strings = StringUtils.split(abbreviation, ":"); if (strings != null) { cocCountryCode.setId(new Long(strings[0])); cocCountryCode.setAbbreviation(strings[1]); ltSubjectCitizenshipCountry.setLtSubject(ltLead.getLtSubject()); ltSubjectCitizenshipCountries.add(ltSubjectCitizenshipCountry); } } } ltLead.getLtSubject().setLtSubjectCitizenshipCountries(ltSubjectCitizenshipCountries); Set<LtAssociatedLead> ltAssociatedLeads = new HashSet<LtAssociatedLead>(); Set<LtAssociatedSubject> ltAssociatedSubjects = new HashSet<LtAssociatedSubject>(); List<AssociatedLeadModel> associates = ltLeadModel.getAssociateModel(); for (AssociatedLeadModel associateModel : associates) { String id = associateModel.getValue(); if (!StringUtils.isEmpty(id)) { RelationshipCode code = associateModel.getRelationshipCode(); code.setId(PageModelUtils.getCode(code.getAbbreviation())); LtSubject ltAssociate = ltLeadsModel.get(Integer.parseInt(id)).getLtLead().getLtSubject(); LtAssociatedSubject ltAssociatedSubject = new LtAssociatedSubject(); ltAssociatedSubject.setLtSubject(ltLead.getLtSubject()); ltAssociatedSubject.setLtSubjectAssociate(ltAssociate); ltAssociatedSubject.setRelationshipCode(code); ltAssociatedSubjects.add(ltAssociatedSubject); LtLead ltAssociateLead = ltLeadsModel.get(Integer.parseInt(id)).getLtLead(); LtAssociatedLead ltAssociatedLead = new LtAssociatedLead(); ltAssociatedLead.setLtLeadByLtLeadId(ltLead); ltAssociatedLead.setLtLeadByLtAssociatedLeadId(ltAssociateLead); ltAssociatedLeads.add(ltAssociatedLead); } } ltLead.setLtAssociatedLeadsForLtLeadId(ltAssociatedLeads); ltLead.getLtSubject().setLtAssociatedSubjects(ltAssociatedSubjects); Set<LtLeadSubject> ltLeadSubjects = new HashSet<LtLeadSubject>(); LtLeadSubject ltLeadSubject = ltLeadModel.getLtLeadSubject(); ltLeadSubject.setLtLead(ltLead); ltLeadSubject.setLtSubject(ltLead.getLtSubject()); ltLeadSubjects.add(ltLeadSubject); ltLead.setLtLeadSubjects(ltLeadSubjects); ltLead.setLtUserByCreateBy(user); ltLead.setLtUserByModifiedBy(user); ltLeads.add(ltLead); } } return ltLeads; }
From source file:gobblin.salesforce.SalesforceExtractor.java
@Override public long getHighWatermark(CommandOutput<?, ?> response, String watermarkColumn, String format) throws HighWatermarkException { this.log.info("Get high watermark from salesforce"); String output;// w ww .j a v a 2s . co m Iterator<String> itr = (Iterator<String>) response.getResults().values().iterator(); if (itr.hasNext()) { output = itr.next(); } else { throw new HighWatermarkException( "Failed to get high watermark from salesforce; REST response has no output"); } JsonElement element = gson.fromJson(output, JsonObject.class); long high_ts; try { JsonObject jsonObject = element.getAsJsonObject(); JsonArray jsonArray = jsonObject.getAsJsonArray("records"); if (jsonArray.size() == 0) { return -1; } String value = jsonObject.getAsJsonArray("records").get(0).getAsJsonObject().get(watermarkColumn) .getAsString(); if (format != null) { SimpleDateFormat inFormat = new SimpleDateFormat(format); Date date = null; try { date = inFormat.parse(value); } catch (ParseException e) { log.error("ParseException: " + e.getMessage(), e); } SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss"); high_ts = Long.parseLong(outFormat.format(date)); } else { high_ts = Long.parseLong(value); } } catch (Exception e) { throw new HighWatermarkException( "Failed to get high watermark from salesforce; error - " + e.getMessage(), e); } return high_ts; }
From source file:org.jahia.services.content.rules.Service.java
public void executeActionLater(AddedNodeFact node, final String propertyName, final String actionToExecute, KnowledgeHelper drools) throws SchedulerException, RepositoryException { final Property property = node.getNode().hasProperty(propertyName) ? node.getNode().getProperty(propertyName) : null;//from ww w . j ava 2 s . co m try { doScheduleAction(node, actionToExecute, getTrigger(node, property != null ? (property.getType() == PropertyType.DATE ? property.getDate().getTime() : property.getString()) : null, null, null), drools); } catch (ParseException e) { logger.error(e.getMessage(), e); } }
From source file:org.apache.nifi.processors.splunk.GetSplunk.java
@Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { final long currentTime = System.currentTimeMillis(); synchronized (isInitialized) { if (!isInitialized.get()) { splunkService = createSplunkService(context); isInitialized.set(true);// w w w. ja v a2 s .c o m } } final String query = context.getProperty(QUERY).getValue(); final String outputMode = context.getProperty(OUTPUT_MODE).getValue(); final String timeRangeStrategy = context.getProperty(TIME_RANGE_STRATEGY).getValue(); final String timeZone = context.getProperty(TIME_ZONE).getValue(); final String timeFieldStrategy = context.getProperty(TIME_FIELD_STRATEGY).getValue(); final JobExportArgs exportArgs = new JobExportArgs(); exportArgs.setSearchMode(JobExportArgs.SearchMode.NORMAL); exportArgs.setOutputMode(JobExportArgs.OutputMode.valueOf(outputMode)); String earliestTime = null; String latestTime = null; if (PROVIDED_VALUE.getValue().equals(timeRangeStrategy)) { // for provided we just use the values of the properties earliestTime = context.getProperty(EARLIEST_TIME).getValue(); latestTime = context.getProperty(LATEST_TIME).getValue(); } else { try { // not provided so we need to check the previous state final TimeRange previousRange = loadState(context.getStateManager()); final SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); if (previousRange == null) { // no previous state so set the earliest time based on the strategy if (MANAGED_CURRENT_VALUE.getValue().equals(timeRangeStrategy)) { earliestTime = dateFormat.format(new Date(currentTime)); } // no previous state so set the latest time to the current time latestTime = dateFormat.format(new Date(currentTime)); // if its the first time through don't actually run, just save the state to get the // initial time saved and next execution will be the first real execution if (latestTime.equals(earliestTime)) { saveState(context.getStateManager(), new TimeRange(earliestTime, latestTime)); return; } } else { // we have previous state so set earliestTime to (latestTime + 1) of last range try { final String previousLastTime = previousRange.getLatestTime(); final Date previousLastDate = dateFormat.parse(previousLastTime); earliestTime = dateFormat.format(new Date(previousLastDate.getTime() + 1)); latestTime = dateFormat.format(new Date(currentTime)); } catch (ParseException e) { throw new ProcessException(e); } } } catch (IOException e) { getLogger().error("Unable to load data from State Manager due to {}", new Object[] { e.getMessage() }, e); context.yield(); return; } } if (!StringUtils.isBlank(earliestTime)) { if (EVENT_TIME_VALUE.getValue().equalsIgnoreCase(timeFieldStrategy)) { exportArgs.setEarliestTime(earliestTime); } else { exportArgs.setIndexEarliest(earliestTime); } } if (!StringUtils.isBlank(latestTime)) { if (EVENT_TIME_VALUE.getValue().equalsIgnoreCase(timeFieldStrategy)) { exportArgs.setLatestTime(latestTime); } else { exportArgs.setIndexLatest(latestTime); } } if (EVENT_TIME_VALUE.getValue().equalsIgnoreCase(timeFieldStrategy)) { getLogger().debug("Using earliest_time of {} and latest_time of {}", new Object[] { earliestTime, latestTime }); } else { getLogger().debug("Using index_earliest of {} and index_latest of {}", new Object[] { earliestTime, latestTime }); } final InputStream exportSearch = splunkService.export(query, exportArgs); FlowFile flowFile = session.create(); flowFile = session.write(flowFile, new OutputStreamCallback() { @Override public void process(OutputStream rawOut) throws IOException { try (BufferedOutputStream out = new BufferedOutputStream(rawOut)) { IOUtils.copyLarge(exportSearch, out); } } }); final Map<String, String> attributes = new HashMap<>(3); attributes.put(EARLIEST_TIME_ATTR, earliestTime); attributes.put(LATEST_TIME_ATTR, latestTime); attributes.put(QUERY_ATTR, query); flowFile = session.putAllAttributes(flowFile, attributes); session.getProvenanceReporter().receive(flowFile, transitUri); session.transfer(flowFile, REL_SUCCESS); getLogger().debug("Received {} from Splunk", new Object[] { flowFile }); // save the time range for the next execution to pick up where we left off // if saving fails then roll back the session so we can try again next execution // only need to do this for the managed time strategies if (!PROVIDED_VALUE.getValue().equals(timeRangeStrategy)) { try { saveState(context.getStateManager(), new TimeRange(earliestTime, latestTime)); } catch (IOException e) { getLogger().error("Unable to load data from State Manager due to {}", new Object[] { e.getMessage() }, e); session.rollback(); context.yield(); } } }
From source file:org.jahia.services.content.rules.Service.java
public void executeRuleLater(AddedNodeFact node, final String propertyName, final String ruleToExecute, KnowledgeHelper drools) throws SchedulerException, RepositoryException { final String uuid = node.getNode().getIdentifier(); final JobDetail jobDetail = BackgroundJob.createJahiaJob("Rule job: " + ruleToExecute + " on node " + uuid, RuleJob.class); jobDetail.setName(ruleToExecute + "-" + uuid); jobDetail.setGroup(BackgroundJob.getGroupName(RuleJob.class) + "." + ruleToExecute); final JobDataMap map = jobDetail.getJobDataMap(); map.put(RuleJob.JOB_RULE_TO_EXECUTE, ruleToExecute); map.put(RuleJob.JOB_NODE_UUID, uuid); map.put(RuleJob.JOB_USER, ((User) drools.getWorkingMemory().getGlobal("user")).getName()); map.put(RuleJob.JOB_USER_REALM, ((User) drools.getWorkingMemory().getGlobal("user")).getRealm()); map.put(RuleJob.JOB_WORKSPACE, ((String) drools.getWorkingMemory().getGlobal("workspace"))); // cancel the scheduled job if exists schedulerService.getScheduler().deleteJob(jobDetail.getName(), jobDetail.getGroup()); try {// w w w . j a v a 2 s . co m final Property property = node.getNode().getProperty(propertyName); // schedule the job schedulerService.getScheduler().scheduleJob(jobDetail, getTrigger(node, property.getType() == PropertyType.DATE ? property.getDate().getTime() : property.getString(), jobDetail.getName(), jobDetail.getGroup())); } catch (ParseException e) { logger.error(e.getMessage(), e); } }
From source file:org.kuali.ole.pdp.service.impl.PaymentFileValidationServiceImpl.java
/** * Checks the payment date is not more than 30 days past or 30 days coming * /*from w w w . jav a 2 s .com*/ * @param paymentGroup <code>PaymentGroup</code> being checked * @param warnings <code>List</code> list of accumulated warning messages */ protected void checkGroupPaymentDate(PaymentGroup paymentGroup, List<String> warnings) { Timestamp now = dateTimeService.getCurrentTimestamp(); Calendar nowPlus30 = Calendar.getInstance(); nowPlus30.setTime(now); nowPlus30.add(Calendar.DATE, 30); Calendar nowMinus30 = Calendar.getInstance(); nowMinus30.setTime(now); nowMinus30.add(Calendar.DATE, -30); if (paymentGroup.getPaymentDate() != null) { Calendar payDate = Calendar.getInstance(); payDate.setTime(paymentGroup.getPaymentDate()); if (payDate.before(nowMinus30)) { addWarningMessage(warnings, PdpKeyConstants.MESSAGE_PAYMENT_LOAD_PAYDATE_OVER_30_DAYS_PAST, dateTimeService.toDateString(paymentGroup.getPaymentDate())); } if (payDate.after(nowPlus30)) { addWarningMessage(warnings, PdpKeyConstants.MESSAGE_PAYMENT_LOAD_PAYDATE_OVER_30_DAYS_OUT, dateTimeService.toDateString(paymentGroup.getPaymentDate())); } } else { try { paymentGroup.setPaymentDate(dateTimeService.convertToSqlDate(now)); } catch (ParseException e) { throw new RuntimeException("Unable to parse current timestamp into sql date " + e.getMessage()); } } }
From source file:eu.optimis.mi.monitoring_manager.resources.MonitorManagerQueryResource.java
@GET @Path("date/type/{resourceType}/{from}.{to}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public MonitoringResourceDatasets getDateTypeLevelResource(@PathParam("resourceType") String resourceType, @PathParam("from") String from, @PathParam("to") String to) { SimpleDateFormat sdf = new SimpleDateFormat(dateformat); java.util.Date dfrom = null;/* w w w.j a va 2 s. c o m*/ java.util.Date dto = null; try { dfrom = sdf.parse(from); dto = sdf.parse(to); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } eu.optimis.mi.monitoring_manager.db.Connection conn; java.sql.Connection dbconn; try { conn = ConnectionPool.getFreeConnection(); dbconn = conn.getDBConnection(DB_TABLE_URL, DB_DRIVER, DB_USERNAME, DB_PASSWORD); } catch (Exception e) { logger.error("DB info:" + DB_TABLE_URL + " | " + DB_DRIVER + " | " + DB_USERNAME + " | " + DB_PASSWORD); logger.error("MonitoringManager DB connection error: " + e.getMessage()); return new MonitoringResourceDatasets(); } return DateTypeLevelQuery.getResource_type_all(dbconn, resourceType, dfrom, dto); }
From source file:eu.optimis.mi.monitoring_manager.resources.MonitorManagerQueryResource.java
@GET @Path("date/type/{resourceType}/{resourceId}/{from}.{to}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public MonitoringResourceDatasets getDateTypeIdLevelResource(@PathParam("resourceType") String resourceType, @PathParam("resourceId") String resourceId, @PathParam("from") String from, @PathParam("to") String to) { SimpleDateFormat sdf = new SimpleDateFormat(dateformat); java.util.Date dfrom = null;//w w w. j ava 2s . c o m java.util.Date dto = null; try { dfrom = sdf.parse(from); dto = sdf.parse(to); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } eu.optimis.mi.monitoring_manager.db.Connection conn; java.sql.Connection dbconn; try { conn = ConnectionPool.getFreeConnection(); dbconn = conn.getDBConnection(DB_TABLE_URL, DB_DRIVER, DB_USERNAME, DB_PASSWORD); } catch (Exception e) { logger.error("DB info:" + DB_TABLE_URL + " | " + DB_DRIVER + " | " + DB_USERNAME + " | " + DB_PASSWORD); logger.error("MonitoringManager DB connection error: " + e.getMessage()); return new MonitoringResourceDatasets(); } return DateTypeLevelQuery.getResource_type_tid(dbconn, resourceType, resourceId, dfrom, dto); }