use of org.apache.stanbol.commons.web.viewable.Viewable in project stanbol by apache.
the class ScopeResource method getHtmlInfo.
@GET
@Produces(TEXT_HTML)
public Response getHtmlInfo(@PathParam("scopeid") String scopeid, @Context HttpHeaders headers) {
ResponseBuilder rb;
scope = onm.getScope(scopeid);
if (scope == null)
rb = Response.status(NOT_FOUND);
else
// TODO move to a dedicated class
rb = Response.ok(new Viewable("index", this));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.commons.web.viewable.Viewable in project stanbol by apache.
the class SessionResource method managedOntologyShow.
@GET
@Path("/{ontologyId:.+}")
@Produces(TEXT_HTML)
public Response managedOntologyShow(@PathParam("ontologyId") String ontologyId, @Context HttpHeaders headers) {
ResponseBuilder rb;
if (session == null)
rb = Response.status(NOT_FOUND);
else if (ontologyId == null || ontologyId.isEmpty())
rb = Response.status(BAD_REQUEST);
else if (!ontologyProvider.hasOntology(OntologyUtils.decode(ontologyId)))
rb = Response.status(NOT_FOUND);
else {
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
OWLOntology o = session.getOntology(OntologyUtils.decode(ontologyId), OWLOntology.class, false, prefix);
if (o == null)
rb = Response.status(NOT_FOUND);
else
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
o.getOWLOntologyManager().saveOntology(o, new ManchesterOWLSyntaxOntologyFormat(), out);
rb = Response.ok(new Viewable("ontology", new OntologyPrettyPrintResource(uriInfo, out, session)));
} catch (OWLOntologyStorageException e) {
throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
}
}
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.commons.web.viewable.Viewable in project stanbol by apache.
the class TopicClassifierRootResource method get.
@GET
@Produces(TEXT_HTML)
public Response get(@Context HttpHeaders headers) {
ResponseBuilder rb = Response.ok(new Viewable("index", this));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
return rb.build();
}
use of org.apache.stanbol.commons.web.viewable.Viewable in project stanbol by apache.
the class ReferencedSiteRootResource method getQueryDocumentation.
@GET
@Path("/query")
@Produces(TEXT_HTML)
public Response getQueryDocumentation(@Context HttpHeaders headers, @PathParam(value = "site") String siteId) {
ResponseBuilder rb = Response.ok(new Viewable("query", new SiteResultData(getSite(siteId))));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
//addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.stanbol.commons.web.viewable.Viewable in project stanbol by apache.
the class ReferencedSiteRootResource method findEntity.
@POST
@Path("/find")
public Response findEntity(@PathParam(value = "site") String siteId, @FormParam(value = "name") String name, @FormParam(value = "field") String parsedField, @FormParam(value = "lang") String language, // @FormParam(value="select") String select,
@FormParam(value = "limit") Integer limit, @FormParam(value = "offset") Integer offset, @FormParam(value = "ldpath") String ldpath, @Context HttpHeaders headers) {
Site site = getSite(siteId);
log.debug("site/{}/find Request", site.getId());
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()) {
if (MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)) {
ResponseBuilder rb = Response.ok(new Viewable("find", new SiteResultData(site)));
rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
//addCORSOrigin(servletContext, rb, headers);
return rb.build();
} else {
return Response.status(Status.BAD_REQUEST).entity("The name must not be null nor empty for find requests. Missing parameter name.\n").header(HttpHeaders.ACCEPT, acceptedMediaType).build();
}
}
final String property;
if (parsedField == null) {
property = DEFAULT_FIND_FIELD;
} else {
parsedField = parsedField.trim();
if (parsedField.isEmpty()) {
property = DEFAULT_FIND_FIELD;
} else {
property = nsPrefixService.getFullName(parsedField);
if (property == null) {
String messsage = String.format("The prefix '%s' of the parsed field '%' is not " + "mapped to any namespace. Please parse the full URI instead!\n", NamespaceMappingUtils.getPrefix(parsedField), parsedField);
return Response.status(Status.BAD_REQUEST).entity(messsage).header(HttpHeaders.ACCEPT, acceptedMediaType).build();
}
}
}
return executeQuery(site, createFieldQueryForFindRequest(name, property, language, limit == null || limit < 1 ? DEFAULT_FIND_RESULT_LIMIT : limit, offset, ldpath), headers);
}
Aggregations