Search in sources :

Example 1 with OperationsMetadata

use of net.opengis.ows.v_1_0_0.OperationsMetadata in project ddf by codice.

the class TestCswEndpoint method verifyOperationsMetadata.

/**
     * Helper method to verify the OperationsMetadata section matches the endpoint's definition
     *
     * @param ct The CapabilitiesType to verify
     */
private void verifyOperationsMetadata(CapabilitiesType ct) {
    OperationsMetadata om = ct.getOperationsMetadata();
    List<Operation> opList = om.getOperation();
    ArrayList<String> opNames = new ArrayList<>();
    for (Operation op : opList) {
        opNames.add(op.getName());
        if (StringUtils.equals(CswConstants.TRANSACTION, op.getName()) || StringUtils.equals(CswConstants.GET_RECORDS, op.getName())) {
            for (DomainType parameter : op.getParameter()) {
                if (StringUtils.equals(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, parameter.getName())) {
                    assertThat(parameter.getValue(), contains(CswConstants.CONSTRAINT_LANGUAGE_FILTER, CswConstants.CONSTRAINT_LANGUAGE_CQL));
                } else if (StringUtils.equals(CswConstants.TYPE_NAMES_PARAMETER, parameter.getName())) {
                    // TODO : Remove conditional when GMD Metacard Transformer is merged (DDF-1976)
                    if (StringUtils.equals(op.getName(), CswConstants.TRANSACTION)) {
                        assertThat(parameter.getValue(), contains(CswConstants.CSW_RECORD));
                    } else {
                        assertThat(parameter.getValue(), hasItems(CswConstants.CSW_RECORD, GmdConstants.GMD_METACARD_TYPE_NAME));
                    }
                }
            }
        }
    }
    assertThat(opNames.contains(CswConstants.GET_CAPABILITIES), is(true));
    assertThat(opNames.contains(CswConstants.DESCRIBE_RECORD), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORDS), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORD_BY_ID), is(true));
    assertThat(opNames.contains(CswConstants.TRANSACTION), is(true));
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) DomainType(net.opengis.ows.v_1_0_0.DomainType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation)

Example 2 with OperationsMetadata

use of net.opengis.ows.v_1_0_0.OperationsMetadata in project ddf by codice.

the class CswEndpointTest method verifyOperationsMetadata.

/**
 * Helper method to verify the OperationsMetadata section matches the endpoint's definition
 *
 * @param ct The CapabilitiesType to verify
 */
