mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
adding validations
This commit is contained in:
parent
8b6fe27cab
commit
4ccf018bb3
@ -205,5 +205,13 @@
|
|||||||
<artifactId>servlet-api</artifactId>
|
<artifactId>servlet-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -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<ConfigurationEntry> configuration;
|
||||||
|
|
||||||
|
public AndroidPlatformConfiguration() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConfigurationEntry> getConfiguration() {
|
||||||
|
return this.configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfiguration(List<ConfigurationEntry> configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,9 +33,13 @@ import java.io.Serializable;
|
|||||||
public class ApplicationInstallation extends AndroidOperation implements Serializable {
|
public class ApplicationInstallation extends AndroidOperation implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(name = "appIdentifier", value = "Application Identifier", required = true)
|
@ApiModelProperty(name = "appIdentifier", value = "Application Identifier", required = true)
|
||||||
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
private String appIdentifier;
|
private String appIdentifier;
|
||||||
|
|
||||||
@ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true)
|
@ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true)
|
||||||
|
@Size(min = 2, max = 12)
|
||||||
|
@Pattern(regexp = "^[A-Za-z]*$")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@ApiModelProperty(name = "url", value = "Application URL", required = true)
|
@ApiModelProperty(name = "url", value = "Application URL", required = true)
|
||||||
|
|||||||
@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,47 +33,52 @@ import java.io.Serializable;
|
|||||||
public class ApplicationUninstallation extends AndroidOperation implements Serializable {
|
public class ApplicationUninstallation extends AndroidOperation implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application to be uninstalled.", required = true)
|
@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 " +
|
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
|
||||||
"are supported: enterprise, public and webapp.", required = true)
|
"are supported: enterprise, public and webapp.", required = true)
|
||||||
private String type;
|
@Size(min = 2, max = 12)
|
||||||
|
@Pattern(regexp = "^[A-Za-z]*$")
|
||||||
|
private String type;
|
||||||
|
|
||||||
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
|
@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)
|
@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() {
|
public String getAppIdentifier() {
|
||||||
return appIdentifier;
|
return appIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAppIdentifier(String appIdentifier) {
|
public void setAppIdentifier(String appIdentifier) {
|
||||||
this.appIdentifier = appIdentifier;
|
this.appIdentifier = appIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(String url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
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 " +
|
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application " +
|
||||||
"to be update.", required = true)
|
"to be update.", required = true)
|
||||||
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
private String appIdentifier;
|
private String appIdentifier;
|
||||||
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
|
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
|
||||||
"are supported: enterprise, public and webapp.", required = true)
|
"are supported: enterprise, public and webapp.", required = true)
|
||||||
|
@Size(min = 2, max = 12)
|
||||||
|
@Pattern(regexp = "^[A-Za-z]*$")
|
||||||
private String type;
|
private String type;
|
||||||
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
|
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
|
||||||
private String url;
|
private String url;
|
||||||
|
|||||||
@ -21,6 +21,8 @@ package org.wso2.carbon.mdm.services.android.bean;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
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.",
|
@ApiModelProperty(name = "appIdentifiers", value = "A list of application package names to be blacklisted.",
|
||||||
required = true)
|
required = true)
|
||||||
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
private List<String> appIdentifiers;
|
private List<String> appIdentifiers;
|
||||||
|
|
||||||
public List<String> getAppIdentifier() {
|
public List<String> getAppIdentifier() {
|
||||||
|
|||||||
@ -34,9 +34,6 @@ public class ErrorResponse {
|
|||||||
private String moreInfo = null;
|
private String moreInfo = null;
|
||||||
private List<ErrorListItem> errorItems = new ArrayList<>();
|
private List<ErrorListItem> errorItems = new ArrayList<>();
|
||||||
|
|
||||||
private ErrorResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty(value = "code")
|
@JsonProperty(value = "code")
|
||||||
@ApiModelProperty(required = true, value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public Long getCode() {
|
public Long getCode() {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.bean;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
import java.io.Serializable;
|
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"
|
+ " 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 "
|
+ " OS when the failed attempts exceed the maximum failed attempts. Android devices will be "
|
||||||
+ "automatically reset to the original factory settings", required = true)
|
+ "automatically reset to the original factory settings", required = true)
|
||||||
|
|
||||||
|
@Max(10)
|
||||||
private int maxFailedAttempts;
|
private int maxFailedAttempts;
|
||||||
@ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the "
|
@ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the "
|
||||||
+ "end-user can enter as his/her passcode", required = true)
|
+ "end-user can enter as his/her passcode", required = true)
|
||||||
|
@Max(15)
|
||||||
private int minLength;
|
private int minLength;
|
||||||
@ApiModelProperty(name = "pinHistory", value = "The end-user will not be allowed to reuse a passcode that"
|
@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)
|
+ " he/she previously entered until he/she exceeds the set pin history length", required = true)
|
||||||
|
@Max(50)
|
||||||
private int pinHistory;
|
private int pinHistory;
|
||||||
@ApiModelProperty(name = "minComplexChars", value = "The minimum number of special characters that the "
|
@ApiModelProperty(name = "minComplexChars", value = "The minimum number of special characters that the "
|
||||||
+ "end-user will have to enter in his/her passcode", required = true)
|
+ "end-user will have to enter in his/her passcode", required = true)
|
||||||
|
@Max(5)
|
||||||
private int minComplexChars;
|
private int minComplexChars;
|
||||||
@ApiModelProperty(name = "maxPINAgeInDays", value = "The number of days after which the device owner has"
|
@ApiModelProperty(name = "maxPINAgeInDays", value = "The number of days after which the device owner has"
|
||||||
+ " to change his/her passcode", required = true)
|
+ " to change his/her passcode", required = true)
|
||||||
|
@Max(730)
|
||||||
private int maxPINAgeInDays;
|
private int maxPINAgeInDays;
|
||||||
@ApiModelProperty(name = "requireAlphanumeric", value = "Whether or not it is mandatory for the end-user"
|
@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)
|
+ " to have a mix of digits and characters in his/her passcode", required = true)
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<Feature> features;
|
||||||
|
private List<Device.Property> 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<Application> applications;
|
||||||
|
|
||||||
|
public AndroidDevice() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AndroidDevice(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo, List<Feature> features, List<Device.Property> 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<Feature> getFeatures() {
|
||||||
|
return this.features;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeatures(List<Feature> features) {
|
||||||
|
this.features = features;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Device.Property> getProperties() {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(List<Device.Property> properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceInfo getDeviceInfo() {
|
||||||
|
return this.deviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceInfo(DeviceInfo deviceInfo) {
|
||||||
|
this.deviceInfo = deviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Application> getApplications() {
|
||||||
|
return this.applications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplications(List<Application> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<String, String> 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<String, String> deviceDetailsMap) {
|
||||||
|
this.deviceDetailsMap = deviceDetailsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getDeviceDetailsMap() {
|
||||||
|
return this.deviceDetailsMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,7 +33,6 @@ public class ApplicationInstallationBeanWrapper {
|
|||||||
|
|
||||||
@ApiModelProperty(name = "deviceIDs", value = "List of Devices", required = true)
|
@ApiModelProperty(name = "deviceIDs", value = "List of Devices", required = true)
|
||||||
private List<String> deviceIDs;
|
private List<String> deviceIDs;
|
||||||
|
|
||||||
@ApiModelProperty(name = "operation", value = "App Installation property", required = true)
|
@ApiModelProperty(name = "operation", value = "App Installation property", required = true)
|
||||||
private ApplicationInstallation operation;
|
private ApplicationInstallation operation;
|
||||||
|
|
||||||
|
|||||||
@ -27,28 +27,28 @@ import java.util.List;
|
|||||||
* This class is used to wrap the UninstallApplication bean with devices.
|
* This class is used to wrap the UninstallApplication bean with devices.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "ApplicationUninstallationBeanWrapper",
|
@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 {
|
public class ApplicationUninstallationBeanWrapper {
|
||||||
|
|
||||||
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||||
private List<String> deviceIDs;
|
private List<String> deviceIDs;
|
||||||
|
|
||||||
@ApiModelProperty(name = "operation", value = "Name of the device", required = true)
|
@ApiModelProperty(name = "operation", value = "Name of the device", required = true)
|
||||||
private ApplicationUninstallation operation;
|
private ApplicationUninstallation operation;
|
||||||
|
|
||||||
public List<String> getDeviceIDs() {
|
public List<String> getDeviceIDs() {
|
||||||
return deviceIDs;
|
return deviceIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceIDs(List<String> deviceIDs) {
|
public void setDeviceIDs(List<String> deviceIDs) {
|
||||||
this.deviceIDs = deviceIDs;
|
this.deviceIDs = deviceIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationUninstallation getOperation() {
|
public ApplicationUninstallation getOperation() {
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOperation(ApplicationUninstallation operation) {
|
public void setOperation(ApplicationUninstallation operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,33 +21,35 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
|
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to wrap the BlacklistApplications bean with devices.
|
* This class is used to wrap the BlacklistApplications bean with devices.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "BlacklistApplicationsBeanWrapper",
|
@ApiModel(value = "BlacklistApplicationsBeanWrapper",
|
||||||
description = "Mapping between blacklist application and the device ids.")
|
description = "Mapping between blacklist application and the device ids.")
|
||||||
public class BlacklistApplicationsBeanWrapper {
|
public class BlacklistApplicationsBeanWrapper {
|
||||||
|
|
||||||
@ApiModelProperty(name = "operation", value = "Blacklist applications information", required = true)
|
@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)
|
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||||
private List<String> deviceIDs;
|
private List<String> deviceIDs;
|
||||||
|
|
||||||
public BlacklistApplications getOperation() {
|
public BlacklistApplications getOperation() {
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOperation(BlacklistApplications operation) {
|
public void setOperation(BlacklistApplications operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getDeviceIDs() {
|
public List<String> getDeviceIDs() {
|
||||||
return deviceIDs;
|
return deviceIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceIDs(List<String> deviceIDs) {
|
public void setDeviceIDs(List<String> deviceIDs) {
|
||||||
this.deviceIDs = deviceIDs;
|
this.deviceIDs = deviceIDs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -21,6 +21,9 @@ package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
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.
|
* 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 {
|
public class EventBeanWrapper {
|
||||||
|
|
||||||
@ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true)
|
@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;
|
private String deviceIdentifier;
|
||||||
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
|
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
|
||||||
private String payload;
|
private String payload;
|
||||||
@ApiModelProperty(name = "type", value = "Type of the event.", required = true)
|
@ApiModelProperty(name = "type", value = "Type of the event.", required = true)
|
||||||
|
@Size(min = 2, max = 20)
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
public String getPayload() {
|
public String getPayload() {
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.Vpn;
|
import org.wso2.carbon.mdm.services.android.bean.Vpn;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +36,8 @@ public class VpnBeanWrapper {
|
|||||||
private Vpn operation;
|
private Vpn operation;
|
||||||
@ApiModelProperty(name = "deviceIDs",
|
@ApiModelProperty(name = "deviceIDs",
|
||||||
value = "List of device Ids to be need to execute VPN operation.", required = true)
|
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<String> deviceIDs;
|
private List<String> deviceIDs;
|
||||||
|
|
||||||
public Vpn getOperation() {
|
public Vpn getOperation() {
|
||||||
|
|||||||
@ -27,27 +27,27 @@ import java.util.List;
|
|||||||
* This class is used to wrap the WipeData bean with devices.
|
* This class is used to wrap the WipeData bean with devices.
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "WipeDataBeanWrapper",
|
@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 {
|
public class WipeDataBeanWrapper {
|
||||||
|
|
||||||
@ApiModelProperty(name = "operation", value = "The information of wipedata operation", required = true)
|
@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)
|
@ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true)
|
||||||
private List<String> deviceIDs;
|
private List<String> deviceIDs;
|
||||||
|
|
||||||
public WipeData getOperation() {
|
public WipeData getOperation() {
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOperation(WipeData operation) {
|
public void setOperation(WipeData operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getDeviceIDs() {
|
public List<String> getDeviceIDs() {
|
||||||
return deviceIDs;
|
return deviceIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceIDs(List<String> deviceIDs) {
|
public void setDeviceIDs(List<String> deviceIDs) {
|
||||||
this.deviceIDs = deviceIDs;
|
this.deviceIDs = deviceIDs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,8 @@
|
|||||||
package org.wso2.carbon.mdm.services.android.exception;
|
package org.wso2.carbon.mdm.services.android.exception;
|
||||||
|
|
||||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
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.WebApplicationException;
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,5 +31,4 @@ public class BadRequestException extends WebApplicationException {
|
|||||||
public BadRequestException(ErrorResponse error) {
|
public BadRequestException(ErrorResponse error) {
|
||||||
super(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
|
super(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -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<ErrorDTO> 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<ErrorDTO> 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<ErrorDTO> error = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,15 +19,28 @@
|
|||||||
package org.wso2.carbon.mdm.services.android.exception;
|
package org.wso2.carbon.mdm.services.android.exception;
|
||||||
|
|
||||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
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.WebApplicationException;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
public class NotFoundException extends WebApplicationException {
|
public class NotFoundException extends WebApplicationException {
|
||||||
|
private String message;
|
||||||
private static final long serialVersionUID = 147943572342342340L;
|
private static final long serialVersionUID = 147943572342342340L;
|
||||||
|
|
||||||
public NotFoundException(ErrorResponse error) {
|
public NotFoundException(ErrorResponse error) {
|
||||||
super(Response.status(Response.Status.NOT_FOUND).entity(error).build());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 <T> ParameterValidationException(Set<ConstraintViolation<T>> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,18 +18,31 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.mdm.services.android.exception;
|
package org.wso2.carbon.mdm.services.android.exception;
|
||||||
|
|
||||||
|
|
||||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
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.WebApplicationException;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
public class UnexpectedServerErrorException extends WebApplicationException {
|
public class UnexpectedServerErrorException extends WebApplicationException {
|
||||||
|
private String message;
|
||||||
private static final long serialVersionUID = 147943579458906890L;
|
private static final long serialVersionUID = 147943579458906890L;
|
||||||
|
|
||||||
public UnexpectedServerErrorException(ErrorResponse error) {
|
public UnexpectedServerErrorException(ErrorResponse error) {
|
||||||
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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<Message> {
|
||||||
|
|
||||||
|
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<Object> arguments = MessageContentsList.getContentsList(message);
|
||||||
|
final Method method = operationResource.getAnnotatedMethod();
|
||||||
|
final Object instance = resourceProvider.getInstance(message);
|
||||||
|
if (method != null && arguments != null) {
|
||||||
|
//validate the parameters(arguments) over the invoked method
|
||||||
|
validate(method, arguments.toArray(), instance);
|
||||||
|
|
||||||
|
//validate the fields of each argument
|
||||||
|
for (Object arg : arguments) {
|
||||||
|
if (arg != null)
|
||||||
|
validate(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public <T> void validate(final Method method, final Object[] arguments, final T instance) {
|
||||||
|
if (validator == null) {
|
||||||
|
log.warn("Bean Validation provider could not be found, no validation will be performed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExecutableValidator methodValidator = validator.forExecutables();
|
||||||
|
Set<ConstraintViolation<T>> violations = methodValidator.validateParameters(instance,
|
||||||
|
method, arguments);
|
||||||
|
|
||||||
|
if (!violations.isEmpty()) {
|
||||||
|
throw new ConstraintViolationException(violations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void validate(final T object) {
|
||||||
|
if (validator == null) {
|
||||||
|
log.warn("Bean Validation provider could be found, no validation will be performed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<ConstraintViolation<T>> violations = validator.validate(object);
|
||||||
|
|
||||||
|
if (!violations.isEmpty()) {
|
||||||
|
throw new ConstraintViolationException(violations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleFault(Message messageParam) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,6 +22,7 @@ import io.swagger.annotations.*;
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -244,7 +245,7 @@ public interface DeviceManagementAdminService {
|
|||||||
})
|
})
|
||||||
Response removePassword(
|
Response removePassword(
|
||||||
@ApiParam(name = "deviceIDs",
|
@ApiParam(name = "deviceIDs",
|
||||||
value = "DeviceIds to be requested to remove password") List<String> deviceIDs);
|
value = "DeviceIds to be requested to remove password") List<String> deviceIDs);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/control-camera")
|
@Path("/control-camera")
|
||||||
@ -562,7 +563,8 @@ public interface DeviceManagementAdminService {
|
|||||||
"Server error occurred while adding a new device ring operation.")
|
"Server error occurred while adding a new device ring operation.")
|
||||||
})
|
})
|
||||||
Response ringDevice(
|
Response ringDevice(
|
||||||
@ApiParam(name = "deviceIDs", value = "Device Ids needed for ring") List<String> deviceIDs);
|
@ApiParam(name = "deviceIDs", value = "Device Ids needed for ring")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/reboot")
|
@Path("/reboot")
|
||||||
@ -613,7 +615,8 @@ public interface DeviceManagementAdminService {
|
|||||||
"Server error occurred while adding a new device reboot operation.")
|
"Server error occurred while adding a new device reboot operation.")
|
||||||
})
|
})
|
||||||
Response rebootDevice(
|
Response rebootDevice(
|
||||||
@ApiParam(name = "deviceIDs", value = "Device Ids needed for reboot.") List<String> deviceIDs);
|
@ApiParam(name = "deviceIDs", value = "Device Ids needed for reboot.")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
@ -664,7 +667,8 @@ public interface DeviceManagementAdminService {
|
|||||||
})
|
})
|
||||||
@Path("/mute")
|
@Path("/mute")
|
||||||
Response muteDevice(
|
Response muteDevice(
|
||||||
@ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List<String> deviceIDs);
|
@ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/install-application")
|
@Path("/install-application")
|
||||||
@ -1094,7 +1098,7 @@ public interface DeviceManagementAdminService {
|
|||||||
})
|
})
|
||||||
Response configureWifi(
|
Response configureWifi(
|
||||||
@ApiParam(name = "wifiBeanWrapper",
|
@ApiParam(name = "wifiBeanWrapper",
|
||||||
value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper);
|
value = "WifiConfigurations and Device Ids") @Valid WifiBeanWrapper wifiBeanWrapper);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/encrypt-storage")
|
@Path("/encrypt-storage")
|
||||||
|
|||||||
@ -19,10 +19,14 @@
|
|||||||
package org.wso2.carbon.mdm.services.android.services;
|
package org.wso2.carbon.mdm.services.android.services;
|
||||||
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -81,11 +85,15 @@ public interface DeviceManagementService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "id",
|
name = "id",
|
||||||
value = "Device Identifier")
|
value = "Device Identifier")
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 2 , max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
@PathParam("id") String id,
|
@PathParam("id") String id,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "applications",
|
name = "applications",
|
||||||
value = "List of applications that need to be persisted against the device")
|
value = "List of applications that need to be persisted against the device")
|
||||||
List<Application> applications);
|
@Valid
|
||||||
|
List<AndroidApplication> androidApplications);
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{id}/pending-operations")
|
@Path("/{id}/pending-operations")
|
||||||
@ -191,7 +199,8 @@ public interface DeviceManagementService {
|
|||||||
message = "Internal Server Error. \n " +
|
message = "Internal Server Error. \n " +
|
||||||
"Server error occurred while adding a new policy.")
|
"Server error occurred while adding a new policy.")
|
||||||
})
|
})
|
||||||
Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") Device device);
|
Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll")
|
||||||
|
@Valid AndroidDevice device);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{id}/status")
|
@Path("/{id}/status")
|
||||||
@ -285,10 +294,13 @@ public interface DeviceManagementService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "id",
|
name = "id",
|
||||||
value = "Device Identifier")
|
value = "Device Identifier")
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 2 , max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
@PathParam("id") String id,
|
@PathParam("id") String id,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "device",
|
name = "device",
|
||||||
value = "Device information to be modify") Device device);
|
value = "Device information to be modify") @Valid AndroidDevice androidDevice);
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{id}")
|
@Path("/{id}")
|
||||||
@ -314,6 +326,9 @@ public interface DeviceManagementService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "id",
|
name = "id",
|
||||||
value = "Device Identifier")
|
value = "Device Identifier")
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 2 , max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
@PathParam("id") String id);
|
@PathParam("id") String id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ package org.wso2.carbon.mdm.services.android.services;
|
|||||||
|
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration;
|
||||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -125,7 +126,7 @@ public interface DeviceTypeConfigurationService {
|
|||||||
Response updateConfiguration(
|
Response updateConfiguration(
|
||||||
@ApiParam(name = "configuration",
|
@ApiParam(name = "configuration",
|
||||||
value = "AndroidPlatformConfiguration")
|
value = "AndroidPlatformConfiguration")
|
||||||
PlatformConfiguration configuration);
|
AndroidPlatformConfiguration androidPlatformConfiguration);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("license")
|
@Path("license")
|
||||||
|
|||||||
@ -22,6 +22,9 @@ import io.swagger.annotations.*;
|
|||||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -86,6 +89,7 @@ public interface EventReceiverService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "eventBeanWrapper",
|
name = "eventBeanWrapper",
|
||||||
value = "Information of the agent event to be published on DAS.")
|
value = "Information of the agent event to be published on DAS.")
|
||||||
|
@Valid
|
||||||
EventBeanWrapper eventBeanWrapper);
|
EventBeanWrapper eventBeanWrapper);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -130,11 +134,14 @@ public interface EventReceiverService {
|
|||||||
code = 500,
|
code = 500,
|
||||||
message = "Error occurred while getting published events for specific device.")
|
message = "Error occurred while getting published events for specific device.")
|
||||||
})
|
})
|
||||||
|
|
||||||
Response retrieveAlerts(
|
Response retrieveAlerts(
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "id",
|
name = "id",
|
||||||
value = "Device Identifier to be need to retrieve events.",
|
value = "Device Identifier to be need to retrieve events.",
|
||||||
required = true)
|
required = true)
|
||||||
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
@QueryParam("id") String deviceId,
|
@QueryParam("id") String deviceId,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "from",
|
name = "from",
|
||||||
@ -147,6 +154,8 @@ public interface EventReceiverService {
|
|||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "type",
|
name = "type",
|
||||||
value = "Type of the Alert to be need to retrieve events.")
|
value = "Type of the Alert to be need to retrieve events.")
|
||||||
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
@QueryParam("type") String type,
|
@QueryParam("type") String type,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "If-Modified-Since",
|
name = "If-Modified-Since",
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminServic
|
|||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -568,7 +569,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
|||||||
@POST
|
@POST
|
||||||
@Path("/configure-vpn")
|
@Path("/configure-vpn")
|
||||||
@Override
|
@Override
|
||||||
public Response configureVPN(VpnBeanWrapper vpnBeanWrapper) {
|
public Response configureVPN(@Valid VpnBeanWrapper vpnBeanWrapper) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Invoking Android VPN device operation");
|
log.debug("Invoking Android VPN device operation");
|
||||||
}
|
}
|
||||||
@ -792,7 +793,6 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) {
|
if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) {
|
||||||
String errorMessage = "The payload of the add webclip operation is incorrect";
|
String errorMessage = "The payload of the add webclip operation is incorrect";
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
|
|||||||
@ -30,6 +30,8 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice;
|
||||||
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
||||||
import org.wso2.carbon.mdm.services.android.services.DeviceManagementService;
|
import org.wso2.carbon.mdm.services.android.services.DeviceManagementService;
|
||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
@ -40,9 +42,14 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Path("/devices")
|
@Path("/devices")
|
||||||
@ -56,7 +63,27 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
@PUT
|
@PUT
|
||||||
@Path("/{id}/applications")
|
@Path("/{id}/applications")
|
||||||
@Override
|
@Override
|
||||||
public Response updateApplicationList(@PathParam("id") String id, List<Application> applications) {
|
public Response updateApplicationList(@PathParam("id")
|
||||||
|
@NotNull
|
||||||
|
@Size(min = 2 , max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
|
String id,@Valid List<AndroidApplication> androidApplications) {
|
||||||
|
Application application;
|
||||||
|
List<Application> applications = new ArrayList<>();
|
||||||
|
for (AndroidApplication androidApplication : androidApplications) {
|
||||||
|
application = new Application();
|
||||||
|
application.setPlatform(androidApplication.getPlatform());
|
||||||
|
application.setCategory(androidApplication.getCategory());
|
||||||
|
application.setName(androidApplication.getName());
|
||||||
|
application.setLocationUrl(androidApplication.getLocationUrl());
|
||||||
|
application.setImageUrl(androidApplication.getImageUrl());
|
||||||
|
application.setVersion(androidApplication.getVersion());
|
||||||
|
application.setType(androidApplication.getType());
|
||||||
|
application.setAppProperties(androidApplication.getAppProperties());
|
||||||
|
application.setApplicationIdentifier(androidApplication.getApplicationIdentifier());
|
||||||
|
application.setMemoryUsage(androidApplication.getMemoryUsage());
|
||||||
|
applications.add(application);
|
||||||
|
}
|
||||||
Message responseMessage = new Message();
|
Message responseMessage = new Message();
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
deviceIdentifier.setId(id);
|
deviceIdentifier.setId(id);
|
||||||
@ -164,32 +191,42 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Override
|
@Override
|
||||||
public Response enrollDevice(Device device) {
|
public Response enrollDevice(@Valid AndroidDevice androidDevice) {
|
||||||
try {
|
try {
|
||||||
|
Device device = new Device();
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
device.setEnrolmentInfo(androidDevice.getEnrolmentInfo());
|
||||||
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||||
|
device.setDeviceInfo(androidDevice.getDeviceInfo());
|
||||||
|
device.setDeviceIdentifier(androidDevice.getDeviceIdentifier());
|
||||||
|
device.setDescription(androidDevice.getDescription());
|
||||||
|
device.setType(androidDevice.getType());
|
||||||
|
device.setName(androidDevice.getName());
|
||||||
|
device.setFeatures(androidDevice.getFeatures());
|
||||||
|
device.setProperties(androidDevice.getProperties());
|
||||||
|
|
||||||
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||||
|
|
||||||
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
||||||
policyManagerService.getEffectivePolicy(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
policyManagerService.getEffectivePolicy(new DeviceIdentifier(androidDevice.getDeviceIdentifier(), androidDevice.getType()));
|
||||||
if (status) {
|
if (status) {
|
||||||
return Response.status(Response.Status.OK).entity("Android device, which carries the id '" +
|
return Response.status(Response.Status.OK).entity("Android device, which carries the id '" +
|
||||||
device.getDeviceIdentifier() + "' has successfully been enrolled").build();
|
androidDevice.getDeviceIdentifier() + "' has successfully been enrolled").build();
|
||||||
} else {
|
} else {
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to enroll '" +
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to enroll '" +
|
||||||
device.getType() + "' device, which carries the id '" +
|
androidDevice.getType() + "' device, which carries the id '" +
|
||||||
device.getDeviceIdentifier() + "'").build();
|
androidDevice.getDeviceIdentifier() + "'").build();
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while enrolling the '" + device.getType() + "', which carries the id '" +
|
String msg = "Error occurred while enrolling the '" + androidDevice.getType() + "', which carries the id '" +
|
||||||
device.getDeviceIdentifier() + "'";
|
androidDevice.getDeviceIdentifier() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
} catch (PolicyManagementException e) {
|
} catch (PolicyManagementException e) {
|
||||||
String msg = "Error occurred while enforcing default enrollment policy upon '" + device.getType() +
|
String msg = "Error occurred while enforcing default enrollment policy upon '" + androidDevice.getType() +
|
||||||
"', which carries the id '" +
|
"', which carries the id '" +
|
||||||
device.getDeviceIdentifier() + "'";
|
androidDevice.getDeviceIdentifier() + "'";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
@ -222,7 +259,18 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
@PUT
|
@PUT
|
||||||
@Path("/{id}")
|
@Path("/{id}")
|
||||||
@Override
|
@Override
|
||||||
public Response modifyEnrollment(@PathParam("id") String id, Device device) {
|
public Response modifyEnrollment(@PathParam("id") String id, AndroidDevice androidDevice) {
|
||||||
|
Device device = new Device();
|
||||||
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
device.setEnrolmentInfo(androidDevice.getEnrolmentInfo());
|
||||||
|
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||||
|
device.setDeviceInfo(androidDevice.getDeviceInfo());
|
||||||
|
device.setDeviceIdentifier(androidDevice.getDeviceIdentifier());
|
||||||
|
device.setDescription(androidDevice.getDescription());
|
||||||
|
device.setType(androidDevice.getType());
|
||||||
|
device.setName(androidDevice.getName());
|
||||||
|
device.setFeatures(androidDevice.getFeatures());
|
||||||
|
device.setProperties(androidDevice.getProperties());
|
||||||
boolean result;
|
boolean result;
|
||||||
try {
|
try {
|
||||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException;
|
||||||
import org.wso2.carbon.mdm.services.android.services.DeviceTypeConfigurationService;
|
import org.wso2.carbon.mdm.services.android.services.DeviceTypeConfigurationService;
|
||||||
@ -32,6 +33,7 @@ import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
|||||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -84,10 +86,12 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Override
|
@Override
|
||||||
public Response updateConfiguration(PlatformConfiguration configuration) {
|
public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) {
|
||||||
String msg;
|
String msg;
|
||||||
Message responseMsg = new Message();
|
Message responseMsg = new Message();
|
||||||
ConfigurationEntry licenseEntry = null;
|
ConfigurationEntry licenseEntry = null;
|
||||||
|
PlatformConfiguration configuration = new PlatformConfiguration();
|
||||||
|
configuration.setConfiguration(androidPlatformConfiguration.getConfiguration());
|
||||||
try {
|
try {
|
||||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
||||||
|
|||||||
@ -32,6 +32,9 @@ import org.wso2.carbon.mdm.services.android.services.EventReceiverService;
|
|||||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -45,7 +48,7 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
|||||||
@POST
|
@POST
|
||||||
@Path("/publish")
|
@Path("/publish")
|
||||||
@Override
|
@Override
|
||||||
public Response publishEvents(EventBeanWrapper eventBeanWrapper) {
|
public Response publishEvents(@Valid EventBeanWrapper eventBeanWrapper) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Invoking Android device even logging.");
|
log.debug("Invoking Android device even logging.");
|
||||||
}
|
}
|
||||||
@ -73,8 +76,14 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Override
|
@Override
|
||||||
public Response retrieveAlerts(@QueryParam("id") String deviceId, @QueryParam("from") long from,
|
public Response retrieveAlerts(@QueryParam("id")
|
||||||
@QueryParam("to") long to, @QueryParam("type") String type,
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$") String deviceId,
|
||||||
|
@QueryParam("from") long from,
|
||||||
|
@QueryParam("to") long to,
|
||||||
|
@Size(min = 2, max = 45)
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]*$")
|
||||||
|
@QueryParam("type") String type,
|
||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
|
|
||||||
if (from != 0l && to != 0l && deviceId != null) {
|
if (from != 0l && to != 0l && deviceId != null) {
|
||||||
|
|||||||
@ -24,6 +24,8 @@ package org.wso2.carbon.mdm.services.android.util;
|
|||||||
public final class AndroidConstants {
|
public final class AndroidConstants {
|
||||||
|
|
||||||
public static final String DEVICE_TYPE_ANDROID = "android";
|
public static final String DEVICE_TYPE_ANDROID = "android";
|
||||||
|
public static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||||
|
public static final String APPLICATION_JSON = "application/json";
|
||||||
|
|
||||||
public final class DeviceProperties {
|
public final class DeviceProperties {
|
||||||
private DeviceProperties() {
|
private DeviceProperties() {
|
||||||
@ -130,4 +132,11 @@ public final class AndroidConstants {
|
|||||||
public static final String ICON = "icon";
|
public static final String ICON = "icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class ErrorMessages {
|
||||||
|
private ErrorMessages () { throw new AssertionError(); }
|
||||||
|
|
||||||
|
public static final String STATUS_BAD_REQUEST_MESSAGE_DEFAULT = "Bad Request";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,14 @@ package org.wso2.carbon.mdm.services.android.util;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.wso2.carbon.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorListItem;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Util class for holding Android device related util methods.
|
* Util class for holding Android device related util methods.
|
||||||
@ -86,4 +92,50 @@ public class AndroidDeviceUtils {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new BadRequestException
|
||||||
|
*
|
||||||
|
* @param description description of the exception
|
||||||
|
* @return a new BadRequestException with the specified details as a response DTO
|
||||||
|
*/
|
||||||
|
public static BadRequestException buildBadRequestException(String description) {
|
||||||
|
ErrorResponse errorResponse = getErrorResponse(AndroidConstants.
|
||||||
|
ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT,400l, description);
|
||||||
|
return new BadRequestException(errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns generic ErrorResponse.
|
||||||
|
* @param message specific error message
|
||||||
|
* @param code
|
||||||
|
* @param description
|
||||||
|
* @return generic Response with error specific details.
|
||||||
|
*/
|
||||||
|
public static ErrorResponse getErrorResponse(String message, Long code, String description) {
|
||||||
|
ErrorResponse errorResponse = new ErrorResponse();
|
||||||
|
errorResponse.setCode(code);
|
||||||
|
errorResponse.setMoreInfo("");
|
||||||
|
errorResponse.setMessage(message);
|
||||||
|
errorResponse.setDescription(description);
|
||||||
|
return errorResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> ErrorResponse getConstraintViolationErrorDTO(Set<ConstraintViolation<T>> violations) {
|
||||||
|
ErrorResponse errorResponse = new ErrorResponse();
|
||||||
|
errorResponse.setDescription("Validation Error");
|
||||||
|
errorResponse.setMessage("Bad Request");
|
||||||
|
errorResponse.setCode(400l);
|
||||||
|
errorResponse.setMoreInfo("");
|
||||||
|
List<ErrorListItem> errorListItems = new ArrayList<>();
|
||||||
|
for (ConstraintViolation violation : violations) {
|
||||||
|
ErrorListItem errorListItemDTO = new ErrorListItem();
|
||||||
|
errorListItemDTO.setCode(400 + "_" + violation.getPropertyPath());
|
||||||
|
errorListItemDTO.setMessage(violation.getPropertyPath() + ": " + violation.getMessage());
|
||||||
|
errorListItems.add(errorListItemDTO);
|
||||||
|
}
|
||||||
|
errorResponse.setErrorItems(errorListItems);
|
||||||
|
return errorResponse;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,11 +18,9 @@
|
|||||||
-->
|
-->
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
|
||||||
xsi:schemaLocation="
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
|
||||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
|
||||||
|
|
||||||
<jaxrs:server id="services" address="/">
|
<jaxrs:server id="services" address="/">
|
||||||
<jaxrs:serviceBeans>
|
<jaxrs:serviceBeans>
|
||||||
<ref bean="deviceManagementService"/>
|
<ref bean="deviceManagementService"/>
|
||||||
@ -35,11 +33,18 @@
|
|||||||
<ref bean="jsonProvider"/>
|
<ref bean="jsonProvider"/>
|
||||||
<ref bean="errorHandler"/>
|
<ref bean="errorHandler"/>
|
||||||
<ref bean="swaggerWriter"/>
|
<ref bean="swaggerWriter"/>
|
||||||
|
<ref bean="GlobalExceptionMapper"/>
|
||||||
</jaxrs:providers>
|
</jaxrs:providers>
|
||||||
|
<jaxrs:properties>
|
||||||
|
<!-- This is added to catch interceptor level exceptions in GlobalThrowableMapper. -->
|
||||||
|
<entry key="map.cxf.interceptor.fault" value="true" />
|
||||||
|
</jaxrs:properties>
|
||||||
</jaxrs:server>
|
</jaxrs:server>
|
||||||
|
|
||||||
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
|
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
|
||||||
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
|
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
|
||||||
|
<bean id="GlobalExceptionMapper" class="org.wso2.carbon.mdm.services.android.exception.GlobalThrowableMapper"/>
|
||||||
|
<bean id="ValidationInterceptor" class="org.wso2.carbon.mdm.services.android.exception.ValidationInterceptor"/>
|
||||||
|
|
||||||
<bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
|
<bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
|
||||||
<property name="resourcePackage" value="org.wso2.carbon.mdm.services.android.services"/>
|
<property name="resourcePackage" value="org.wso2.carbon.mdm.services.android.services"/>
|
||||||
@ -60,5 +65,10 @@
|
|||||||
<bean id="deviceTypeConfigurationService" class="org.wso2.carbon.mdm.services.android.services.impl.DeviceTypeConfigurationServiceImpl"/>
|
<bean id="deviceTypeConfigurationService" class="org.wso2.carbon.mdm.services.android.services.impl.DeviceTypeConfigurationServiceImpl"/>
|
||||||
<bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/>
|
<bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/>
|
||||||
<bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
|
<bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
|
||||||
|
<cxf:bus>
|
||||||
|
<cxf:inInterceptors>
|
||||||
|
<ref bean="ValidationInterceptor"/>
|
||||||
|
</cxf:inInterceptors>
|
||||||
|
</cxf:bus>
|
||||||
</beans>
|
</beans>
|
||||||
|
|
||||||
|
|||||||
7
pom.xml
7
pom.xml
@ -1062,6 +1062,11 @@
|
|||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
<version>${javax.version}</version>
|
<version>${javax.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<version>${hibernate-validator.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@ -1204,6 +1209,8 @@
|
|||||||
<project.scm.id>github-scm</project.scm.id>
|
<project.scm.id>github-scm</project.scm.id>
|
||||||
|
|
||||||
<servlet-api.version>2.5</servlet-api.version>
|
<servlet-api.version>2.5</servlet-api.version>
|
||||||
|
|
||||||
|
<hibernate-validator.version>5.0.2.Final</hibernate-validator.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user