mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #250 from ayyoob/transport
removed method and type from feature definition
This commit is contained in:
commit
3bef5155e0
@ -438,10 +438,10 @@ public class RoleImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Role {
|
||||
String msg = "Error occurred while retrieving the list of user roles.";
|
||||
throw new MDMAPIException(msg, e);
|
||||
}
|
||||
// removing all internal roles and roles created for Service-providers
|
||||
// removing all internal roles, roles created for Service-providers and application related roles.
|
||||
List<String> filteredRoles = new ArrayList<>();
|
||||
for (String role : roles) {
|
||||
if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) {
|
||||
if (!(role.startsWith("Internal/") || role.startsWith("Authentication/") || role.startsWith("Application/"))) {
|
||||
filteredRoles.add(role);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,8 +39,7 @@ public class Feature implements Serializable {
|
||||
"Features allow you to perform operations on any device type, " +
|
||||
"such as android, iOS or windows..", required = true )
|
||||
private String deviceType;
|
||||
private String method;
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(name = "metadataEntries", value = "Properties related to features.", required = true )
|
||||
private List<MetadataEntry> metadataEntries;
|
||||
|
||||
@ -97,24 +96,6 @@ public class Feature implements Serializable {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public static class MetadataEntry implements Serializable {
|
||||
|
||||
private int id;
|
||||
|
||||
@ -32,5 +32,4 @@ public @interface Feature {
|
||||
|
||||
String description();
|
||||
|
||||
String type();
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ public class AnnotationUtil {
|
||||
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework";
|
||||
private static final String STRING_ARR = "string_arr";
|
||||
private static final String STRING = "string";
|
||||
private static final String METHOD = "method";
|
||||
private Class<org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature>
|
||||
featureAnnotationClazz;
|
||||
private ClassLoader classLoader;
|
||||
@ -147,7 +148,7 @@ public class AnnotationUtil {
|
||||
Map<String, Object> apiParams = new HashMap<>();
|
||||
for (int i = 0; i < annotations.length; i++) {
|
||||
Annotation currentAnnotation = annotations[i];
|
||||
feature = processHttpMethodAnnotation(feature, currentAnnotation);
|
||||
processHttpMethodAnnotation(apiParams, currentAnnotation);
|
||||
if (currentAnnotation.annotationType().getName().equals(Path.class.getName())) {
|
||||
String uri = getPathAnnotationValue(currentMethod);
|
||||
apiParams.put("uri", uri);
|
||||
@ -199,24 +200,20 @@ public class AnnotationUtil {
|
||||
|
||||
/**
|
||||
* Read Method annotations indicating HTTP Methods
|
||||
* @param feature
|
||||
* @param currentAnnotation
|
||||
* @return
|
||||
*/
|
||||
private Feature processHttpMethodAnnotation(Feature feature, Annotation currentAnnotation) {
|
||||
private void processHttpMethodAnnotation(Map<String, Object> apiParams, Annotation currentAnnotation) {
|
||||
//Extracting method with which feature is exposed
|
||||
if (currentAnnotation.annotationType().getName().equals(GET.class.getName())) {
|
||||
feature.setMethod(HttpMethod.GET);
|
||||
apiParams.put(METHOD, HttpMethod.GET);
|
||||
} else if (currentAnnotation.annotationType().getName().equals(POST.class.getName())) {
|
||||
feature.setMethod(HttpMethod.POST);
|
||||
apiParams.put(METHOD, HttpMethod.POST);
|
||||
} else if (currentAnnotation.annotationType().getName().equals(OPTIONS.class.getName())) {
|
||||
feature.setMethod(HttpMethod.OPTIONS);
|
||||
apiParams.put(METHOD, HttpMethod.OPTIONS);
|
||||
} else if (currentAnnotation.annotationType().getName().equals(DELETE.class.getName())) {
|
||||
feature.setMethod(HttpMethod.DELETE);
|
||||
apiParams.put(METHOD, HttpMethod.DELETE);
|
||||
} else if (currentAnnotation.annotationType().getName().equals(PUT.class.getName())) {
|
||||
feature.setMethod(HttpMethod.PUT);
|
||||
apiParams.put(METHOD, HttpMethod.PUT);
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,9 +237,6 @@ public class AnnotationUtil {
|
||||
case "description":
|
||||
feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
||||
break;
|
||||
case "type":
|
||||
feature.setType(invokeMethod(featureAnnoMethods[k], featureAnno, STRING));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return feature;
|
||||
|
||||
@ -40,14 +40,11 @@ var operationModule = function () {
|
||||
privateMethods.getOperationsFromFeatures = function (deviceType, operationType) {
|
||||
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/features/" + deviceType;
|
||||
var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) {
|
||||
var features = responsePayload;
|
||||
var featureList = [];
|
||||
var feature;
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
feature = {};
|
||||
if (features[i].type != operationType) {
|
||||
continue;
|
||||
} else if (features[i].type == 'monitor') {
|
||||
var features = responsePayload;
|
||||
var featureList = [];
|
||||
var feature;
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
feature = {};
|
||||
var analyticStreams = utility.getDeviceTypeConfig(deviceType)["analyticStreams"];
|
||||
if (analyticStreams) {
|
||||
for (var stream in analyticStreams) {
|
||||
@ -57,23 +54,22 @@ var operationModule = function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
feature["operation"] = features[i].code;
|
||||
feature["name"] = features[i].name;
|
||||
feature["method"] = features[i].method;
|
||||
feature["description"] = features[i].description;
|
||||
feature["deviceType"] = deviceType;
|
||||
feature["params"] = [];
|
||||
var metaData = features[i].metadataEntries;
|
||||
if (metaData) {
|
||||
for (var j = 0; j < metaData.length; j++) {
|
||||
feature["params"].push(metaData[j].value);
|
||||
|
||||
feature["operation"] = features[i].code;
|
||||
feature["name"] = features[i].name;
|
||||
feature["description"] = features[i].description;
|
||||
feature["deviceType"] = deviceType;
|
||||
feature["params"] = [];
|
||||
var metaData = features[i].metadataEntries;
|
||||
if (metaData) {
|
||||
for (var j = 0; j < metaData.length; j++) {
|
||||
feature["params"].push(metaData[j].value);
|
||||
}
|
||||
featureList.push(feature);
|
||||
}
|
||||
featureList.push(feature);
|
||||
}
|
||||
}
|
||||
return featureList;
|
||||
}, function (responsePayload) {
|
||||
return featureList;
|
||||
}, function (responsePayload) {
|
||||
var response = {};
|
||||
response["status"] = "error";
|
||||
return response;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user