diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
index 1258094d9b..cf45b7153b 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml
@@ -205,5 +205,13 @@
servlet-api
provided
+
+ org.hibernate
+ hibernate-validator
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java
new file mode 100644
index 0000000000..19623877ee
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.bean;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement(
+ name = "PlatformConfiguration"
+)
+@XmlAccessorType(XmlAccessType.NONE)
+@ApiModel(
+ value = "PlatformConfiguration",
+ description = "This class carries all information related to a Tenant configuration"
+)
+public class AndroidPlatformConfiguration implements Serializable {
+ public static final int INVALID_NOTIFIER_FREQUENCY = -1;
+ @XmlElement(
+ name = "type"
+ )
+ @ApiModelProperty(
+ name = "type",
+ value = "type of device",
+ required = true
+ )
+ @NotNull
+ @Size(min = 2, max = 10)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
+ private String type;
+ @ApiModelProperty(
+ name = "configuration",
+ value = "List of Configuration Entries",
+ required = true
+ )
+ @XmlElement(
+ name = "configuration"
+ )
+ private List configuration;
+
+ public AndroidPlatformConfiguration() {
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public List getConfiguration() {
+ return this.configuration;
+ }
+
+ public void setConfiguration(List configuration) {
+ this.configuration = configuration;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java
index b0ed373779..454dc905a8 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java
@@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
import java.io.Serializable;
/**
@@ -31,9 +33,13 @@ import java.io.Serializable;
public class ApplicationInstallation extends AndroidOperation implements Serializable {
@ApiModelProperty(name = "appIdentifier", value = "Application Identifier", required = true)
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
private String appIdentifier;
@ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true)
+ @Size(min = 2, max = 12)
+ @Pattern(regexp = "^[A-Za-z]*$")
private String type;
@ApiModelProperty(name = "url", value = "Application URL", required = true)
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java
index a946eedc72..45b98b47d6 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java
@@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
import java.io.Serializable;
/**
@@ -31,47 +33,52 @@ import java.io.Serializable;
public class ApplicationUninstallation extends AndroidOperation implements Serializable {
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application to be uninstalled.", required = true)
- private String appIdentifier;
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
+ private String appIdentifier;
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
- "are supported: enterprise, public and webapp.", required = true)
- private String type;
+ "are supported: enterprise, public and webapp.", required = true)
+ @Size(min = 2, max = 12)
+ @Pattern(regexp = "^[A-Za-z]*$")
+ private String type;
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
- private String url;
+ private String url;
@ApiModelProperty(name = "name", value = "The name of the application.", required = true)
- private String name;
+ @Size(min = 2, max = 45)
+ private String name;
- public String getAppIdentifier() {
- return appIdentifier;
- }
+ public String getAppIdentifier() {
+ return appIdentifier;
+ }
- public void setAppIdentifier(String appIdentifier) {
- this.appIdentifier = appIdentifier;
- }
+ public void setAppIdentifier(String appIdentifier) {
+ this.appIdentifier = appIdentifier;
+ }
- public String getType() {
- return type;
- }
+ public String getType() {
+ return type;
+ }
- public void setType(String type) {
- this.type = type;
- }
+ public void setType(String type) {
+ this.type = type;
+ }
- public String getUrl() {
- return url;
- }
+ public String getUrl() {
+ return url;
+ }
- public void setUrl(String url) {
- this.url = url;
- }
+ public void setUrl(String url) {
+ this.url = url;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java
index f732f74a93..14f7c31dbc 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java
@@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
import java.io.Serializable;
/**
@@ -32,9 +34,13 @@ public class ApplicationUpdate extends AndroidOperation implements Serializable
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application " +
"to be update.", required = true)
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
private String appIdentifier;
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
"are supported: enterprise, public and webapp.", required = true)
+ @Size(min = 2, max = 12)
+ @Pattern(regexp = "^[A-Za-z]*$")
private String type;
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
private String url;
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java
index 665735b519..97c1ae5dee 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java
@@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;
@@ -33,6 +35,8 @@ public class BlacklistApplications extends AndroidOperation implements Serializa
@ApiModelProperty(name = "appIdentifiers", value = "A list of application package names to be blacklisted.",
required = true)
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
private List appIdentifiers;
public List getAppIdentifier() {
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java
index 7680e36641..457782adea 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java
@@ -34,9 +34,6 @@ public class ErrorResponse {
private String moreInfo = null;
private List errorItems = new ArrayList<>();
- private ErrorResponse() {
- }
-
@JsonProperty(value = "code")
@ApiModelProperty(required = true, value = "")
public Long getCode() {
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java
index 0b1f93743a..c2e48ce70c 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java
@@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.Max;
import java.io.Serializable;
/**
@@ -34,18 +35,24 @@ public class PasscodePolicy extends AndroidOperation implements Serializable {
+ " his/her device passcode incorrectly. EMM will take different courses of action based on the"
+ " OS when the failed attempts exceed the maximum failed attempts. Android devices will be "
+ "automatically reset to the original factory settings", required = true)
+
+ @Max(10)
private int maxFailedAttempts;
@ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the "
+ "end-user can enter as his/her passcode", required = true)
+ @Max(15)
private int minLength;
@ApiModelProperty(name = "pinHistory", value = "The end-user will not be allowed to reuse a passcode that"
+ " he/she previously entered until he/she exceeds the set pin history length", required = true)
+ @Max(50)
private int pinHistory;
@ApiModelProperty(name = "minComplexChars", value = "The minimum number of special characters that the "
+ "end-user will have to enter in his/her passcode", required = true)
+ @Max(5)
private int minComplexChars;
@ApiModelProperty(name = "maxPINAgeInDays", value = "The number of days after which the device owner has"
+ " to change his/her passcode", required = true)
+ @Max(730)
private int maxPINAgeInDays;
@ApiModelProperty(name = "requireAlphanumeric", value = "Whether or not it is mandatory for the end-user"
+ " to have a mix of digits and characters in his/her passcode", required = true)
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java
new file mode 100644
index 0000000000..8dee1a60d0
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java
@@ -0,0 +1,206 @@
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+@ApiModel(
+ value = "Application",
+ description = "This class carries all information related application"
+)
+public class AndroidApplication implements Serializable{
+ private static final long serialVersionUID = 1998101711L;
+ @ApiModelProperty(
+ name = "id",
+ value = "The ID given to the application when it is stored in the EMM database",
+ required = true
+ )
+ private int id;
+ @ApiModelProperty(
+ name = "platform",
+ value = "The mobile device platform. It can be android, ios or windows",
+ required = true
+ )
+ private String platform;
+ @ApiModelProperty(
+ name = "category",
+ value = "The application category",
+ required = true
+ )
+ private String category;
+ @ApiModelProperty(
+ name = "name",
+ value = "The application\'s name",
+ required = true
+ )
+ private String name;
+ private String locationUrl;
+ @ApiModelProperty(
+ name = "imageUrl",
+ value = "The icon url of the application",
+ required = true
+ )
+ private String imageUrl;
+ @ApiModelProperty(
+ name = "version",
+ value = "The application\'s version",
+ required = true
+ )
+ private String version;
+ @ApiModelProperty(
+ name = "type",
+ value = "The application type",
+ required = true
+ )
+ private String type;
+ @ApiModelProperty(
+ name = "appProperties",
+ value = "The properties of the application",
+ required = true
+ )
+ private Properties appProperties;
+ @ApiModelProperty(
+ name = "applicationIdentifier",
+ value = "The application identifier",
+ required = true
+ )
+ private String applicationIdentifier;
+ @ApiModelProperty(
+ name = "memoryUsage",
+ value = "Amount of memory used by the application",
+ required = true
+ )
+ private int memoryUsage;
+ @ApiModelProperty(
+ name = "isActive",
+ value = "Is the application actively running",
+ required = true
+ )
+ private boolean isActive;
+
+ public AndroidApplication() {
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getLocationUrl() {
+ return this.locationUrl;
+ }
+
+ public void setLocationUrl(String locationUrl) {
+ this.locationUrl = locationUrl;
+ }
+
+ public String getImageUrl() {
+ return this.imageUrl;
+ }
+
+ public void setImageUrl(String imageUrl) {
+ this.imageUrl = imageUrl;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getPlatform() {
+ return this.platform;
+ }
+
+ public void setPlatform(String platform) {
+ this.platform = platform;
+ }
+
+ public String getCategory() {
+ return this.category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getApplicationIdentifier() {
+ return this.applicationIdentifier;
+ }
+
+ public void setApplicationIdentifier(String applicationIdentifier) {
+ this.applicationIdentifier = applicationIdentifier;
+ }
+
+ public int getMemoryUsage() {
+ return this.memoryUsage;
+ }
+
+ public void setMemoryUsage(int memoryUsage) {
+ this.memoryUsage = memoryUsage;
+ }
+
+ public boolean equals(Object o) {
+ if(this == o) {
+ return true;
+ } else if(o != null && this.getClass() == o.getClass()) {
+ AndroidApplication that = (AndroidApplication)o;
+ if(this.applicationIdentifier != null) {
+ if(!this.applicationIdentifier.equals(that.applicationIdentifier)) {
+ return false;
+ }
+ } else if(that.applicationIdentifier != null) {
+ return false;
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ int result = this.id;
+ result = 31 * result + (this.applicationIdentifier != null?this.applicationIdentifier.hashCode():0);
+ return result;
+ }
+
+ public Properties getAppProperties() {
+ return this.appProperties;
+ }
+
+ public void setAppProperties(Properties appProperties) {
+ this.appProperties = appProperties;
+ }
+
+ public boolean isActive() {
+ return this.isActive;
+ }
+
+ public void setActive(boolean active) {
+ this.isActive = active;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java
new file mode 100644
index 0000000000..cbd0f0339e
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.wso2.carbon.device.mgt.common.Device;
+import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
+import org.wso2.carbon.device.mgt.common.Feature;
+import org.wso2.carbon.device.mgt.common.app.mgt.Application;
+import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.List;
+
+public class AndroidDevice implements Serializable {
+ private static final long serialVersionUID = 1998101711L;
+
+ @ApiModelProperty(
+ name = "name",
+ value = "The device name that can be set on the device by the device user.",
+ required = true
+ )
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
+ private String name;
+ @ApiModelProperty(
+ name = "type",
+ value = "The OS type of the device.",
+ required = true
+ )
+ @NotNull
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z]*$")
+ private String type;
+ @ApiModelProperty(
+ name = "description",
+ value = "Additional information on the device.",
+ required = true
+ )
+ private String description;
+ @ApiModelProperty(
+ name = "deviceIdentifier",
+ value = "This is a 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user\'s device. The value may change if a factory reset is performed on the device.",
+ required = true
+ )
+ @NotNull
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
+ private String deviceIdentifier;
+ @ApiModelProperty(
+ name = "enrolmentInfo",
+ value = "This defines the device registration related information. It is mandatory to define this information.",
+ required = true
+ )
+ private EnrolmentInfo enrolmentInfo;
+ @ApiModelProperty(
+ name = "features",
+ value = "List of features.",
+ required = true
+ )
+ private List features;
+ private List properties;
+ @ApiModelProperty(
+ name = "advanceInfo",
+ value = "This defines the device registration related information. It is mandatory to define this information.",
+ required = false
+ )
+ private DeviceInfo deviceInfo;
+ @ApiModelProperty(
+ name = "applications",
+ value = "This represents the application list installed into the device",
+ required = false
+ )
+ private List applications;
+
+ public AndroidDevice() {
+ }
+
+ public AndroidDevice(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo, List features, List properties) {
+ this.name = name;
+ this.type = type;
+ this.description = description;
+ this.deviceIdentifier = deviceId;
+ this.enrolmentInfo = enrolmentInfo;
+ this.features = features;
+ this.properties = properties;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDeviceIdentifier() {
+ return this.deviceIdentifier;
+ }
+
+ public void setDeviceIdentifier(String deviceIdentifier) {
+ this.deviceIdentifier = deviceIdentifier;
+ }
+
+ public EnrolmentInfo getEnrolmentInfo() {
+ return this.enrolmentInfo;
+ }
+
+ public void setEnrolmentInfo(EnrolmentInfo enrolmentInfo) {
+ this.enrolmentInfo = enrolmentInfo;
+ }
+
+ public List getFeatures() {
+ return this.features;
+ }
+
+ public void setFeatures(List features) {
+ this.features = features;
+ }
+
+ public List getProperties() {
+ return this.properties;
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ public DeviceInfo getDeviceInfo() {
+ return this.deviceInfo;
+ }
+
+ public void setDeviceInfo(DeviceInfo deviceInfo) {
+ this.deviceInfo = deviceInfo;
+ }
+
+ public List getApplications() {
+ return this.applications;
+ }
+
+ public void setApplications(List applications) {
+ this.applications = applications;
+ }
+
+ public String toString() {
+ return "device [name=" + this.name + ";" + "type=" + this.type + ";" + "description=" + this.description + ";" + "identifier=" + this.deviceIdentifier + ";" + "]";
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ } else if (!(o instanceof AndroidDevice)) {
+ return false;
+ } else {
+ AndroidDevice device = (AndroidDevice) o;
+ return this.getDeviceIdentifier().equals(device.getDeviceIdentifier());
+ }
+ }
+
+ public int hashCode() {
+ return this.getDeviceIdentifier().hashCode();
+ }
+
+ public static class Property {
+ private String name;
+ private String value;
+
+ public Property() {
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java
new file mode 100644
index 0000000000..bf775edfed
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java
@@ -0,0 +1,321 @@
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
+import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@ApiModel(
+ value = "DeviceInfo",
+ description = "This class carries all information related to the device information provided by a device."
+)
+public class AndroidDeviceInfo extends DeviceInfo implements Serializable {
+ private static final long serialVersionUID = 1998101733L;
+ @ApiModelProperty(
+ name = "IMEI",
+ value = "IMEI number of the device.",
+ required = true
+ )
+ private String IMEI;
+ @ApiModelProperty(
+ name = "IMSI",
+ value = "IMSI number of the device.",
+ required = true
+ )
+ private String IMSI;
+ @ApiModelProperty(
+ name = "deviceModel",
+ value = "Model of the device.",
+ required = true
+ )
+ private String deviceModel;
+ @ApiModelProperty(
+ name = "vendor",
+ value = "Vendor of the device.",
+ required = true
+ )
+ private String vendor;
+ @ApiModelProperty(
+ name = "osVersion",
+ value = "Operating system version.",
+ required = true
+ )
+ private String osVersion;
+ @ApiModelProperty(
+ name = "batteryLevel",
+ value = "Battery level of the device.",
+ required = true
+ )
+ private Double batteryLevel;
+ @ApiModelProperty(
+ name = "internalTotalMemory",
+ value = "Total internal memory of the device.",
+ required = true
+ )
+ private Double internalTotalMemory;
+ @ApiModelProperty(
+ name = "internalAvailableMemory",
+ value = "Total available memory of the device.",
+ required = true
+ )
+ private Double internalAvailableMemory;
+ @ApiModelProperty(
+ name = "externalTotalMemory",
+ value = "Total external memory of the device.",
+ required = true
+ )
+ private Double externalTotalMemory;
+ @ApiModelProperty(
+ name = "externalAvailableMemory",
+ value = "Total external memory avilable of the device.",
+ required = true
+ )
+ private Double externalAvailableMemory;
+ @ApiModelProperty(
+ name = "operator",
+ value = "Mobile operator of the device.",
+ required = true
+ )
+ private String operator;
+ @ApiModelProperty(
+ name = "connectionType",
+ value = "How the device is connected to the network.",
+ required = true
+ )
+ private String connectionType;
+ @ApiModelProperty(
+ name = "mobileSignalStrength",
+ value = "Current mobile signal strength.",
+ required = true
+ )
+ private Double mobileSignalStrength;
+ @ApiModelProperty(
+ name = "ssid",
+ value = "ssid of the connected WiFi.",
+ required = true
+ )
+ private String ssid;
+ @ApiModelProperty(
+ name = "cpuUsage",
+ value = "Current total cpu usage.",
+ required = true
+ )
+ private Double cpuUsage;
+ @ApiModelProperty(
+ name = "totalRAMMemory",
+ value = "Total Ram memory size.",
+ required = true
+ )
+ private Double totalRAMMemory;
+ @ApiModelProperty(
+ name = "availableRAMMemory",
+ value = "Available total memory of RAM.",
+ required = true
+ )
+ private Double availableRAMMemory;
+ @ApiModelProperty(
+ name = "pluggedIn",
+ value = "Whether the device is plugged into power or not.",
+ required = true
+ )
+ private boolean pluggedIn;
+ @ApiModelProperty(
+ name = "updatedTime",
+ value = "Device updated time.",
+ required = true
+ )
+ private Date updatedTime;
+ @ApiModelProperty(
+ name = "location",
+ value = "Last updated location of the device",
+ required = false
+ )
+ private DeviceLocation location;
+ @ApiModelProperty(
+ name = "deviceDetailsMap",
+ value = ".",
+ required = true
+ )
+ private Map deviceDetailsMap = new HashMap();
+
+ public AndroidDeviceInfo() {
+ }
+
+ public DeviceLocation getLocation() {
+ return this.location;
+ }
+
+ public void setLocation(DeviceLocation location) {
+ this.location = location;
+ }
+
+ public String getIMEI() {
+ return this.IMEI != null?this.IMEI:"";
+ }
+
+ public void setIMEI(String IMEI) {
+ this.IMEI = IMEI;
+ }
+
+ public String getIMSI() {
+ return this.IMSI != null?this.IMSI:"";
+ }
+
+ public void setIMSI(String IMSI) {
+ this.IMSI = IMSI;
+ }
+
+ public String getDeviceModel() {
+ return this.deviceModel != null?this.deviceModel:"";
+ }
+
+ public void setDeviceModel(String deviceModel) {
+ this.deviceModel = deviceModel;
+ }
+
+ public String getVendor() {
+ return this.vendor != null?this.vendor:"";
+ }
+
+ public void setVendor(String vendor) {
+ this.vendor = vendor;
+ }
+
+ public String getOsVersion() {
+ return this.osVersion != null?this.osVersion:"";
+ }
+
+ public void setOsVersion(String osVersion) {
+ this.osVersion = osVersion;
+ }
+
+ public Double getBatteryLevel() {
+ return this.batteryLevel != null?this.batteryLevel:Double.valueOf(0.0D);
+ }
+
+ public void setBatteryLevel(Double batteryLevel) {
+ this.batteryLevel = batteryLevel;
+ }
+
+ public Double getInternalTotalMemory() {
+ return this.internalTotalMemory != null?this.internalTotalMemory:Double.valueOf(0.0D);
+ }
+
+ public void setInternalTotalMemory(Double internalTotalMemory) {
+ this.internalTotalMemory = internalTotalMemory;
+ }
+
+ public Double getInternalAvailableMemory() {
+ return this.internalAvailableMemory != null?this.internalAvailableMemory:Double.valueOf(0.0D);
+ }
+
+ public void setInternalAvailableMemory(Double internalAvailableMemory) {
+ this.internalAvailableMemory = internalAvailableMemory;
+ }
+
+ public Double getExternalTotalMemory() {
+ return this.externalTotalMemory != null?this.externalTotalMemory:Double.valueOf(0.0D);
+ }
+
+ public void setExternalTotalMemory(Double externalTotalMemory) {
+ this.externalTotalMemory = externalTotalMemory;
+ }
+
+ public Double getExternalAvailableMemory() {
+ return this.externalAvailableMemory != null?this.externalAvailableMemory:Double.valueOf(0.0D);
+ }
+
+ public void setExternalAvailableMemory(Double externalAvailableMemory) {
+ this.externalAvailableMemory = externalAvailableMemory;
+ }
+
+ public String getOperator() {
+ return this.operator != null?this.operator:"";
+ }
+
+ public void setOperator(String operator) {
+ this.operator = operator;
+ }
+
+ public String getConnectionType() {
+ return this.connectionType != null?this.connectionType:"";
+ }
+
+ public void setConnectionType(String connectionType) {
+ this.connectionType = connectionType;
+ }
+
+ public Double getMobileSignalStrength() {
+ return this.mobileSignalStrength != null?this.mobileSignalStrength:Double.valueOf(0.0D);
+ }
+
+ public void setMobileSignalStrength(Double mobileSignalStrength) {
+ this.mobileSignalStrength = mobileSignalStrength;
+ }
+
+ public String getSsid() {
+ return this.ssid != null?this.ssid:"";
+ }
+
+ public void setSsid(String ssid) {
+ this.ssid = ssid;
+ }
+
+ public Double getCpuUsage() {
+ return this.cpuUsage != null?this.cpuUsage:Double.valueOf(0.0D);
+ }
+
+ public void setCpuUsage(Double cpuUsage) {
+ this.cpuUsage = cpuUsage;
+ }
+
+ public Double getTotalRAMMemory() {
+ return this.totalRAMMemory != null?this.totalRAMMemory:Double.valueOf(0.0D);
+ }
+
+ public void setTotalRAMMemory(Double totalRAMMemory) {
+ this.totalRAMMemory = totalRAMMemory;
+ }
+
+ public Double getAvailableRAMMemory() {
+ return this.availableRAMMemory != null?this.availableRAMMemory:Double.valueOf(0.0D);
+ }
+
+ public void setAvailableRAMMemory(Double availableRAMMemory) {
+ this.availableRAMMemory = availableRAMMemory;
+ }
+
+ public boolean isPluggedIn() {
+ return this.pluggedIn;
+ }
+
+ public void setPluggedIn(boolean pluggedIn) {
+ this.pluggedIn = pluggedIn;
+ }
+
+ public Date getUpdatedTime() {
+ if(this.updatedTime.equals((Object)null)) {
+ this.updatedTime = new Date();
+ }
+
+ return this.updatedTime;
+ }
+
+ public void setUpdatedTime(Date updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public void setDeviceDetailsMap(Map deviceDetailsMap) {
+ this.deviceDetailsMap = deviceDetailsMap;
+ }
+
+ public Map getDeviceDetailsMap() {
+ return this.deviceDetailsMap;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java
index 2d4ea4d00f..b0bd54cf30 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java
@@ -33,7 +33,6 @@ public class ApplicationInstallationBeanWrapper {
@ApiModelProperty(name = "deviceIDs", value = "List of Devices", required = true)
private List deviceIDs;
-
@ApiModelProperty(name = "operation", value = "App Installation property", required = true)
private ApplicationInstallation operation;
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java
index 568b85f0c7..28c72c6cd0 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java
@@ -27,28 +27,28 @@ import java.util.List;
* This class is used to wrap the UninstallApplication bean with devices.
*/
@ApiModel(value = "ApplicationUninstallationBeanWrapper",
- description = "This class carries all information related to Uninstall Application")
+ description = "This class carries all information related to Uninstall Application")
public class ApplicationUninstallationBeanWrapper {
- @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
- private List deviceIDs;
+ @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
+ private List deviceIDs;
- @ApiModelProperty(name = "operation", value = "Name of the device", required = true)
- private ApplicationUninstallation operation;
+ @ApiModelProperty(name = "operation", value = "Name of the device", required = true)
+ private ApplicationUninstallation operation;
- public List getDeviceIDs() {
- return deviceIDs;
- }
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
- public void setDeviceIDs(List deviceIDs) {
- this.deviceIDs = deviceIDs;
- }
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
- public ApplicationUninstallation getOperation() {
- return operation;
- }
+ public ApplicationUninstallation getOperation() {
+ return operation;
+ }
- public void setOperation(ApplicationUninstallation operation) {
- this.operation = operation;
- }
+ public void setOperation(ApplicationUninstallation operation) {
+ this.operation = operation;
+ }
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java
index 1f824661df..3abf32c22c 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java
@@ -21,33 +21,35 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
+import javax.validation.Valid;
import java.util.List;
/**
* This class is used to wrap the BlacklistApplications bean with devices.
*/
@ApiModel(value = "BlacklistApplicationsBeanWrapper",
- description = "Mapping between blacklist application and the device ids.")
+ description = "Mapping between blacklist application and the device ids.")
public class BlacklistApplicationsBeanWrapper {
@ApiModelProperty(name = "operation", value = "Blacklist applications information", required = true)
- private BlacklistApplications operation;
+ @Valid
+ private BlacklistApplications operation;
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
- private List deviceIDs;
+ private List deviceIDs;
- public BlacklistApplications getOperation() {
- return operation;
- }
+ public BlacklistApplications getOperation() {
+ return operation;
+ }
- public void setOperation(BlacklistApplications operation) {
- this.operation = operation;
- }
+ public void setOperation(BlacklistApplications operation) {
+ this.operation = operation;
+ }
- public List getDeviceIDs() {
- return deviceIDs;
- }
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
- public void setDeviceIDs(List deviceIDs) {
- this.deviceIDs = deviceIDs;
- }
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java
new file mode 100644
index 0000000000..b2f77cc31b
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.wso2.carbon.mdm.services.android.bean.wrapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.wso2.carbon.device.mgt.common.Device;
+import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
+
+import java.io.Serializable;
+
+@ApiModel(value = "EnrolmentInfo", description = "This class carries all information related to a devices enrollment" +
+ " status.")
+public class DeviceEnrollmentInfo extends EnrolmentInfo implements Serializable {
+ private static final long serialVersionUID = 1998101712L;
+
+ @ApiModelProperty(name = "device", value = "Enrolled device.", required = true)
+ private Device device;
+ @ApiModelProperty(name = "dateOfEnrolment", value = "Date of the device enrollment.", required = true)
+ private Long dateOfEnrolment;
+ @ApiModelProperty(name = "dateOfLastUpdate", value = "Date of the device's last update.", required = true)
+ private Long dateOfLastUpdate;
+ @ApiModelProperty(name = "ownership", value = "Defines the ownership details. The ownership type can be any of the" +
+ " following values.\n" +
+ "BYOD - Bring your own device (BYOD).\n" +
+ "COPE - Corporate owned personally enabled (COPE).", required = true)
+ private OwnerShip ownership;
+ @ApiModelProperty(name = "status", value = "Current status of the device, such as whether the device " +
+ "is active, removed etc.", required = true)
+ private Status status;
+ @ApiModelProperty(name = "owner", value = "The device owner's name.", required = true)
+ private String owner;
+
+ public DeviceEnrollmentInfo() {
+ }
+
+ public DeviceEnrollmentInfo(Device device, String owner, OwnerShip ownership, Status status) {
+ this.device = device;
+ this.owner = owner;
+ this.ownership = ownership;
+ this.status = status;
+ }
+
+ public Long getDateOfEnrolment() {
+ return dateOfEnrolment;
+ }
+
+ public void setDateOfEnrolment(Long dateOfEnrolment) {
+ this.dateOfEnrolment = dateOfEnrolment;
+ }
+
+ public Long getDateOfLastUpdate() {
+ return dateOfLastUpdate;
+ }
+
+ public void setDateOfLastUpdate(Long dateOfLastUpdate) {
+ this.dateOfLastUpdate = dateOfLastUpdate;
+ }
+
+ public OwnerShip getOwnership() {
+ return ownership;
+ }
+
+ public void setOwnership(OwnerShip ownership) {
+ this.ownership = ownership;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public Device getDevice() {
+ return device;
+ }
+
+ public void setDevice(Device device) {
+ this.device = device;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof DeviceEnrollmentInfo) {
+ DeviceEnrollmentInfo tempInfo = (DeviceEnrollmentInfo) obj;
+ if (this.owner != null && this.ownership != null) {
+ if (this.owner.equals(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return owner.hashCode() ^ ownership.hashCode();
+ }
+
+
+}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java
index d05cb58f8e..c6efc21318 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java
@@ -21,6 +21,9 @@ package org.wso2.carbon.mdm.services.android.bean.wrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
/**
* This class is used to wrap the events which receive from the agent application.
*/
@@ -29,10 +32,13 @@ import io.swagger.annotations.ApiModelProperty;
public class EventBeanWrapper {
@ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true)
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
private String deviceIdentifier;
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
private String payload;
@ApiModelProperty(name = "type", value = "Type of the event.", required = true)
+ @Size(min = 2, max = 20)
private String type;
public String getPayload() {
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java
index bfdbd43da3..e0d1d6bc13 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java
@@ -21,6 +21,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.mdm.services.android.bean.Vpn;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
import java.util.List;
/**
@@ -34,6 +36,8 @@ public class VpnBeanWrapper {
private Vpn operation;
@ApiModelProperty(name = "deviceIDs",
value = "List of device Ids to be need to execute VPN operation.", required = true)
+ @Size(min = 2, max = 45)
+ @Pattern(regexp = "^[A-Za-z0-9]*$")
private List deviceIDs;
public Vpn getOperation() {
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java
index 1c72af45b4..b7ebb2903c 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java
@@ -27,27 +27,27 @@ import java.util.List;
* This class is used to wrap the WipeData bean with devices.
*/
@ApiModel(value = "WipeDataBeanWrapper",
- description = "Mapping between wipe operation and device list to be applied.")
+ description = "Mapping between wipe operation and device list to be applied.")
public class WipeDataBeanWrapper {
@ApiModelProperty(name = "operation", value = "The information of wipedata operation", required = true)
- private WipeData operation;
+ private WipeData operation;
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
- private List deviceIDs;
+ private List deviceIDs;
- public WipeData getOperation() {
- return operation;
- }
+ public WipeData getOperation() {
+ return operation;
+ }
- public void setOperation(WipeData operation) {
- this.operation = operation;
- }
+ public void setOperation(WipeData operation) {
+ this.operation = operation;
+ }
- public List getDeviceIDs() {
- return deviceIDs;
- }
+ public List getDeviceIDs() {
+ return deviceIDs;
+ }
- public void setDeviceIDs(List deviceIDs) {
- this.deviceIDs = deviceIDs;
- }
+ public void setDeviceIDs(List deviceIDs) {
+ this.deviceIDs = deviceIDs;
+ }
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java
index 741f24b313..5fa5ededc6 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java
@@ -19,10 +19,8 @@
package org.wso2.carbon.mdm.services.android.exception;
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
-import org.wso2.carbon.mdm.services.android.util.Message;
import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
@@ -33,5 +31,4 @@ public class BadRequestException extends WebApplicationException {
public BadRequestException(ErrorResponse error) {
super(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
}
-
}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java
new file mode 100644
index 0000000000..ebd5ec8fc9
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.exception;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ErrorDTO {
+
+ private Long code = null;
+ private String message = null;
+ private String description = null;
+
+ public void setMoreInfo(String moreInfo) {
+ this.moreInfo = moreInfo;
+ }
+
+ public void setCode(Long code) {
+ this.code = code;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setError(List error) {
+ this.error = error;
+ }
+
+ private String moreInfo = null;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public Long getCode() {
+ return code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getMoreInfo() {
+ return moreInfo;
+ }
+
+ public List getError() {
+ return error;
+ }
+
+ public String toString() {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("class ErrorDTO {\n");
+ stringBuilder.append(" code: ").append(code).append("\n");
+ stringBuilder.append(" message: ").append(message).append("\n");
+ stringBuilder.append(" description: ").append(description).append("\n");
+ stringBuilder.append(" moreInfo: ").append(moreInfo).append("\n");
+ stringBuilder.append(" error: ").append(error).append("\n");
+ stringBuilder.append("}\n");
+ return stringBuilder.toString();
+ }
+
+ private List error = new ArrayList<>();
+
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java
new file mode 100644
index 0000000000..75113f8501
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.exception;
+
+import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+/**
+ * Exception class that is corresponding to 401 Forbidden response
+ */
+
+public class ForbiddenException extends WebApplicationException {
+
+ private String message;
+
+ public ForbiddenException() {
+ super(Response.status(Response.Status.FORBIDDEN)
+ .build());
+ }
+
+ public ForbiddenException(ErrorDTO errorDTO) {
+ super(Response.status(Response.Status.FORBIDDEN)
+ .entity(errorDTO)
+ .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
+ .build());
+ message = errorDTO.getDescription();
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java
new file mode 100644
index 0000000000..f324a2d0fc
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.exception;
+
+import com.google.gson.JsonParseException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
+
+import javax.naming.AuthenticationException;
+import javax.validation.ConstraintViolationException;
+import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/**
+ * Handle the cxf level exceptions.
+ */
+public class GlobalThrowableMapper implements ExceptionMapper {
+ private static final Log log = LogFactory.getLog(GlobalThrowableMapper.class);
+
+ private ErrorDTO e500 = new ErrorDTO();
+
+ GlobalThrowableMapper() {
+ e500.setCode((long) 500);
+ e500.setMessage("Internal server error.");
+ e500.setMoreInfo("");
+ e500.setDescription("The server encountered an internal error. Please contact administrator.");
+
+ }
+
+ @Override
+ public Response toResponse(Throwable e) {
+
+ if (e instanceof JsonParseException) {
+ String errorMessage = "Malformed request body.";
+ log.error(errorMessage);
+ return AndroidDeviceUtils.buildBadRequestException(errorMessage).getResponse();
+
+ }
+ if (e instanceof NotFoundException) {
+ return ((NotFoundException) e).getResponse();
+ }
+ if (e instanceof ConstraintViolationException) {
+ log.error("Constraint violation", e);
+ return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json")
+ .entity(400l).build();
+ }
+ if (e instanceof UnexpectedServerErrorException) {
+ log.error("Unexpected server error", e);
+ return ((UnexpectedServerErrorException) e).getResponse();
+ }
+ if (e instanceof ConstraintViolationException) {
+ return ((ParameterValidationException) e).getResponse();
+ }
+ if (e instanceof IllegalArgumentException) {
+ log.error("Illegal exception.", e);
+ return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json")
+ .entity(400l).build();
+ }
+ if (e instanceof ClientErrorException) {
+ log.error("Client error", e);
+ return ((ClientErrorException) e).getResponse();
+ }
+ if (e instanceof AuthenticationException) {
+ ErrorDTO errorDetail = new ErrorDTO();
+ errorDetail.setCode((long) 401);
+ errorDetail.setMoreInfo("");
+ errorDetail.setMessage("");
+ errorDetail.setDescription(e.getMessage());
+ return Response
+ .status(Response.Status.UNAUTHORIZED)
+ .entity(errorDetail)
+ .build();
+ }
+ if (e instanceof ForbiddenException) {
+ log.error("Resource forbidden", e);
+ return ((ForbiddenException) e).getResponse();
+ }
+ //unknown exception log and return
+ log.error("An Unknown exception has been captured by global exception mapper.", e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("Content-Type", "application/json")
+ .entity(e500).build();
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java
index bda2219bf5..53863c3acd 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java
@@ -19,15 +19,28 @@
package org.wso2.carbon.mdm.services.android.exception;
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
+import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
+
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
public class NotFoundException extends WebApplicationException {
-
+ private String message;
private static final long serialVersionUID = 147943572342342340L;
public NotFoundException(ErrorResponse error) {
super(Response.status(Response.Status.NOT_FOUND).entity(error).build());
}
+ public NotFoundException(ErrorDTO errorDTO) {
+ super(Response.status(Response.Status.NOT_FOUND)
+ .entity(errorDTO)
+ .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
+ .build());
+ message = errorDTO.getDescription();
+ }
+ @Override
+ public String getMessage() {
+ return message;
+ }
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java
new file mode 100644
index 0000000000..efb38a3d7a
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.exception;
+
+import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
+import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
+
+import javax.validation.ConstraintViolation;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import java.util.Set;
+
+public class ParameterValidationException extends WebApplicationException {
+
+ private String message;
+ public ParameterValidationException(Set> violations) {
+ super(Response.status(Response.Status.BAD_REQUEST)
+ .entity(AndroidDeviceUtils.getConstraintViolationErrorDTO(violations))
+ .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
+ .build());
+
+ //Set the error message
+ StringBuilder stringBuilder = new StringBuilder();
+ for (ConstraintViolation violation : violations) {
+ stringBuilder.append(violation.getRootBeanClass().getSimpleName());
+ stringBuilder.append(".");
+ stringBuilder.append(violation.getPropertyPath());
+ stringBuilder.append(": ");
+ stringBuilder.append(violation.getMessage());
+ stringBuilder.append(", ");
+ }
+ message = stringBuilder.toString();
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java
index 6db5b0e69c..a66c2f506c 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java
@@ -18,18 +18,31 @@
*/
package org.wso2.carbon.mdm.services.android.exception;
-
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
+import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
public class UnexpectedServerErrorException extends WebApplicationException {
-
+ private String message;
private static final long serialVersionUID = 147943579458906890L;
public UnexpectedServerErrorException(ErrorResponse error) {
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
}
+ public UnexpectedServerErrorException(ErrorDTO errorDTO) {
+ super(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
+ .entity(errorDTO)
+ .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
+ .build());
+ message = errorDTO.getDescription();
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ValidationInterceptor.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ValidationInterceptor.java
new file mode 100644
index 0000000000..172a1e5ff0
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ValidationInterceptor.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.carbon.mdm.services.android.exception;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+import javax.validation.*;
+import javax.validation.executable.ExecutableValidator;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+
+public class ValidationInterceptor extends AbstractPhaseInterceptor {
+
+ private Log log = LogFactory.getLog(getClass());
+ private Validator validator = null; //validator interface is thread-safe
+
+ public ValidationInterceptor() {
+ super(Phase.PRE_INVOKE);
+ ValidatorFactory defaultFactory = Validation.buildDefaultValidatorFactory();
+ validator = defaultFactory.getValidator();
+ if (validator == null) {
+ log.warn("Bean Validation provider could not be found, no validation will be performed");
+ } else {
+ log.debug("Validation In-Interceptor initialized successfully");
+ }
+ }
+ @Override
+ public void handleMessage(Message message) throws Fault {
+ final OperationResourceInfo operationResource = message.getExchange().get(OperationResourceInfo.class);
+ if (operationResource == null) {
+ log.info("OperationResourceInfo is not available, skipping validation");
+ return;
+ }
+
+ final ClassResourceInfo classResource = operationResource.getClassResourceInfo();
+ if (classResource == null) {
+ log.info("ClassResourceInfo is not available, skipping validation");
+ return;
+ }
+
+ final ResourceProvider resourceProvider = classResource.getResourceProvider();
+ if (resourceProvider == null) {
+ log.info("ResourceProvider is not available, skipping validation");
+ return;
+ }
+
+ final List