public CSWRecordBuilder() { super(CSWRecordDescriptor.getInstance()); }
public SimpleCatalogStore(File root) { support(CSWRecordDescriptor.getInstance()); this.root = root; if (!root.exists()) { throw new IllegalArgumentException("Record directory does not exists: " + root.getPath()); } else if (!root.isDirectory()) { throw new IllegalArgumentException( "Got an existing reference on the file system, but it's not a directory: " + root.getPath()); } }
public SimpleCatalogStore(Resource root) { support(CSWRecordDescriptor.getInstance()); this.root = root; if (root.getType() == Type.RESOURCE) { throw new IllegalArgumentException( "Got an existing reference on the file system, but it's not a directory: " + root.path()); } }
public InternalCatalogStore(Catalog catalog) { support(CSWRecordDescriptor.getInstance()); support(MetaDataDescriptor.getInstance()); this.catalog = catalog; }
public InternalCatalogStore(Catalog catalog) { support(CSWRecordDescriptor.getInstance()); support(MetaDataDescriptor.getInstance()); this.catalog = catalog; }
/** * Search for the record descriptor maching the typename, throws a service exception in case none * is found * * @param request * @return */ private RecordDescriptor getRecordDescriptor(Name typeName) { if (typeName == null) { return CSWRecordDescriptor.getInstance(); } for (RecordDescriptor rd : recordDescriptors) { if (typeName.equals(rd.getFeatureDescriptor().getName())) { return rd; } } throw new ServiceException("Unknown type: " + typeName, ServiceException.INVALID_PARAMETER_VALUE, "typeNames"); }
/** * Search for the record descriptor maching the typename, throws a service exception in case * none is found * * @param request */ private RecordDescriptor getRecordDescriptor(Name typeName) { if (typeName == null) { return CSWRecordDescriptor.getInstance(); } for (RecordDescriptor rd : recordDescriptors) { if (typeName.equals(rd.getFeatureDescriptor().getName())) { return rd; } } throw new ServiceException( "Unknown type: " + typeName, ServiceException.INVALID_PARAMETER_VALUE, "typeNames"); }
@Override public FeatureCollection getRecords(Query q, Transaction t, String outputSchema) throws IOException { RecordDescriptor rd; Name typeName = null; if (q.getTypeName() == null) { typeName = CSWRecordDescriptor.RECORD_DESCRIPTOR.getName(); } else if (q.getNamespace() != null) { typeName = new NameImpl(q.getNamespace().toString(), q.getTypeName()); } else { typeName = new NameImpl(q.getTypeName()); } rd = descriptorByType.get(typeName); RecordDescriptor rdOutput; if (outputSchema == null || "".equals(outputSchema)) { rdOutput = descriptorByOutputSchema.get( CSWRecordDescriptor.getInstance().getOutputSchema()); } else { rdOutput = descriptorByOutputSchema.get(outputSchema); } if (rd == null) { throw new IOException(q.getTypeName() + " is not a supported type"); } if (rdOutput == null) { throw new IOException(outputSchema + " is not a supported output schema"); } return getRecordsInternal(rd, rdOutput, q, t); }
@Test public void testNamespaceSupport() throws IOException, URISyntaxException { AbstractCatalogStore store = new AbstractCatalogStore() { { support(CSWRecordDescriptor.getInstance()); support(GSRecordDescriptor.getInstance()); } @Override public FeatureCollection getRecordsInternal(RecordDescriptor rd, RecordDescriptor rdOutput, Query q, Transaction t) throws IOException { if(rd == GSRecordDescriptor.getInstance()) { return new MemoryFeatureCollection(GSRecordDescriptor.getInstance().getFeatureType()); } else { throw new RuntimeException("Was expecting the geoserver record descriptor"); } } }; RecordDescriptor[] descriptors = store.getRecordDescriptors(); assertEquals(2, descriptors.length); assertEquals(CSWRecordDescriptor.getInstance(), descriptors[0]); assertEquals(GSRecordDescriptor.getInstance(), descriptors[1]); Query query = new Query("Record"); query.setNamespace(new URI(GSRecordDescriptor.GS_NAMESPACE)); FeatureCollection records = store.getRecords(query, Transaction.AUTO_COMMIT, null); assertEquals(GSRecordDescriptor.getInstance().getFeatureType(), records.getSchema()); }