List of usage examples for java.lang IllegalArgumentException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.openestate.io.idx.IdxRecord.java
public Currency getCurrency() { String value = this.get(FIELD_CURRENCY); try {// w w w.j a v a 2 s. c o m return (value != null) ? Currency.getInstance(value) : null; } catch (IllegalArgumentException ex) { LOGGER.warn("Can't read currency from '" + value + "'!"); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); return null; } }
From source file:it.geosolutions.geoserver.rest.GeoServerRESTPublisher.java
/** * Create a store or harvest the coverage from the provided <b>external</b> path. * //from w ww . jav a 2s. co m * @param workspace the GeoServer workspace * @param coverageStore the GeoServer coverageStore * @param format the format of the file to upload * @param the absolut path to the file to upload * * @return <code>true</code> if the call succeeds or <code>false</code> otherwise. */ public boolean harvestExternal(String workspace, String coverageStore, String format, String path) { try { GeoServerRESTStructuredGridCoverageReaderManager manager = new GeoServerRESTStructuredGridCoverageReaderManager( new URL(restURL), gsuser, gspass); return manager.harvestExternal(workspace, coverageStore, format, path); } catch (IllegalArgumentException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } } catch (MalformedURLException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } } return false; }
From source file:it.geosolutions.geoserver.rest.GeoServerRESTPublisher.java
/** * Remove a granule from a structured coverage by id. * /*from w w w . j ava2 s. c o m*/ * @param workspace the GeoServer workspace * @param coverageStore the GeoServer coverageStore * @param coverage the name of the target coverage from which we are going to remove * @param filter the absolute path to the file to upload * * @return <code>null</code> in case the call does not succeed, or an instance of {@link RESTStructuredCoverageGranulesList}. * * @throws MalformedURLException * @throws UnsupportedEncodingException */ public boolean removeGranuleById(final String workspace, String coverageStore, String coverage, String granuleId) { try { GeoServerRESTStructuredGridCoverageReaderManager manager = new GeoServerRESTStructuredGridCoverageReaderManager( new URL(restURL), gsuser, gspass); return manager.removeGranuleById(workspace, coverageStore, coverage, granuleId); } catch (IllegalArgumentException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } } catch (MalformedURLException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } } return false; }
From source file:it.geosolutions.geoserver.rest.GeoServerRESTPublisher.java
/** * Remove granules from a structured coverage, by providing a CQL filter. * /* w w w .ja v a 2 s . co m*/ * @param workspace the GeoServer workspace * @param coverageStore the GeoServer coverageStore * @param coverage the name of the target coverage from which we are going to remove * @param filter the absolute path to the file to upload * * @return <code>null</code> in case the call does not succeed, or an instance of {@link RESTStructuredCoverageGranulesList}. * * @throws MalformedURLException * @throws UnsupportedEncodingException */ public boolean removeGranulesByCQL(final String workspace, String coverageStore, String coverage, String filter) throws UnsupportedEncodingException { try { GeoServerRESTStructuredGridCoverageReaderManager manager = new GeoServerRESTStructuredGridCoverageReaderManager( new URL(restURL), gsuser, gspass); return manager.removeGranulesByCQL(workspace, coverageStore, coverage, filter); } catch (IllegalArgumentException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } } catch (MalformedURLException e) { if (LOGGER.isInfoEnabled()) { LOGGER.info(e.getLocalizedMessage(), e); } } return false; }
From source file:org.deegree.style.se.parser.GraphicSymbologyParser.java
private Pair<Mark, Continuation<Mark>> parseMark(XMLStreamReader in) throws XMLStreamException { in.require(START_ELEMENT, null, "Mark"); Mark base = new Mark(); Continuation<Mark> contn = null; in.nextTag();//from ww w .j a v a 2 s . co m while (!(in.isEndElement() && in.getLocalName().equals("Mark"))) { if (in.isEndElement()) { in.nextTag(); } if (in.getLocalName().equals("WellKnownName")) { String wkn = in.getElementText(); try { base.wellKnown = SimpleMark.valueOf(wkn.toUpperCase()); } catch (IllegalArgumentException e) { LOG.warn("Specified unsupported WellKnownName of '{}', using square instead.", wkn); base.wellKnown = SimpleMark.SQUARE; } } else sym: if (in.getLocalName().equals("OnlineResource") || in.getLocalName().equals("InlineContent")) { LOG.debug("Loading mark from external file."); Triple<InputStream, String, Continuation<StringBuffer>> pair = getOnlineResourceOrInlineContent( in); if (pair == null) { in.nextTag(); break sym; } InputStream is = pair.first; in.nextTag(); in.require(START_ELEMENT, null, "Format"); String format = in.getElementText(); in.require(END_ELEMENT, null, "Format"); in.nextTag(); if (in.getLocalName().equals("MarkIndex")) { base.markIndex = Integer.parseInt(in.getElementText()); } if (is != null) { try { java.awt.Font font = null; if (format.equalsIgnoreCase("ttf")) { font = createFont(TRUETYPE_FONT, is); } if (format.equalsIgnoreCase("type1")) { font = createFont(TYPE1_FONT, is); } if (format.equalsIgnoreCase("svg")) { base.shape = ShapeHelper.getShapeFromSvg(is, pair.second); } if (font == null && base.shape == null) { LOG.warn("Mark was not loaded, because the format '{}' is not supported.", format); break sym; } if (font != null && base.markIndex >= font.getNumGlyphs() - 1) { LOG.warn("The font only contains {} glyphs, but the index given was {}.", font.getNumGlyphs(), base.markIndex); break sym; } base.font = font; } catch (FontFormatException e) { LOG.debug("Stack trace:", e); LOG.warn("The file was not a valid '{}' file: '{}'", format, e.getLocalizedMessage()); } catch (IOException e) { LOG.debug("Stack trace:", e); LOG.warn("The file could not be read: '{}'.", e.getLocalizedMessage()); } finally { closeQuietly(is); } } } else if (in.getLocalName().equals("Fill")) { final Pair<Fill, Continuation<Fill>> fill = context.fillParser.parseFill(in); base.fill = fill.first; if (fill.second != null) { contn = new Continuation<Mark>(contn) { @Override public void updateStep(Mark base, Feature f, XPathEvaluator<Feature> evaluator) { fill.second.evaluate(base.fill, f, evaluator); } }; } } else if (in.getLocalName().equals("Stroke")) { final Pair<Stroke, Continuation<Stroke>> stroke = context.strokeParser.parseStroke(in); base.stroke = stroke.first; if (stroke.second != null) { contn = new Continuation<Mark>(contn) { @Override public void updateStep(Mark base, Feature f, XPathEvaluator<Feature> evaluator) { stroke.second.evaluate(base.stroke, f, evaluator); } }; } } else if (in.isStartElement()) { Location loc = in.getLocation(); LOG.error("Found unknown element '{}' at line {}, column {}, skipping.", new Object[] { in.getLocalName(), loc.getLineNumber(), loc.getColumnNumber() }); skipElement(in); } } in.require(END_ELEMENT, null, "Mark"); return new Pair<Mark, Continuation<Mark>>(base, contn); }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String GetInternetData(String sHost, String sPort, String sURL) { String sRet = ""; String sNewURL = ""; HttpClient httpClient = new DefaultHttpClient(); try {//w ww .j ava2 s . c o m sNewURL = "http://" + sHost + ((sPort.length() > 0) ? (":" + sPort) : "") + sURL; HttpGet request = new HttpGet(sNewURL); HttpResponse response = httpClient.execute(request); int status = response.getStatusLine().getStatusCode(); // we assume that the response body contains the error message if (status != HttpStatus.SC_OK) { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); response.getEntity().writeTo(ostream); Log.e("HTTP CLIENT", ostream.toString()); } else { InputStream content = response.getEntity().getContent(); byte[] data = new byte[2048]; int nRead = content.read(data); sRet = new String(data, 0, nRead); content.close(); // this will also close the connection } } catch (IllegalArgumentException e) { sRet = e.getLocalizedMessage(); e.printStackTrace(); } catch (ClientProtocolException e) { sRet = e.getLocalizedMessage(); e.printStackTrace(); } catch (IOException e) { sRet = e.getLocalizedMessage(); e.printStackTrace(); } return (sRet); }
From source file:ca.phon.session.io.xml.v12.XMLSessionReader_v12.java
Record copyRecord(SessionFactory factory, Session session, RecordType rt) { final Record retVal = factory.createRecord(); retVal.setExcludeFromSearches(rt.isExcludeFromSearches()); try {//w w w.j a va 2s. co m if (rt.getId() != null) { UUID uuid = UUID.fromString(rt.getId()); retVal.setUuid(uuid); } } catch (IllegalArgumentException e) { } if (rt.getSpeaker() != null) { final ParticipantType pt = (ParticipantType) rt.getSpeaker(); for (int pIdx = 0; pIdx < session.getParticipantCount(); pIdx++) { final Participant participant = session.getParticipant(pIdx); if (participant.getName() != null && participant.getName().equals(pt.getName())) { retVal.setSpeaker(participant); break; } else if (participant.getId() != null && participant.getId().equals(pt.getId())) { retVal.setSpeaker(participant); break; } } } // orthography final OrthographyType ot = rt.getOrthography(); final Tier<Orthography> orthoTier = copyOrthography(factory, ot); retVal.setOrthography(orthoTier); // ipa target/actual for (IpaTierType ipaTt : rt.getIpaTier()) { final Tier<IPATranscript> ipaTranscript = copyTranscript(factory, ipaTt); if (ipaTt.getForm() == PhoTypeType.ACTUAL) { retVal.setIPAActual(ipaTranscript); } else { retVal.setIPATarget(ipaTranscript); } } Tier<IPATranscript> ipaTargetTier = retVal.getIPATarget(); while (ipaTargetTier.numberOfGroups() < retVal.numberOfGroups()) ipaTargetTier.addGroup(); Tier<IPATranscript> ipaActualTier = retVal.getIPAActual(); while (ipaActualTier.numberOfGroups() < retVal.numberOfGroups()) ipaActualTier.addGroup(); // blind transcriptions for (BlindTierType btt : rt.getBlindTranscription()) { // get the correct ipa object from our new record final Tier<IPATranscript> ipaTier = (btt.getForm() == PhoTypeType.MODEL ? retVal.getIPATarget() : retVal.getIPAActual()); int gidx = 0; for (BgType bgt : btt.getBg()) { final StringBuffer buffer = new StringBuffer(); for (WordType wt : bgt.getW()) { if (buffer.length() > 0) buffer.append(" "); buffer.append(wt.getContent()); } final IPATranscript ipa = (gidx < ipaTier.numberOfGroups() ? ipaTier.getGroup(gidx) : null); if (ipa != null) { try { final IPATranscript blindTranscript = IPATranscript.parseIPATranscript(buffer.toString()); final TranscriberType tt = (TranscriberType) btt.getUser(); final String name = tt.getId(); AlternativeTranscript at = ipa.getExtension(AlternativeTranscript.class); if (at == null) { at = new AlternativeTranscript(); ipa.putExtension(AlternativeTranscript.class, at); } at.put(name, blindTranscript); } catch (ParseException e) { LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } } gidx++; } } // notes if (rt.getNotes() != null) retVal.getNotes().setGroup(0, rt.getNotes().getContent()); // segment if (rt.getSegment() != null) { final MediaSegment segment = factory.createMediaSegment(); segment.setStartValue(rt.getSegment().getStartTime()); segment.setEndValue(rt.getSegment().getStartTime() + rt.getSegment().getDuration()); segment.setUnitType(MediaUnit.Millisecond); retVal.getSegment().setGroup(0, segment); } else { retVal.getSegment().setGroup(0, factory.createMediaSegment()); } // alignment for (AlignmentTierType att : rt.getAlignment()) { final Tier<PhoneMap> alignment = copyAlignment(factory, retVal, att); while (alignment.numberOfGroups() < retVal.numberOfGroups()) alignment.addGroup(); retVal.setPhoneAlignment(alignment); break; // only processing the first alignment element (which should be the only one) } // user tiers for (FlatTierType ftt : rt.getFlatTier()) { final Tier<String> flatTier = factory.createTier(ftt.getTierName(), String.class, false); flatTier.setGroup(0, ftt.getContent()); retVal.putTier(flatTier); } for (GroupTierType gtt : rt.getGroupTier()) { final Tier<String> groupTier = factory.createTier(gtt.getTierName(), String.class, true); int gidx = 0; for (TgType tgt : gtt.getTg()) { final StringBuffer buffer = new StringBuffer(); for (WordType wt : tgt.getW()) { if (buffer.length() > 0) buffer.append(" "); buffer.append(wt.getContent()); } groupTier.setGroup(gidx++, buffer.toString()); } // ensure the dependent tier has the correct number of groups while (groupTier.numberOfGroups() < retVal.numberOfGroups()) { groupTier.addGroup(); } retVal.putTier(groupTier); } return retVal; }