protected Map<String, String> getFeatureTypeNsPrefixes( Collection<FeatureType> fts ) { if ( fts == null ) { fts = format.getMaster().getStoreManager().getFeatureTypes(); } Map<String, String> prefixToNs = new HashMap<String, String>(); for ( FeatureType ft : fts ) { QName ftName = ft.getName(); if ( ftName.getPrefix() != null ) { prefixToNs.put( ftName.getPrefix(), ftName.getNamespaceURI() ); } } return prefixToNs; }
List<QName> collectAndSortFeatureTypesToExport( List<QName> configuredReturnFeatureTypes ) { Collection<FeatureType> featureTypes = wfs.getStoreManager().getFeatureTypes(); List<QName> ftNames = collectFeatureTypes( configuredReturnFeatureTypes, featureTypes ); Collections.sort( ftNames, new Comparator<QName>() { @Override public int compare( QName arg0, QName arg1 ) { String s0 = arg0.toString(); String s1 = arg1.toString(); return s0.compareTo( s1 ); } } ); return ftNames; }
public Set<String> getAppSchemaNamespaces() { Set<String> set = new LinkedHashSet<String>(); for ( FeatureStore fs : format.getMaster().getStoreManager().getStores() ) { set.addAll( fs.getSchema().getAppNamespaces() ); } set.remove( GMLNS ); set.remove( GML3_2_NS ); return set; }
private List<QName> collectFeatureTypes( StoredQueryDefinition queryDef ) { Collection<FeatureType> featureTypes = wfs.getStoreManager().getFeatureTypes(); List<QueryExpressionText> queryExpressionTextEls = queryDef.getQueryExpressionTextEls(); List<QName> allConfiguredReturnFeatureTypes = new ArrayList<QName>(); for ( QueryExpressionText queryExpressionTextEl : queryExpressionTextEls ) { List<QName> configuredReturnFeatureTypes = queryExpressionTextEl.getReturnFeatureTypes(); List<QName> featureTypesToExport = collectFeatureTypes( configuredReturnFeatureTypes, featureTypes ); for ( QName featureTypeToExport : featureTypesToExport ) { if ( !allConfiguredReturnFeatureTypes.contains( featureTypeToExport ) ) allConfiguredReturnFeatureTypes.add( featureTypeToExport ); } } return allConfiguredReturnFeatureTypes; }
private Set<String> findUnhandledNs( Set<String> set ) { Set<String> dependentNamespaces = new HashSet<String>(); WfsFeatureStoreManager storeManager = format.getMaster().getStoreManager(); for ( String ns : set ) { for ( FeatureStore fs : storeManager.getStores() ) { AppSchema schema = fs.getSchema(); List<String> depNs = schema.getNamespacesDependencies( ns ); for ( String n : depNs ) { if ( !set.contains( n ) ) { dependentNamespaces.add( n ); } } } } return dependentNamespaces; }
private LockManager getLockManager() throws OWSException { LockManager manager = null; try { // TODO strategy for multiple LockManagers / feature stores manager = master.getStoreManager().getStores()[0].getLockManager(); } catch ( FeatureStoreException e ) { LOG.debug( e.getMessage(), e ); throw new OWSException( "Cannot acquire lock manager: " + e.getMessage(), NO_APPLICABLE_CODE ); } return manager; } }
format.getMaster(), format.getMaster().getStoreManager(), options.isCheckAreaOfUse() ); String contentType = options.getMimeType();
private GMLSchemaInfoSet findGmlSchema( Collection<String> namespaces, GMLVersion version ) { LOG.debug( "Try to find GML schema from store supporting namespaces {}", namespaces ); WfsFeatureStoreManager storeManager = format.getMaster().getStoreManager(); for ( FeatureStore store : storeManager.getStores() ) { if ( storeSupportsAllRequestedNamespaces( store, namespaces ) ) { GMLSchemaInfoSet gmlSchema = store.getSchema().getGMLSchema(); if ( gmlSchema != null && gmlSchema.getVersion() == version ) return gmlSchema; } } return null; }
private Lock acquireLock( LockFeature request, LockManager manager, long expiryInMilliseconds ) throws OWSException { // default: lock all boolean lockAll = true; if ( request.getLockAll() != null ) { lockAll = request.getLockAll(); } List<Query> fsQueries = null; try { QueryAnalyzer queryAnalyzer = new QueryAnalyzer( request.getQueries(), master, master.getStoreManager(), master.getCheckAreaOfUse() ); fsQueries = queryAnalyzer.getQueries().get( master.getStoreManager().getStores()[0] ); } catch ( Exception e ) { throw new OWSException( "Cannot determine feature store queries for locking: " + e.getMessage(), NO_APPLICABLE_CODE ); } Lock lock = null; try { lock = manager.acquireLock( fsQueries, lockAll, expiryInMilliseconds ); } catch ( OWSException e ) { LOG.debug( e.getMessage(), e ); throw new OWSException( e.getMessage(), "CannotLockAllFeatures" ); } catch ( Exception e ) { LOG.debug( e.getMessage(), e ); throw new OWSException( "Cannot acquire lock: " + e.getMessage(), NO_APPLICABLE_CODE ); } return lock; }
private void reencodeSchema( DescribeFeatureType request, XMLStreamWriter writer, String targetNs, Collection<String> importNs, GMLVersion version ) throws XMLStreamException { Map<String, String> importMap = buildImportMap( request, importNs ); WfsFeatureStoreManager storeManager = format.getMaster().getStoreManager(); Map<String, String> prefixToNs = storeManager.getPrefixToNs(); GMLAppSchemaWriter exporter = new GMLAppSchemaWriter( version, targetNs, importMap, prefixToNs ); List<FeatureType> fts = new ArrayList<FeatureType>(); for ( FeatureStore fs : storeManager.getStores() ) { for ( FeatureType ft : fs.getSchema().getFeatureTypes( targetNs, true, true ) ) { fts.add( ft ); } } exporter.export( writer, fts ); }
/** * Determines the application namespaces that have to be included in the generated schema response. * * @param request * @return key: namespace, value: list of feature types in the namespace * @throws OWSException */ private List<String> determineRequiredNamespaces( DescribeFeatureType request ) throws OWSException { Set<String> set; WfsFeatureStoreManager storeManager = format.getMaster().getStoreManager(); if ( request.getTypeNames() == null || request.getTypeNames().length == 0 ) { if ( request.getNsBindings() == null ) { set = getAppSchemaNamespaces(); } else { set = getExplicitlyRequestedNamespaces( request, storeManager ); } } else { set = getNamespacesForRequestedFeatureTypes( request, storeManager ); } // add dependent namespaces Set<String> add = findUnhandledNs( set ); while ( !add.isEmpty() ) { set.addAll( add ); add = findUnhandledNs( set ); } set.remove( GMLNS ); set.remove( GML3_2_NS ); return new ArrayList<String>( set ); }
private String createNextUri( BigInteger count, int startIndex, Map<String, String> kvpGetFeature, GetFeature request ) throws OWSException, FeatureStoreException, FilterEvaluationException { QueryAnalyzer analyzer = new QueryAnalyzer( request.getQueries(), format.getMaster(), format.getMaster().getStoreManager(), options.isCheckAreaOfUse() ); Hits hits = retrieveHits( request, analyzer ); int nextStartIndex = ResponsePagingUtils.calculateNextStartIndex( startIndex, count.intValue(), hits.hitsTotal ); if ( nextStartIndex >= 0 ) return createUrlWithStartindex( kvpGetFeature, nextStartIndex ); return null; }
format.getMaster().getStoreManager(), options.isCheckAreaOfUse() ); Lock lock = acquireLock( request, analyzer ); String schemaLocation = null;
protected GMLObject retrieveObject( String id ) throws OWSException { GMLObject o = null; for ( FeatureStore fs : format.getMaster().getStoreManager().getStores() ) { try { o = fs.getObjectById( id ); } catch ( FeatureStoreException e ) { throw new OWSException( e.getMessage(), NO_APPLICABLE_CODE ); } if ( o != null ) { break; } } if ( o == null ) { String msg = Messages.getMessage( "WFS_NO_SUCH_OBJECT", id ); throw new OWSException( new InvalidParameterValueException( msg ) ); } return o; }
format.getMaster().getStoreManager(), options.isCheckAreaOfUse() ); Lock lock = acquireLock( request, analyzer ); gmlStream.setGeometrySimplifier( options.getGeometrySimplifier() ); Map<String, String> prefixToNs = new HashMap<String, String>( format.getMaster().getStoreManager().getPrefixToNs() ); prefixToNs.putAll( getFeatureTypeNsPrefixes( analyzer.getFeatureTypes() ) ); gmlStream.setNamespaceBindings( prefixToNs );
format.getMaster(), format.getMaster().getStoreManager(), options.isCheckAreaOfUse() ); String schemaLocation = getSchemaLocation( request.getVersion(), analyzer.getFeatureTypes() ); gmlStream.setGenerateBoundedByForFeatures( options.isGenerateBoundedByForFeatures() ); Map<String, String> prefixToNs = new HashMap<String, String>( format.getMaster().getStoreManager().getPrefixToNs() ); prefixToNs.putAll( getFeatureTypeNsPrefixes( analyzer.getFeatureTypes() ) ); gmlStream.setNamespaceBindings( prefixToNs );
try { WfsFeatureStoreManager storeManager = format.getMaster().getStoreManager(); manager = storeManager.getStores()[0].getLockManager(); List<Query> queries = analyzer.getQueries().get( storeManager.getStores()[0] );
gmlStream.setReferenceResolveStrategy( strategy ); gmlStream.setCoordinateFormatter( options.getFormatter() ); gmlStream.setNamespaceBindings( format.getMaster().getStoreManager().getPrefixToNs() ); gmlStream.setGenerateBoundedByForFeatures( options.isGenerateBoundedByForFeatures() ); try {