/** * 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 get( props.get( loc ), key, arguments );
@Override public void throwSRSException( String name ) throws OWSException { throw new OWSException( get( "WMS.INVALID_SRS", name ), OWSException.INVALID_CRS ); }
private void checkTransactionsEnabled( String requestName ) throws OWSException { if ( !enableTransactions ) { throw new OWSException( Messages.get( "WFS_TRANSACTIONS_DISABLED", requestName ), OWSException.OPERATION_NOT_SUPPORTED ); } }
@Override public void throwSRSException( String name ) throws OWSException { throw new OWSException( get( "WMS.INVALID_SRS", name ), INVALID_SRS ); }
private void checkTransactionsEnabled( String requestName ) throws OWSException { if ( !enableTransactions ) { throw new OWSException( Messages.get( "CSW_TRANSACTIONS_DISABLED", requestName ), OWSException.OPERATION_NOT_SUPPORTED ); } }
private FeatureStoreTransaction acquireTransaction( FeatureStore fs ) throws OWSException { FeatureStoreTransaction ta = acquiredTransactions.get( fs ); if ( ta == null ) { try { LOG.debug( "Acquiring transaction for feature store " + fs ); ta = fs.acquireTransaction(); acquiredTransactions.put( fs, ta ); } catch ( FeatureStoreException e ) { throw new OWSException( Messages.get( "WFS_CANNOT_ACQUIRE_TA", e.getMessage() ), NO_APPLICABLE_CODE ); } } return ta; }
private Set<String> getNamespacesForRequestedFeatureTypes( DescribeFeatureType request, WfsFeatureStoreManager storeManager ) throws OWSException { Set<String> set = new LinkedHashSet<String>(); LOG.debug( "Adding namespaces of requested feature types." ); for ( QName ftName : request.getTypeNames() ) { FeatureType ft = storeManager.lookupFeatureType( ftName ); if ( ft == null ) { throw new OWSException( Messages.get( "WFS_FEATURE_TYPE_NOT_SERVED", ftName ), OWSException.INVALID_PARAMETER_VALUE, "typenames" ); } set.add( ft.getName().getNamespaceURI() ); } return set; }
/** * Checks if a request version can be handled by this controller (i.e. if is supported by the implementation *and* * offered by the current configuration). * <p> * NOTE: This method does use exception code {@link OWSException#INVALID_PARAMETER_VALUE}, not * {@link OWSException#VERSION_NEGOTIATION_FAILED} -- the latter should only be used for failed GetCapabilities * requests. * </p> * * @param requestedVersion * version to be checked, may be null (causes exception) * @return <code>requestedVersion</code> (if it is not null), or highest version supported * @throws OWSException * if the requested version is not available */ protected Version checkVersion( Version requestedVersion ) throws OWSException { Version version = requestedVersion; if ( requestedVersion == null ) { LOG.debug( "Assuming version: " + offeredVersions.last() ); version = offeredVersions.last(); } else if ( !offeredVersions.contains( requestedVersion ) ) { throw new OWSException( Messages.get( "CONTROLLER_UNSUPPORTED_VERSION", requestedVersion, getOfferedVersionsString() ), OWSException.INVALID_PARAMETER_VALUE ); } return version; }
/** * Checks if a request version can be handled by this controller (i.e. if is supported by the implementation *and* * offered by the current configuration). * <p> * NOTE: This method does use exception code {@link OWSException#INVALID_PARAMETER_VALUE}, not * {@link OWSException#VERSION_NEGOTIATION_FAILED} -- the latter should only be used for failed GetCapabilities * requests. * </p> * * @param requestedVersion * version to be checked, may be null (causes exception) * @return <code>requestedVersion</code> (if it is not null), or highest version supported * @throws OWSException * if the requested version is not available */ @Override protected Version checkVersion( Version requestedVersion ) throws OWSException { Version version = requestedVersion; if ( requestedVersion == null ) { LOG.debug( "Assuming version 1.1.0 (the only one that has an optional version attribute)." ); version = VERSION_110; } if ( !offeredVersions.contains( version ) ) { throw new OWSException( Messages.get( "CONTROLLER_UNSUPPORTED_VERSION", version, getOfferedVersionsString() ), OWSException.INVALID_PARAMETER_VALUE ); } return version; }
@Override public void getCapabilities( String getUrl, String postUrl, String updateSequence, MapService service, HttpResponseBuffer response, ServiceIdentification identification, ServiceProvider provider, Map<String, String> customParameters, WMSController controller, OWSMetadataProvider metadata ) throws OWSException, IOException { getUrl = getUrl.substring( 0, getUrl.length() - 1 ); if ( updateSequence != null && updateSequence.trim().length() > 0 ) { try { int seq = parseInt( updateSequence ); if ( seq > service.getCurrentUpdateSequence() ) { throw new OWSException( get( "WMS.INVALID_UPDATE_SEQUENCE", updateSequence ), OWSException.INVALID_UPDATE_SEQUENCE ); } if ( seq == service.getCurrentUpdateSequence() ) { throw new OWSException( get( "WMS.CURRENT_UPDATE_SEQUENCE" ), OWSException.CURRENT_UPDATE_SEQUENCE ); } } catch ( NumberFormatException e ) { throw new OWSException( get( "WMS.INVALID_UPDATE_SEQUENCE", updateSequence ), OWSException.INVALID_UPDATE_SEQUENCE ); } } XMLOutputFactory factory = XMLOutputFactory.newInstance(); factory.setProperty( IS_REPAIRING_NAMESPACES, true ); exportCapas( getUrl, postUrl, service, response, identification, provider, customParameters, controller, metadata ); }
public void sendImage( BufferedImage img, HttpResponseBuffer response, String format ) throws OWSException, IOException { response.setContentType( format ); ImageSerializer serializer = imageSerializers.get( format ); if ( serializer != null ) { serializer.serialize( null, img, response.getOutputStream() ); return; } format = format.substring( format.indexOf( "/" ) + 1 ); if ( format.equals( "x-ms-bmp" ) ) { format = "bmp"; } if ( format.equals( "png; subtype=8bit" ) || format.equals( "png; mode=8bit" ) ) { img = ColorQuantizer.quantizeImage( img, 256, false, false ); format = "png"; } LOG.debug( "Sending in format " + format ); if ( !write( img, format, response.getOutputStream() ) ) { throw new OWSException( get( "WMS.CANNOT_ENCODE_IMAGE", format ), OWSException.NO_APPLICABLE_CODE ); } }
synchronized ( this ) { if ( schemaToStore.containsValue( fs ) ) { String msg = get( "WFS_FEATURESTORE_ALREADY_REGISTERED", fs ); LOG.error( msg ); throw new IllegalArgumentException( msg ); String msg = get( "WFS_FEATURETYPE_ALREADY_SERVED", ft.getName() ); LOG.error( msg ); throw new IllegalArgumentException( msg );
private void getLegendGraphic( Map<String, String> map, HttpResponseBuffer response ) throws OWSException, IOException { GetLegendGraphic glg = new GetLegendGraphic( map ); if ( !supportedImageFormats.contains( glg.getFormat() ) ) { throw new OWSException( get( "WMS.UNSUPPORTED_IMAGE_FORMAT", glg.getFormat() ), OWSException.INVALID_FORMAT ); } BufferedImage img = service.getLegend( glg ); sendImage( img, response, glg.getFormat() ); }
req = (WMSRequestType) ( (ImplementationMetadata<?>) ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata() ).getRequestTypeByName( requestName ); } catch ( IllegalArgumentException e ) { controllers.get( version ).sendException( new OWSException( get( "WMS.OPERATION_NOT_KNOWN", requestName ), OWSException.OPERATION_NOT_SUPPORTED ), response, this ); return; } catch ( NullPointerException e ) { controllers.get( version ).sendException( new OWSException( get( "WMS.PARAM_MISSING", "REQUEST" ), OWSException.OPERATION_NOT_SUPPORTED ), response, this );
private void doDelete( Delete delete, Lock lock ) throws OWSException { LOG.debug( "doDelete: " + delete ); QName ftName = delete.getTypeName(); FeatureStore fs = service.getStore( ftName ); if ( fs == null ) { throw new OWSException( Messages.get( "WFS_FEATURE_TYPE_NOT_SERVED", ftName ), INVALID_PARAMETER_VALUE ); } FeatureStoreTransaction ta = acquireTransaction( fs ); Filter filter = delete.getFilter(); // superimpose default query CRS Filters.setDefaultCRS( filter, master.getDefaultQueryCrs() ); try { switch ( filter.getType() ) { case ID_FILTER: { deleted += ta.performDelete( (IdFilter) filter, lock ); break; } case OPERATOR_FILTER: { deleted += ta.performDelete( ftName, (OperatorFilter) filter, lock ); break; } } } catch ( FeatureStoreException e ) { throw new OWSException( Messages.get( "WFS_ERROR_PERFORMING_DELETE", e.getMessage() ), NO_APPLICABLE_CODE ); } }
private void checkGetFeatureInfo( Version version, org.deegree.protocol.wms.ops.GetFeatureInfo gfi ) throws OWSException { if ( gfi.getInfoFormat() != null && !gfi.getInfoFormat().equals( "" ) && !featureInfoManager.getSupportedFormats().contains( gfi.getInfoFormat() ) ) { throw new OWSException( get( "WMS.INVALID_INFO_FORMAT", gfi.getInfoFormat() ), OWSException.INVALID_FORMAT ); } for ( LayerRef lr : gfi.getQueryLayers() ) { if ( !service.hasTheme( lr.getName() ) ) { throw new OWSException( "The layer with name " + lr.getName() + " is not defined.", "LayerNotDefined", "layers" ); } } for ( StyleRef sr : gfi.getStyles() ) { // TODO check style availability } try { if ( gfi.getCoordinateSystem() == null ) { // this can happen if some AUTO SRS id was invalid controllers.get( version ).throwSRSException( "automatic" ); } ICRS crs = gfi.getCoordinateSystem(); if ( crs instanceof CRSRef ) { ( (CRSRef) crs ).getReferencedObject(); } } catch ( ReferenceResolvingException e ) { // only throw an exception if a truly invalid srs is found // this makes it possible to request srs that are not advertised, which may be useful controllers.get( version ).throwSRSException( gfi.getCoordinateSystem().getAlias() ); } }
private void doReplace( Replace replace, Lock lock ) throws OWSException { LOG.debug( "doReplace: " + replace ); XMLStreamReader xmlStream = replace.getReplacementFeatureStream(); QName ftName = xmlStream.getName(); FeatureStore fs = service.getStore( ftName ); if ( fs == null ) { throw new OWSException( Messages.get( "WFS_FEATURE_TYPE_NOT_SERVED", ftName ), INVALID_PARAMETER_VALUE ); } Feature replacementFeature = null; Filter filter = null; try { GMLStreamReader gmlReader = createGMLStreamReader( GML_32, xmlStream ); gmlReader.setApplicationSchema( fs.getSchema() ); replacementFeature = gmlReader.readFeature(); filter = replace.getFilter(); // superimpose default CRS Filters.setDefaultCRS( filter, master.getDefaultQueryCrs() ); } catch ( Exception e ) { throw new OWSException( e.getMessage(), INVALID_PARAMETER_VALUE ); } FeatureStoreTransaction ta = acquireTransaction( fs ); try { String newFid = ta.performReplace( replacementFeature, filter, lock, idGenMode ); replaced.add( newFid, replace.getHandle() ); } catch ( FeatureStoreException e ) { throw new OWSException( "Error performing replace: " + e.getMessage(), e, NO_APPLICABLE_CODE ); } }
private void checkGetMap( Version version, org.deegree.protocol.wms.ops.GetMap gm ) throws OWSException { if ( !supportedImageFormats.contains( gm.getFormat() ) ) { throw new OWSException( get( "WMS.UNSUPPORTED_IMAGE_FORMAT", gm.getFormat() ), OWSException.INVALID_FORMAT );
private void doUpdate( Update update, Lock lock ) throws OWSException { LOG.debug( "doUpdate: " + update ); QName ftName = update.getTypeName(); FeatureType ft = service.lookupFeatureType( ftName ); FeatureStore fs = service.getStore( ftName ); if ( fs == null ) { throw new OWSException( Messages.get( "WFS_FEATURE_TYPE_NOT_SERVED", ftName ), INVALID_PARAMETER_VALUE ); } GMLVersion inputFormat = determineFormat( request.getVersion(), update.getInputFormat() ); FeatureStoreTransaction ta = acquireTransaction( fs ); List<ParsedPropertyReplacement> replacementProps = getReplacementProps( update, ft, inputFormat ); Filter filter = null; try { filter = update.getFilter(); // superimpose default query CRS Filters.setDefaultCRS( filter, master.getDefaultQueryCrs() ); } catch ( Exception e ) { throw new OWSException( e.getMessage(), INVALID_PARAMETER_VALUE ); } try { List<String> updatedFids = ta.performUpdate( ftName, replacementProps, filter, lock ); for ( String updatedFid : updatedFids ) { this.updated.add( updatedFid, update.getHandle() ); } } catch ( FeatureStoreException e ) { throw new OWSException( "Error performing update: " + e.getMessage(), e, NO_APPLICABLE_CODE ); } }