/** * Checks if the current media type is concrete. A media type is concrete if * neither the main type nor the sub-type are equal to "*". * * @return True if this media type is concrete. */ public boolean isConcrete() { return !getName().contains("*"); }
/** * Checks if the current media type is concrete. A media type is concrete if * neither the main type nor the sub-type are equal to "*". * * @return True if this media type is concrete. */ public boolean isConcrete() { return !getName().contains("*"); }
public static Representation getJsonRepresentation(final Ontology nextOntology, final MediaType variant, final Reference resourceReference) throws ResourceException, RepositoryException, RDFHandlerException { return RestletUtils.toRDFSerialisation(MediaType.APPLICATION_JSON.getName(), SesameUtils.toRDFRepository(nextOntology, null)); }
public static Representation getJsonRepresentation(final ResourceCount results, final Variant variant, final Reference resourceRef) throws RepositoryException, RDFHandlerException { return RestletUtils.toRDFSerialisation(MediaType.APPLICATION_JSON.getName(), SesameUtils.toRDFRepository(results, null)); }
public static Representation getRdfRepresentation(final Ontology nextOntology, final MediaType variant, final Reference resourceReference) throws ResourceException, RepositoryException, RDFHandlerException { return RestletUtils.toRDFSerialisation(variant.getName(), SesameUtils.toRDFRepository(nextOntology, null)); }
/** * Returns the wrapped representation's media type. * * @return The wrapped representation's media type. * @see ContentStream#getContentType() */ public String getContentType() { if (representation.getMediaType() != null) return representation.getMediaType().getName(); return null; }
public static Representation getRdfRepresentation(final ResourceCount results, final Variant variant, final Reference resourceRef) throws RepositoryException, RDFHandlerException { return RestletUtils.toRDFSerialisation(variant.getMediaType().getName(), SesameUtils.toRDFRepository(results, null)); }
public static Representation getJsonRepresentationShortOntologies(final Collection<Ontology> ontologies, final MediaType variant, final Reference resourceReference) throws ResourceException, RepositoryException, RDFHandlerException { final Repository myRepository = new SailRepository(new MemoryStore()); myRepository.initialize(); for(final Ontology nextOntology : ontologies) { SesameUtils.toRDFRepository(nextOntology, myRepository); } return RestletUtils.toRDFSerialisation(variant.getName(), myRepository); }
@Test public void testGetAllCount() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/sf:PrimitiveGeoFeature?mode=count"); assertEquals(200, response.getStatusCode()); assertTrue(response.getContentType().startsWith(MediaType.TEXT_PLAIN.getName())); assertEquals("5", response.getOutputStreamContent()); }
@Test public void testSort() throws Exception { // property data store does not support sorting MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?order_by=ADDRESS"); assertEquals(500, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); }
@Test public void testLimitOffset() throws Exception { // property data store does not support offset MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?limit=1&offset=2"); assertEquals(500, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); }
@Test public void testDescribeMissingLayer() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "describe/abc:notThere"); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: abc:notThere", response.getOutputStreamContent()); }
@Test public void testLimit() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?limit=1"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); testFirstBuilding(collection); }
@Test public void testPointFilter() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?lon=0.0008&lat=0.0005&tolerance=0.0001"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); testFirstBuilding(collection); }
@Test public void testPointFilterLarge() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?lon=0.0008&lat=0.0005&tolerance=0.01"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); // print(collection); testAllBuildings(collection); }
@Test public void testEqualityFilter() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?queryable=FID&FID__eq=113"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); testFirstBuilding(collection); }
@Test public void testILikeFilter() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?queryable=ADDRESS&ADDRESS__ilike=123%20m%25"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); // print(collection); testFirstBuilding(collection); }
@Test public void testGetMissingLayer() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/abc:notThere"); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: abc:notThere", response.getOutputStreamContent()); }
@Test public void testDescribeCoverage() throws Exception { final String tasmania = getLayerId(MockData.TASMANIA_BM); MockHttpServletResponse response = getAsServletResponse(root() + "describe/" + tasmania); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: " + tasmania, response.getOutputStreamContent()); } }
@Test public void testGetCoverage() throws Exception { final String tasmania = getLayerId(MockData.TASMANIA_BM); MockHttpServletResponse response = getAsServletResponse(root() + "data/" + tasmania); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: " + tasmania, response.getOutputStreamContent()); }