private void verifyOperationsMetadata(CapabilitiesType ct) {
    OperationsMetadata om = ct.getOperationsMetadata();
    List<Operation> opList = om.getOperation();
    ArrayList<String> opNames = new ArrayList<>();
    for (Operation op : opList) {
        opNames.add(op.getName());
        if (StringUtils.equals(CswConstants.TRANSACTION, op.getName()) || StringUtils.equals(CswConstants.GET_RECORDS, op.getName())) {
            for (DomainType parameter : op.getParameter()) {
                if (StringUtils.equals(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, parameter.getName())) {
                    assertThat(parameter.getValue(), contains(CswConstants.CONSTRAINT_LANGUAGE_FILTER, CswConstants.CONSTRAINT_LANGUAGE_CQL));
                } else if (StringUtils.equals(CswConstants.TYPE_NAMES_PARAMETER, parameter.getName())) {
                    if (StringUtils.equals(op.getName(), CswConstants.TRANSACTION)) {
                        assertThat(parameter.getValue(), contains(CswConstants.CSW_RECORD));
                    } else {
                        assertThat(parameter.getValue(), hasItems(CswConstants.CSW_RECORD, THIRD_PARTY_TYPE_NAME));
                    }
                }
            }
        }
    }
    assertThat(opNames.contains(CswConstants.GET_CAPABILITIES), is(true));
    assertThat(opNames.contains(CswConstants.DESCRIBE_RECORD), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORDS), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORD_BY_ID), is(true));
    assertThat(opNames.contains(CswConstants.TRANSACTION), is(true));
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) DomainType(net.opengis.ows.v_1_0_0.DomainType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 3 with OperationsMetadata

use of net.opengis.ows.v_1_0_0.OperationsMetadata in project ddf by codice.

the class CswEndpointTest method testGetCapabilitiesTypeOperationsMetadata.

@Test
public void testGetCapabilitiesTypeOperationsMetadata() {
    // Should only return the OperationsMetadata section
    GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
    SectionsType stv = new SectionsType();
    stv.setSection(Arrays.asList(CswEndpoint.OPERATIONS_METADATA));
    gct.setSections(stv);
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gct);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    verifyOperationsMetadata(ct);
    verifyFilterCapabilities(ct);
    assertThat(ct.getServiceIdentification(), nullValue());
    assertThat(ct.getServiceProvider(), nullValue());
}
Also used : SectionsType(net.opengis.ows.v_1_0_0.SectionsType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 4 with OperationsMetadata

use of net.opengis.ows.v_1_0_0.OperationsMetadata in project ddf by codice.

the class CswEndpoint method buildOperationsMetadata.

/**
 * Creates the OperationsMetadata portion of the GetCapabilities response TODO: As these
 * operations are implemented or added, update their descriptions to ensure they match up with the
 * functionality
 *
 * @return The constructed OperationsMetadata object
 */
private OperationsMetadata buildOperationsMetadata() {
    List<String> typeNames = getTypeNames();
    OperationsMetadata om = new OperationsMetadata();
    List<QName> getAndPost = Arrays.asList(CswConstants.GET, CswConstants.POST);
    Set<String> schemasSet = new HashSet<>(schemaTransformerManager.getAvailableSchemas());
    List<String> availableSchemas = new ArrayList<>(schemasSet);
    // Builds GetCapabilities operation metadata
    Operation getCapabilitiesOp = buildOperation(CswConstants.GET_CAPABILITIES, getAndPost);
    addOperationParameter("sections", GET_CAPABILITIES_PARAMS, getCapabilitiesOp);
    // Builds DescribeRecord operation metadata
    Operation describeRecordOp = buildOperation(CswConstants.DESCRIBE_RECORD, getAndPost);
    addOperationParameter(CswConstants.TYPE_NAME_PARAMETER, typeNames, describeRecordOp);
    Set<String> mimeTypeSet = new HashSet<>();
    mimeTypeSet.add(DEFAULT_OUTPUT_FORMAT);
    mimeTypeSet.addAll(mimeTypeTransformerManager.getAvailableMimeTypes());
    List<String> mimeTypes = new ArrayList<>(mimeTypeSet);
    addOperationParameter(CswConstants.OUTPUT_FORMAT_PARAMETER, mimeTypes, describeRecordOp);
    addOperationParameter("schemaLanguage", CswConstants.VALID_SCHEMA_LANGUAGES, describeRecordOp);
    // Builds GetRecords operation metadata
    Operation getRecordsOp = buildOperation(CswConstants.GET_RECORDS, getAndPost);
    addOperationParameter(CswConstants.RESULT_TYPE_PARAMETER, Arrays.asList("hits", "results", "validate"), getRecordsOp);
    addOperationParameter(CswConstants.OUTPUT_FORMAT_PARAMETER, mimeTypes, getRecordsOp);
    addOperationParameter(CswConstants.OUTPUT_SCHEMA_PARAMETER, availableSchemas, getRecordsOp);
    addOperationParameter(CswConstants.TYPE_NAMES_PARAMETER, typeNames, getRecordsOp);
    addOperationParameter(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, CswConstants.CONSTRAINT_LANGUAGES, getRecordsOp);
    addFederatedCatalogs(getRecordsOp);
    // Builds GetRecordById operation metadata
    mimeTypes.add(MediaType.APPLICATION_OCTET_STREAM);
    List<String> supportedSchemas = new ArrayList<>(availableSchemas);
    supportedSchemas.add(OCTET_STREAM_OUTPUT_SCHEMA);
    Operation getRecordByIdOp = buildOperation(CswConstants.GET_RECORD_BY_ID, getAndPost);
    addOperationParameter(CswConstants.OUTPUT_SCHEMA_PARAMETER, supportedSchemas, getRecordByIdOp);
    addOperationParameter(CswConstants.OUTPUT_FORMAT_PARAMETER, mimeTypes, getRecordByIdOp);
    addOperationParameter(CswConstants.RESULT_TYPE_PARAMETER, Arrays.asList("hits", "results", "validate"), getRecordByIdOp);
    addOperationParameter(CswConstants.ELEMENT_SET_NAME_PARAMETER, ELEMENT_NAMES, getRecordByIdOp);
    // Builds Transactions operation metadata
    Operation transactionOp = buildOperation(CswConstants.TRANSACTION, Collections.singletonList(CswConstants.POST));
    addOperationParameter(CswConstants.TYPE_NAMES_PARAMETER, inputTransformerManager.getAvailableIds(), transactionOp);
    addOperationParameter(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, CswConstants.CONSTRAINT_LANGUAGES, transactionOp);
    List<Operation> ops = Arrays.asList(getCapabilitiesOp, describeRecordOp, getRecordsOp, getRecordByIdOp, transactionOp);
    om.setOperation(ops);
    om.getParameter().add(createDomainType(CswConstants.SERVICE, CswConstants.CSW));
    om.getParameter().add(createDomainType(CswConstants.VERSION, CswConstants.VERSION_2_0_2));
    return om;
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation) HashSet(java.util.HashSet)

Example 5 with OperationsMetadata

use of net.opengis.ows.v_1_0_0.OperationsMetadata in project ddf by codice.

the class AbstractCswSource method readGetRecordsOperation.

/**
 * Parses the getRecords {@link Operation} to understand the capabilities of the
 * org.codice.ddf.spatial.ogc.csw.catalog.common.Csw Server. A sample GetRecords Operation may
 * look like this:
 *
 * <p>
 *
 * <pre>
 *   <ows:Operation name="GetRecords">
 *     <ows:DCP>
 *       <ows:HTTP>
 *         <ows:Get  xlink:href="http://www.cubewerx.com/cwcsw.cgi?" />
 *         <ows:Post xlink:href="http://www.cubewerx.com/cwcsw.cgi" />
 *       </ows:HTTP>
 *     </ows:DCP>
 *     <ows:Parameter name="TypeName">
 *       <ows:Value>csw:Record</ows:Value>
 *     </ows:Parameter>
 *     <ows:Parameter name="outputFormat">
 *       <ows:Value>application/xml</ows:Value>
 *       <ows:Value>text/html</ows:Value>
 *       <ows:Value>text/plain</ows:Value>
 *     </ows:Parameter>
 *     <ows:Parameter name="outputSchema">
 *       <ows:Value>http://www.opengis.net/cat/csw/2.0.2</ows:Value>
 *     </ows:Parameter>
 *     <ows:Parameter name="resultType">
 *       <ows:Value>hits</ows:Value>
 *       <ows:Value>results</ows:Value>
 *       <ows:Value>validate</ows:Value>
 *     </ows:Parameter>
 *     <ows:Parameter name="ElementSetName">
 *       <ows:Value>brief</ows:Value>
 *       <ows:Value>summary</ows:Value>
 *       <ows:Value>full</ows:Value>
 *     </ows:Parameter>
 *     <ows:Parameter name="CONSTRAINTLANGUAGE">
 *       <ows:Value>Filter</ows:Value>
 *     </ows:Parameter>
 *   </ows:Operation>
 * </pre>
 *
 * @param capabilitiesType The capabilities the org.codice.ddf.spatial.ogc.csw.catalog.common.Csw
 *     Server supports
 */
private void readGetRecordsOperation(CapabilitiesType capabilitiesType) {
    OperationsMetadata operationsMetadata = capabilitiesType.getOperationsMetadata();
    if (null == operationsMetadata) {
        LOGGER.info("{}: CSW Source contains no operations", cswSourceConfiguration.getId());
        return;
    }
    description = capabilitiesType.getServiceIdentification().getAbstract();
    Operation getRecordsOp = getOperation(operationsMetadata, CswConstants.GET_RECORDS);
    if (null == getRecordsOp) {
        LOGGER.info("{}: CSW Source contains no getRecords Operation", cswSourceConfiguration.getId());
        return;
    }
    this.supportedOutputSchemas = getParameter(getRecordsOp, CswConstants.OUTPUT_SCHEMA_PARAMETER);
    DomainType constraintLanguage = getParameter(getRecordsOp, CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
    if (null != constraintLanguage) {
        DomainType outputFormatValues = getParameter(getRecordsOp, CswConstants.OUTPUT_FORMAT_PARAMETER);
        DomainType resultTypesValues = getParameter(getRecordsOp, CswConstants.RESULT_TYPE_PARAMETER);
        readSetDetailLevels(getParameter(getRecordsOp, CswConstants.ELEMENT_SET_NAME_PARAMETER));
        List<String> constraints = new ArrayList<>();
        for (String s : constraintLanguage.getValue()) {
            constraints.add(s.toLowerCase());
        }
        if (constraints.contains(CswConstants.CONSTRAINT_LANGUAGE_CQL.toLowerCase()) && !constraints.contains(CswConstants.CONSTRAINT_LANGUAGE_FILTER.toLowerCase())) {
            isConstraintCql = true;
        } else {
            isConstraintCql = false;
        }
        setFilterDelegate(getRecordsOp, capabilitiesType.getFilterCapabilities(), outputFormatValues, resultTypesValues, cswSourceConfiguration);
        if (!NO_FORCE_SPATIAL_FILTER.equals(forceSpatialFilter)) {
            SpatialOperatorType sot = new SpatialOperatorType();
            SpatialOperatorNameType sont = SpatialOperatorNameType.fromValue(forceSpatialFilter);
            sot.setName(sont);
            sot.setGeometryOperands(cswFilterDelegate.getGeoOpsForSpatialOp(sont));
            SpatialOperatorsType spatialOperators = new SpatialOperatorsType();
            spatialOperators.setSpatialOperator(Arrays.asList(sot));
            cswFilterDelegate.setSpatialOps(spatialOperators);
        }
    }
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) DomainType(net.opengis.ows.v_1_0_0.DomainType) SpatialOperatorsType(net.opengis.filter.v_1_1_0.SpatialOperatorsType) SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation) SpatialOperatorNameType(net.opengis.filter.v_1_1_0.SpatialOperatorNameType)

Aggregations

Operation (net.opengis.ows.v_1_0_0.Operation)7 ArrayList (java.util.ArrayList)6 OperationsMetadata (net.opengis.ows.v_1_0_0.OperationsMetadata)6 DomainType (net.opengis.ows.v_1_0_0.DomainType)5 CapabilitiesType (net.opengis.cat.csw.v_2_0_2.CapabilitiesType)3 QName (javax.xml.namespace.QName)2 GetCapabilitiesType (net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)2 SectionsType (net.opengis.ows.v_1_0_0.SectionsType)2 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)2 Test (org.junit.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Metacard (ddf.catalog.data.Metacard)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 HashSet (java.util.HashSet)1 JAXBElement (javax.xml.bind.JAXBElement)1 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)1 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)1 ComparisonOperatorType (net.opengis.filter.v_1_1_0.ComparisonOperatorType)1 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)1 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)1