Package org.apache.marmotta.commons.http

Examples of org.apache.marmotta.commons.http.ContentType


*/
public class StanbolEndpoint extends Endpoint {

    public StanbolEndpoint(String name, String endpointUrl, String resourcePattern) {
        super(name, CacheProvider.PROVIDER_NAME,resourcePattern,buildEndpointUrl(endpointUrl),86400L);
        addContentType(new ContentType("text","turtle"));
    }
View Full Code Here


    /**
     * Check whether the content type returned by the server is acceptable to the endpoint and data provider
     */
    protected boolean isValidContentType(String contentType, Endpoint endpoint) {
        if(endpoint != null && endpoint.getContentTypes().size() > 0) {
            ContentType parsed = parseContentType(contentType);
            for(ContentType valid : endpoint.getContentTypes()) {
                if(valid.matches(parsed) || valid.matchesWildcard(parsed)) {
                    return true;
                }
            }
View Full Code Here

public class WikipediaIndexEndpoint extends Endpoint {

    public WikipediaIndexEndpoint() {
        super("Wikipedia Provider (Index)", MediawikiProvider.PROVIDER_NAME, "^http://([^.]+)\\.wikipedia\\.org/w/index\\.php.*", "http://$1.wikipedia.org/w/api.php", 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("text", "xml"));
    }
View Full Code Here

    /**
     * return the content type that will be produced
     * @return
     */
    public ContentType getContentType() {
        return new ContentType("text","html");
    }
View Full Code Here

            try {
                final Date date = MementoUtils.MEMENTO_DATE_FORMAT.parse(date_string);

                final URI resource = conn.getValueFactory().createURI(resource_string);

                final ContentType type = getContentType(types_string);

                //get serializer
                final RDFFormat serializer = lmfIOService.getSerializer(type.getMime());

                //create response serialisation
                StreamingOutput entity = new StreamingOutput() {
                    @Override
                    public void write(OutputStream output) throws IOException, WebApplicationException {
                        RDFWriter writer = Rio.createWriter(serializer, output);
                        try {
                            RepositoryConnection con = versioningService.getSnapshot(date);
                            URI subject = con.getValueFactory().createURI(resource.stringValue());
                            try {
                                con.exportStatements(subject,null,null,true,writer);
                            } catch (RepositoryException e) {
                                throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
                            } catch (RDFHandlerException e) {
                                throw new IOException("error while writing RDF data to stream");
                            } finally {
                                con.commit();
                                con.close();
                            }
                        } catch (RepositoryException e) {
                            throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
                        }
                    }
                };

                //get versions
                MementoVersionSet versions = mementoService.getVersionSet(resource, date);

                //build version links
                Set<String> links = versions.buildLinks(configurationService.getBaseUri());

                //add timegate link
                links.add("<" + MementoUtils.timegateURI(resource_string, configurationService.getBaseUri()) + ">;rel=timegate");

                //add timemap link
                links.add("<" + MementoUtils.timemapURI(resource_string, configurationService.getBaseUri()) + ">;rel=timemap");

                //create response
                return Response
                        .ok()
                        .header("Link", CollectionUtils.fold(links," ,"))
                        .header("Content-Type", type.toString())
                        .header("Memento-Datetime", versions.getCurrent().getCommitTime().toString())
                        .entity(entity)
                        .build();

            } catch (ParseException e) {
View Full Code Here

     * @throws IllegalArgumentException if no type is supported
     */
    private ContentType getContentType(String types) throws IllegalArgumentException {
        List<ContentType> acceptedTypes = MarmottaHttpUtils.parseAcceptHeader(types);
        List<ContentType> offeredTypes  = MarmottaHttpUtils.parseStringList(lmfIOService.getProducedTypes());
        ContentType type = MarmottaHttpUtils.bestContentType(offeredTypes,acceptedTypes);
        if(type == null) throw new IllegalArgumentException("Requested type is not supported");
        return type;
    }
View Full Code Here

    /**
     * return the content type that will be produced
     * @return
     */
    public ContentType getContentType() {
        return new ContentType("application","link-format");
    }
View Full Code Here

public class YoutubeVideoPageEndpointWeb extends Endpoint {

    public YoutubeVideoPageEndpointWeb() {
        super("YouTube Page (Web)", "YouTube Page", "^http://www\\.youtube\\.com/v/.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("text","html"));
    }
View Full Code Here

public class YoutubeVideoPageEndpointWatch extends Endpoint {

    public YoutubeVideoPageEndpointWatch() {
        super("YouTube Page (Watch)", "YouTube Page", "^http://www\\.youtube\\.com/watch.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("text","html"));
    }
View Full Code Here

public class YoutubePlaylistEndpointWeb extends Endpoint {

    public YoutubePlaylistEndpointWeb() {
        super("YouTube Playlist (Web)", "YouTube Playlist", "^http://www\\.youtube\\.com/p/.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("application","atom+xml"));
    }
View Full Code Here

TOP

Related Classes of org.apache.marmotta.commons.http.ContentType

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.