Package org.exoplatform.services.rest.resource

Examples of org.exoplatform.services.rest.resource.ResourceMethodDescriptor


      float previousQValue = 0.0F;
      int n = 0, p = 0;
      for (ListIterator<T> i = methods.listIterator(); i.hasNext();)
      {
         n = i.nextIndex();
         ResourceMethodDescriptor rmd = i.next();
         float qValue = MediaTypeHelper.processQuality(acceptable, rmd.produces());
         if (qValue > previousQValue)
         {
            previousQValue = qValue;
            p = n; // position of the best resource at the moment
         }
View Full Code Here


               List<MediaType> consumes = MediaTypeHelper.createConsumesList(c);

               if (subPath == null)
               {
                  // resource method
                  ResourceMethodDescriptor res =
                     new ResourceMethodDescriptorImpl(method, httpMethod.value(), params, this, consumes, produces,
                        getMethodInvoker());
                  ResourceMethodDescriptor exist =
                     findMethodResourceMediaType(resourceMethods.getList(httpMethod.value()), res.consumes(), res
                        .produces());
                  if (exist == null)
                  {
                     resourceMethods.add(httpMethod.value(), res);
View Full Code Here

    */
   protected <T extends ResourceMethodDescriptor> ResourceMethodDescriptor findMethodResourceMediaType(List<T> rmds,
      List<MediaType> consumes, List<MediaType> produces)
   {

      ResourceMethodDescriptor matched = null;
      for (T rmd : rmds)
      {
         if (rmd.consumes().size() != consumes.size())
         {
            return null;
View Full Code Here

      float previousQValue = 0.0F;
      int n = 0, p = 0;
      for (ListIterator<T> i = methods.listIterator(); i.hasNext();)
      {
         n = i.nextIndex();
         ResourceMethodDescriptor rmd = i.next();
         float qValue = MediaTypeHelper.processQuality(acceptable, rmd.produces());
         if (qValue > previousQValue)
         {
            previousQValue = qValue;
            p = n; // position of the best resource at the moment
         }
View Full Code Here

   public void testResourceMethods()
   {
      AbstractResourceDescriptor resource = new AbstractResourceDescriptorImpl(SampleResource.class);
      // GET
      ResourceMethodDescriptor methodDescriptor = resource.getResourceMethods().getFirst("GET");
      assertEquals("GET", methodDescriptor.getHttpMethod());
      assertEquals(MediaTypeHelper.DEFAULT_TYPE, methodDescriptor.consumes().get(0));
      assertEquals(MediaType.valueOf("application/xml"), methodDescriptor.produces().get(0));
      assertEquals(SampleResource.class, methodDescriptor.getParentResource().getObjectClass());
      assertEquals(1, methodDescriptor.getMethodParameters().size());
      MethodParameter methodParameter = methodDescriptor.getMethodParameters().get(0);
      assertEquals("hello", methodParameter.getDefaultValue());
      assertEquals(String.class, methodParameter.getParameterClass());
      assertEquals(PathParam.class, methodParameter.getAnnotation().annotationType());
      assertEquals(2, methodParameter.getAnnotations().length);
      assertEquals(PathParam.class, methodParameter.getAnnotations()[0].annotationType());
      assertEquals(DefaultValue.class, methodParameter.getAnnotations()[1].annotationType());
      // the same must be for HEAD
      methodDescriptor = resource.getResourceMethods().getFirst("HEAD");
      assertEquals("HEAD", methodDescriptor.getHttpMethod());
      assertEquals(MediaTypeHelper.DEFAULT_TYPE, methodDescriptor.consumes().get(0));
      assertEquals(MediaType.valueOf("application/xml"), methodDescriptor.produces().get(0));
      assertEquals(SampleResource.class, methodDescriptor.getParentResource().getObjectClass());
      assertEquals(1, methodDescriptor.getMethodParameters().size());
      methodParameter = methodDescriptor.getMethodParameters().get(0);
      assertEquals("hello", methodParameter.getDefaultValue());
      assertEquals(String.class, methodParameter.getParameterClass());
      assertEquals(PathParam.class, methodParameter.getAnnotation().annotationType());
      assertEquals(2, methodParameter.getAnnotations().length);
      assertEquals(PathParam.class, methodParameter.getAnnotations()[0].annotationType());
View Full Code Here

TOP

Related Classes of org.exoplatform.services.rest.resource.ResourceMethodDescriptor

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.