/** * Adds several parameters to the query component. The name and value are * automatically URL encoded if necessary. * * @param parameters * The parameters to add. * @return The updated reference. */ public Reference addQueryParameters(Iterable<Parameter> parameters) { for (Parameter param : parameters) { addQueryParameter(param); } return this; }
/** * Adds several parameters to the query component. The name and value are * automatically URL encoded if necessary. * * @param parameters * The parameters to add. * @return The updated reference. */ public Reference addQueryParameters(Iterable<Parameter> parameters) { for (Parameter param : parameters) { addQueryParameter(param); } return this; }
/** * Adds a parameter to the query component. The name and value are * automatically encoded if necessary. * * @param parameter * The parameter to add. * @return The updated reference. * @see Reference#addQueryParameter(Parameter) */ public Reference addQueryParameter(Parameter parameter) { return getReference().addQueryParameter(parameter); }
/** * Adds a parameter to the query component. The name and value are * automatically encoded if necessary. * * @param name * The parameter name. * @param value * The optional parameter value. * @return The updated reference. * @see Reference#addQueryParameter(String, String) */ public Reference addQueryParameter(String name, String value) { return getReference().addQueryParameter(name, value); }
/** * Adds a parameter to the query component. The name and value are * automatically URL encoded if necessary. * * @param parameter * The parameter to add. * @return The updated reference. */ public Reference addQueryParameter(Parameter parameter) { return addQueryParameter(parameter.getName(), parameter.getValue()); }
/** * Adds a parameter to the query component. The name and value are * automatically URL encoded if necessary. * * @param parameter * The parameter to add. * @return The updated reference. */ public Reference addQueryParameter(Parameter parameter) { return addQueryParameter(parameter.getName(), parameter.getValue()); }
private void addQueryParam(Request request, String representationAsText, Annotation annotation) { request.getResourceRef().addQueryParameter( new Parameter(((QueryParam) annotation).value(), representationAsText)); }
@Test public void testOntologyBrowserDirectJson() throws Exception { final ClientResource ontologyBrowserClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_BROWSER_PATH, OasProps.DEF_ONTOLOGY_BROWSER_PATH))); ontologyBrowserClientResource.getReference().addQueryParameter("ontologyUri", this.ontologyUri); ontologyBrowserClientResource.getReference().addQueryParameter("ontologyVersionUri", this.ontologyVersionUri); ontologyBrowserClientResource.getReference().addQueryParameter("directChildrenOnly", "true"); final Representation representation = ontologyBrowserClientResource.get(MediaType.APPLICATION_JSON); Assert.assertNotNull(representation); Assert.assertEquals(Status.SUCCESS_OK.getCode(), ontologyBrowserClientResource.getStatus().getCode()); // this.log.trace("result={}", representation.getText()); }
@Test public void testOntologyBrowserDirectRdfXml() throws Exception { final ClientResource ontologyBrowserClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_BROWSER_PATH, OasProps.DEF_ONTOLOGY_BROWSER_PATH))); ontologyBrowserClientResource.getReference().addQueryParameter("ontologyUri", this.ontologyUri); ontologyBrowserClientResource.getReference().addQueryParameter("ontologyVersionUri", this.ontologyVersionUri); ontologyBrowserClientResource.getReference().addQueryParameter("directChildrenOnly", "true"); final Representation representation = ontologyBrowserClientResource.get(MediaType.APPLICATION_RDF_XML); Assert.assertNotNull(representation); Assert.assertEquals(Status.SUCCESS_OK.getCode(), ontologyBrowserClientResource.getStatus().getCode()); // this.log.trace("result={}", representation.getText()); }
@Test public void testOntologyBrowserDirectHtml() throws Exception { final ClientResource ontologyBrowserClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_BROWSER_PATH, OasProps.DEF_ONTOLOGY_BROWSER_PATH))); ontologyBrowserClientResource.getReference().addQueryParameter("ontologyUri", this.ontologyUri); ontologyBrowserClientResource.getReference().addQueryParameter("ontologyVersionUri", this.ontologyVersionUri); ontologyBrowserClientResource.getReference().addQueryParameter("directChildrenOnly", "true"); final Representation representation = ontologyBrowserClientResource.get(MediaType.TEXT_HTML); Assert.assertNotNull(representation); Assert.assertEquals(Status.SUCCESS_OK.getCode(), ontologyBrowserClientResource.getStatus().getCode()); // this.log.trace("result={}", representation.getText()); final String resultsText = representation.getText(); this.assertFreemarker(resultsText); Assert.assertTrue(resultsText.contains("OAS-testwebsite test Ajaxified Ontology Browser template")); }
/** * Test whether Ontologies can be deleted after creating the ontology using an RDF/XML file. * * Specifically tests deletion with only the ontologyUri and no managedOntologyVersionUri * parameter. * */ @Test public void testOntologyDeleteNoUploadWithDeleteAllFalse() { try { final ClientResource deletionClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_MANAGER_DELETE_PATH, OasProps.DEF_ONTOLOGY_MANAGER_DELETE_PATH))); deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test"); deletionClientResource.getReference().addQueryParameter("deleteAllVersions", "true"); RestletTestUtils.doTestAuthenticatedRequest(deletionClientResource, Method.POST, null, MediaType.TEXT_PLAIN, Status.SUCCESS_NO_CONTENT, this.testWithAdminPrivileges); Assert.fail("Did not find expected exception while attempting to call the delete service with just an ontology URI"); } catch(final ResourceException ex) { Assert.assertEquals(Status.CLIENT_ERROR_BAD_REQUEST, ex.getStatus()); } }
OasProps.DEF_ONTOLOGY_MANAGER_DELETE_PATH))); deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test"); deletionClientResource.getReference().addQueryParameter("ontologyVersionUri", "http://does.not.exist.example.org/test/delete/ontology");
/** * Test whether Ontologies can be searched using a JSON result type */ @Test public void testOntologySearchJson() throws Exception { // Get the resource and dump it to the console final ClientResource searchOntologyClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH, OasProps.DEF_SEARCH_ONTOLOGIES_PATH))); searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf"); final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_JSON); final StatementCollector results = new StatementCollector(); final RDFParser parser = Rio.createParser(RDFFormat.RDFJSON); parser.setRDFHandler(results); parser.parse(searchResults.getStream(), ""); Assert.assertEquals(474, results.getStatements().size()); }
/** * Test whether Ontologies can be searched using a JSON result type */ @Test public void testOntologySearchJson() throws Exception { // Get the resource and dump it to the console final ClientResource searchOntologyClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGY_LABELS_PATH, OasProps.DEF_SEARCH_ONTOLOGY_LABELS_PATH))); searchOntologyClientResource.getReference().addQueryParameter("searchterm", "plant"); final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_JSON); final StatementCollector results = new StatementCollector(); final RDFParser parser = Rio.createParser(RDFFormat.RDFJSON); parser.setRDFHandler(results); parser.parse(searchResults.getStream(), ""); Assert.assertEquals(2, results.getStatements().size()); }
/** * Test whether Ontologies can be searched using an RDF/XML result type. */ @Test public void testOntologySearchRdfXml() throws Exception { // Get the resource and dump it to the console final ClientResource searchOntologyClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH, OasProps.DEF_SEARCH_ONTOLOGIES_PATH))); searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf"); final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_RDF_XML); final StatementCollector results = new StatementCollector(); final RDFParser parser = Rio.createParser(RDFFormat.RDFXML); parser.setRDFHandler(results); parser.parse(searchResults.getStream(), ""); Assert.assertEquals(474, results.getStatements().size()); }
/** * Test whether Ontologies can be searched using a JSON result type */ @Test public void testOntologySearchJson() throws Exception { // Get the resource and dump it to the console final ClientResource searchOntologyClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH, OasProps.DEF_SEARCH_ONTOLOGIES_PATH))); searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf"); final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_JSON); final StatementCollector results = new StatementCollector(); final RDFParser parser = Rio.createParser(RDFFormat.RDFJSON); parser.setRDFHandler(results); parser.parse(searchResults.getStream(), ""); Assert.assertEquals(474, results.getStatements().size()); }
/** * Test whether Ontologies can be searched using an RDF/XML result type. */ @Test public void testOntologySearchRdfXml() throws Exception { // Get the resource and dump it to the console final ClientResource searchOntologyClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGY_LABELS_PATH, OasProps.DEF_SEARCH_ONTOLOGY_LABELS_PATH))); searchOntologyClientResource.getReference().addQueryParameter("searchterm", "plant"); final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_RDF_XML); final StatementCollector results = new StatementCollector(); final RDFParser parser = Rio.createParser(RDFFormat.RDFXML); parser.setRDFHandler(results); parser.parse(searchResults.getStream(), ""); // DebugUtils.printStatements(results.getStatements()); Assert.assertEquals(2, results.getStatements().size()); }
/** * Test whether Ontologies can be searched using an RDF/XML result type. */ @Test public void testOntologySearchRdfXml() throws Exception { // Get the resource and dump it to the console final ClientResource searchOntologyClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH, OasProps.DEF_SEARCH_ONTOLOGIES_PATH))); searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf"); final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_RDF_XML); final StatementCollector results = new StatementCollector(); final RDFParser parser = Rio.createParser(RDFFormat.RDFXML); parser.setRDFHandler(results); parser.parse(searchResults.getStream(), ""); Assert.assertEquals(474, results.getStatements().size()); }
/** * Test whether Ontologies can be deleted after creating the ontology using an RDF/XML file. * * Specifically tests deletion with only the ontologyUri and no managedOntologyVersionUri * parameter. * */ @Test public void testOntologyDeleteNoUploadWithOntologyUriFalse() { try { final ClientResource deletionClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_MANAGER_PATH, OasProps.DEF_ONTOLOGY_MANAGER_PATH))); deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test"); RestletTestUtils.doTestAuthenticatedRequest(deletionClientResource, Method.DELETE, null, MediaType.TEXT_PLAIN, Status.SUCCESS_NO_CONTENT, this.testWithAdminPrivileges); Assert.fail("Did not find expected exception while attempting to call the delete service with just an ontology URI"); } catch(final ResourceException ex) { Assert.assertEquals(Status.CLIENT_ERROR_BAD_REQUEST, ex.getStatus()); } }
/** * Test whether Ontologies can be deleted after creating the ontology using an RDF/XML file. * * Specifically tests deletion with only the ontologyUri and no managedOntologyVersionUri * parameter. * */ @Test public void testOntologyDeleteNoUploadWithOntologyUriFalse() { try { final ClientResource deletionClientResource = new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_MANAGER_DELETE_PATH, OasProps.DEF_ONTOLOGY_MANAGER_DELETE_PATH))); deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test"); RestletTestUtils.doTestAuthenticatedRequest(deletionClientResource, Method.POST, null, MediaType.TEXT_PLAIN, Status.SUCCESS_NO_CONTENT, this.testWithAdminPrivileges); Assert.fail("Did not find expected exception while attempting to call the delete service with just an ontology URI"); } catch(final ResourceException ex) { Assert.assertEquals(Status.CLIENT_ERROR_BAD_REQUEST, ex.getStatus()); } }