protected boolean isOperationSupported( String operationName ) { if ( metadata == null ) { return false; } return metadata.getOperation( operationName ) != null; }
protected List<URL> getGetUrls( String operationName ) { if ( metadata == null ) { return Collections.emptyList(); } return metadata.getGetUrls( operationName ); }
protected List<URL> getPostUrls( String operationName ) { if ( metadata == null ) { return Collections.emptyList(); } return metadata.getPostUrls( operationName ); }
private static void exportOperationsMetadata( XMLStreamWriter writer ) throws XMLStreamException { List<Operation> operations = new LinkedList<Operation>(); List<DCP> dcps = null; try { DCP dcp = new DCP( new URL( OGCFrontController.getHttpGetURL() ), new URL( OGCFrontController.getHttpPostURL() ) ); dcps = Collections.singletonList( dcp ); } catch ( MalformedURLException e ) { // should never happen } List<Domain> params = new ArrayList<Domain>(); List<Domain> constraints = new ArrayList<Domain>(); List<OMElement> mdEls = new ArrayList<OMElement>(); operations.add( new Operation( "GetCapabilities", dcps, params, constraints, mdEls ) ); operations.add( new Operation( "DescribeProcess", dcps, params, constraints, mdEls ) ); operations.add( new Operation( "Execute", dcps, params, constraints, mdEls ) ); OperationsMetadata operationsMd = new OperationsMetadata( operations, params, constraints, null ); exportOperationsMetadata110( writer, operationsMd ); }
for ( Operation operation : operationsMd.getOperation() ) { for ( Domain param : operationsMd.getParameters() ) { writer.writeStartElement( OWS_NS, "Parameter" ); exportDomainType100( writer, param ); for ( Domain constraint : operationsMd.getConstraints() ) { writer.writeStartElement( OWS_NS, "Constraint" ); exportDomainType100( writer, constraint ); if ( !operationsMd.getExtendedCapabilities().isEmpty() ) { copy( writer, operationsMd.getExtendedCapabilities().get( 0 ).getXMLStreamReader() );
/** * Use parseOperationsMetadata().getGetUrls( request.name() ) or parseOperationsMetadata().getPostUrls( * request.name() ) instead * * @param request * @param get * true means HTTP GET, false means HTTP POST * @return the address, or null, if not defined or request unavailable */ public String getAddress( WMSRequestType request, boolean get ) { if ( !isOperationSupported( request ) ) { return null; } List<URL> urls; if ( get ) { urls = parseOperationsMetadata().getGetUrls( request.name() ); } else { urls = parseOperationsMetadata().getPostUrls( request.name() ); } return urls.size() > 0 ? urls.get( 0 ).toExternalForm() : null; }
void exportOperationsMetadata() throws XMLStreamException { List<Operation> operations = new LinkedList<Operation>(); List<DCP> dcps = null; try { DCP dcp = new DCP( new URL( OGCFrontController.getHttpGetURL() ), null ); dcps = Collections.singletonList( dcp ); } catch ( MalformedURLException e ) { // should never happen } List<Domain> params = new ArrayList<Domain>(); List<Domain> constraints = new ArrayList<Domain>(); constraints.add( new Domain( "GetEncoding", Collections.singletonList( "KVP" ) ) ); List<OMElement> mdEls = new ArrayList<OMElement>(); operations.add( new Operation( "GetCapabilities", dcps, params, constraints, mdEls ) ); operations.add( new Operation( "GetTile", dcps, params, constraints, mdEls ) ); operations.add( new Operation( "GetFeatureInfo", dcps, params, constraints, mdEls ) ); OperationsMetadata operationsMd = new OperationsMetadata( operations, params, constraints, null ); exportOperationsMetadata110( writer, operationsMd ); }
for ( Operation operation : operationsMd.getOperation() ) { for ( Domain param : operationsMd.getParameters() ) { writer.writeStartElement( OWS110_NS, "Parameter" ); exportDomainType110( writer, param ); for ( Domain constraint : operationsMd.getConstraints() ) { writer.writeStartElement( OWS110_NS, "Constraint" ); exportDomainType110( writer, constraint ); if ( !operationsMd.getExtendedCapabilities().isEmpty() ) { copy( writer, operationsMd.getExtendedCapabilities().get( 0 ).getXMLStreamReader() );
@Override public OperationsMetadata parseOperationsMetadata() throws XMLParsingException { OMElement requestEl = getElement( getRootElement(), new XPath( getPrefix() + "Capability/" + getPrefix() + "Request", nsContext ) ); if ( requestEl == null ) { return null; } XPath xpath = new XPath( "./*", nsContext ); List<OMElement> opEls = getElements( requestEl, xpath ); List<Operation> operations = new ArrayList<Operation>( opEls.size() ); if ( opEls != null ) { for ( OMElement opEl : opEls ) { Operation op = parseOperation( opEl ); operations.add( op ); } } return new OperationsMetadata( operations, new ArrayList<Domain>(), new ArrayList<Domain>(), new ArrayList<OMElement>() ); }
/** * Returns the endpoint {@link URL}s for the specified operation and method HTTP-GET. * * @return endpoint URLs, can be empty, but never <code>null</code> */ public List<URL> getGetUrls( String operationName ) { Operation operation = getOperation( operationName ); if ( operation != null ) { return operation.getGetUrls(); } return null; }
@SuppressWarnings("unchecked") private void sendCapabilities( Map<String, String> map, HttpServletRequest request, HttpResponseBuffer response ) throws IOException { GetCapabilities req = GetCapabilitiesKVPParser.parse( map ); XMLOutputFactory factory = XMLOutputFactory.newInstance(); factory.setProperty( IS_REPAIRING_NAMESPACES, true ); try { XMLStreamWriter xsw = factory.createXMLStreamWriter( response.getOutputStream(), "UTF-8" ); IndentingXMLStreamWriter xmlWriter = new IndentingXMLStreamWriter( xsw ); List<Operation> operations = new ArrayList<Operation>(); List<DCP> dcps = Collections.singletonList( new DCP( new URL( OGCFrontController.getHttpGetURL() ), null ) ); List<Domain> params = Collections.emptyList(); List<Domain> constraints = Collections.emptyList(); for ( String operation : allowedOperations ) { operations.add( new Operation( operation, dcps, params, constraints, EMPTY_LIST ) ); } OperationsMetadata operationsMd = new OperationsMetadata( operations, params, constraints, null ); new CapabilitiesXMLAdapter().export040( xmlWriter, req, identification, provider, operationsMd, service.getServiceConfiguration() ); xmlWriter.writeEndDocument(); } catch ( XMLStreamException e ) { throw new IOException( e ); } }
/** * Returns the endpoint {@link URL}s for the specified operation and method HTTP-POST. * * @return endpoint URLs, can be empty, but never <code>null</code> */ public List<URL> getPostUrls( String operationName ) { Operation operation = getOperation( operationName ); if ( operation != null ) { return operation.getPostUrls(); } return null; }
return new OperationsMetadata( operations, params, constraints, extendedCaps );
private void ckeckOperationSupported( String operationName ) throws UnsupportedOperationException { OperationsMetadata om = getOperations(); if ( om.getOperation( operationName ) == null ) throw new UnsupportedOperationException( "Operation " + operationName + " is not supported!" ); }
return new OperationsMetadata( operations, params, constraints, extendedCaps );
private Map<WMSRequestType, LinkedList<String>> parseFormats( OperationsMetadata operationsMetadata ) { Map<WMSRequestType, LinkedList<String>> opToFormats = new HashMap<WMSRequestType, LinkedList<String>>(); if ( operationsMetadata == null ) { return opToFormats; } for ( Operation operation : operationsMetadata.getOperation() ) { String operationName = operation.getName(); XPath xp = new XPath( "//" + getPrefix() + operationName + "/" + getPrefix() + "Format", nsContext ); LinkedList<String> formats = new LinkedList<String>(); Object res = evaluateXPath( xp, getRootElement() ); if ( res instanceof List<?> ) { for ( Object o : (List<?>) res ) { formats.add( ( (OMElement) o ).getText() ); } } opToFormats.put( WMSRequestType.valueOf( operationName ), formats ); } return opToFormats; }
new OperationsMetadata( operations, null, null, versionToExtendedCaps.get( "1.1.0" ) ) );
RequestUtils.getCurrentThreadRequestParameters().get(), defaultGetFeatureInfo, hardGetFeatureInfo ); Operation op = client.getOperations().getOperation( "GetFeatureInfo" ); if ( op == null ) { throw new OWSException( "The remote WMTS claims not to support GetFeatureInfo.",
constraints.add( new Domain( "QueryExpressions", queryExprs ) ); OperationsMetadata operationsMd = new OperationsMetadata( operations, globalParams,
Operation operation = getOperations().getOperation( GetRecords.name() ); for ( DCP dcp : operation.getDCPs() ) { for ( Pair<URL, List<Domain>> pe : dcp.getPostEndpoints() ) {