Package com.linkedin.restli.server

Examples of com.linkedin.restli.server.ResourceConfigException


  public RestLiApiBuilder(final RestLiConfig config)
  {
    if (config.getResourcePackageNamesSet().isEmpty() && config.getResourceClassNamesSet().isEmpty())
    {
      throw new ResourceConfigException("At least one package containing Rest.li annotated classes or one resource class must be specified");
    }

    _packageNames = config.getResourcePackageNamesSet();
    _classNames = config.getResourceClassNamesSet();
  }
View Full Code Here


        {
          String errorMessage = String.format("Resource classes \"%s\" and \"%s\" clash on the resource name \"%s\".",
                                        existingResource.getResourceClass().getCanonicalName(),
                                        resourceModel.getResourceClass().getCanonicalName(),
                                        existingResource.getName());
          throw new ResourceConfigException(errorMessage);
        }
        rootResourceModels.put(path, resourceModel);
      }
      else
      {
        ResourceModel parentModel = resourceModels.get(resourceModel.getParentResourceClass());
        if (parentModel == null)
        {
          throw new ResourceConfigException("Could not find model for parent class'"
              + resourceModel.getParentResourceClass().getName() + "'for: "
              + resourceModel.getName());
        }
        resourceModel.setParentResourceModel(parentModel);
        parentModel.addSubResource(resourceModel.getName(), resourceModel);
View Full Code Here

          {
            scanDirectory(new File(u.getPath()));
          }
          else
          {
            throw new ResourceConfigException("Unable to scan resource '" + u.toString()
                + "'. URI scheme not supported by scanner.");
          }
        }
      }
    }
    catch (IOException e)
    {
      throw new ResourceConfigException("Unable to scan resources", e);
    }
    catch (URISyntaxException e)
    {
      throw new ResourceConfigException("Unable to scan resources", e);
    }
  }
View Full Code Here

          (Class<? extends SingleObjectResource<?>>) resourceClass;
      model = processSingleObjectResource(clazz);
    }
    else
    {
      throw new ResourceConfigException("Class '" + resourceClass.getName()
          + "' must be annotated with a valid @RestLi... annotation");
    }

    DataMap annotationsMap = ResourceModelAnnotation.getAnnotationsMap(resourceClass.getAnnotations());
    addDeprecatedAnnotation(annotationsMap, resourceClass);
View Full Code Here

            currentExpect == RestLiAssociation.class ||
            currentExpect == RestLiSimpleResource.class)
        {
          if (resourceClass.getAnnotation(currentExpect) == null)
          {
            throw new ResourceConfigException(resourceClass.getName() + " is not annotated with "
              + currentExpect.getName() + ", expected by " + templateClass.getName());
          }
          else
          {
            return;
          }
        }
        else
        {
          throw new ResourceConfigException("Unknown expected annotation " + currentExpect.getName()
            + " from " + templateClass.getName());
        }
      }
    }
  }
View Full Code Here

      if (RecordTemplate.class.isAssignableFrom(keyClass))
      {
        // a complex key is being used and thus ComplexKeyResource should be implemented so that we can wrap it in a
        // ComplexResourceKey
        throw new ResourceConfigException("Class '" + collectionResourceClass.getName() +
                                              "' should implement 'ComplexKeyResource' as a complex key '" +
                                              keyClass.getName() + "' is being used.");
      }
      else if (TyperefInfo.class.isAssignableFrom(keyClass))
      {
        throw new ResourceConfigException("Typeref '" + keyClass.getName() + "' cannot be key type for class '" +
                                              collectionResourceClass.getName() + "'.");
      }

      if (keyClass.equals(ComplexResourceKey.class))
      {
        @SuppressWarnings("unchecked")
        Type[] typeArguments = ((ParameterizedType)actualTypeArguments.get(0)).getActualTypeArguments();
        keyKeyClass = ReflectionUtils.getClass(typeArguments[0]).asSubclass(RecordTemplate.class);
        keyParamsClass = ReflectionUtils.getClass(typeArguments[1]).asSubclass(RecordTemplate.class);
      }

      valueClass = ReflectionUtils.getClass(actualTypeArguments.get(1)).asSubclass(RecordTemplate.class);
    }

    ResourceType resourceType = getResourceType(collectionResourceClass);

    RestLiAnnotationData annotationData;
    if (collectionResourceClass.isAnnotationPresent(RestLiCollection.class))
    {
      annotationData =
          new RestLiAnnotationData(collectionResourceClass.getAnnotation(RestLiCollection.class));
    }
    else if (collectionResourceClass.isAnnotationPresent(RestLiAssociation.class))
    {
      annotationData =
          new RestLiAnnotationData(collectionResourceClass.getAnnotation(RestLiAssociation.class));
    }
    else
    {
      throw new ResourceConfigException("No valid annotation on resource class '"
          + collectionResourceClass.getName() + "'");
    }

    String name = annotationData.name();
    String namespace = annotationData.namespace();
