From 7eaee141e07f7fa2425a24fe0ca79fc087bd1f59 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 5 Dec 2016 10:34:11 +0530 Subject: [PATCH] Adding content-type to descriptor --- .../type/deployer/config/Operation.java | 27 +++++++++++++++++++ .../ConfigurationBasedFeatureManager.java | 2 ++ .../src/test/resources/sample.xml | 2 +- .../modules/business-controllers/operation.js | 5 ++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Operation.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Operation.java index 81ab8fdaf2..0a954c242d 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Operation.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Operation.java @@ -40,6 +40,7 @@ import javax.xml.bind.annotation.XmlType; * </sequence> * <attribute name="context" type="{http://www.w3.org/2001/XMLSchema}string" /> * <attribute name="method" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> * </restriction> * </complexContent> * </complexType> @@ -62,6 +63,32 @@ public class Operation { protected String context; @XmlAttribute(name = "method") protected String method; + @XmlAttribute(name = "type") + protected String type; + + /** + * Gets the value of the Content Type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the Content Type property. + * + * @param type + * allowed object is + * {@link String } + * + */ + public void setType(String type) { + this.type = type; + } /** * Gets the value of the queryParameters property. diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java index 7e53718442..5d689fec5c 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/feature/ConfigurationBasedFeatureManager.java @@ -38,6 +38,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { private List features = new ArrayList<>(); private static final String METHOD = "method"; private static final String URI = "uri"; + private static final String CONTENT_TYPE = "contentType"; private static final String PATH_PARAMS = "pathParams"; private static final String QUERY_PARAMS = "queryParams"; private static final String FORM_PARAMS = "formParams"; @@ -55,6 +56,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { Map apiParams = new HashMap<>(); apiParams.put(METHOD, operation.getMethod().toUpperCase()); apiParams.put(URI, operation.getContext()); + apiParams.put(CONTENT_TYPE, operation.getType()); List pathParams = new ArrayList<>(); List queryParams = new ArrayList<>(); List formParams = new ArrayList<>(); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml index 6e21c52ef2..a3d19a34ac 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml @@ -25,7 +25,7 @@ abc this is a feature - + deviceId diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index f072a27d5b..127a0df064 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -48,6 +48,7 @@ var operationModule = function () { feature["operation"] = features[i].code; feature["name"] = features[i].name; feature["description"] = features[i].description; + feature["contentType"] = features[i].contentType; feature["deviceType"] = deviceType; feature["params"] = []; var metaData = features[i].metadataEntries; @@ -81,6 +82,10 @@ var operationModule = function () { var iconPath = utility.getOperationIcon(deviceType, iconIdentifier); operations[op]["icon"] = iconPath; } + var formParams = features[iconIdentifier].formParams; + if (formParams) { + operations[op]["uiParams"] = formParams; + } } } return operations;