/** * 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 ); }
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; }
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; } }
/** * 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 ); }
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; }
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 ) ); }
/** * Parses the {@link GetRecords} kvp request and decides which version has to parse because of the requested version * * @param normalizedKVPParams * that are requested as key to a value. * @return {@link GetRecords} */ public static GetRecords parse( Map<String, String> normalizedKVPParams, String defaultOutputFormat, String defaultOutputSchema ) { Version version = Version.parseVersion( KVPUtils.getRequired( normalizedKVPParams, "VERSION" ) ); GetRecords result = null; if ( VERSION_202.equals( version ) ) { result = parse202( VERSION_202, normalizedKVPParams, defaultOutputFormat, defaultOutputSchema ); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_202 ) ); throw new InvalidParameterValueException( msg ); } return result; }
/** * Parses a normalized KVP-map as a WFS {@link ListStoredQueries} request. * * @param kvpParams * normalized KVP-map; keys must be uppercase, each key only has one associated value * @return parsed {@link ListStoredQueries} request * @throws MissingParameterException * if the request version is unsupported * @throws InvalidParameterValueException * if a parameter contains a syntax error */ public static ListStoredQueries 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 ); } return new ListStoredQueries( version, null ); } }
/** * Parses the {@link GetRecordById} kvp request and decides which version has to parse because of the requested * version * * @param normalizedKVPParams * that are requested containing all mandatory and optional parts regarding CSW spec * @return {@link GetRecordById} * @throws MetadataStoreException */ public static GetRecordById parse( Map<String, String> normalizedKVPParams, String defaultOutputFormat, String defaultOuputSchema ) { Version version = Version.parseVersion( KVPUtils.getRequired( normalizedKVPParams, "VERSION" ) ); GetRecordById result = null; if ( VERSION_202.equals( version ) ) { result = parse202( VERSION_202, normalizedKVPParams, defaultOutputFormat, defaultOuputSchema ); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_202 ) ); throw new InvalidParameterValueException( msg ); } return result; }
public TransactionXmlReader createReader( Version version ) { if ( VERSION_100.equals( version ) ) { return new TransactionXmlReader100(); } else if ( VERSION_110.equals( version ) ) { return new TransactionXmlReader110(); } else if ( VERSION_200.equals( version ) ) { return new TransactionXmlReader200(); } String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_100, VERSION_110, VERSION_200 ) ); throw new InvalidParameterValueException( msg ); }
/** * Parses the {@link DescribeRecord} XML request. * * @param version * @return {@link DescribeRecord} */ public DescribeRecord parse( Version version ) { if ( version == null ) { version = Version.parseVersion( getRequiredNodeAsString( rootElement, new XPath( "@version", nsContext ) ) ); } DescribeRecord result = null; if ( VERSION_202.equals( version ) ) { result = parse202(); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_202 ) ); throw new InvalidParameterValueException( msg ); } return result; }
/** * Parses a normalized KVP-map as a WFS {@link DropStoredQuery} request. * * @param kvpParams * normalized KVP-map; keys must be uppercase, each key only has one associated value * @return parsed {@link DropStoredQuery} request * @throws MissingParameterException * if the request version is unsupported * @throws InvalidParameterValueException * if a parameter contains a syntax error */ public static DropStoredQuery 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 id = KVPUtils.getRequired( kvpParams, "STOREDQUERY_ID" ); return new DropStoredQuery( version, null, id ); } }
/** * Parses the {@link Transaction} XML request by deciding which version has to be parsed because of the requested * version. * * @param version * @return {@link Transaction} */ public Transaction parse( Version version ) { if ( version == null ) { version = Version.parseVersion( getRequiredNodeAsString( rootElement, new XPath( "@version", nsContext ) ) ); } Transaction result = null; if ( VERSION_202.equals( version ) ) { result = parse202(); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_202 ) ); throw new InvalidParameterValueException( msg ); } return result; }
/** * Parses the {@link GetRecords} XML request by deciding which version has to be parsed because of the requested * version. * * @param version * @return {@Link GetRecords} */ public GetRecords parse( Version version, String defaultOutputFormat, String defaultOutputSchema ) { if ( version == null ) { version = Version.parseVersion( getRequiredNodeAsString( rootElement, new XPath( "@version", nsContext ) ) ); } GetRecords result = null; if ( VERSION_202.equals( version ) ) { result = parse202( defaultOutputFormat, defaultOutputSchema ); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_202 ) ); throw new InvalidParameterValueException( msg ); } return result; }
public static GetRepositoryItem parse( Map<String, String> normalizedKVPParams ) { Version version = Version.parseVersion( KVPUtils.getRequired( normalizedKVPParams, "VERSION" ) ); if ( VERSION_202.equals( version ) || VERSION_100.equals( version ) ) { return new GetRepositoryItem( KVPUtils.getRequired( normalizedKVPParams, "ID" ) ); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_202 ) + Version.getVersionsString( VERSION_100 ) ); throw new InvalidParameterValueException( msg ); } }
/** * Parses the {@link GetRecordById} XML request by deciding which version has to be parsed because of the requested * version. * * @param requestVersion * @return {@link GetRecordById} */ public GetRecordById parse( Version requestVersion, String defaultOutputFormat, String defaultOutputSchema ) { if ( requestVersion == null ) { requestVersion = Version.parseVersion( getRequiredNodeAsString( rootElement, new XPath( "@version", nsContext ) ) ); } GetRecordById result = null; if ( VERSION_202.equals( requestVersion ) ) { result = parse202( defaultOutputFormat, defaultOutputSchema ); } else { String msg = Messages.get( "UNSUPPORTED_VERSION", requestVersion, Version.getVersionsString( VERSION_202 ) ); throw new InvalidParameterValueException( msg ); } return result; }
@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( "wms:EX_GeographicBoundingBox", nsContext ) ); if ( bbox != null ) { try { min[0] = getRequiredNodeAsDouble( bbox, new XPath( "wms:westBoundLongitude", nsContext ) ); min[1] = getRequiredNodeAsDouble( bbox, new XPath( "wms:southBoundLatitude", nsContext ) ); max[0] = getRequiredNodeAsDouble( bbox, new XPath( "wms:eastBoundLongitude", nsContext ) ); max[1] = getRequiredNodeAsDouble( bbox, new XPath( "wms:northBoundLatitude", nsContext ) ); 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; }
/** * Parses a WFS <code>ListStoredQueries</code> document into a {@link ListStoredQueries} request. * * @return parsed {@link ListStoredQueries} request, never <code>null</code> * @throws InvalidParameterValueException * if a parameter contains a syntax error */ public ListStoredQueries parse() throws InvalidParameterValueException { // <xsd:attribute name="version" type="xsd:string" use="required" fixed="2.0.0"/> Version version = Version.parseVersion( getRequiredNodeAsString( rootElement, new XPath( "@version", nsContext ) ) ); if ( !( VERSION_200.equals( version ) ) ) { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_200 ) ); throw new InvalidParameterValueException( msg ); } // <xsd:attribute name="handle" type="xsd:string"/> String handle = getNodeAsString( rootElement, new XPath( "@handle", nsContext ), null ); return new ListStoredQueries( version, handle ); } }
/** * Parses a WFS <code>DescribeStoredQueries</code> document into a {@link DescribeStoredQueries} request. * * @return parsed {@link DescribeStoredQueries} request, never <code>null</code> * @throws InvalidParameterValueException * if a parameter contains a syntax error */ public DescribeStoredQueries parse() throws InvalidParameterValueException { // <xsd:attribute name="version" type="xsd:string" use="required" fixed="2.0.0"/> Version version = Version.parseVersion( getRequiredNodeAsString( rootElement, new XPath( "@version", nsContext ) ) ); if ( !( VERSION_200.equals( version ) ) ) { String msg = Messages.get( "UNSUPPORTED_VERSION", version, Version.getVersionsString( VERSION_200 ) ); throw new InvalidParameterValueException( msg ); } // <xsd:attribute name="handle" type="xsd:string"/> String handle = getNodeAsString( rootElement, new XPath( "@handle", nsContext ), null ); // <xsd:element name="StoredQueryId" type="xsd:anyURI" minOccurs="0" maxOccurs="unbounded"/> String[] storedQueryIds = getNodesAsStrings( rootElement, new XPath( "wfs200:StoredQueryId", nsContext ) ); return new DescribeStoredQueries( version, handle, storedQueryIds ); } }