From 087adafeb7c247cd8a1d2c9eb15fbb158645b127 Mon Sep 17 00:00:00 2001 From: Madhawa Perera Date: Fri, 13 May 2016 01:25:29 +0530 Subject: [PATCH 1/2] Adding swagger annotations to beans --- .../device/mgt/jaxrs/beans/PolicyWrapper.java | 31 ++++++++++++++++++ .../beans/PriorityUpdatedPolicyWrapper.java | 8 +++++ .../org.wso2.carbon.policy.mgt.common/pom.xml | 7 ++++ .../wso2/carbon/policy/mgt/common/Policy.java | 32 +++++++++++++++++-- 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java index c05fa535a5..b8558856fe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java @@ -18,21 +18,52 @@ package org.wso2.carbon.device.mgt.jaxrs.beans; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.Device; import java.util.List; +@ApiModel(value = "PolicyWrapper", description = "This class carries all information related to Policy " + + "Wrappers") public class PolicyWrapper { + @ApiModelProperty(name = "id", value = "The policy ID", required = true) private int id; + @ApiModelProperty(name = "profile", value = "Contains the details of the profile that is included in the" + + " policy", required = true) private Profile profile; + @ApiModelProperty(name = "policyName", value = "The name of the policy", required = true) private String policyName; + @ApiModelProperty(name = "description", value = "Gives a description on the policy", required = true) private String description; + @ApiModelProperty(name = "compliance", value = "Provides the non-compliance rules. WSO2 EMM provides the" + + " following non-compliance rules:\n" + + "Enforce - Forcefully enforce the policies on the devices\n" + + "Warning - If the device does not adhere to the given policies a warning message will be sent\n" + + "Monitor - If the device does not adhere to the given policies the server is notified of the " + + "violation unknown to the user and the administrator can take the necessary actions with regard" + + " to the reported", required = true) private String compliance; + @ApiModelProperty(name = "roles", value = "The roles to whom the policy is applied on", required = true) private List roles; + @ApiModelProperty(name = "ownershipType", value = "The policy ownership type. It can be any of the " + + "following values:\n" + + "ANY - The policy will be applied on the BYOD and COPE device types\n" + + "BYOD (Bring Your Own Device) - The policy will only be applied on the BYOD device type\n" + + "COPE (Corporate-Owned, Personally-Enabled) - The policy will only be applied on the COPE " + + "device type", required = true) private String ownershipType; + @ApiModelProperty(name = "devices", value = "Lists out the devices the policy is enforced on", + required = true) private List devices; + @ApiModelProperty(name = "users", value = "Lists out the users on whose devices the policy is enforced", + required = true) private List users; + @ApiModelProperty(name = "tenantId", value = "The ID of the tenant that created the policy", + required = true) private int tenantId; + @ApiModelProperty(name = "profileId", value = "The ID of each profile that is in the selected policy", + required = true) private int profileId; public int getId() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PriorityUpdatedPolicyWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PriorityUpdatedPolicyWrapper.java index 20f5248f85..56a4764d0b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PriorityUpdatedPolicyWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PriorityUpdatedPolicyWrapper.java @@ -18,9 +18,17 @@ package org.wso2.carbon.device.mgt.jaxrs.beans; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(value = "PriorityUpdatedPolicyWrapper", description = "This class carries all information related " + + "to Priority Updated Policy Wrapper ") public class PriorityUpdatedPolicyWrapper { + @ApiModelProperty(name = "id", value = "Define the ID of the policy", required = true) private int id; + @ApiModelProperty(name = "priority", value = "Define the priority of the order, where 1 indicates the " + + "highest priority", required = true) private int priority; public int getId() { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index cfa51b818b..c8251cb93b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -53,6 +53,8 @@ ${carbon.device.mgt.version} Policy Management Common Bundle + javax.xml.bind.annotation, + io.swagger.annotations.*;resolution:=optional org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.dto.*, javax.xml.bind.*, @@ -91,6 +93,11 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core + + io.swagger + swagger-annotations + provided + diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java index 25c5f48cc4..4620adb72e 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.policy.mgt.common; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.Device; import javax.xml.bind.annotation.XmlElement; @@ -29,24 +31,50 @@ import java.util.Map; * This class will be the used to create policy object with relevant information for evaluating. */ @XmlRootElement +@ApiModel(value = "Policy", description = "This class carries all information related to Policies") public class Policy implements Comparable, Serializable { private static final long serialVersionUID = 19981017L; + @ApiModelProperty(name = "id", value = "The policy ID", required = true) private int id; // Identifier of the policy. - private int priorityId; // Priority of the policies. This will be used only for simple evaluation. + @ApiModelProperty(name = "priorityId", value = "The priority order of the policy. 1 indicates the highest" + + " priority", required = true) + private int priorityId; // Priority of the policies. This will be used only for simple evaluation. + @ApiModelProperty(name = "profile", value = "Contains the details of the profile that is included in the " + + "policy", required = true) private Profile profile; // Profile + @ApiModelProperty(name = "policyName", value = "The name of the policy", required = true) private String policyName; // Name of the policy. + @ApiModelProperty(name = "generic", value = "If true, this should be applied to all related device", + required = true) private boolean generic; // If true, this should be applied to all related device. + @ApiModelProperty(name = "roles", value = "The roles to whom the policy is applied on", required = true) private List roles; // Roles which this policy should be applied. + @ApiModelProperty(name = "ownershipType", value = "The policy ownership type. It can be any of the " + + "following values:\n" + + "ANY - The policy will be applied on the BYOD and COPE device types\n" + + "BYOD (Bring Your Own Device) - The policy will only be applied on the BYOD device type\n" + + "COPE (Corporate-Owned, Personally-Enabled) - The policy will only be applied on the COPE " + + "device type\n", required = true) private String ownershipType; // Ownership type (COPE, BYOD, CPE) + @ApiModelProperty(name = "devices", value = "Lists out the devices the policy is enforced on", + required = true) private List devices; // Individual devices this policy should be applied + @ApiModelProperty(name = "users", value = "Lists out the users on whose devices the policy is enforced", + required = true) private List users; + @ApiModelProperty(name = "active", value = "If the value is true it indicates that the policy is active. " + + "If the value is false it indicates that the policy is inactive", required = true) private boolean active; + @ApiModelProperty(name = "updated", value = "If you have made changes to the policy but have not applied" + + " these changes to the devices that are registered with EMM, then the value is defined as true." + + " But if you have already applied any changes made to the policy then the value is defined as" + + " false.", required = true) private boolean updated; + @ApiModelProperty(name = "description", value = "Gives a description on the policy", required = true) private String description; - /* Compliance data*/ private String compliance; From 5d1bf67630bfbb0c35982c11b68fcd29a73f33e7 Mon Sep 17 00:00:00 2001 From: Madhawa Perera Date: Fri, 13 May 2016 01:31:33 +0530 Subject: [PATCH 2/2] Adding swagger annotations to beans --- components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index c8251cb93b..597ea8239a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -54,7 +54,7 @@ Policy Management Common Bundle javax.xml.bind.annotation, - io.swagger.annotations.*;resolution:=optional + io.swagger.annotations.*;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.dto.*, javax.xml.bind.*,