/** * 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; }
/** * 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; }
public Operation( String name, List<DCP> dcps, List<Domain> params, List<Domain> constraints, List<OMElement> metadata ) { this.name = name; this.dcp = dcps; if ( params != null ) { this.parameters = params; } else { this.parameters = new ArrayList<Domain>(); } if ( constraints != null ) { this.constraints = constraints; } else { this.constraints = new ArrayList<Domain>(); } if ( metadata != null ) { this.metadata = metadata; } else { this.metadata = new ArrayList<OMElement>(); } for ( DCP dcp : dcps ) { for ( Pair<URL, List<Domain>> urls : dcp.getGetEndpoints() ) { getUrls.add( urls.first ); } for ( Pair<URL, List<Domain>> urls : dcp.getPostEndpoints() ) { postUrls.add( urls.first ); } } }
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 ); }
private void addOperation( WFSRequestType wfsRequestType, List<Domain> params, List<DCP> getAndPost, List<DCP> post, List<DCP> get, List<Operation> operations ) { if ( isGetSupported( wfsRequestType ) && isPostSupported( wfsRequestType ) ) operations.add( new Operation( wfsRequestType.name(), getAndPost, params, null, null ) ); else if ( isPostSupported( wfsRequestType ) ) operations.add( new Operation( wfsRequestType.name(), post, params, null, null ) ); else if ( isGetSupported( wfsRequestType ) ) operations.add( new Operation( wfsRequestType.name(), get, params, null, null ) ); }
writer.writeAttribute( "name", operation.getName() ); for ( DCP dcp : operation.getDCPs() ) { exportDCP( writer, dcp, OWS_NS ); for ( Domain param : operation.getParameters() ) { writer.writeStartElement( OWS_NS, "Parameter" ); exportDomainType100( writer, param ); for ( Domain constraint : operation.getConstraints() ) { writer.writeStartElement( OWS_NS, "Constraint" ); exportDomainType100( writer, constraint ); for ( OMElement md : operation.getMetadata() ) { copy( writer, md.getXMLStreamReader() );
private DCP parseDCP( OMElement dcpEl ) { XPath xpath = new XPath( getPrefix() + "HTTP/" + getPrefix() + "Get", nsContext ); List<OMElement> getEls = getElements( dcpEl, xpath ); List<Pair<URL, List<Domain>>> getEndpoints = new ArrayList<Pair<URL, List<Domain>>>( getEls.size() ); if ( getEls != null ) { for ( OMElement getEl : getEls ) { xpath = new XPath( getPrefix() + "OnlineResource/@xlink:href", nsContext ); URL href = getNodeAsURL( getEl, xpath, null ); getEndpoints.add( new Pair<URL, List<Domain>>( href, new ArrayList<Domain>() ) ); } } xpath = new XPath( getPrefix() + "HTTP/" + getPrefix() + "Post", nsContext ); List<OMElement> postEls = getElements( dcpEl, xpath ); List<Pair<URL, List<Domain>>> postEndpoints = new ArrayList<Pair<URL, List<Domain>>>( postEls.size() ); if ( postEls != null ) { for ( OMElement postEl : postEls ) { xpath = new XPath( getPrefix() + "OnlineResource/@xlink:href", nsContext ); URL href = getNodeAsURL( postEl, xpath, null ); postEndpoints.add( new Pair<URL, List<Domain>>( href, new ArrayList<Domain>() ) ); } } return new DCP( getEndpoints, postEndpoints ); }
for ( DCP dcp : operation.getDCPs() ) { for ( Pair<URL, List<Domain>> pe : dcp.getPostEndpoints() ) { for ( Domain d : pe.second ) { if ( "PostEncoding".equals( d.getName() ) ) {
public OperationsMetadata( List<Operation> operations, List<Domain> parameters, List<Domain> constraints, List<OMElement> extendedCapabilities ) { for ( Operation operation : operations ) { operationNameToMD.put( operation.getName(), operation ); } if ( parameters != null ) { this.parameters = parameters; } else { this.parameters = new ArrayList<Domain>(); } if ( constraints != null ) { this.constraints = constraints; } else { this.constraints = new ArrayList<Domain>(); } if ( extendedCapabilities != null ) { this.extendedCapabilities = extendedCapabilities; } else { this.extendedCapabilities = new ArrayList<OMElement>(); } }
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 ); }
private Operation parseOperation( OMElement opEl ) { String name = opEl.getLocalName(); XPath xpath = new XPath( getPrefix() + "DCPType", nsContext ); List<OMElement> dcpEls = getElements( opEl, xpath ); List<DCP> dcps = new ArrayList<DCP>( dcpEls.size() ); if ( dcpEls != null ) { for ( OMElement dcpEl : dcpEls ) { DCP dcp = parseDCP( dcpEl ); dcps.add( dcp ); } } return new Operation( name, dcps, new ArrayList<Domain>(), new ArrayList<Domain>(), new ArrayList<OMElement>() ); }
writer.writeAttribute( "name", operation.getName() ); for ( DCP dcp : operation.getDCPs() ) { exportDCP( writer, dcp, OWS110_NS ); for ( Domain param : operation.getParameters() ) { writer.writeStartElement( OWS110_NS, "Parameter" ); exportDomainType110( writer, param ); for ( Domain constraint : operation.getConstraints() ) { writer.writeStartElement( OWS110_NS, "Constraint" ); exportDomainType110( writer, constraint ); for ( OMElement md : operation.getMetadata() ) { copy( writer, md.getXMLStreamReader() );
return new DCP( getEndpoints, postEndpoints );
if ( dcp.getGetEndpoints() != null ) { for ( Pair<URL, List<Domain>> getEndpoint : dcp.getGetEndpoints() ) { writer.writeEmptyElement( owsNS, "Get" ); writer.writeAttribute( XLN_NS, "href", getEndpoint.first.toString() ); if ( dcp.getPostEndpoints() != null ) { for ( Pair<URL, List<Domain>> postEndpoint : dcp.getPostEndpoints() ) { writer.writeEmptyElement( owsNS, "Post" ); writer.writeAttribute( XLN_NS, "href", postEndpoint.first.toString() );
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; }
@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 ); } }
return new Operation( name, dcps, params, constraints, metadataEls );
List<DCP> post = null; try { getAndPost = Collections.singletonList( new DCP( new URL( getHttpGetURL() ), new URL( getHttpPostURL() ) ) ); post = singletonList( new DCP( null, new URL( getHttpPostURL() ) ) ); get = singletonList( new DCP( new URL( getHttpGetURL() ), null ) ); } catch ( MalformedURLException e ) {
List<DCP> get = null; try { getAndPost = singletonList( new DCP( new URL( getHttpGetURL() ), new URL( getHttpPostURL() ) ) ); post = singletonList( new DCP( null, new URL( getHttpPostURL() ) ) ); get = singletonList( new DCP( new URL( getHttpGetURL() ), null ) ); } catch ( MalformedURLException e ) { constraints.add( new Domain( "PreservesSiblingOrder", "TRUE" ) ); if ( supportedEncodings.isEncodingSupported( Transaction, "POST" ) ) operations.add( new Operation( Transaction.name(), post, null, constraints, null ) );
List<OMElement> metadataEls = getElements( opEl, xpath ); return new Operation( name, dcps, params, constraints, metadataEls );