Package javax.ws.rs.core

Examples of javax.ws.rs.core.MediaType


        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
        assertThat(contentType, hasMediaType("application"));
        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/version"));
        assertThat(contentType, is(RepresentationType.VERSION.getMediaType()));
    }
View Full Code Here


        // when
        final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
        assertThat(contentType, hasMediaType("application"));
        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/user"));
        assertThat(contentType, is(RepresentationType.USER.getMediaType()));
    }
View Full Code Here

        // then
        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));

        assertThat(restfulResponse.getHeader(Header.CONTENT_LENGTH), is(greaterThan(6000)));

        final MediaType actualHeader = restfulResponse.getHeader(Header.CONTENT_TYPE);
        assertThat(actualHeader, hasMediaType(MediaType.APPLICATION_JSON));
        assertThat(actualHeader, hasMediaTypeProfile(RestfulMediaType.APPLICATION_JSON_OBJECT));
        assertThat(actualHeader, hasMediaTypeXRoDomainType("domain-types/PRMV"));
    }
View Full Code Here

        // when
        final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
        assertThat(contentType, hasMediaType("application"));
        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/homepage"));
        assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));
    }
View Full Code Here

        // when
        final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
        assertThat(contentType, hasMediaType("application"));
        assertThat(contentType, hasSubType("json"));
        assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/list"));
        assertThat(contentType, is(RepresentationType.LIST.getMediaType()));
    }
View Full Code Here

         if (contentType.equals(MediaType.WILDCARD))
         {
            cacheControlValue = cacheControlMap.get(MediaType.WILDCARD_TYPE);
            break;
         }
         else if (mediaType.isCompatible(new MediaType(contentType.split("/")[0], contentType.split("/")[1])))
         {
            cacheControlValue = cacheControlMap.get(mediaType);
            break;
         }
      }
View Full Code Here

            {
               String cacheValue = element.split(":")[1];
               String keys = element.split(":")[0];
               for (String key : keys.split(","))
               {
                  MediaType mediaType = new MediaType(key.split("/")[0], key.split("/")[1]);
                  cacheControlMap.put(mediaType, cacheValue);
               }
            }
         }
         catch (Exception e)
View Full Code Here

public class CharsetResponseFilter implements ContainerResponseFilter
{

    public ContainerResponse filter(ContainerRequest request, ContainerResponse response)
    {
    MediaType contentType = response.getMediaType();

    // For JSON responses use UTF-8 charset
    if((contentType != null) && contentType.equals(MediaType.APPLICATION_JSON_TYPE)) {
      response.getHttpHeaders().putSingle("Content-Type",
          contentType.toString() + ";charset=UTF-8");
    }

        return response;
    }
View Full Code Here

       
        if (o == null) {
            return;
        }
       
        MediaType contentType = MediaType.valueOf(headers.getFirst("Content-Type"));
       
        MessageBodyWriter mbw = ProviderFactory.getInstance(outMessage).createMessageBodyWriter(
            cls, type, anns, contentType, outMessage);
        if (mbw == null) {
            mbw = ProviderFactory.getInstance().createMessageBodyWriter(
View Full Code Here

            }
        } catch (IOException ex) {
            // won't happen at this stage
        }
       
        MediaType contentType = getResponseContentType(r);
       
        MessageBodyReader mbr = ProviderFactory.getInstance(outMessage).createMessageBodyReader(
            cls, type, anns, contentType, outMessage);
        if (mbr == null) {
            ProviderFactory.getInstance().createMessageBodyReader(
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.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.