View Full Code Here

      annotationData =
          new RestLiAnnotationData(singleObjectResourceClass.getAnnotation(RestLiSimpleResource.class));
    }
    else
    {
      throw new ResourceConfigException("No valid annotation on resource class '"
                                            + singleObjectResourceClass.getName() + "'");
    }

    String name = annotationData.name();
    String namespace = annotationData.namespace();
View Full Code Here

    RestLiAssociation assocAnno = resourceClass.getAnnotation(RestLiAssociation.class);
    RestLiSimpleResource simpleResourceAnno = resourceClass.getAnnotation(RestLiSimpleResource.class);

    if (resourceClass.isAnnotationPresent(RestLiActions.class))
    {
      throw new ResourceConfigException("Resource class '" + resourceClass.getName()
                                            + "' cannot have both @RestLiCollection and @RestLiActions annotations.");
    }

    int annoCount = 0;
    annoCount += collAnno != null ? 1 : 0;
    annoCount += assocAnno != null ? 1 : 0;
    annoCount += simpleResourceAnno != null ? 1 : 0;

    if (annoCount > 1)
    {
      throw new ResourceConfigException("Class '" + resourceClass.getName()
          + "' is annotated " + "with too many RestLi annotations");
    }
    else if (collAnno != null)
    {
      return ResourceType.COLLECTION;
    }
    else if (assocAnno != null)
    {
      return ResourceType.ASSOCIATION;
    }
    else if (simpleResourceAnno != null)
    {
      return ResourceType.SIMPLE;
    }
    else
    {
      throw new ResourceConfigException("Class '" + resourceClass.getName()
          + "' should be annotated " + "with '" + RestLiAssociation.class.getName() + "'"
          + " or '" + RestLiCollection.class.getName() + "'" + " or '"
          + RestLiSimpleResource.class.getName() + "'");
    }
  }
View Full Code Here

        {
          param = buildResourceContextParam(paramAnnotations, paramType);
        }
        else
        {
          throw new ResourceConfigException(buildMethodMessage(method)
              + " must annotate each parameter with @QueryParam, @ActionParam, @AssocKeyParam, @PagingContextParam, " +
              "@ProjectionParam, @MetadataProjectionParam, @PagingProjectionParam, @PathKeysParam, @HeaderParam, " +
              "@CallbackParam, @ResourceContext or @ParSeqContextParam");
        }
      }
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  private static Parameter<ResourceContext> buildResourceContextParam(AnnotationSet annotations, final Class<?> paramType)
  {
      if (!paramType.equals(ResourceContext.class))
      {
        throw new ResourceConfigException("Incorrect data type for param: @" + ResourceContextParam.class.getSimpleName() + " parameter annotation must be of type " +  ResourceContext.class.getName());
      }
      Optional optional = annotations.get(Optional.class);
      return new Parameter("",
                           paramType,
                           null,
View Full Code Here

TOP

Related Classes of com.linkedin.restli.server.ResourceConfigException

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.