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); } }
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); } }
/** * 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"); }
/** * 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"); } }
results.add(store.getRecords(q, Transaction.AUTO_COMMIT, request.getOutputSchema())); request.getOutputSchema(), numberOfRecordsMatched, numberOfRecordsReturned, nextRecord, timestamp, records); return result; } catch(IOException e) {
q, Transaction.AUTO_COMMIT, request.getOutputSchema())); new CSWRecordsResult( elementSet, request.getOutputSchema(), numberOfRecordsMatched, numberOfRecordsReturned,
@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("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());