/** * 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 ); }
+ QUERY_ID_GET_FEATURE_BY_ID + "&ID={}#{}"; } else { throw new UnsupportedOperationException( Messages.getMessage( "WFS_BACKREFERENCE_UNSUPPORTED", version ) );
@Override public void throwSRSException( String name ) throws OWSException { throw new OWSException( get( "WMS.INVALID_SRS", name ), OWSException.INVALID_CRS ); }
String msg = Messages.getMessage( "CSW_NO_IDENTIFIER_FOUND", requestedIdList ); LOG.debug( msg ); throw new MetadataStoreException( msg );
private void checkTransactionsEnabled( String requestName ) throws OWSException { if ( !enableTransactions ) { throw new OWSException( Messages.get( "WFS_TRANSACTIONS_DISABLED", requestName ), OWSException.OPERATION_NOT_SUPPORTED ); } }
protected GMLObject retrieveObject( String id ) throws OWSException { GMLObject o = null; for ( FeatureStore fs : format.getMaster().getStoreManager().getStores() ) { try { o = fs.getObjectById( id ); } catch ( FeatureStoreException e ) { throw new OWSException( e.getMessage(), NO_APPLICABLE_CODE ); } if ( o != null ) { break; } } if ( o == null ) { String msg = Messages.getMessage( "WFS_NO_SUCH_OBJECT", id ); throw new OWSException( new InvalidParameterValueException( msg ) ); } return o; }
@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 );
default: if ( controllers.get( version ) == null ) { throw new OWSException( get( "WMS.VERSION_UNSUPPORTED", version ), OWSException.INVALID_PARAMETER_VALUE ); throw new OWSException( get( "WMS.OPERATION_NOT_SUPPORTED_IMPLEMENTATION", req.name() ), OPERATION_NOT_SUPPORTED ); case capabilities: throw new OWSException( get( "WMS.DIMENSION_VALUE_MISSING", e.name ), "MissingDimensionValue" ); } catch ( InvalidDimensionValue e ) { LOG.trace( "Stack trace:", e ); throw new OWSException( get( "WMS.DIMENSION_VALUE_INVALID", e.value, e.name ), "InvalidDimensionValue" );
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 );