use of com.iggroup.oss.restdoclet.doclet.util.RequestMappingParamsParser in project RESTdoclet by IG-Group.
the class MethodBuilder method initRestParams.
/**
* Initialises the REST-parameters of this method.
*
* @param method method to initialise
* @param methodDoc the method's Java documentation object.
* @param baseUri the controller base uri
*/
private void initRestParams(Method method, final MethodDoc methodDoc, final String baseUri) {
LOG.debug(method.getName());
ArrayList<RestParameter> restParams = new ArrayList<RestParameter>();
for (NameValuePair pair : new RequestMappingParamsParser(elementValue(methodDoc, RequestMapping.class, "params")).parse()) {
final Predicate predicate = new ParameterNamePredicate(pair.getName());
if (!CollectionUtils.exists(method.getRequestParams(), predicate)) {
LOG.debug(pair.getName() + " - " + pair.getValue());
restParams.add(new RestParameter(pair));
}
}
AnnotationValue urlAnnotation = elementValue(methodDoc, RequestMapping.class, "value");
if (urlAnnotation != null) {
Boolean deprecatedMatch = false;
String[] methodUris = parseValueAnnotation(urlAnnotation);
String[] deprecatedURIs = DocTypeUtils.getDeprecatedURIs(methodDoc);
for (final String uri : methodUris) {
LOG.debug("uri:" + baseUri + uri);
boolean deprecated = false;
if (deprecatedURIs != null) {
for (final String deprecatedUri : deprecatedURIs) {
LOG.debug("deprecated:" + deprecatedUri);
if (StringUtils.equals(deprecatedUri, uri)) {
LOG.debug("=DEPRECATED");
deprecated = true;
deprecatedMatch = true;
break;
}
}
}
method.getUris().add(new Uri(baseUri + uri, deprecated));
}
if (deprecatedURIs != null && !deprecatedMatch) {
LOG.warn("Deprecated URI tag on method " + methodDoc.name() + " does not match any service URIs.");
}
}
method.setRestParams(restParams);
}
Aggregations