/** * Provides metadata about this referenced site as representation * @param headers the request headers used to get the requested {@link MediaType} * @param uriInfo used to get the URI of the current request * @return the response */ @GET @Produces({APPLICATION_JSON,RDF_XML,N3,TURTLE,X_TURTLE,RDF_JSON,N_TRIPLE}) public Response getInfo(@PathParam(value = "site") String siteId, @Context HttpHeaders headers, @Context UriInfo uriInfo) { MediaType acceptedMediaType = getAcceptableMediaType(headers, REPRESENTATION_SUPPORTED_MEDIA_TYPES,MediaType.APPLICATION_JSON_TYPE); ResponseBuilder rb = Response.ok(site2Representation(getSite(siteId), uriInfo.getAbsolutePath().toString())); rb.header(HttpHeaders.CONTENT_TYPE, acceptedMediaType+"; charset=utf-8"); //addCORSOrigin(servletContext, rb, headers); return rb.build(); } @GET
if(MediaTypeUtil.isAcceptableMediaType(header,MediaType.TEXT_HTML_TYPE)){ ResponseBuilder rb = Response.ok(new Viewable("index", this, BaseGoogleRefineReconcileResource.class)); rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
/** * Default GET method for obtaining the set of (both active and, optionally, inactive) ontology scopes * currently registered with this instance of KReS. * * @param inactive * if true, both active and inactive scopes will be included. Default is false. * @param headers * the HTTP headers, supplied by the REST call. * @param servletContext * the servlet context, supplied by the REST call. * @return a string representation of the requested scope set, in a format acceptable by the client. */ @GET @Produces(value = {RDF_XML, OWL_XML, TURTLE, X_TURTLE, FUNCTIONAL_OWL, MANCHESTER_OWL, RDF_JSON, N3, N_TRIPLE, TEXT_PLAIN}) public Response getScopeModel(@DefaultValue("false") @QueryParam("with-inactive") boolean inactive, @Context HttpHeaders headers, @Context ServletContext servletContext) { Set<Scope> scopes = inactive ? onm.getRegisteredScopes() : onm.getActiveScopes(); OWLOntology ontology = ScopeSetRenderer.getScopes(scopes); ResponseBuilder rb = Response.ok(ontology); MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null); if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType); // addCORSOrigin(servletContext, rb, headers); return rb.build(); }
public Response deleteEntity(@QueryParam(value="id") String id, @Context HttpHeaders headers){ MediaType accepted = getAcceptableMediaType(headers, JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES, MediaType.APPLICATION_JSON_TYPE);
log.info(" > id: " + symbolId); log.info(" > accept: " + headers.getAcceptableMediaTypes()); MediaType acceptedMediaType = getAcceptableMediaType(headers, ENTITY_SUPPORTED_MEDIA_TYPE_INCL_HTML, APPLICATION_JSON_TYPE);
log.info(" > create : " + create); log.info(" > accept: " + headers.getAcceptableMediaTypes()); MediaType acceptedMediaType = getAcceptableMediaType(headers, ENTITY_SUPPORTED_MEDIA_TYPE_INCL_HTML, APPLICATION_JSON_TYPE);
Set<String> supported = new HashSet<String>(JerseyUtils.REPRESENTATION_SUPPORTED_MEDIA_TYPES); supported.add(TEXT_HTML); MediaType acceptedMediaType = getAcceptableMediaType( headers,supported, APPLICATION_JSON_TYPE);
MediaType acceptedMediaType = getAcceptableMediaType( headers,supported, APPLICATION_JSON_TYPE);
/** * Allows to parse any kind of {@link FieldQuery} in its JSON Representation. * <p> * TODO: as soon as the entityhub supports multiple query types this need to be refactored. The idea is * that this dynamically detects query types and than redirects them to the referenced site * implementation. * * @param query The field query in JSON format * @param headers the header information of the request * @return the results of the query */ @POST @Path("/query") //@Consumes( {APPLICATION_FORM_URLENCODED + ";qs=1.0", MULTIPART_FORM_DATA + ";qs=0.9"}) @Consumes( {MediaType.APPLICATION_JSON}) public Response queryEntities(/*@FormParam("query")*/ FieldQuery query, @Context HttpHeaders headers) { final MediaType acceptedMediaType = getAcceptableMediaType(headers, JerseyUtils.QUERY_RESULT_SUPPORTED_MEDIA_TYPES, MediaType.APPLICATION_JSON_TYPE); if(query == null && MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)){ return getQueryDocumentation(headers); } return executeQuery(query, headers, acceptedMediaType); }
Collection<String> supported = new HashSet<String>(JerseyUtils.QUERY_RESULT_SUPPORTED_MEDIA_TYPES); supported.add(TEXT_HTML); final MediaType acceptedMediaType = getAcceptableMediaType( headers, supported, MediaType.APPLICATION_JSON_TYPE); if(query == null){
MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null); if (mediaType != null) responseBuilder.header(HttpHeaders.CONTENT_TYPE, mediaType);
MediaType acceptedMediaType = getAcceptableMediaType( headers,supported, APPLICATION_JSON_TYPE);
final MediaType acceptedMediaType = getAcceptableMediaType( headers, supported, MediaType.APPLICATION_JSON_TYPE); if (id == null || id.isEmpty()) {
MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null); if (mediaType != null) { rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null); if (mediaType != null) { rb.header(HttpHeaders.CONTENT_TYPE, mediaType);
Collection<String> supported = new HashSet<String>(JerseyUtils.QUERY_RESULT_SUPPORTED_MEDIA_TYPES); supported.add(TEXT_HTML); final MediaType acceptedMediaType = getAcceptableMediaType( headers, supported, MediaType.APPLICATION_JSON_TYPE); if(name == null || name.isEmpty()){
/** * Getter for the id's of all referenced sites * * @return the id's of all referenced sites. */ @GET @Path(value = "/referenced") @Produces({MediaType.APPLICATION_JSON,MediaType.TEXT_HTML}) public Response getReferencedSites(@Context UriInfo uriInfo, @Context HttpHeaders headers) { MediaType acceptable = getAcceptableMediaType(headers, Arrays.asList(MediaType.APPLICATION_JSON,MediaType.TEXT_HTML) , MediaType.APPLICATION_JSON_TYPE); if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptable)){ ResponseBuilder rb = Response.ok(new Viewable("referenced", this)); rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8"); //addCORSOrigin(servletContext, rb, headers); return rb.build(); } else { JSONArray referencedSites = new JSONArray(); for (String site : referencedSiteManager.getSiteIds()) { referencedSites.put(String.format("%sentityhub/site/%s/", uriInfo.getBaseUri(), site)); } ResponseBuilder rb = Response.ok(referencedSites.toString()); rb.header(HttpHeaders.CONTENT_TYPE, acceptable+"; charset=utf-8"); //addCORSOrigin(servletContext, rb, headers); return rb.build(); } }
@PathParam(value = "name") String name) { Site site = getSite(siteId); MediaType acceptedMediaType = getAcceptableMediaType(headers, MediaType.APPLICATION_JSON_TYPE); if(name == null || name.isEmpty()){
@QueryParam(value="id") String id, @Context HttpHeaders headers){ MediaType accepted = getAcceptableMediaType(headers, JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES, MediaType.APPLICATION_JSON_TYPE); final MediaType acceptedMediaType = getAcceptableMediaType(headers, new HashSet<String>(JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES), MediaType.APPLICATION_JSON_TYPE);
@Context HttpHeaders headers) { log.debug("/find Request"); final MediaType acceptedMediaType = getAcceptableMediaType(headers, ENTITY_SUPPORTED_MEDIA_TYPE_INCL_HTML, MediaType.APPLICATION_JSON_TYPE);