Package org.apache.marmotta.commons.http

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


public class YoutubeChannelEndpointGData extends Endpoint {

    public YoutubeChannelEndpointGData() {
        super("YouTube Channel (GData)", "YouTube Channel", "^http://gdata\\.youtube\\.com/feeds/api/users/.*/uploads", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("application","atom+xml"));
    }
View Full Code Here


public class YoutubeChannelEndpointWeb extends Endpoint {

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

public class YoutubePlaylistEndpointGData extends Endpoint {

    public YoutubePlaylistEndpointGData() {
        super("YouTube Playlist (GData)", "YouTube Playlist", "^http://gdata\\.youtube\\.com/feeds/api/playlists/.*", null, 86400L);
        setPriority(PRIORITY_HIGH);
        addContentType(new ContentType("application","atom+xml"));
    }
View Full Code Here

public class YoutubePlaylistEndpointWebLong extends Endpoint {

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

            acceptedTypes = LMFHttpUtils.parseAcceptHeader(format);
        } else {
            acceptedTypes = LMFHttpUtils.parseAcceptHeader(accept);
        }
        List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(exportService.getProducedTypes());
        offeredTypes.removeAll(Collections.unmodifiableList(Arrays.asList(new ContentType("text", "html"), new ContentType("application", "xhtml+xml"))));
        final ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes, acceptedTypes);
        return new URI(configurationService.getBaseUri() + "export/download?context=" + uri + "&format=" + bestType.getMime());
    }
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

                for(ContentType t : offeredTypes) {
                  t.setParameter("rel", "meta");
                }
                String contentmime = contentService.getContentType(resource);
                if(contentmime != null) {
                  ContentType tContent = LMFHttpUtils.parseContentType(contentmime);
                  tContent.setParameter("rel", "content");
                  offeredTypes.add(0,tContent);
                }
               
                if (types == null || types.equals("")) {
                  return build406(Collections.<ContentType>emptyList(), offeredTypes);
                }

                List<ContentType> acceptedTypes = LMFHttpUtils.parseAcceptHeader(types);
                ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes,acceptedTypes);

                log.debug("identified best type: {}",bestType);

                if(bestType != null) {
                    Response response = buildGetResponse(resource, bestType);
View Full Code Here

            // much about the order ...
            List<ContentType> acceptable = LMFHttpUtils.parseStringList(kiWiIOService.getProducedTypes());
            for(ContentType a : acceptable) {
                a.setParameter("rel", "meta");
            }
            ContentType allContent = new ContentType("*","*");
            allContent.setParameter("rel", "content");
            acceptable.add(0,allContent);

            // determine the best match between the offered types and the acceptable types
            ContentType bestType = LMFHttpUtils.bestContentType(types,acceptable);

            if (bestType != null) {
                if (configurationService.getBooleanConfiguration("linkeddata.redirect.put", true)) {
                    final RepositoryConnection con = sesameService.getConnection();
                    try {
                        con.begin();
                        URI resource = ResourceUtils.getUriResource(con, uri);
                        con.commit();
                        return Response
                                .status(configurationService.getIntConfiguration("linkeddata.redirect.status", 303))
                                // .location(new URI(configurationService.getBaseUri() +
                                // bestType.getParameter("rel") + "/" + bestType.getMime() + appendix))
                                .location(new java.net.URI(ResourceWebServiceHelper.buildResourceLink(resource, bestType, configurationService)))
                                .build();
                    } finally {
                        con.close();
                    }
                } else {
                    if("content".equalsIgnoreCase(bestType.getParameter("rel")))
                        return contentWebService.putContent(uri, bestType.getMime(), request);
                    else if ("meta".equalsIgnoreCase(bestType.getParameter("rel")))
                        return metaWebService.putMeta(uri, bestType.getMime(), request);
                    else
                        return Response.serverError().entity("request did not specify whether it uploads content or metadata; use rel=content|meta attribute in Content-Type header").build();
                }
            } else {
                Response response = Response.status(415).entity("type " + mimetype + " not supported").build();
View Full Code Here

    public Response selectGet(@QueryParam("query") String query, @QueryParam("output") String resultType, @Context HttpServletRequest request) {
        if(resultType == null) {
            List<ContentType> acceptedTypes = LMFHttpUtils.parseAcceptHeader(request.getHeader("Accept"));
            List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(Lists.newArrayList("application/sparql-results+xml","application/sparql-results+json","text/html", "application/rdf+xml", "text/csv"));

            ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes,acceptedTypes);

            if(bestType != null) {
                resultType = bestType.getMime();
            }
        }

        try {
            if(resultType != null) {
View Full Code Here

        try {
            if(resultType == null) {
                List<ContentType> acceptedTypes = LMFHttpUtils.parseAcceptHeader(request.getHeader("Accept"));
                List<ContentType> offeredTypes  = LMFHttpUtils.parseStringList(Lists.newArrayList("application/sparql-results+xml","application/sparql-results+json","text/html", "application/rdf+xml", "text/csv"));

                ContentType bestType = LMFHttpUtils.bestContentType(offeredTypes,acceptedTypes);

                if(bestType != null) {
                    resultType = bestType.getMime();
                }
            }
            if(resultType != null) {
                if (StringUtils.isNotBlank(query))
                    return buildQueryResponse(resultType, query);
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.