public ExecutionStatusType run(DropStoredQueryType request) throws WFSException { if (request.getId() == null) { throw new WFSException(request, "No stored query id specified"); } StoredQuery query = storedQueryProvider.getStoredQuery(request.getId()); if (query != null) { storedQueryProvider.removeStoredQuery(query); } else { WFSException exception = new WFSException( request, String.format("Stored query %s does not exist.", request.getId()), ServiceException.INVALID_PARAMETER_VALUE); // CITE tests vagary, the XML uses "id" and KVP uses "STOREDQUERY_ID", the CITE tests // mandate "id" // in all bindings exception.setLocator("id"); throw exception; } Wfs20Factory factory = Wfs20Factory.eINSTANCE; ExecutionStatusType response = factory.createExecutionStatusType(); response.setStatus("OK"); return response; } }
@Test public void canRemoveStoredQueryDefinition() throws IOException { File myStoredQueryDefinition = createMyStoredQueryDefinitionFile(storedQueryProvider.storedQueryDir().dir()); List<StoredQuery> queries = storedQueryProvider.listStoredQueries(); assertThat(queries, hasSize(2)); StoredQuery myStoredQuery = storedQueryProvider.getStoredQuery(MY_STORED_QUERY); assertThat(myStoredQuery.getName(), is(MY_STORED_QUERY)); storedQueryProvider.removeStoredQuery(myStoredQuery); assertThat(myStoredQueryDefinition.exists(), is(false)); assertThat(storedQueryProvider.getStoredQuery(myStoredQuery.getName()), is(nullValue())); }