/** * Search for the record descriptor maching the request, throws a service exception in case none * is found * * @param request * @return */ private RecordDescriptor getRecordDescriptor(GetRecordsType request) { String outputSchema = request.getOutputSchema(); if (outputSchema == null) { outputSchema = CSW.NAMESPACE; request.setOutputFormat(CSW.NAMESPACE); } for (RecordDescriptor rd : recordDescriptors) { if (outputSchema.equals(rd.getOutputSchema())) { return rd; } } throw new ServiceException("Cannot encode records in output schema " + outputSchema, ServiceException.INVALID_PARAMETER_VALUE, "outputSchema"); }
private ResultType getResultType(RequestBaseType request) { if (request instanceof GetRecordsType) { return ((GetRecordsType) request).getResultType(); } else { return ResultType.RESULTS; } }
assertEquals("CSW", gr.getService()); assertEquals("2.0.2", gr.getVersion()); assertEquals(ResultType.RESULTS, gr.getResultType()); assertEquals("myId", gr.getRequestId()); assertEquals("application/xml", gr.getOutputFormat()); assertEquals("http://www.opengis.net/cat/csw/2.0.2", gr.getOutputSchema()); assertNotNull(gr.getDistributedSearch()); assertEquals(new Integer(10), gr.getDistributedSearch().getHopCount()); assertEquals("http://www.geoserver.org", gr.getResponseHandler()); QueryType query = (QueryType) gr.getQuery(); assertEquals("AnyText like '%pollution%'", query.getConstraint().getCqlText()); assertEquals(2, query.getTypeNames().size());
QueryType cswQuery = (QueryType) request.getQuery(); List<Query> queries = toGtQueries(outputRd, cswQuery, request); if(request.getMaxRecords() == null) { maxRecords = 10; } else { maxRecords = request.getMaxRecords(); int offset = request.getStartPosition() == null ? 0 : request.getStartPosition() - 1; if(offset < 0) { throw new ServiceException("startPosition must be a positive number", ServiceException.INVALID_PARAMETER_VALUE, "startPosition"); ResultType resultType = request.getResultType(); if(maxRecords == 0 && resultType == ResultType.RESULTS) { resultType = ResultType.HITS; results.add(store.getRecords(q, Transaction.AUTO_COMMIT, request.getOutputSchema())); request.getOutputSchema(), numberOfRecordsMatched, numberOfRecordsReturned, nextRecord, timestamp, records); return result; } catch(IOException e) {
@Test public void testXMLReaderParameter() throws Exception { CSWXmlReader reader = new CSWXmlReader("GetRecords", "2.0.2", new CSWConfiguration()); GetRecordsType gr = (GetRecordsType) reader.read(null, getResourceAsReader("GetRecordsBrief.xml"), (Map) null); // check the attributes assertEquals("application/xml", gr.getOutputFormat()); assertEquals("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", gr.getOutputSchema()); // the query QueryType query = (QueryType) gr.getQuery(); List<QName> expected = new ArrayList<QName>(); String rimNamespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"; expected.add(new QName(rimNamespace, "Service")); expected.add(new QName(rimNamespace, "Classification")); expected.add(new QName(rimNamespace, "Association")); assertEquals(expected, query.getTypeNames()); // the element set name ElementSetNameType esn = query.getElementSetName(); expected.clear(); expected.add(new QName(rimNamespace, "Service")); assertEquals(expected, esn.getTypeNames()); assertEquals(ElementSetType.BRIEF, esn.getValue()); }
assertEquals("CSW", gr.getService()); assertEquals("2.0.2", gr.getVersion()); QueryType query = (QueryType) gr.getQuery();
private String getRequestedSchema(Operation operation) { Object request = operation.getParameters()[0]; if (request instanceof GetRecordByIdType) { GetRecordByIdType gr = (GetRecordByIdType) request; return gr.getOutputSchema(); } else if (request instanceof GetRecordsType) { GetRecordsType gr = (GetRecordsType) request; return gr.getOutputSchema(); } else { throw new IllegalArgumentException("Unsupported request object type: " + request); } }
adapted.getHints().put(KEY_BASEURL, request.getBaseUrl());
QueryType cswQuery = (QueryType) request.getQuery(); List<Query> queries = toGtQueries(outputRd, cswQuery, request); if (request.getMaxRecords() == null) { maxRecords = 10; } else { maxRecords = request.getMaxRecords(); int offset = request.getStartPosition() == null ? 0 : request.getStartPosition() - 1; if (offset < 0) { throw new ServiceException( ResultType resultType = request.getResultType(); if (maxRecords == 0 && resultType == ResultType.RESULTS) { resultType = ResultType.HITS; q, Transaction.AUTO_COMMIT, request.getOutputSchema())); new CSWRecordsResult( elementSet, request.getOutputSchema(), numberOfRecordsMatched, numberOfRecordsReturned,
private String getRequestedSchema(Operation operation) { Object request = operation.getParameters()[0]; if (request instanceof GetRecordByIdType) { GetRecordByIdType gr = (GetRecordByIdType) request; return gr.getOutputSchema(); } else if (request instanceof GetRecordsType) { GetRecordsType gr = (GetRecordsType) request; return gr.getOutputSchema(); } else { throw new IllegalArgumentException("Unsupported request object type: " + request); } }
adapted.getHints().put(KEY_BASEURL, request.getBaseUrl());
/** * Search for the record descriptor maching the request, throws a service exception in case none * is found * * @param request */ private RecordDescriptor getRecordDescriptor(GetRecordsType request) { String outputSchema = request.getOutputSchema(); if (outputSchema == null) { outputSchema = CSW.NAMESPACE; request.setOutputFormat(CSW.NAMESPACE); } for (RecordDescriptor rd : recordDescriptors) { if (outputSchema.equals(rd.getOutputSchema())) { return rd; } } throw new ServiceException( "Cannot encode records in output schema " + outputSchema, ServiceException.INVALID_PARAMETER_VALUE, "outputSchema"); } }
private ResultType getResultType(RequestBaseType request) { if(request instanceof GetRecordsType) { return ((GetRecordsType) request).getResultType(); } else { return ResultType.RESULTS; } }