|
|
@ -64,6 +64,7 @@ public class AnnotationUtil {
|
|
|
|
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework";
|
|
|
|
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework";
|
|
|
|
private static final String STRING_ARR = "string_arr";
|
|
|
|
private static final String STRING_ARR = "string_arr";
|
|
|
|
private static final String STRING = "string";
|
|
|
|
private static final String STRING = "string";
|
|
|
|
|
|
|
|
private static final String METHOD = "method";
|
|
|
|
private Class<org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature>
|
|
|
|
private Class<org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature>
|
|
|
|
featureAnnotationClazz;
|
|
|
|
featureAnnotationClazz;
|
|
|
|
private ClassLoader classLoader;
|
|
|
|
private ClassLoader classLoader;
|
|
|
@ -147,8 +148,7 @@ public class AnnotationUtil {
|
|
|
|
Map<String, Object> apiParams = new HashMap<>();
|
|
|
|
Map<String, Object> apiParams = new HashMap<>();
|
|
|
|
for (int i = 0; i < annotations.length; i++) {
|
|
|
|
for (int i = 0; i < annotations.length; i++) {
|
|
|
|
Annotation currentAnnotation = annotations[i];
|
|
|
|
Annotation currentAnnotation = annotations[i];
|
|
|
|
String method = processHttpMethodAnnotation(feature, currentAnnotation);
|
|
|
|
processHttpMethodAnnotation(apiParams, currentAnnotation);
|
|
|
|
apiParams.put("method", method);
|
|
|
|
|
|
|
|
if (currentAnnotation.annotationType().getName().equals(Path.class.getName())) {
|
|
|
|
if (currentAnnotation.annotationType().getName().equals(Path.class.getName())) {
|
|
|
|
String uri = getPathAnnotationValue(currentMethod);
|
|
|
|
String uri = getPathAnnotationValue(currentMethod);
|
|
|
|
apiParams.put("uri", uri);
|
|
|
|
apiParams.put("uri", uri);
|
|
|
@ -200,25 +200,20 @@ public class AnnotationUtil {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Read Method annotations indicating HTTP Methods
|
|
|
|
* Read Method annotations indicating HTTP Methods
|
|
|
|
* @param feature
|
|
|
|
|
|
|
|
* @param currentAnnotation
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private String processHttpMethodAnnotation(Feature feature, Annotation currentAnnotation) {
|
|
|
|
private void processHttpMethodAnnotation(Map<String, Object> apiParams, Annotation currentAnnotation) {
|
|
|
|
//Extracting method with which feature is exposed
|
|
|
|
//Extracting method with which feature is exposed
|
|
|
|
String method = null;
|
|
|
|
|
|
|
|
if (currentAnnotation.annotationType().getName().equals(GET.class.getName())) {
|
|
|
|
if (currentAnnotation.annotationType().getName().equals(GET.class.getName())) {
|
|
|
|
method = HttpMethod.GET;
|
|
|
|
apiParams.put(METHOD, HttpMethod.GET);
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(POST.class.getName())) {
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(POST.class.getName())) {
|
|
|
|
method = HttpMethod.POST;
|
|
|
|
apiParams.put(METHOD, HttpMethod.POST);
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(OPTIONS.class.getName())) {
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(OPTIONS.class.getName())) {
|
|
|
|
method = HttpMethod.OPTIONS;
|
|
|
|
apiParams.put(METHOD, HttpMethod.OPTIONS);
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(DELETE.class.getName())) {
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(DELETE.class.getName())) {
|
|
|
|
method = HttpMethod.DELETE;
|
|
|
|
apiParams.put(METHOD, HttpMethod.DELETE);
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(PUT.class.getName())) {
|
|
|
|
} else if (currentAnnotation.annotationType().getName().equals(PUT.class.getName())) {
|
|
|
|
method = HttpMethod.PUT;
|
|
|
|
apiParams.put(METHOD, HttpMethod.PUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return method;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -233,15 +228,15 @@ public class AnnotationUtil {
|
|
|
|
Annotation featureAnno = currentMethod.getAnnotation(featureAnnotationClazz);
|
|
|
|
Annotation featureAnno = currentMethod.getAnnotation(featureAnnotationClazz);
|
|
|
|
for (int k = 0; k < featureAnnoMethods.length; k++) {
|
|
|
|
for (int k = 0; k < featureAnnoMethods.length; k++) {
|
|
|
|
switch (featureAnnoMethods[k].getName()) {
|
|
|
|
switch (featureAnnoMethods[k].getName()) {
|
|
|
|
case "name":
|
|
|
|
case "name":
|
|
|
|
feature.setName(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
|
|
|
feature.setName(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "code":
|
|
|
|
case "code":
|
|
|
|
feature.setCode(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
|
|
|
feature.setCode(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "description":
|
|
|
|
case "description":
|
|
|
|
feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
|
|
|
feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return feature;
|
|
|
|
return feature;
|
|
|
|