From ec7727e8bf46962e68caac63d631d43e4de33fe4 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Thu, 12 May 2016 22:01:48 +0530 Subject: [PATCH 1/3] removed method and type from features --- .../carbon/device/mgt/common/Feature.java | 20 ---------- .../feature/mgt/annotations/Feature.java | 1 - .../feature/mgt/util/AnnotationUtil.java | 39 +++++++++---------- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java index 375b8d4562..eb48ea1ee5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java @@ -28,8 +28,6 @@ public class Feature implements Serializable { private String name; private String description; private String deviceType; - private String method; - private String type; private List metadataEntries; @XmlElement @@ -85,24 +83,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; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/annotations/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/annotations/Feature.java index da0040f982..02c9ba96e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/annotations/Feature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/annotations/Feature.java @@ -32,5 +32,4 @@ public @interface Feature { String description(); - String type(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java index dbca91f10e..42e7d9d87d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java @@ -147,7 +147,8 @@ public class AnnotationUtil { Map apiParams = new HashMap<>(); for (int i = 0; i < annotations.length; i++) { Annotation currentAnnotation = annotations[i]; - feature = processHttpMethodAnnotation(feature, currentAnnotation); + String method = processHttpMethodAnnotation(feature, currentAnnotation); + apiParams.put("method", method); if (currentAnnotation.annotationType().getName().equals(Path.class.getName())) { String uri = getPathAnnotationValue(currentMethod); apiParams.put("uri", uri); @@ -203,20 +204,21 @@ public class AnnotationUtil { * @param currentAnnotation * @return */ - private Feature processHttpMethodAnnotation(Feature feature, Annotation currentAnnotation) { + private String processHttpMethodAnnotation(Feature feature, Annotation currentAnnotation) { //Extracting method with which feature is exposed + String method = null; if (currentAnnotation.annotationType().getName().equals(GET.class.getName())) { - feature.setMethod(HttpMethod.GET); + method = HttpMethod.GET; } else if (currentAnnotation.annotationType().getName().equals(POST.class.getName())) { - feature.setMethod(HttpMethod.POST); + method = HttpMethod.POST; } else if (currentAnnotation.annotationType().getName().equals(OPTIONS.class.getName())) { - feature.setMethod(HttpMethod.OPTIONS); + method = HttpMethod.OPTIONS; } else if (currentAnnotation.annotationType().getName().equals(DELETE.class.getName())) { - feature.setMethod(HttpMethod.DELETE); + method = HttpMethod.DELETE; } else if (currentAnnotation.annotationType().getName().equals(PUT.class.getName())) { - feature.setMethod(HttpMethod.PUT); + method = HttpMethod.PUT; } - return feature; + return method; } /** @@ -231,18 +233,15 @@ public class AnnotationUtil { Annotation featureAnno = currentMethod.getAnnotation(featureAnnotationClazz); for (int k = 0; k < featureAnnoMethods.length; k++) { switch (featureAnnoMethods[k].getName()) { - case "name": - feature.setName(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; - case "code": - feature.setCode(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; - case "description": - feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; - case "type": - feature.setType(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; + case "name": + feature.setName(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); + break; + case "code": + feature.setCode(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); + break; + case "description": + feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); + break; } } return feature; From bee9a106cc86c4420cb154cd1ea2e94adba62415 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Fri, 13 May 2016 02:53:08 +0530 Subject: [PATCH 2/3] removed method and type from feature --- .../feature/mgt/util/AnnotationUtil.java | 39 ++++++++--------- .../devicemgt/app/modules/operation.js | 42 +++++++++---------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java index 42e7d9d87d..a70c9c5dc1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/feature/mgt/util/AnnotationUtil.java @@ -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 featureAnnotationClazz; private ClassLoader classLoader; @@ -147,8 +148,7 @@ public class AnnotationUtil { Map apiParams = new HashMap<>(); for (int i = 0; i < annotations.length; i++) { Annotation currentAnnotation = annotations[i]; - String method = processHttpMethodAnnotation(feature, currentAnnotation); - apiParams.put("method", method); + processHttpMethodAnnotation(apiParams, currentAnnotation); if (currentAnnotation.annotationType().getName().equals(Path.class.getName())) { String uri = getPathAnnotationValue(currentMethod); apiParams.put("uri", uri); @@ -200,25 +200,20 @@ public class AnnotationUtil { /** * Read Method annotations indicating HTTP Methods - * @param feature - * @param currentAnnotation - * @return */ - private String processHttpMethodAnnotation(Feature feature, Annotation currentAnnotation) { + private void processHttpMethodAnnotation(Map apiParams, Annotation currentAnnotation) { //Extracting method with which feature is exposed - String method = null; 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())) { - method = HttpMethod.POST; + apiParams.put(METHOD, HttpMethod.POST); } 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())) { - method = HttpMethod.DELETE; + apiParams.put(METHOD, HttpMethod.DELETE); } 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); for (int k = 0; k < featureAnnoMethods.length; k++) { switch (featureAnnoMethods[k].getName()) { - case "name": - feature.setName(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; - case "code": - feature.setCode(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; - case "description": - feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); - break; + case "name": + feature.setName(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); + break; + case "code": + feature.setCode(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); + break; + case "description": + feature.setDescription(invokeMethod(featureAnnoMethods[k], featureAnno, STRING)); + break; } } return feature; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js index c621975708..1655adf1ed 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/operation.js @@ -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; From b3075cf1bc6b4c6aa38e93cae915edb9c32d8ba9 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sat, 14 May 2016 00:10:39 +0530 Subject: [PATCH 3/3] removing application related roles --- .../org/wso2/carbon/device/mgt/jaxrs/api/impl/RoleImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/RoleImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/RoleImpl.java index 278a7dfd26..3b9c8420fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/RoleImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/RoleImpl.java @@ -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 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); } }