List of usage examples for java.text ParseException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.deegree.services.sos.SOSController.java
@Override public void doKVP(Map<String, String> param, HttpServletRequest request, HttpResponseBuffer response, List<FileItem> multiParts) throws ServletException, IOException { // see javadoc for this SOSController class for more information on KVP handling try {//from ww w . jav a 2s .c om checkRequiredKeys(param); response.setContentType("text/xml"); if (param.containsKey("REQUEST")) { String requestName = param.get("REQUEST"); switch (IMPLEMENTATION_METADATA.getRequestTypeByName(requestName)) { case GetCapabilities: GetCapabilities capabilities = GetCapabilitiesKVPParser.parse(param); doGetCapabilities(capabilities, mainMetadataConf, response); break; case DescribeSensor: DescribeSensor sensor = DescribeSensor100KVPAdapter.parse(param); doDescribeSensor(sensor, response); break; case GetObservation: GetObservation observation = GetObservation100KVPAdapter.parse(param); doGetObservation(observation, response); break; } // default handled by getRequestTypeByName } } catch (ParseException e) { sendServiceException(new OWSException(e.getLocalizedMessage(), INVALID_DATE), response); } catch (InvalidParameterValueException ex) { sendServiceException(new OWSException(ex.getLocalizedMessage(), VERSION_NEGOTIATION_FAILED), response); } catch (OWSException ex) { sendServiceException(ex, response); } catch (ObservationDatastoreException e) { sendServiceException(new OWSException("an error occured while processing a request", ""), response); LOG.error("an error occured while processing a request", e); } catch (Throwable e) { sendServiceException( new OWSException("an error occured while processing a request", NO_APPLICABLE_CODE), response); LOG.error("an error occured while processing a request", e); } }
From source file:ca.phon.session.io.xml.v12.XMLSessionReader_v12.java
/** * Copy ipa data./* www. ja v a 2 s. com*/ * * Attempts to copy phone objects as-is, if not possible * the transcription is re-parsed. * * @param factory * @param ipaType */ private Tier<IPATranscript> copyTranscript(SessionFactory factory, IpaTierType itt) { final SystemTierType tierType = (itt.getForm() == PhoTypeType.MODEL ? SystemTierType.IPATarget : SystemTierType.IPAActual); final Tier<IPATranscript> retVal = factory.createTier(tierType.getName(), IPATranscript.class, tierType.isGrouped()); // attempt an exact copy first for (PhoType pt : itt.getPg()) { if (pt != null && pt.getW() != null) { final StringBuffer groupBuffer = new StringBuffer(); for (WordType wt : pt.getW()) { if (groupBuffer.length() > 0) groupBuffer.append(" "); groupBuffer.append(wt.getContent()); } if (groupBuffer.toString().trim().length() == 0) { retVal.addGroup(new IPATranscript()); } else { try { final IPATranscript transcript = IPATranscript.parseIPATranscript(groupBuffer.toString()); // copy syllabification if transcript is the same size as our provided syllabification if (pt.getSb() != null && pt.getSb().getPh() != null && transcript.length() == pt.getSb().getPh().size()) { final CopyTranscriptVisitor visitor = new CopyTranscriptVisitor(pt.getSb().getPh()); transcript.accept(visitor); } retVal.addGroup(transcript); } catch (ParseException pe) { LOGGER.log(Level.FINE, pe.getLocalizedMessage(), pe); final IPATranscript ipa = new IPATranscript(); ipa.putExtension(UnvalidatedValue.class, new UnvalidatedValue(groupBuffer.toString(), pe)); retVal.addGroup(ipa); } } } else { retVal.addGroup(new IPATranscript()); } } return retVal; }
From source file:com.serena.rlc.provider.schedule.ScheduleExecutionProvider.java
@Action(name = WAIT_UNTIL, displayName = "Wait until (time)", description = "Wait until a specific time.") @Params(params = {/*from ww w .j ava2s . c om*/ @Param(fieldName = SCHEDULED_TIME, displayName = "Scheduled Time", description = "Scheduled time", required = true, environmentProperty = true, deployUnit = false, dataType = DataType.TEXT) }) public ExecutionInfo waitUntil(List<Field> properties, Boolean validateOnly) throws ProviderException { ExecutionInfo execInfo = new ExecutionInfo(); try { Boolean bValid = validateWaitUntil(properties); if (validateOnly) { logger.debug("Validating waitUntil with: " + properties.toString()); execInfo.setSuccess(bValid); execInfo.setMessage("Valid schedule action: " + WAIT_UNTIL); return execInfo; } else { UUID executionId = UUID.randomUUID(); Date scheduledDate; try { scheduledDate = new SimpleDateFormat(dateFormat).parse(scheduledTime); logger.debug("Scheduled date is: " + scheduledDate.toString()); } catch (ParseException ex) { throw new ProviderException("Invalid scheduled time, format is " + dateFormat); } long sleepTime = scheduledDate.getTime() - (new Date()).getTime(); try { ScheduleWaiter scheduleWaiter = new ScheduleWaiter(callbackUrl, callbackUsername, callbackPassword, executionId, sleepTime); Thread waiterThread = new Thread(scheduleWaiter, "ScheduleWaiter-" + executionId.toString()); waiterThread.start(); } catch (Exception ex) { throw new ProviderException(ex.getLocalizedMessage()); } execInfo.setStatus(ExecutionStatus.IN_PROGRESS); execInfo.setExecutionId(executionId.toString()); return execInfo; } } catch (ProviderException ex) { if (validateOnly) { execInfo.setSuccess(false); execInfo.setMessage(ex.getLocalizedMessage()); return execInfo; } throw ex; } }
From source file:org.pengyou.ooo.OpenDialog.java
private String formatList(String[] t) { String res = new String(); if (t[2] == "COLLECTION") { if (t[4].length() > SPACES_FILE - 4) res = t[4].substring(0, SPACES_FILE - 5) + ""; else//from www . j a v a2 s. c o m res = t[4]; res = " " + res; } else { if (t[4].length() > SPACES_FILE - 2) res = t[4].substring(0, SPACES_FILE - 3) + ""; else res = t[4]; } while (res.length() < SPACES_FILE) res += " "; res += t[6]; while (res.length() < SPACES_AUTHOR) res += " "; Locale locale = Locale.FRENCH; Date date = null; String s = null; try { date = DateFormat.getDateTimeInstance().parse(t[5]); s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date); res += s; while (res.length() < SPACES_CDATE) res += " "; } catch (ParseException e) { e.printStackTrace(); log.log(Level.DEBUG, e.getLocalizedMessage()); } date = null; s = null; try { date = DateFormat.getDateTimeInstance().parse(t[3]); s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date); res += s; while (res.length() < SPACES_EDATE) res += " "; } catch (ParseException e) { e.printStackTrace(); log.log(Level.DEBUG, e.getLocalizedMessage()); } return res; }
From source file:org.pengyou.ooo.PublishAsDialog.java
private String formatList(String[] t) { String res = new String(); if (t[2] == "COLLECTION") { if (t[4].length() > 21) res = t[4].substring(0, 20) + ""; else/*from w w w . j a v a2 s . c om*/ res = t[4]; //res = " " + res; res = " " + res; } else { if (t[4].length() > 23) res = t[4].substring(0, 22) + ""; else res = t[4]; } //int l = res.length(); while (res.length() < 25) res += " "; res += t[6]; while (res.length() < 42) res += " "; Locale locale = Locale.FRENCH; Date date = null; String s = null; try { date = DateFormat.getDateTimeInstance().parse(t[5]); s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date); res += s; while (res.length() < 57) res += " "; } catch (ParseException e) { e.printStackTrace(); log.log(Level.DEBUG, e.getLocalizedMessage()); } date = null; s = null; try { date = DateFormat.getDateTimeInstance().parse(t[3]); s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date); res += s; while (res.length() < 71) res += " "; } catch (ParseException e) { e.printStackTrace(); log.log(Level.DEBUG, e.getLocalizedMessage()); } return res; }
From source file:org.dd4t.core.factories.impl.PageFactoryImpl.java
/** * @param url the url of the page * @param publicationId the publication Id * @return a GenericPage object//ww w . java 2s . co m * @throws org.dd4t.core.exceptions.FactoryException */ @Override public Page findPageByUrl(String url, int publicationId) throws FactoryException { LOG.debug("Enter findPageByUrl with url: {} and publicationId: {}", url, publicationId); String cacheKey = publicationId + "-" + url; CacheElement<Page> cacheElement = cacheProvider.loadPayloadFromLocalCache(cacheKey); Page page; if (cacheElement.isExpired()) { synchronized (cacheElement) { if (cacheElement.isExpired()) { cacheElement.setExpired(false); String pageSource; pageSource = pageProvider.getPageContentByURL(url, publicationId); if (pageSource == null || pageSource.length() == 0) { cacheElement.setPayload(null); cacheProvider.storeInItemCache(cacheKey, cacheElement); throw new ItemNotFoundException("Page with url: " + url + " not found."); } try { page = deserialize(pageSource, PageImpl.class); cacheElement.setPayload(page); final TCMURI tcmUri = new TCMURI(page.getId()); LOG.debug("Running pre caching processors"); this.executeProcessors(page, RunPhase.BEFORE_CACHING, getRequestContext()); cacheProvider.storeInItemCache(cacheKey, cacheElement, publicationId, tcmUri.getItemId()); LOG.debug("Added page with uri: {} and publicationId: {} to cache", url, publicationId); } catch (ParseException e) { throw new ItemNotFoundException(e); } } else { LOG.debug("Return a page with url: {} and publicationId: {} from cache", url, publicationId); page = cacheElement.getPayload(); } } } else { LOG.debug("Return page with url: {} and publicationId: {} from cache", url, publicationId); page = cacheElement.getPayload(); } if (page != null) { LOG.debug("Running Post caching Processors"); try { this.executeProcessors(page, RunPhase.AFTER_CACHING, getRequestContext()); } catch (ProcessorException e) { LOG.error(e.getLocalizedMessage(), e); } } return page; }
From source file:dk.cubing.liveresults.action.admin.ScoresheetAction.java
/** * @param line//from www . j a v a2s. c om * @return */ private Competitor getCompetitor(String[] line) { Competitor competitor = new Competitor(); competitor.setFirstname(StringUtil.parseFirstname(line[1])); competitor.setSurname(StringUtil.parseSurname(line[1])); competitor.setCountry(countryUtil.getCountryCodeByName(line[2])); competitor.setWcaId(line[3]); Date date = new Date(); if (line[4] != null) { try { date = birthdayFormat.parse(line[4]); } catch (ParseException e) { log.error(e.getLocalizedMessage(), e); } } competitor.setBirthday(date); competitor.setGender(line[5]); return competitor; }
From source file:net.ustyugov.jtalk.service.JTalkService.java
private void registerSip(String username, String password) { if (!prefs.getBoolean("EnableSIP", false)) return;// w ww . jav a2 s .co m if (SipManager.isApiSupported(JTalkService.this) && SipManager.isVoipSupported(JTalkService.this)) { Log.d("SIP", "Api supported"); String user = StringUtils.parseName(username); String host = StringUtils.parseServer(username); int port = 5060; try { Lookup lookup = new Lookup("_sip._udp." + host, Type.SRV); lookup.setCredibility(Credibility.ANY); Record[] records = lookup.run(); if (lookup.getResult() == Lookup.SUCCESSFUL) { if (records.length > 0) { SRVRecord record = (SRVRecord) records[0]; host = record.getTarget().toString(); host = host.substring(0, host.length() - 1); port = record.getPort(); } } } catch (Exception ignored) { } Log.d("SIP", "user: " + user + "; host: " + host + "; port: " + port); try { SipProfile.Builder builder = new SipProfile.Builder("sip:" + username); builder.setDisplayName(username); builder.setProfileName(username); builder.setAutoRegistration(true); builder.setOutboundProxy(host); builder.setProtocol("UDP"); builder.setPort(port); builder.setPassword(password); builder.setSendKeepAlive(true); SipProfile profile = builder.build(); SipManager manager = getSipManager(username); if (manager == null) manager = SipManager.newInstance(JTalkService.this); Intent intent = new Intent(); intent.putExtra("account", username); intent.setAction(Constants.INCOMING_CALL); PendingIntent pendingIntent = PendingIntent.getBroadcast(JTalkService.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); if (!manager.isOpened(profile.getUriString())) manager.open(profile, pendingIntent, null); Thread.sleep(4000); manager.setRegistrationListener(profile.getUriString(), new SipRegistrationListener() { @Override public void onRegistering(String localProfileUri) { Log.d("REGLISTENER", "Registering with SIP Server..."); } @Override public void onRegistrationDone(String localProfileUri, long expiryTime) { Log.d("REGLISTENER", "Ready"); } @Override public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { Log.d("REGLISTENER", "Registration failed. Please check settings. MSG: [" + errorCode + "] " + errorMessage); } }); addSipManager(username, manager); } catch (ParseException pe) { Log.e("CreateSipProfile", pe.getLocalizedMessage()); } catch (SipException se) { Log.e("SIPExtension", se.getLocalizedMessage()); } catch (InterruptedException ignored) { } } }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java
/** * @return/* ww w. jav a 2 s. c o m*/ */ @SuppressWarnings("unchecked") public String getCriteriaFormula(final TableAbbreviator ta, final List<Pair<String, Object>> paramList) throws ParseException { if (operatorCBX.getSelectedItem().equals(SpQueryField.OperatorType.EMPTY)) { boolean isNot = isNotCheckbox.isSelected(); String nullCond = fieldQRI.getNullCondition(ta, schemaItem != null, isNot, getFormatName()); if (fieldQRI.getDataClass().equals(String.class)) { String fieldSpec = fieldQRI.getSQLFldSpec(ta, true, schemaItem != null, getFormatName()); return "(" + nullCond + (isNot ? " and " : " or ") + fieldSpec + (isNot ? " <> " : " = ") + "'')"; } return nullCond; } if (hasCriteria()) { boolean addNullConjunction = false; boolean nullPick = criteria instanceof PickListCriteriaCombo && ((PickListCriteriaCombo) criteria).nullItemIsPicked(); Object[] criteriaStrs = parseCriteria(getCriteriaText(true).trim()); String criteriaFormula = ""; //String operStr = operatorCBX.getSelectedItem().toString(); String operStr = getOperatorQLText(); if (!(criteriaStrs[0] instanceof String) && !(criteriaStrs[0] instanceof Pair)) { //XXX - If the field has a formatter and it returned non-String data // then assume all parsing and conversion has been accomplished?? //(hopefully this will never occur) log.info(fieldQRI.getFieldInfo() + ": formatter returned non-string data."); criteriaFormula = concatCriteria(criteriaStrs, operStr, false, ta); } else { if (fieldQRI.getDataClass().equals(Boolean.class)) { if (operStr.equals(SpQueryField.OperatorType.getOp(SpQueryField.OperatorType.TRUE.getOrdinal())) || operStr.equals(SpQueryField.OperatorType .getOp(SpQueryField.OperatorType.TRUEORNULL.getOrdinal()))) { criteriaFormula = "true"; } else { criteriaFormula = "false"; } addNullConjunction = operStr.equals( SpQueryField.OperatorType.getOp(SpQueryField.OperatorType.FALSEORNULL.getOrdinal())) || operStr.equals(SpQueryField.OperatorType .getOp(SpQueryField.OperatorType.TRUEORNULL.getOrdinal())); operStr = "="; } else if (fieldQRI.getDataClass().equals(String.class) && !isNumericCatalogNumber()) { criteriaFormula = concatCriteria(criteriaStrs, operStr, !(pickList instanceof PickListTableAdapter), ta); } else if (fieldQRI.getDataClass().equals(Calendar.class) || fieldQRI.getDataClass().equals(java.sql.Timestamp.class)) { for (int p = 0; p < criteriaStrs.length; p++) { String paramName = "spparam" + paramList.size(); try { if (fieldQRI instanceof DateAccessorQRI) { new Integer((String) criteriaStrs[p]); } else { Object arg = dateConverter.convert((String) criteriaStrs[p]); if (fieldQRI.getDataClass().equals(java.sql.Timestamp.class)) { arg = new java.sql.Timestamp(((Calendar) arg).getTimeInMillis()); } paramList.add(new Pair<String, Object>(paramName, arg)); } } catch (ParseException ex) { throw new ParseException(getLabel() + " - " + String.format( UIRegistry.getResourceString("QB_PARSE_ERROR"), ex.getLocalizedMessage()), -1); } if (p > 0) { if (operatorCBX.getSelectedItem() == SpQueryField.OperatorType.BETWEEN) { criteriaFormula += " and "; } else { criteriaFormula += ", "; } } if (fieldQRI instanceof DateAccessorQRI) { criteriaFormula += (String) criteriaStrs[p]; } else { criteriaFormula += ":" + paramName; } } if (SpQueryField.OperatorType.getOrdForOp(operStr) == SpQueryField.OperatorType.IN .getOrdinal()) { criteriaFormula = "(" + criteriaFormula + ")"; } } else if (Number.class.isAssignableFrom(fieldQRI.getDataClass()) || isNumericCatalogNumber()) { Constructor<?> tester; try { tester = isNumericCatalogNumber() ? BigInteger.class.getConstructor(String.class) : fieldQRI.getDataClass().getConstructor(String.class); for (int s = 0; s < criteriaStrs.length; s++) { Object critter = criteriaStrs[s]; List<String> strs = new ArrayList<String>(2); if (critter instanceof String) { strs.add(critter.toString()); } else { //seriesPresent = true; if (!operStr.equals(SpQueryField.OperatorType .getOp(SpQueryField.OperatorType.IN.getOrdinal()))) { throw new ParseException(getLabel() + " - " + UIRegistry.getResourceString("QB_INVALID_CRITERIA"), -1); } strs.add(((Pair<String, String>) critter).getFirst()); strs.add(((Pair<String, String>) critter).getSecond()); } List<String> newStrs = new ArrayList<String>(2); for (String str : strs) { tester.newInstance(str); //remove leading zeroes String newString = str; boolean isZeroes = false; while (newString.startsWith("0")) { newString = newString.substring(1); isZeroes = true; } if (isZeroes && StringUtils.isBlank(newString)) { newString = "0"; } newStrs.add(newString); } if (newStrs.size() == 2) { ((Pair<String, String>) criteriaStrs[s]).setFirst(newStrs.get(0)); ((Pair<String, String>) criteriaStrs[s]).setSecond(newStrs.get(1)); } else { criteriaStrs[s] = newStrs.get(0); } } } catch (NoSuchMethodException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryFieldPanel.class, ex); // this will never happen. trust me. throw new RuntimeException(ex); } catch (InvocationTargetException ex) { if (ex.getTargetException() instanceof NumberFormatException) { String msg = ex.getTargetException().getLocalizedMessage(); if (StringUtils.isBlank(msg)) { msg = ex.getTargetException().getClass().getSimpleName(); } throw new ParseException( getLabel() + " - " + String.format(UIRegistry.getResourceString("QB_PARSE_ERROR"), msg), -1); } throw new RuntimeException(ex); } catch (IllegalAccessException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryFieldPanel.class, ex); throw new RuntimeException(ex); } catch (InstantiationException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryFieldPanel.class, ex); throw new RuntimeException(ex); } catch (NumberFormatException ex) { String msg = ex.getLocalizedMessage(); if (StringUtils.isBlank(msg)) { msg = ex.getClass().getSimpleName(); } throw new ParseException(getLabel() + " - " + String.format(UIRegistry.getResourceString("QB_PARSE_ERROR"), msg), -1); } criteriaFormula = concatCriteria(criteriaStrs, operStr, false, ta); } } if (operStr.equals(SpQueryField.OperatorType.getOp(SpQueryField.OperatorType.CONTAINS.getOrdinal()))) { operStr = "Like"; } if (criteriaFormula.length() > 0 || nullPick || fieldQRI instanceof TreeLevelQRI) { if (fieldQRI instanceof TreeLevelQRI) { try { return ((TreeLevelQRI) fieldQRI).getNodeNumberCriteria(criteriaFormula, ta, operStr, isNotCheckbox.isSelected()); } catch (ParseException pe) { throw new ParseException(getLabel() + " - " + String .format(UIRegistry.getResourceString("QB_PARSE_ERROR"), pe.getLocalizedMessage()), -1); } } StringBuilder str = new StringBuilder(); str.append(isNotCheckbox.isSelected() ? "(NOT " : ""); if (!operStr.equals(SpQueryField.OperatorType.getOp(SpQueryField.OperatorType.IN.getOrdinal()))) { str.append(fieldQRI.getSQLFldSpec(ta, true, schemaItem != null, getFormatName()) + " "); } if (nullPick && "=".equals(operStr)) { str.append(" is null "); } else if (!operStr .equals(SpQueryField.OperatorType.getOp(SpQueryField.OperatorType.IN.getOrdinal()))) { str.append(operStr); } str.append(" "); if (!(nullPick && "=".equals(operStr))) { str.append(criteriaFormula); } if (isNotCheckbox.isSelected()) { if (!operStr.equals( SpQueryField.OperatorType.getOp(SpQueryField.OperatorType.EMPTY.getOrdinal()))) { str.append(" or " + fieldQRI.getSQLFldSpec(ta, true, schemaItem != null, getFormatName()) + " is null"); } str.append(")"); } String result = str.toString(); if (addNullConjunction || (StringUtils.isNotBlank(result) && isEnforcedCkbx != null && isEnforcedCkbx.isSelected() && schemaMapping != null) || (nullPick && !"=".equals(operStr))) { //Currently, when the null value is picked with the IN condition, a '' entry is included in the IN list //This is not technically correct, but probably will never matter, and possibly produce more desirable //results then the technically correct criteria result = "(" + result + " or " + fieldQRI.getSQLFldSpec(ta, true, schemaItem != null, getFormatName()) + " is null)"; } return result; } } return null; }
From source file:org.openestate.io.idx.IdxRecord.java
public Calendar getAvailableFrom() { try {//w ww. ja va 2 s .com return IdxFormat.parseDateAsCalendar(this.get(FIELD_AVAILABLE_FROM)); } catch (ParseException ex) { LOGGER.warn("Can't read availability date!"); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); return null; } }