StoredQueryHandler { public void doCreateStoredQuery( CreateStoredQuery request, HttpResponseBuffer response ) throws IOException, XMLStreamException, OWSException { if ( managedStoredQueryDirectory == null ) throw new OWSException( "Performing CreateStoredQuery requests is not configured.", OPERATION_PROCESSING_FAILED ); if ( !managedStoredQueryDirectory.exists() ) throw new OWSException( "Performing CreateStoredQuery requests is not configured.", OPERATION_PROCESSING_FAILED ); checkIdsOfStoredQueries( request ); checkLanguageOfStoredQueries( request ); handleCreateStoredQuery( request ); writeCreateStoredQueryResponse( response ); } StoredQueryHandler( WebFeatureService wfs, List<URL> storedQueryTemplates,
                               File managedStoredQueryDirectory ); void doCreateStoredQuery( CreateStoredQuery request, HttpResponseBuffer response ); void doDescribeStoredQueries( DescribeStoredQueries request, HttpResponseBuffer response ); void doDropStoredQuery( DropStoredQuery request, HttpResponseBuffer response ); void doListStoredQueries( ListStoredQueries request, HttpResponseBuffer response ); boolean hasStoredQuery( String id ); URL getStoredQueryTemplate( String id ); static final String LANGUAGE_WFS_QUERY_EXPRESSION; static final String GET_FEATURE_BY_ID; static final String GET_FEATURE_BY_TYPE; }
@Test(expected = OWSException.class) public void testDoCreateStoredQuery_NullManagedStoredQueryDirectory() throws Exception { List<FeatureType> featureTypes = featureTypes(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), null ); String id = "mangedStoredQuery"; CreateStoredQuery request = createStoredQuery( id ); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( outStream ); storedQueryHandler.doCreateStoredQuery( request, mockHttpResponseBuffer( xmlStreamWriter ) ); xmlStreamWriter.close(); }
@Test(expected = OWSException.class) public void testDoCreateStoredQuery_NotExistingManagedStoredQueryDirectory() throws Exception { List<FeatureType> featureTypes = featureTypes(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), new File( "this/directory/does/not/exist" ) ); String id = "mangedStoredQuery"; CreateStoredQuery request = createStoredQuery( id ); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( outStream ); storedQueryHandler.doCreateStoredQuery( request, mockHttpResponseBuffer( xmlStreamWriter ) ); xmlStreamWriter.close(); }
@Test(expected = OWSException.class) public void testDoCreateStoredQuery_DuplicateId() throws Exception { List<FeatureType> featureTypes = featureTypes(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), managedStoredQueries ); String id = "mangedStoredQuery"; CreateStoredQuery request = createStoredQuery( id ); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( outStream ); try { storedQueryHandler.doCreateStoredQuery( request, mockHttpResponseBuffer( xmlStreamWriter ) ); storedQueryHandler.doCreateStoredQuery( request, mockHttpResponseBuffer( xmlStreamWriter ) ); } finally { xmlStreamWriter.close(); } }
@Test(expected = OWSException.class) public void testDoCreateStoredQuery_UnsupportedLanguage() throws Exception { List<FeatureType> featureTypes = featureTypes(); StoredQueryHandler storedQueryHandler = new StoredQueryHandler( mockWFS( featureTypes ), new ArrayList<URL>(), managedStoredQueries ); String id = "mangedStoredQuery"; CreateStoredQuery request = createStoredQuery( id, "http: ByteArrayOutputStream outStream = new ByteArrayOutputStream(); XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( outStream ); storedQueryHandler.doCreateStoredQuery( request, mockHttpResponseBuffer( xmlStreamWriter ) ); xmlStreamWriter.close(); }