private void checkParameter(Parameter p, Object source, String nameForLogging, String paramNameForLogging) { int annotCount = 0; for (Annotation a : p.getAnnotations()) { if (ParamAnnotationSET.contains(a.annotationType())) { annotCount++; if (annotCount > 1) { issueList.add(new ResourceModelIssue( source, ImplMessages.AMBIGUOUS_PARAMETER(nameForLogging, paramNameForLogging), false)); break; } } } final Type t = p.getParameterType(); if (!isConcreteType(t)) { issueList.add(new ResourceModelIssue( source, "Parameter " + paramNameForLogging + " of type " + t + " from " + nameForLogging + " is not resolvable to a concrete type", false)); } }
issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_RETURNS_VOID(method.getMethod()), issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_CONSUMES_ENTITY(method.getMethod()), issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_CONSUMES_FORM_PARAM(method.getMethod()), httpAnnotList.add(a.toString()); } else if ((a.annotationType() == Path.class) && !(method instanceof AbstractSubResourceMethod)) { issueList.add(new ResourceModelIssue( method, ImplMessages.SUB_RES_METHOD_TREATED_AS_RES_METHOD(method.getMethod(), ((Path)a).value()), false)); issueList.add(new ResourceModelIssue( method, ImplMessages.MULTIPLE_HTTP_METHOD_DESIGNATORS(method.getMethod(), httpAnnotList.toString()), issueList.add(new ResourceModelIssue( method.getMethod(), "Return type " + t + " of method " + method.getMethod().toGenericString() + " is not resolvable to a concrete type",
private void checkNonPublicMethods(final AbstractResource ar) { final MethodList declaredMethods = new MethodList( getDeclaredMethods(ar.getResourceClass())); // non-public resource methods for (AnnotatedMethod m : declaredMethods.hasMetaAnnotation(HttpMethod.class). hasNotAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_RES_METHOD(m.getMethod().toGenericString()), false)); } // non-public subres methods for (AnnotatedMethod m : declaredMethods.hasMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_SUB_RES_METHOD(m.getMethod().toGenericString()), false)); } // non-public subres locators for (AnnotatedMethod m : declaredMethods.hasNotMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_SUB_RES_LOC(m.getMethod().toGenericString()), false)); } }
@Override public void visitAbstractSubResourceMethod(AbstractSubResourceMethod method) { // check the same things that are being checked for resource methods visitAbstractResourceMethod(method); // and make sure the Path is not null if ((null == method.getPath()) || (null == method.getPath().getValue()) || (method.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_SUBRES_METHOD_URI_PATH_INVALID(method.getMethod(), method.getPath()), true)); } }
@Override public void visitAbstractSubResourceLocator(AbstractSubResourceLocator locator) { checkParameters(locator, locator.getMethod()); if (void.class == locator.getMethod().getReturnType()) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_RETURNS_VOID(locator.getMethod()), true)); } if ((null == locator.getPath()) || (null == locator.getPath().getValue()) || (locator.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_URI_PATH_INVALID(locator.getMethod(), locator.getPath()), true)); } // Sub-resource locator can not have an entity parameter for (Parameter parameter : locator.getParameters()) { if (Parameter.Source.ENTITY == parameter.getSource()) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_HAS_ENTITY_PARAM(locator.getMethod()), true)); } } } private static final Set<Class> ParamAnnotationSET = createParamAnnotationSet();
@Override public void visitAbstractResource(AbstractResource resource) { // uri template of the resource, if present should not contain null value if (resource.isRootResource() && ((null == resource.getPath()) || (null == resource.getPath().getValue()))) { issueList.add(new ResourceModelIssue( resource, ImplMessages.ERROR_RES_URI_PATH_INVALID(resource.getResourceClass(), resource.getPath()), true)); // TODO: is it really a fatal issue? } checkNonPublicMethods(resource); }
private void checkParameter(Parameter p, Object source, String nameForLogging, String paramNameForLogging) { int annotCount = 0; for (Annotation a : p.getAnnotations()) { if (ParamAnnotationSET.contains(a.annotationType())) { annotCount++; if (annotCount > 1) { issueList.add(new ResourceModelIssue( source, ImplMessages.AMBIGUOUS_PARAMETER(nameForLogging, paramNameForLogging), false)); break; } } } final Type t = p.getParameterType(); if (!isConcreteType(t)) { issueList.add(new ResourceModelIssue( source, "Parameter " + paramNameForLogging + " of type " + t + " from " + nameForLogging + " is not resolvable to a concrete type", false)); } }
private void checkParameter(Parameter p, Object source, String nameForLogging, String paramNameForLogging) { int annotCount = 0; for (Annotation a : p.getAnnotations()) { if (ParamAnnotationSET.contains(a.annotationType())) { annotCount++; if (annotCount > 1) { issueList.add(new ResourceModelIssue( source, ImplMessages.AMBIGUOUS_PARAMETER(nameForLogging, paramNameForLogging), false)); break; } } } final Type t = p.getParameterType(); if (!isConcreteType(t)) { issueList.add(new ResourceModelIssue( source, "Parameter " + paramNameForLogging + " of type " + t + " from " + nameForLogging + " is not resolvable to a concrete type", false)); } }
issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_RETURNS_VOID(method.getMethod()), issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_CONSUMES_ENTITY(method.getMethod()), issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_CONSUMES_FORM_PARAM(method.getMethod()), httpAnnotList.add(a.toString()); } else if ((a.annotationType() == Path.class) && !(method instanceof AbstractSubResourceMethod)) { issueList.add(new ResourceModelIssue( method, ImplMessages.SUB_RES_METHOD_TREATED_AS_RES_METHOD(method.getMethod(), ((Path)a).value()), false)); issueList.add(new ResourceModelIssue( method, ImplMessages.MULTIPLE_HTTP_METHOD_DESIGNATORS(method.getMethod(), httpAnnotList.toString()), issueList.add(new ResourceModelIssue( method.getMethod(), "Return type " + t + " of method " + method.getMethod().toGenericString() + " is not resolvable to a concrete type",
private void checkNonPublicMethods(final AbstractResource ar) { final MethodList declaredMethods = new MethodList( getDeclaredMethods(ar.getResourceClass())); // non-public resource methods for (AnnotatedMethod m : declaredMethods.hasMetaAnnotation(HttpMethod.class). hasNotAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_RES_METHOD(m.getMethod().toGenericString()), false)); } // non-public subres methods for (AnnotatedMethod m : declaredMethods.hasMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_SUB_RES_METHOD(m.getMethod().toGenericString()), false)); } // non-public subres locators for (AnnotatedMethod m : declaredMethods.hasNotMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_SUB_RES_LOC(m.getMethod().toGenericString()), false)); } }
private void checkNonPublicMethods(final AbstractResource ar) { final MethodList declaredMethods = new MethodList( getDeclaredMethods(ar.getResourceClass())); // non-public resource methods for (AnnotatedMethod m : declaredMethods.hasMetaAnnotation(HttpMethod.class). hasNotAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_RES_METHOD(m.getMethod().toGenericString()), false)); } // non-public subres methods for (AnnotatedMethod m : declaredMethods.hasMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_SUB_RES_METHOD(m.getMethod().toGenericString()), false)); } // non-public subres locators for (AnnotatedMethod m : declaredMethods.hasNotMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class).isNotPublic()) { issueList.add(new ResourceModelIssue(ar, ImplMessages.NON_PUB_SUB_RES_LOC(m.getMethod().toGenericString()), false)); } }
issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_RETURNS_VOID(method.getMethod()), issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_CONSUMES_ENTITY(method.getMethod()), issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_GET_CONSUMES_FORM_PARAM(method.getMethod()), httpAnnotList.add(a.toString()); } else if ((a.annotationType() == Path.class) && !(method instanceof AbstractSubResourceMethod)) { issueList.add(new ResourceModelIssue( method, ImplMessages.SUB_RES_METHOD_TREATED_AS_RES_METHOD(method.getMethod(), ((Path)a).value()), false)); issueList.add(new ResourceModelIssue( method, ImplMessages.MULTIPLE_HTTP_METHOD_DESIGNATORS(method.getMethod(), httpAnnotList.toString()), issueList.add(new ResourceModelIssue( method.getMethod(), "Return type " + t + " of method " + method.getMethod().toGenericString() + " is not resolvable to a concrete type",
@Override public void visitAbstractSubResourceMethod(AbstractSubResourceMethod method) { // check the same things that are being checked for resource methods visitAbstractResourceMethod(method); // and make sure the Path is not null if ((null == method.getPath()) || (null == method.getPath().getValue()) || (method.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_SUBRES_METHOD_URI_PATH_INVALID(method.getMethod(), method.getPath()), true)); } }
@Override public void visitAbstractSubResourceMethod(AbstractSubResourceMethod method) { // check the same things that are being checked for resource methods visitAbstractResourceMethod(method); // and make sure the Path is not null if ((null == method.getPath()) || (null == method.getPath().getValue()) || (method.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_SUBRES_METHOD_URI_PATH_INVALID(method.getMethod(), method.getPath()), true)); } }
@Override public void visitAbstractSubResourceLocator(AbstractSubResourceLocator locator) { checkParameters(locator, locator.getMethod()); if (void.class == locator.getMethod().getReturnType()) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_RETURNS_VOID(locator.getMethod()), true)); } if ((null == locator.getPath()) || (null == locator.getPath().getValue()) || (locator.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_URI_PATH_INVALID(locator.getMethod(), locator.getPath()), true)); } // Sub-resource locator can not have an entity parameter for (Parameter parameter : locator.getParameters()) { if (Parameter.Source.ENTITY == parameter.getSource()) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_HAS_ENTITY_PARAM(locator.getMethod()), true)); } } } private static final Set<Class> ParamAnnotationSET = createParamAnnotationSet();
@Override public void visitAbstractSubResourceLocator(AbstractSubResourceLocator locator) { checkParameters(locator, locator.getMethod()); if (void.class == locator.getMethod().getReturnType()) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_RETURNS_VOID(locator.getMethod()), true)); } if ((null == locator.getPath()) || (null == locator.getPath().getValue()) || (locator.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_URI_PATH_INVALID(locator.getMethod(), locator.getPath()), true)); } // Sub-resource locator can not have an entity parameter for (Parameter parameter : locator.getParameters()) { if (Parameter.Source.ENTITY == parameter.getSource()) { issueList.add(new ResourceModelIssue( locator, ImplMessages.ERROR_SUBRES_LOC_HAS_ENTITY_PARAM(locator.getMethod()), true)); } } } private static final Set<Class> ParamAnnotationSET = createParamAnnotationSet();
@Override public void visitAbstractResource(AbstractResource resource) { // uri template of the resource, if present should not contain null value if (resource.isRootResource() && ((null == resource.getPath()) || (null == resource.getPath().getValue()))) { issueList.add(new ResourceModelIssue( resource, ImplMessages.ERROR_RES_URI_PATH_INVALID(resource.getResourceClass(), resource.getPath()), true)); // TODO: is it really a fatal issue? } checkNonPublicMethods(resource); }
@Override public void visitAbstractResource(AbstractResource resource) { // uri template of the resource, if present should not contain null value if (resource.isRootResource() && ((null == resource.getPath()) || (null == resource.getPath().getValue()))) { issueList.add(new ResourceModelIssue( resource, ImplMessages.ERROR_RES_URI_PATH_INVALID(resource.getResourceClass(), resource.getPath()), true)); // TODO: is it really a fatal issue? } checkNonPublicMethods(resource); }