Package com.semagia.atomico

Examples of com.semagia.atomico.MediaType


                lastModification);
        applyAuthorInfo(config, feed);
        for (ICollectionInfo info: storage.getCollectionInfos(config.getCollectionSortOrder())) {
            feed.addEntry(info, LinkUtils.linkToCollection(baseURI, info));
        }
        final MediaType mediaType = getFeedMediaType(feedMediaTypes);
        final IOutputAwareFeedHandler handler = makeFeedHandler(mediaType);
        return new FeedWritable(new OverviewFeedWriter(feed, handler), mediaType);
    }
View Full Code Here


                                config.getSnapshotsEntryTitle(collTitle),
                                storage.lastSnapshotModification(collId));
        feed.setFragmentsEntry(LinkUtils.linkToFragments(baseURI, collInfo).toASCIIString(),
                                config.getFragmentsEntryTitle(collTitle),
                                storage.lastFragmentModification(collId));
        final MediaType mediaType = getFeedMediaType(feedMediaTypes);
        final IOutputAwareFeedHandler handler = makeFeedHandler(mediaType);
        return new FeedWritable(new CollectionFeedWriter(feed, handler), mediaType);
    }
View Full Code Here

                    lastModification);
        applyAuthorInfo(config, feed, collInfo);
        for (IFragmentInfo info: storage.getFragmentInfos(collInfo.getCollectionId())) {
            feed.addEntry(info, LinkUtils.linkTo(baseURI, collInfo, info));
        }
        final MediaType mediaType = getFeedMediaType(feedMediaTypes);
        final IOutputAwareFeedHandler handler = makeFeedHandler(mediaType);
        return new FeedWritable(new FragmentsFeedWriter(feed, handler), mediaType);
    }
View Full Code Here

                                lastModification);
        applyAuthorInfo(config, feed, collInfo);
        for (ISnapshotInfo info: storage.getSnapshotInfos(collInfo.getCollectionId())) {
            feed.addEntry(info, LinkUtils.linkTo(baseURI, collInfo, info));
        }
        final MediaType mediaType = getFeedMediaType(feedMediaTypes);
        final IOutputAwareFeedHandler handler = makeFeedHandler(mediaType);
        return new FeedWritable(new SnapshotsFeedWriter(feed, handler), mediaType);
    }
View Full Code Here

            List<MediaType> acceptedMediaTypes) {
        if (acceptedMediaTypes.isEmpty()) {
            return supportedMediaTypes.get(0);
        }
        int bestMatchCount = -1;
        MediaType bestMatch = null;
        for (MediaType mt: acceptedMediaTypes) {
            String type = mt.getType();
            String subType = mt.getSubtype();
            if (bestMatch == null && "*".equals(type) && "*".equals(subType)) {
                bestMatch = supportedMediaTypes.get(0);
View Full Code Here

     * @param acceptedMediaTypes The preferred media types (client-side).
     * @return A media type which may satisfy the client or {@code defaultMediaType}
     *          if no suitable media type was found.
     */
    public static MediaType getPreferredMediaType(final List<MediaType> supportedMediaTypes, final List<MediaType> acceptedMediaTypes, final MediaType defaultMediaType) {
        final MediaType mediaType = getPreferredMediaType(supportedMediaTypes, acceptedMediaTypes);
        return mediaType != null ? mediaType : defaultMediaType;
    }
View Full Code Here

     * @throws UnsupportedMediaTypeException
     */
    @POST
    public Response addFragment(final InputStream in, @Context HttpHeaders headers) throws StorageException, UnsupportedMediaTypeException {
        final IModifiableStorage storage = super.getModifiableStorage();
        final MediaType mediaType = MediaTypeUtils.toAtomicoMediaType(headers.getMediaType());
        // Reject request iff the media type is null.
        if (mediaType == null) {
            // 415 == Unsupported Media Type
            return Response.status(415).build();
        }
View Full Code Here

     * @throws UnsupportedMediaTypeException
     */
    @POST
    public Response addSnapshot(final InputStream in, @Context HttpHeaders headers) throws StorageException, UnsupportedMediaTypeException {
        final IModifiableStorage storage = super.getModifiableStorage();
        final MediaType mediaType = MediaTypeUtils.toAtomicoMediaType(headers.getMediaType());
        // Reject request iff the media type is null.
        if (mediaType == null) {
            // 415 == Unsupported Media Type
            return Response.status(415).build();
        }
View Full Code Here

     */
    @GET
    @Produces("*/*")
    public Response getFragment(@Context HttpHeaders headers) throws StorageException {
        final Response.ResponseBuilder builder = makeResponseBuilder();
        final MediaType mediaType = com.semagia.atomico.server.utils.MediaTypeUtils.getPreferredMediaType(_fragmentInfo.getMediaTypes(),
                MediaTypeUtils.toAtomicoMediaType(headers.getAcceptableMediaTypes()));
        if (mediaType == null) {
            return ResponseUtils.notAcceptable(_fragmentInfo.getMediaTypes());
        }
        // Add Vary header
View Full Code Here

     * @throws StorageException In case of an error.
     */
    @GET
    @Produces("*/*")
    public Response getSnapshot(@Context HttpHeaders headers) throws StorageException {
        final MediaType mediaType = com.semagia.atomico.server.utils.MediaTypeUtils.getPreferredMediaType(_snapshotInfo.getMediaTypes(), MediaTypeUtils.toAtomicoMediaType(headers.getAcceptableMediaTypes()));
        if (mediaType == null) {
            return ResponseUtils.notAcceptable(_snapshotInfo.getMediaTypes());
        }
        final ResponseBuilder builder = makeResponseBuilder();
        // Add Vary header
View Full Code Here

TOP

Related Classes of com.semagia.atomico.MediaType

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.