/** * Returns the message assigned to the passed key. If no message is assigned, an error message will be returned that * indicates the missing key. * * @see MessageFormat for conventions on string formatting and escape characters. * * @param key * @param arguments * @return the message assigned to the passed key */ public static String getMessage( String key, Object... arguments ) { return get( defaultProps, key, arguments ); }
return getMessage( key, arguments ); overrideMessages( fileName, p ); fileName = "/messages_en.properties"; overrideMessages( fileName, p ); fileName = "messages_" + l + ".properties"; overrideMessages( fileName, p ); fileName = "/messages_" + l + ".properties"; overrideMessages( fileName, p ); } catch ( IOException e ) { LOG.error( "Error loading language file for language '" + l + "': ", e ); return get( props.get( loc ), key, arguments );
/** * Short version for lazy people. * * @param key * @param arguments * @return the same as #getMessage */ public static String get( String key, Object... arguments ) { return getMessage( key, arguments ); }
String msg = Messages.getMessage( "CSW_NAMESPACE_PARAM_INVALID", nsString ); throw new InvalidParameterValueException( msg );
private Boolean parseLockAction( String lockActionStr ) { Boolean lockAll = null; if ( lockActionStr != null ) { if ( "ALL".equals( lockActionStr ) ) { lockAll = true; } else if ( "SOME".equals( lockActionStr ) ) { lockAll = false; } else { String msg = Messages.get( "WFS_UNKNOWN_LOCK_ACTION", lockActionStr ); throw new XMLParsingException( this, rootElement, msg ); } } return lockAll; }
String msg = Messages.getMessage( "WFS_NAMESPACE_PARAM110_INVALID", nsString ); throw new InvalidParameterValueException( msg );
private Boolean parseLockAction( String lockActionStr ) { Boolean lockAll = null; if ( lockActionStr != null ) { if ( "ALL".equals( lockActionStr ) ) { lockAll = true; } else if ( "SOME".equals( lockActionStr ) ) { lockAll = false; } else { String msg = Messages.get( "WFS_UNKNOWN_LOCK_ACTION", lockActionStr ); throw new XMLParsingException( this, rootElement, msg ); } } return lockAll; } }
String msg = Messages.getMessage( "WFS_NAMESPACE_PARAM200_INVALID", param ); throw new InvalidParameterValueException( msg );
/** * Returns the object representation for the given <code>wfs:Insert</code> element. * <p> * NOTE: In order to allow stream-oriented processing, this method does *not* consume all events corresponding to * the <code>wfs:Insert</code> element from the given <code>XMLStream</code>. After a call to this method, the XML * stream points at the <code>START_ELEMENT</code> of the insert payload. * </p> * * @param xmlStream * cursor must point at the <code>START_ELEMENT</code> event (<wfs:Insert>) * @return corresponding {@link Insert} object, never <code>null</code> * @throws NoSuchElementException * @throws XMLStreamException * @throws XMLParsingException */ Insert readInsert( XMLStreamReader xmlStream ) throws XMLStreamException { // optional: '@handle' String handle = xmlStream.getAttributeValue( null, "handle" ); if ( xmlStream.nextTag() != START_ELEMENT ) { throw new XMLParsingException( xmlStream, Messages.get( "WFS_INSERT_MISSING_FEATURE_ELEMENT" ) ); } return new Insert( handle, null, null, null, xmlStream ); }
idGen = USE_EXISTING; } else { String msg = Messages.get( "WFS_UNKNOWN_IDGEN_MODE", idGenString, "1.1.0", "'GenerateNew', 'ReplaceDuplicate' and 'UseExisting'" ); throw new XMLParsingException( xmlStream, msg ); throw new XMLParsingException( xmlStream, Messages.get( "WFS_INSERT_MISSING_FEATURE_ELEMENT" ) );
/** * Returns the object representation for the given <code>wfs:Insert</code> element. * <p> * NOTE: In order to allow stream-oriented processing, this method does *not* consume all events corresponding to * the <code>wfs:Insert</code> elemetn from the given <code>XMLStream</code>. After a call to this method, the XML * stream points at the <code>START_ELEMENT</code> of the insert payload. * </p> * * @param xmlStream * cursor must point at the <code>START_ELEMENT</code> event (<wfs:Insert>) * @return corresponding {@link Insert} object, never <code>null</code> * @throws NoSuchElementException * @throws XMLStreamException * @throws XMLParsingException */ Insert readInsert( XMLStreamReader xmlStream ) throws NoSuchElementException, XMLStreamException { // <xsd:attribute name="handle" type="xsd:string"/> String handle = xmlStream.getAttributeValue( null, "handle" ); // <xsd:attribute name="inputFormat" type="xsd:string" default="application/gml+xml; version=3.2"/> String inputFormat = xmlStream.getAttributeValue( null, "inputFormat" ); // <xsd:attribute name="srsName" type="xsd:anyURI"/> String srsName = xmlStream.getAttributeValue( null, "srsName" ); nextElement( xmlStream ); if ( !xmlStream.isStartElement() ) { throw new XMLParsingException( xmlStream, Messages.get( "WFS_INSERT_MISSING_FEATURE_ELEMENT" ) ); } return new Insert( handle, null, inputFormat, srsName, xmlStream ); }
/** * Returns the object representation for the given <code>wfs:Replace</code> element. * <p> * NOTE: In order to allow stream-oriented processing, this method does *not* consume all events corresponding to * the <code>wfs:Replace</code> element from the given <code>XMLStream</code>. After a call to this method, the XML * stream points at the <code>START_ELEMENT</code> of the replacement feature. The replacement feature is followed * by a <code>fes:Filter</code> element. * </p> * * @param xmlStream * cursor must point at the <code>START_ELEMENT</code> event (<wfs:Replace>) * @return corresponding {@link Replace} object, never <code>null</code> * @throws NoSuchElementException * @throws XMLStreamException * @throws XMLParsingException */ Replace readReplace( XMLStreamReader xmlStream ) throws NoSuchElementException, XMLStreamException { // <xsd:attribute name="handle" type="xsd:string"/> String handle = xmlStream.getAttributeValue( null, "handle" ); nextElement( xmlStream ); if ( !xmlStream.isStartElement() ) { throw new XMLParsingException( xmlStream, Messages.get( "WFS_REPLACE_MISSING_FEATURE_ELEMENT" ) ); } return new Replace( handle, xmlStream ); }
private void checkCapabilities() { List<Version> supportedVersions = getIdentification().getServiceTypeVersion(); for ( Version version : supportedVersions ) { if ( VERSION_111.equals( version ) || VERSION_130.equals( version ) ) { return; } } throw new IllegalArgumentException( get( "WMSCLIENT.WRONG_VERSION_CAPABILITIES", supportedVersions, VERSION_111 + ", " + VERSION_130 ) ); }
@Override protected Envelope parseLatLonBoundingBox( OMElement elem ) { double[] min = new double[2]; double[] max = new double[2]; while ( elem.getLocalName().equals( "Layer" ) ) { OMElement bbox = getElement( elem, new XPath( "LatLonBoundingBox", null ) ); if ( bbox != null ) { try { min[0] = Double.parseDouble( bbox.getAttributeValue( new QName( "minx" ) ) ); min[1] = Double.parseDouble( bbox.getAttributeValue( new QName( "miny" ) ) ); max[0] = Double.parseDouble( bbox.getAttributeValue( new QName( "maxx" ) ) ); max[1] = Double.parseDouble( bbox.getAttributeValue( new QName( "maxy" ) ) ); return new GeometryFactory().createEnvelope( min, max, CRSManager.getCRSRef( WGS84 ) ); } catch ( NumberFormatException nfe ) { LOG.warn( get( "WMSCLIENT.SERVER_INVALID_NUMERIC_VALUE", nfe.getLocalizedMessage() ) ); } } else { elem = (OMElement) elem.getParent(); } } return null; }
private Map<String, Envelope> parseBoundingBoxes( String layer ) { Map<String, Envelope> crsToBBox = new HashMap<String, Envelope>(); OMElement elem = getLayerElement( layer ); while ( elem != null && elem.getLocalName().equals( "Layer" ) ) { List<OMElement> bboxes = getElements( elem, new XPath( getPrefix() + "BoundingBox", nsContext ) ); for ( OMElement bbox : bboxes ) { String crs = getNodeAsString( bbox, new XPath( "@" + getLayerCRSElementName(), nsContext ), null ); if ( crs != null && !crsToBBox.containsKey( crs ) ) { try { double minx = Double.parseDouble( bbox.getAttributeValue( new QName( "minx" ) ) ); double miny = Double.parseDouble( bbox.getAttributeValue( new QName( "miny" ) ) ); double maxx = Double.parseDouble( bbox.getAttributeValue( new QName( "maxx" ) ) ); double maxy = Double.parseDouble( bbox.getAttributeValue( new QName( "maxy" ) ) ); crsToBBox.put( crs, new GeometryFactory().createEnvelope( minx, miny, maxx, maxy, CRSManager.getCRSRef( crs ) ) ); } catch ( NumberFormatException nfe ) { LOG.warn( get( "WMSCLIENT.SERVER_INVALID_NUMERIC_VALUE", nfe.getLocalizedMessage() ) ); } } } elem = (OMElement) elem.getParent(); } return crsToBBox; }
protected WMSCapabilitiesAdapter getCapabilitiesAdapter( OMElement root, String version ) throws IOException { if ( version != null ) { wmsVersion = Version.parseVersion( version ); } else { LOG.warn( "No version attribute in WMS capabilities document. Defaulting to 1.1.1." ); wmsVersion = VERSION_111; } if ( VERSION_111.equals( wmsVersion ) ) { return new WMS111CapabilitiesAdapter( root ); } else if ( VERSION_130.equals( wmsVersion ) ) { return new WMS130CapabilitiesAdapter( root ); } throw new IllegalArgumentException( get( "WMSCLIENT.WRONG_VERSION_CAPABILITIES", getIdentification().getServiceTypeVersion(), VERSION_111 + ", " + VERSION_130 ) ); }
LOG.warn( get( "WMSCLIENT.SERVER_NO_GETMAP_URL" ), "Capabilities: ", capaDoc ); return null;
/** * Parses a normalized KVP-map as a WFS {@link DescribeStoredQueries} request. * * @param kvpParams * normalized KVP-map; keys must be uppercase, each key only has one associated value * @return parsed {@link DescribeStoredQueries} request * @throws MissingParameterException * if the request version is unsupported * @throws InvalidParameterValueException * if a parameter contains a syntax error */ public static DescribeStoredQueries parse( Map<String, String> kvpParams ) throws MissingParameterException, InvalidParameterValueException { Version version = Version.parseVersion( KVPUtils.getRequired( kvpParams, "VERSION" ) ); if ( !( VERSION_200.equals( version ) ) ) { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_200 ) ); throw new InvalidParameterValueException( msg ); } String[] storedQueryIds = null; if ( kvpParams.get( "STOREDQUERY_ID" ) != null ) { storedQueryIds = StringUtils.split( kvpParams.get( "STOREDQUERY_ID" ), "," ); } return new DescribeStoredQueries( version, null, storedQueryIds ); } }
constraint = Filter100XMLDecoder.parse( xmlStream ); } else { String msg = Messages.get( "CSW_FILTER_VERSION_NOT_SPECIFIED", versionConstraint, Version.getVersionsString( new Version( 1, 1, 0 ) ), Version.getVersionsString( new Version( 1, 0, 0 ) ) ); String msg = Messages.get( "CSW_UNSUPPORTED_CQL_FILTER" ); LOG.info( msg ); throw new NotImplementedError( msg ); } else { String msg = Messages.get( "CSW_MISSING_FILTER_OR_CQL" ); LOG.debug( msg ); throw new InvalidParameterValueException( msg );
LOG.warn( get( "WMSCLIENT.SERVER_NO_GETMAP_URL" ), "Capabilities: ", capaDoc ); return null;