Package org.apache.stanbol.commons.viewable

Examples of org.apache.stanbol.commons.viewable.Viewable


    }

    @GET
    @Produces(TEXT_HTML)
    public Response getHtmlInfo(@Context HttpHeaders headers) {
        ResponseBuilder rb = Response.ok(new Viewable("index", this));
        rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here


                    if (guessed != null && !guessed.isAnonymous() && ontologyProvider.hasOntology(guessed)) {
                        rb = Response.status(Status.CONFLICT);
                        this.submitted = guessed;
                        if (headers.getAcceptableMediaTypes().contains(MediaType.TEXT_HTML_TYPE)) {
                            rb.entity(new Viewable("/imports/409", this));
                            rb.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML + "; charset=utf-8");
                        }
                        break;
                    } else {
                        content = new FileInputStream(file);
                        key = ontologyProvider.loadInStore(content, f, true, keys);
                    }
                } catch (UnsupportedFormatException e) {
                    log.warn(
                            "POST method failed for media type {}. This should not happen (should fail earlier)",
                            headers.getMediaType());
                    // rb = Response.status(UNSUPPORTED_MEDIA_TYPE);
                    unsupported++;
                } catch (IOException e) {
                    log.debug(">>> FAILURE format {} (I/O error)", f);
                    failed++;
                } catch (Exception e) { // SAXParseException and others
                    log.debug(">>> FAILURE format {} (parse error)", f);
                    failed++;
                }
            } while ((key == null/* || key.isAnonymous() */) && itf.hasNext());
            if ((key == null || key.isAnonymous()) && rb == null) {
                if (failed > 0) {
                    throw new WebApplicationException(BAD_REQUEST);
                } else if (unsupported > 0) {
                    throw new WebApplicationException(UNSUPPORTED_MEDIA_TYPE);
                }
            }
        } else if (location != null) {
            try { // Here we try every format supported by the Java API
                key = ontologyProvider.loadInStore(location, null, true, keys);
            } catch (Exception e) {
                log.error("Failed to load ontology from " + location, e);
                throw new WebApplicationException(e, BAD_REQUEST);
            }
        } else if (!aliases.isEmpty()) // No content but there are aliases.
        {
            for (Origin<?> origin : keys) {
                if (origin.getReference() instanceof OWLOntologyID) {
                    OWLOntologyID primary = ((OWLOntologyID) origin.getReference());
                    if (ontologyProvider.getStatus(primary) != org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyProvider.Status.NO_MATCH) {
                        for (OWLOntologyID alias : aliases) {
                            try {
                                if (ontologyProvider.addAlias(primary, alias) && key == null) {
                                    key = alias;
                                }
                            } catch (IllegalArgumentException ex) {
                                log.warn("Cannot add alias");
                                log.warn(" ... ontology key: {}", primary);
                                log.warn(" ... alias: {}", alias);
                                log.warn(" ... reason: ", ex);
                                continue;
                            }
                        }
                    }
                }
            }
        } else {
            log.error("Bad request");
            log.error(" file is: {}", file);
            throw new WebApplicationException(BAD_REQUEST);
        }

        if (key != null && !key.isAnonymous()) {
            String uri = OntologyUtils.encode(key);
            if (uri != null && !uri.isEmpty()) {
                rb = Response.ok();
                if (headers.getAcceptableMediaTypes().contains(MediaType.TEXT_HTML_TYPE)) {
                    rb.entity(new Viewable("index", this));
                    rb.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML + "; charset=utf-8");
                }
            } else {
                rb = Response.ok();
            }
View Full Code Here

                }
            }
        }
        // ByteArrayOutputStream out = new ByteArrayOutputStream();
        // o.getOWLOntologyManager().saveOntology(o, new ManchesterOWLSyntaxOntologyFormat(), out);
        return Response.ok(new Viewable("ontology",
                // new OntologyPrettyPrintResource(servletContext,
                // uriInfo, out)
                new OntologyStatsResource(servletContext, uriInfo, key, o, ontologyProvider.listAliases(key),
                handles)));
        // } catch (OWLOntologyStorageException e) {
View Full Code Here

    @GET
    @Produces(TEXT_HTML)
    public Response getHtmlInfo(@Context HttpHeaders headers) {
        ResponseBuilder rb;
        if (session == null) rb = Response.status(NOT_FOUND);
        else rb = Response.ok(new Viewable("index", this));
        rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

                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(servletContext,
                        uriInfo, out, session)));
            } catch (OWLOntologyStorageException e) {
                throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
            }
        }
View Full Code Here

                        if (guessed != null && !guessed.isAnonymous()
                            && ontologyProvider.hasOntology(guessed)) {
                            rb = Response.status(Status.CONFLICT);
                            this.submitted = guessed;
                            if (headers.getAcceptableMediaTypes().contains(MediaType.TEXT_HTML_TYPE)) {
                                rb.entity(new Viewable("/imports/409", this));
                                rb.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML + "; charset=utf-8");
                            }
                        } else {
                            content = new BufferedInputStream(new FileInputStream(file));
                            src = new GraphContentInputSource(content, f, ontologyProvider.getStore());
View Full Code Here

    }

    @GET
    @Produces(TEXT_HTML)
    public Response getHtmlInfo(@Context HttpHeaders headers) {
        ResponseBuilder rb = Response.ok(new Viewable("index", this));
        rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

                        String.format("Error while searching on %s (%s: %s)",
                            getSiteName(),SiteException.class.getSimpleName(),e.getMessage())).build());
            }
        } else {
            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");
                addCORSOrigin(servletContext, rb, header);
                return rb.build();
            }
            throw new WebApplicationException(
View Full Code Here

        return res.build();
    }
    @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");
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

        MediaType acceptedMediaType = getAcceptableMediaType(headers,
            ENTITY_SUPPORTED_MEDIA_TYPE_INCL_HTML,
            APPLICATION_JSON_TYPE);
        if(acceptedMediaType.isCompatible(TEXT_HTML_TYPE) && symbolId == null){
            //return HTML docu
            ResponseBuilder rb = Response.ok(new Viewable("entity", this));
            rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
            addCORSOrigin(servletContext, rb, headers);
            return rb.build();
        }
        if (symbolId == null || symbolId.isEmpty()) {
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.viewable.Viewable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.