diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/pom.xml new file mode 100644 index 000000000..06b18a00d --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/pom.xml @@ -0,0 +1,101 @@ + + + + + + android-plugin + org.wso2.carbon.devicemgt-plugins + 5.0.7-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.android.addons + bundle + WSO2 Carbon - Mobile Device Management Android Addons Impl + WSO2 Carbon - Mobile Device Management Android Addons Implementation + https://entgra.io/ + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.devicemgt.plugins.version} + Device Management Mobile Android addons Impl Bundle + + com.google.gson.* + + + org.wso2.carbon.device.mgt.mobile.android.addons.* + + + + + + + + + + javax.servlet + servlet-api + provided + + + org.apache.cxf + cxf-rt-frontend-jaxws + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-transports-http + provided + + + org.hibernate + hibernate-validator + + + org.wso2.carbon + org.wso2.carbon.logging + + + com.google.code.gson + gson + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidAgentException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/AndroidAgentException.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidAgentException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/AndroidAgentException.java index c12d03538..681c39f68 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidAgentException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/AndroidAgentException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.exception; +package org.wso2.carbon.device.mgt.mobile.android.addons; /** * diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/ApiOriginFilter.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ApiOriginFilter.java similarity index 84% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/ApiOriginFilter.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ApiOriginFilter.java index 455d582bb..e9c4c69da 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/ApiOriginFilter.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ApiOriginFilter.java @@ -16,9 +16,14 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.addons; -import javax.servlet.*; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletResponse; import java.io.IOException; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ErrorHandler.java similarity index 90% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ErrorHandler.java index 542cd6078..1023bdef2 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ErrorHandler.java @@ -15,9 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.common; - -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; +package org.wso2.carbon.device.mgt.mobile.android.addons; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ErrorMessage.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ErrorMessage.java index fd880c04c..a27c9b5ad 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ErrorMessage.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.common; +package org.wso2.carbon.device.mgt.mobile.android.addons; public class ErrorMessage { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/GsonMessageBodyHandler.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/GsonMessageBodyHandler.java index 297630029..bd6b7931f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/GsonMessageBodyHandler.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.common; +package org.wso2.carbon.device.mgt.mobile.android.addons; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ValidationInterceptor.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ValidationInterceptor.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ValidationInterceptor.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ValidationInterceptor.java index a563f09d1..adc298e18 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ValidationInterceptor.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.addons/src/main/java/org/wso2/carbon/device/mgt/mobile/android/addons/ValidationInterceptor.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.common; +package org.wso2.carbon.device.mgt.mobile.android.addons; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,7 +29,11 @@ import org.apache.cxf.message.MessageContentsList; import org.apache.cxf.phase.AbstractPhaseInterceptor; import org.apache.cxf.phase.Phase; -import javax.validation.*; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; import javax.validation.executable.ExecutableValidator; import java.lang.reflect.Method; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 7610952c3..589cbba98 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -49,44 +49,6 @@ api#device-mgt#android#v1.0 - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - @@ -99,7 +61,7 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 + 1.8 compile @@ -118,54 +80,6 @@ - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - - - - - client - - test - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - test - - java - - - - @@ -176,6 +90,32 @@ org.apache.cxf cxf-rt-frontend-jaxws + + + asm + asm + + + neethi + org.apache.neethi + + + wsdl4j + wsdl4j + + + xml-resolver + xml-resolver + + + xmlschema-core + org.apache.ws.xmlschema + + + stax2-api + org.codehaus.woodstox + + org.apache.cxf @@ -194,6 +134,12 @@ org.wso2.carbon org.wso2.carbon.utils provided + + + commons-lang + commons-lang.wso2 + + org.wso2.carbon @@ -213,36 +159,16 @@ provided - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core + commons-httpclient.wso2 + commons-httpclient provided - org.slf4j - slf4j-api + commons-logging + commons-logging - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.core - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.android - provided - - - commons-httpclient.wso2 - commons-httpclient - provided - com.google.code.gson gson @@ -256,12 +182,42 @@ org.slf4j slf4j-api + + commons-logging + commons-logging + + + neethi + org.wso2.orbit.org.apache.neethi + + + httpcore + org.apache.httpcomponents + + + geronimo-javamail_1.4_spec + org.apache.geronimo.specs + org.wso2.carbon.analytics org.wso2.carbon.analytics.api provided + + + asm + org.ow2.asm + + + objenesis + org.objenesis + + + guava + com.google.guava + + io.swagger @@ -285,13 +241,29 @@ org.slf4j slf4j-api + + guava + com.google.guava + + - javax.servlet - servlet-api - provided + com.google.apis + google-api-services-androidenterprise + v1-rev186-1.25.0 + + + guava + com.google.guava + + + jackson-core + com.fasterxml.jackson.core + + + org.hibernate hibernate-validator @@ -299,79 +271,124 @@ javax.ws.rs javax.ws.rs-api + provided + - org.testng - testng - test - - - org.powermock - powermock-module-testng - test - - - org.powermock - powermock-api-mockito - test - - - com.h2database.wso2 - h2-database-engine - test - - - org.wso2.carbon - org.wso2.carbon.queuing - test - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - test + org.codehaus.jackson + jackson-core-asl - commons-dbcp.wso2 - commons-dbcp - test + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + provided + + + commons-logging + commons-logging + + + neethi + org.apache.neethi.wso2 + + + wsdl4j + wsdl4j.wso2 + + + geronimo-stax-api_1.0_spec + org.apache.geronimo.specs.wso2 + + + org.wso2.securevault + org.wso2.securevault + + + axis2-client + org.apache.axis2.wso2 + + - commons-pool.wso2 - commons-pool - test + org.apache.httpcomponents + httpclient + - org.wso2.carbon - javax.cache.wso2 - test + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.common + provided - javassist - javassist - test + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.addons - org.codehaus.jackson - jackson-core-asl + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.core + provided + + + org.wso2.carbon.feature.mgt.core + org.wso2.carbon + + + commons-lang3 + org.apache.commons + + + annotations + com.google.code.findbugs + + + stax2-api + org.codehaus.woodstox + + + jaxb-impl + com.sun.xml.bind + + + jackson-datatype-joda + com.fasterxml.jackson.datatype + + org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.application.extension + org.wso2.carbon.policy.mgt.common provided - - com.google.apis - google-api-services-androidenterprise - v1-rev186-1.25.0 - org.wso2.carbon.devicemgt - org.wso2.carbon.device.application.mgt.common + org.wso2.carbon.policy.mgt.core provided - - - org.apache.httpcomponents - httpclient + + + commons-logging + commons-logging + + + axis2-client + org.apache.axis2.wso2 + + + neethi + org.wso2.orbit.org.apache.neethi + + + wsdl4j + wsdl4j.wso2 + + + XmlSchema + org.apache.ws.commons.schema.wso2 + + + axiom-api + org.apache.ws.commons.axiom + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/AndroidEnterpriseService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/AndroidEnterpriseAPI.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/AndroidEnterpriseService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/AndroidEnterpriseAPI.java index dafc60e02..d48c79523 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/AndroidEnterpriseService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/AndroidEnterpriseAPI.java @@ -15,9 +15,8 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.services; +package org.wso2.carbon.device.mgt.mobile.android.api; -import com.google.api.services.androidenterprise.model.Device; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -32,22 +31,17 @@ import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.application.mgt.common.dto.ApplicationPolicyDTO; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.mdm.services.android.bean.DeviceState; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStoreCluster; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePage; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePageLinks; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseInstallPolicy; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseUser; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStoreCluster; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePage; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePageLinks; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseInstallPolicy; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; -import javax.validation.Valid; -import javax.validation.constraints.Size; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; @@ -69,10 +63,11 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "android,device_management", description = "") + @Tag(name = "android,device_management", description = "Android Device Management Service") } ) -@Api(value = "Android Enterprise Service", description = "Android Enterprise Service ") + +@Api(value = "Android Enterprise Service") @Path("/enterprise") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -92,7 +87,7 @@ import javax.ws.rs.core.Response; ) } ) -public interface AndroidEnterpriseService { +public interface AndroidEnterpriseAPI { @POST @Path("/user") @@ -148,8 +143,7 @@ public interface AndroidEnterpriseService { }) Response addUser(@ApiParam( name = "user", - value = "Enterprise user and device data.") - EnterpriseUser enterpriseUser); + value = "Enterprise user and device data.") EnterpriseUser enterpriseUser); //###################################################################################################################### //###################################################################################################################### @@ -209,8 +203,7 @@ public interface AndroidEnterpriseService { }) Response updateUser(@ApiParam( name = "device", - value = "Enterprise user and device data.") - EnterpriseInstallPolicy device); + value = "Enterprise user and device data.") EnterpriseInstallPolicy device); //###################################################################################################################### //###################################################################################################################### @@ -269,43 +262,38 @@ public interface AndroidEnterpriseService { Response getStoreUrl( @ApiParam( name = "approveApps", - value = "Boolean flag indicating whether to permanently delete the device.", - required = false) + value = "Boolean flag indicating whether to permanently delete the device.") @QueryParam("approveApps") boolean approveApps, @ApiParam( name = "searchEnabled", - value = "Boolean flag indicating whether to permanently delete the device.", - required = false) + value = "Boolean flag indicating whether to permanently delete the device.") @QueryParam("searchEnabled") boolean searchEnabled, @ApiParam( name = "isPrivateAppsEnabled", - value = "Boolean flag indicating whether to permanently delete the device.", - required = false) @QueryParam("isPrivateAppsEnabled") boolean isPrivateAppsEnabled, + value = "Boolean flag indicating whether to permanently delete the device.") + @QueryParam("isPrivateAppsEnabled") boolean isPrivateAppsEnabled, @ApiParam( name = "isWebAppEnabled", - value = "Boolean flag indicating whether to permanently delete the device.", - required = false) @QueryParam("isWebAppEnabled") boolean isWebAppEnabled, + value = "Boolean flag indicating whether to permanently delete the device.") + @QueryParam("isWebAppEnabled") boolean isWebAppEnabled, @ApiParam( name = "isOrganizeAppPageVisible", - value = "Boolean flag indicating whether to permanently delete the device.", - required = false) @QueryParam("isOrganizeAppPageVisible") boolean isOrganizeAppPageVisible, + value = "Boolean flag indicating whether to permanently delete the device.") + @QueryParam("isOrganizeAppPageVisible") boolean isOrganizeAppPageVisible, @ApiParam( name = "isManagedConfigEnabled", - value = "Boolean flag indicating whether to permanently delete the device.", - required = false) @QueryParam("isManagedConfigEnabled") boolean isManagedConfigEnabled, + value = "Boolean flag indicating whether to permanently delete the device.") + @QueryParam("isManagedConfigEnabled") boolean isManagedConfigEnabled, @ApiParam(name = "host", value = "Boolean flag indicating whether to permanently delete the device.", required = true) @QueryParam("host") String host); - - - @GET @Path("/products/sync") @ApiOperation( @@ -416,8 +404,7 @@ public interface AndroidEnterpriseService { }) Response addPage(@ApiParam( name = "page", - value = "Enterprise page.") - EnterpriseStorePage page); + value = "Enterprise page.") EnterpriseStorePage page); //###################################################################################################################### //###################################################################################################################### @@ -777,8 +764,7 @@ public interface AndroidEnterpriseService { }) Response addCluster(@ApiParam( name = "storeCluster", - value = "Enterprise cluster.") - EnterpriseStoreCluster storeCluster); + value = "Enterprise cluster.") EnterpriseStoreCluster storeCluster); //###################################################################################################################### //###################################################################################################################### @@ -965,7 +951,7 @@ public interface AndroidEnterpriseService { @ApiParam( name = "pageId", value = "The unique page pageId") - @PathParam("pageId") String pageId); + @PathParam("id") String pageId); //###################################################################################################################### //###################################################################################################################### @@ -1025,8 +1011,7 @@ public interface AndroidEnterpriseService { }) Response updateLinks(@ApiParam( name = "links", - value = "Enterprise page links.") - EnterpriseStorePageLinks links); + value = "Enterprise page links.") EnterpriseStorePageLinks links); //###################################################################################################################### //###################################################################################################################### diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceManagementAPI.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceManagementAPI.java index a3910c870..73db4dd71 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceManagementAPI.java @@ -32,16 +32,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.services; +package org.wso2.carbon.device.mgt.mobile.android.api; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; 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 org.wso2.carbon.mdm.services.android.util.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -73,11 +73,10 @@ import java.util.List; } ), tags = { - @Tag(name = "android,device_management", description = "") + @Tag(name = "android,device_management", description = "Android Device Management Service") } ) -@Api(value = "Android Device Management", - description = "This carries all the resources related to the Android device management functionalities.") +@Api(value = "Android Device Management") @Path("/devices") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -97,7 +96,7 @@ import java.util.List; ) } ) -public interface DeviceManagementService { +public interface DeviceManagementAPI { @PUT @Path("/{id}/applications") @@ -211,8 +210,7 @@ public interface DeviceManagementService { Response getPendingOperations( @ApiParam( name = "disableGoogleApps", - value = "Specifically disable having Google apps installed.", - required = false) + value = "Specifically disable having Google apps installed.") @QueryParam("disableGoogleApps") boolean disableGoogleApps, @ApiParam( name = "id", @@ -223,8 +221,7 @@ public interface DeviceManagementService { name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time.\n" + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200.", - required = false) + "Example: Mon, 05 Jan 2014 15:10:00 +0200.") @HeaderParam("If-Modified-Since") String ifModifiedSince, @ApiParam( name = "resultOperations", @@ -339,8 +336,7 @@ public interface DeviceManagementService { name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time.\n" + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) + "Example: Mon, 05 Jan 2014 15:10:00 +0200") @HeaderParam("If-Modified-Since") String ifModifiedSince); @PUT diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceManagementAdminAPI.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceManagementAdminAPI.java index 89787ea68..118874bec 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceManagementAdminAPI.java @@ -33,7 +33,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.services; +package org.wso2.carbon.device.mgt.mobile.android.api; import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Info; @@ -49,8 +49,26 @@ import io.swagger.annotations.ResponseHeader; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; 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.util.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationInstallationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationRestrictionBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUninstallationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUpdateBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.BlacklistApplicationsBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.CameraBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.DeviceLockBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.DisplayMessageBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EncryptionBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.FileTransferBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.GlobalProxyBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.LockCodeBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.NotificationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.PasswordPolicyBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.UpgradeFirmwareBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.VpnBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WebClipBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WifiBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WipeDataBeanWrapper; import javax.validation.Valid; import javax.ws.rs.Consumes; @@ -75,11 +93,11 @@ import java.util.List; } ), tags = { - @Tag(name = "android,device_management", description = "") + @Tag(name = "android,device_management", description = "Android Device Management Admin Service") } ) @Path("/admin/devices") -@Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") +@Api(value = "Android Device Management Administrative Service") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Scopes( @@ -266,7 +284,7 @@ import java.util.List; ) } ) -public interface DeviceManagementAdminService { +public interface DeviceManagementAdminAPI { @POST @Path("/file-transfer") @@ -632,8 +650,7 @@ public interface DeviceManagementAdminService { "Disable the camera on the device by assigning true as the value or enable the " + "camera on the device to function by defining false as the value and the ID of the Android device. " + "Multiple device IDs can be added by using comma separated values. ", - required = true) - CameraBeanWrapper cameraBeanWrapper); + required = true) CameraBeanWrapper cameraBeanWrapper); @POST @Path("/info") @@ -880,8 +897,7 @@ public interface DeviceManagementAdminService { name = "wipeData", value = "Provide the the passcode, which is the passcode that the Android agent prompts the device owner to set at the time of device enrollment, " + "to enable the factory reset operation, and the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) - WipeDataBeanWrapper wipeDataBeanWrapper); + required = true) WipeDataBeanWrapper wipeDataBeanWrapper); @POST @Path("/applications") @@ -1248,8 +1264,7 @@ public interface DeviceManagementAdminService { value = "Properties required to install an application on Android devices. Provide the the package name, type," + " URL and name of the application, the date and time for the scheduled installation, and the ID of the " + "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); + required = true) ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); @POST @Path("/update-application") @@ -1313,8 +1328,7 @@ public interface DeviceManagementAdminService { value = "Properties required to update an application on Android devices. Provide the the package name, type," + "URL and name of the application, the date and time for the scheduled installation, and the ID of the" + "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); + required = true) ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); @POST @Path("/uninstall-application") @@ -1375,8 +1389,7 @@ public interface DeviceManagementAdminService { value = "Properties required to uninstall an application. Provide the the package name, type," + "URL and name of the application, the date and time for the scheduled installation, and the ID of the" + "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper); + required = true) ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper); @POST @Path("/blacklist-applications") @@ -1504,8 +1517,7 @@ public interface DeviceManagementAdminService { "yyyy-MM-dd'T'HH:mm:ss.SSSXXX format, the OTA upgrade server URL in one of the following formats " + "(example: http//abc.com, http://abc.com/ota), " + "and the ID of the Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper); + required = true) UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper); @POST @Path("/configure-vpn") @@ -1565,8 +1577,7 @@ public interface DeviceManagementAdminService { @ApiParam( name = "vpnBean", value = "VPN configuration and DeviceIds", - required = true) - VpnBeanWrapper vpnBeanWrapper); + required = true) VpnBeanWrapper vpnBeanWrapper); @POST @Path("/send-notification") @@ -1626,8 +1637,7 @@ public interface DeviceManagementAdminService { name = "notification", value = "The properties required to send a notification. Provide the message you wish to send and the ID of the " + "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - NotificationBeanWrapper notificationBeanWrapper); + required = true) NotificationBeanWrapper notificationBeanWrapper); @POST @Path("/configure-wifi") @@ -1688,8 +1698,7 @@ public interface DeviceManagementAdminService { value = "The properties required to configure Wi-Fi. Provide the password to connect to the specified Wi-Fi network," + "the ssid or the name of the Wi-Fi network that you wish to configure and the ID of the Android device." + " Multiple device IDs can be added by using comma separated values.", - required = true) - WifiBeanWrapper wifiBeanWrapper); + required = true) WifiBeanWrapper wifiBeanWrapper); @POST @Path("/encrypt-storage") @@ -1750,8 +1759,7 @@ public interface DeviceManagementAdminService { value = "Properties required to encrypt the storage. Encrypt the storage on the device by assigning " + "true as the value or do not encrypt the storage on the device by assigning false as the value and " + "provide the ID of the Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - EncryptionBeanWrapper encryptionBeanWrapper); + required = true) EncryptionBeanWrapper encryptionBeanWrapper); @POST @Path("/change-lock-code") @@ -1812,8 +1820,7 @@ public interface DeviceManagementAdminService { value = "The properties to change th lock code. Provide the lock code that will replace the current lock code on Android devices and " + "the ID of the Android device. Multiple device IDs can be added by using comma separated values. " + "If a passcode policy has been set in EMM, the lock code should comply to the passcode policy.\t", - required = true) - LockCodeBeanWrapper lockCodeBeanWrapper); + required = true) LockCodeBeanWrapper lockCodeBeanWrapper); @POST @Path("/set-password-policy") @@ -1872,8 +1879,7 @@ public interface DeviceManagementAdminService { @ApiParam( name = "passwordPolicy", value = "The properties required to set a password policy.", - required = true) - PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); + required = true) PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); @POST @Path("/set-webclip") @@ -1932,8 +1938,7 @@ public interface DeviceManagementAdminService { @ApiParam( name = "webClip", value = "The properties to set the web clip.", - required = true) - WebClipBeanWrapper webClipBeanWrapper); + required = true) WebClipBeanWrapper webClipBeanWrapper); @POST @Path("/send-app-conf") @ApiOperation( @@ -1994,8 +1999,7 @@ public interface DeviceManagementAdminService { value = "The properties required to send application restrictions. Provide the restriction you " + "wish to send and the ID of the Android device. Multiple device IDs can be added by using" + " comma separated values.", - required = true) - ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper); + required = true) ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper); @POST @Path("/configure-global-proxy") @@ -2056,8 +2060,7 @@ public interface DeviceManagementAdminService { @ApiParam( name = "globalProxyInfo", value = "The properties to set the global proxy settings.", - required = true) - GlobalProxyBeanWrapper globalProxyBeanWrapper); + required = true) GlobalProxyBeanWrapper globalProxyBeanWrapper); @POST @Path("/configure-display-message") @@ -2107,6 +2110,5 @@ public interface DeviceManagementAdminService { name = "display-message", value = "The properties required to send a messages. Provide the message you wish to send and the ID of the " + "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - DisplayMessageBeanWrapper displayMessageBeanWrapper); + required = true) DisplayMessageBeanWrapper displayMessageBeanWrapper); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceTypeConfigurationAPI.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceTypeConfigurationAPI.java index 5e2440941..e3cce4634 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/DeviceTypeConfigurationAPI.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.services; +package org.wso2.carbon.device.mgt.mobile.android.api; import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Info; @@ -32,9 +32,8 @@ import io.swagger.annotations.ResponseHeader; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; 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.util.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.AndroidPlatformConfiguration; import javax.validation.Valid; import javax.ws.rs.*; @@ -55,10 +54,10 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "android,device_management", description = "") + @Tag(name = "android,device_management", description = "Device Type Configuration Service") } ) -@Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.") +@Api(value = "Android Configuration Management") @Path("/configuration") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -84,7 +83,7 @@ import javax.ws.rs.core.Response; ) } ) -public interface DeviceTypeConfigurationService { +public interface DeviceTypeConfigurationAPI { @GET @ApiOperation( @@ -136,8 +135,7 @@ public interface DeviceTypeConfigurationService { name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time.\n" + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) + "Example: Mon, 05 Jan 2014 15:10:00 +0200") @HeaderParam("If-Modified-Since") String ifModifiedSince); @PUT @@ -245,8 +243,7 @@ public interface DeviceTypeConfigurationService { name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time.\n" + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200.", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince) throws AndroidAgentException; + "Example: Mon, 05 Jan 2014 15:10:00 +0200.") + @HeaderParam("If-Modified-Since") String ifModifiedSince); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/EventReceiverAPI.java similarity index 92% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/EventReceiverAPI.java index 93b914a5f..09f61943c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/EventReceiverAPI.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.services; +package org.wso2.carbon.device.mgt.mobile.android.api; import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Info; @@ -31,9 +31,9 @@ import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; -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.util.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EventBeanWrapper; import javax.validation.Valid; import javax.validation.constraints.Size; @@ -53,12 +53,10 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "android,device_management", description = "") + @Tag(name = "android,device_management", description = "Android Even Receiver Service") } ) -@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" + - " configure WSO2 EMM as explained in https://docs.wso2.com/display/EMM220/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " + - "https://docs.wso2.com/display/EMM220/Creating+a+New+Event+Stream+and+Receiver") +@Api(value = "Event Receiver") @Path("/events") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -72,7 +70,7 @@ import javax.ws.rs.core.Response; ) } ) -public interface EventReceiverService { +public interface EventReceiverAPI { @POST @Path("/publish") @@ -131,8 +129,7 @@ public interface EventReceiverService { @ApiParam( name = "eventBeanWrapper", value = "Information of the agent event to be published on DAS.") - @Valid - EventBeanWrapper eventBeanWrapper); + @Valid EventBeanWrapper eventBeanWrapper); @GET @ApiOperation( @@ -207,8 +204,7 @@ public interface EventReceiverService { name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time.\n" + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) + "Example: Mon, 05 Jan 2014 15:10:00 +0200") @HeaderParam("If-Modified-Since") String ifModifiedSince); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/AndroidEnterpriseServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/AndroidEnterpriseAPIImpl.java similarity index 61% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/AndroidEnterpriseServiceImpl.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/AndroidEnterpriseAPIImpl.java index 508421a3b..23bbfa553 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/AndroidEnterpriseServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/AndroidEnterpriseAPIImpl.java @@ -16,9 +16,9 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.services.impl; +package org.wso2.carbon.device.mgt.mobile.android.api.impl; -import com.google.api.services.androidenterprise.model.AppRestrictionsSchema; +import com.google.api.client.http.HttpStatusCodes; import com.google.api.services.androidenterprise.model.ProductsListResponse; import com.google.api.services.androidenterprise.model.StoreCluster; import com.google.api.services.androidenterprise.model.StoreLayout; @@ -37,34 +37,34 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; 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.policy.mgt.ProfileFeature; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseConfigs; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStoreCluster; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePackages; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePage; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePageLinks; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseTokenUrl; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.GoogleAppSyncResponse; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseApp; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseInstallPolicy; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseUser; -import org.wso2.carbon.mdm.services.android.bean.wrapper.TokenWrapper; -import org.wso2.carbon.mdm.services.android.common.GoogleAPIInvoker; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; -import org.wso2.carbon.mdm.services.android.exception.NotFoundException; -import org.wso2.carbon.mdm.services.android.services.AndroidEnterpriseService; -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.AndroidDeviceUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidEnterpriseUtils; +import org.wso2.carbon.device.mgt.mobile.android.api.AndroidEnterpriseAPI; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.GoogleAPIInvoker; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseConfigs; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStoreCluster; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePackages; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePage; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePageLinks; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseTokenUrl; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.GoogleAppSyncResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseApp; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseInstallPolicy; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.TokenWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.NotFoundException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidEnterpriseUtils; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; import javax.ws.rs.Consumes; @@ -85,8 +85,8 @@ import java.util.List; @Path("/enterprise") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { - private static final Log log = LogFactory.getLog(AndroidEnterpriseServiceImpl.class); +public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI { + private static final Log log = LogFactory.getLog(AndroidEnterpriseAPIImpl.class); @Override @Produces(MediaType.APPLICATION_JSON) @@ -120,11 +120,24 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { } catch (EnterpriseServiceException e) { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when saving user").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while adding user"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } return Response.status(Response.Status.OK).entity(token).build(); } - public String insertUser(EnterpriseUser enterpriseUser) throws EnterpriseServiceException { + public String insertUser(EnterpriseUser enterpriseUser) + throws EnterpriseServiceException, AndroidDeviceMgtPluginException { EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); String token; boolean deviceIdExist = false; @@ -174,9 +187,9 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { public Response updateUser(EnterpriseInstallPolicy device) { boolean sentToDevice = false; - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); List enterpriseUserInstances = AndroidAPIUtils.getAndroidPluginService() .getEnterpriseUser(device.getUsername()); GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); @@ -193,8 +206,21 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { } catch (EnterpriseServiceException e) { String errorMessage = "App install failed. No user found for name " + device.getUsername(); log.error(errorMessage); - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage(errorMessage).build()); + return Response.status(Response.Status.NOT_FOUND).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND) + .setMessage(errorMessage).build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while updating user"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } if (sentToDevice) { return Response.status(Response.Status.OK).build(); @@ -215,23 +241,24 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { @QueryParam("isOrganizeAppPageVisible") boolean isOrganizeAppPageVisible, @QueryParam("isManagedConfigEnabled") boolean isManagedConfigEnabled, @QueryParam("host") String host) { - - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); - EnterpriseTokenUrl enterpriseTokenUrl = new EnterpriseTokenUrl(); - if (enterpriseConfigs == null || enterpriseConfigs.getEnterpriseId() == null) { - return Response.status(Response.Status.NOT_FOUND).entity( - new ErrorResponse.ErrorResponseBuilder().setMessage("Not configured for AFW").build()).build(); - } - enterpriseTokenUrl.setEnterpriseId(enterpriseConfigs.getEnterpriseId()); - enterpriseTokenUrl.setApproveApps(approveApps); - enterpriseTokenUrl.setSearchEnabled(searchEnabled); - enterpriseTokenUrl.setPrivateAppsEnabled(isPrivateAppsEnabled); - enterpriseTokenUrl.setWebAppEnabled(isWebAppEnabled); - enterpriseTokenUrl.setOrganizeAppPageVisible(isOrganizeAppPageVisible); - enterpriseTokenUrl.setParentHost(host); - enterpriseTokenUrl.setManagedConfigEnabled(isManagedConfigEnabled); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + EnterpriseTokenUrl enterpriseTokenUrl = new EnterpriseTokenUrl(); + if (enterpriseConfigs == null || enterpriseConfigs.getEnterpriseId() == null) { + return Response.status(Response.Status.NOT_FOUND).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage("Not configured for AFW").build()).build(); + } + enterpriseTokenUrl.setEnterpriseId(enterpriseConfigs.getEnterpriseId()); + enterpriseTokenUrl.setApproveApps(approveApps); + enterpriseTokenUrl.setSearchEnabled(searchEnabled); + enterpriseTokenUrl.setPrivateAppsEnabled(isPrivateAppsEnabled); + enterpriseTokenUrl.setWebAppEnabled(isWebAppEnabled); + enterpriseTokenUrl.setOrganizeAppPageVisible(isOrganizeAppPageVisible); + enterpriseTokenUrl.setParentHost(host); + enterpriseTokenUrl.setManagedConfigEnabled(isManagedConfigEnabled); + String token = googleAPIInvoker.getAdministratorWebToken(enterpriseTokenUrl); TokenWrapper tokenWrapper = new TokenWrapper(); tokenWrapper.setToken(token); @@ -240,6 +267,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when calling get web token").build()) .build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while getting store url"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -247,9 +286,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { @GET @Path("/products/sync") public Response syncApps() { - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + ProductsListResponse productsListResponse = googleAPIInvoker .listProduct(enterpriseConfigs.getEnterpriseId(), null); AndroidEnterpriseUtils.persistApp(productsListResponse); @@ -267,6 +307,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when persisting app").build()) .build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while syncing apps"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -300,9 +352,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { new ErrorResponse.ErrorResponseBuilder().setMessage("Message body is empty or incorrect").build()) .build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + String id = googleAPIInvoker.insertPage(enterpriseConfigs.getEnterpriseId(), page); page.setPageId(id); return Response.status(Response.Status.OK).entity(page).build(); @@ -314,6 +367,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting page " + page.getPageName() + " , due to an error with ESA").build() ).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while adding page"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -327,9 +392,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { .build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + String id = googleAPIInvoker.updatePage(enterpriseConfigs.getEnterpriseId(), page); page.setPageId(id); return Response.status(Response.Status.OK).entity(page).build(); @@ -341,6 +407,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page " + page.getPageName() + " , due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while updating page"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -355,9 +433,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { .build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + googleAPIInvoker.deletePage(enterpriseConfigs.getEnterpriseId(), id); return Response.status(Response.Status.OK).build(); } catch (IOException e) { @@ -368,6 +447,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page " + id + " , Due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while deleting page"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -375,9 +466,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { @Path("/store-layout/page") @Override public Response getPages() { - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + StoreLayoutPagesListResponse pages = googleAPIInvoker.listPages(enterpriseConfigs.getEnterpriseId()); return Response.status(Response.Status.OK).entity(pages).build(); } catch (IOException e) { @@ -388,6 +480,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page " + " , Due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while getting pages"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -401,9 +505,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { new ErrorResponse.ErrorResponseBuilder().setMessage("Id cannot be empty").build()) .build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + StoreLayout layout = googleAPIInvoker.setStoreLayout(enterpriseConfigs.getEnterpriseId(), id); return Response.status(Response.Status.OK).entity(layout).build(); } catch (IOException e) { @@ -414,6 +519,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting home page " + id + " , due to an error with ESA").build() ).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while setting home"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -421,9 +538,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { @Path("/store-layout/home-page") @Override public Response getHome() { - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + StoreLayout layout = googleAPIInvoker.getStoreLayout(enterpriseConfigs.getEnterpriseId()); return Response.status(Response.Status.OK).entity(layout).build(); } catch (IOException e) { @@ -433,6 +551,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching home page.").build() ) .build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while getting home"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -455,9 +585,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { new ErrorResponse.ErrorResponseBuilder().setMessage("Cluster order cannot be empty").build()).build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + String id = googleAPIInvoker.insertCluster(enterpriseConfigs.getEnterpriseId(), storeCluster); storeCluster.setClusterId(id); return Response.status(Response.Status.OK).entity(storeCluster).build(); @@ -469,6 +600,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster " + storeCluster.getName() + " , due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while adding cluster"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -491,9 +634,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { new ErrorResponse.ErrorResponseBuilder().setMessage("Cluster order cannot be empty").build()).build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + String id = googleAPIInvoker.updateCluster(enterpriseConfigs.getEnterpriseId(), storeCluster); storeCluster.setClusterId(id); return Response.status(Response.Status.OK).entity(storeCluster).build(); @@ -505,6 +649,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster " + storeCluster.getName() + " , due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while updating cluster"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -521,9 +677,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { new ErrorResponse.ErrorResponseBuilder().setMessage("Page id cannot be empty").build()).build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + googleAPIInvoker.deleteCluster(enterpriseConfigs.getEnterpriseId(), pageId, clusterId); return Response.status(Response.Status.OK).build(); } catch (IOException e) { @@ -534,6 +691,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when deleting cluster " + clusterId + " , due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while deleting cluster"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -546,9 +715,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { new ErrorResponse.ErrorResponseBuilder().setMessage("Page id cannot be empty").build()).build(); } - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + StoreLayoutClustersListResponse response = googleAPIInvoker.getClusters(enterpriseConfigs.getEnterpriseId(), pageId); if (response == null || response.getCluster() == null) { return Response.status(Response.Status.NOT_FOUND).entity( @@ -603,6 +773,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching all details in PageId " + pageId).build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while getting clusters in page"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -610,9 +792,10 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { @Path("/store-layout/page-link") @Override public Response updateLinks(EnterpriseStorePageLinks link) { - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + googleAPIInvoker.addLinks(enterpriseConfigs.getEnterpriseId(), link.getPageId(), link.getLinks()); return Response.status(Response.Status.OK).build(); @@ -624,6 +807,18 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page " + " , Due to an error with ESA").build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while updating links"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } } @@ -727,11 +922,12 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { public Response updateUser(ApplicationPolicyDTO applicationPolicyDTO) { boolean sentToDevice = false; - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + for (DeviceIdentifier deviceIdentifier : applicationPolicyDTO.getDeviceIdentifierList()) { try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); AndroidEnterpriseUser userDetail = AndroidAPIUtils.getAndroidPluginService() .getEnterpriseUserByDevice(deviceIdentifier.getId()); @@ -761,9 +957,9 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { String errorMessage = "App: " + applicationPolicyDTO.getApplicationDTO() .getPackageName() + " for device " + deviceIdentifier.getId(); log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(Response.Status.BAD_REQUEST - .getStatusCode()).setMessage(errorMessage).build()); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); } } googleAPIInvoker.installApps(enterpriseConfigs.getEnterpriseId(), userDetail @@ -785,17 +981,28 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { } catch (EnterpriseServiceException e) { String errorMessage = "App install failed for device " + deviceIdentifier.getId(); log.error(errorMessage); - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(Response.Status.NOT_FOUND - .getStatusCode()).setMessage(errorMessage).build()); + return Response.status(Response.Status.NOT_FOUND).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND) + .setMessage(errorMessage).build()).build(); } catch (FeatureManagementException e) { String errorMessage = "Could not fetch effective policy for device " + deviceIdentifier.getId(); log.error(errorMessage); - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(Response.Status.INTERNAL_SERVER_ERROR - .getStatusCode()).setMessage(errorMessage).build()); + return Response.status(Response.Status.NOT_FOUND).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND) + .setMessage(errorMessage).build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Not found"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while updating user"; + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } - } if (sentToDevice) { @@ -813,67 +1020,79 @@ public class AndroidEnterpriseServiceImpl implements AndroidEnterpriseService { @Path("/wipe-device") public Response wipeEnterprise() { log.warn("Wiping all devices!!!"); - EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); - try { - // Take all enterprise devices in the DB. - List androidEnterpriseUsers = AndroidAPIUtils.getAndroidPluginService() - .getAllEnterpriseDevices(enterpriseConfigs.getEnterpriseId()); - - // Extract the device identifiers of enterprise devices. - List deviceID = new ArrayList<>(); - if (androidEnterpriseUsers != null && !androidEnterpriseUsers.isEmpty()) { - for (AndroidEnterpriseUser userDevice: androidEnterpriseUsers) { - deviceID.add(userDevice.getEmmDeviceId()); + try{ + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + try { + // Take all enterprise devices in the DB. + List androidEnterpriseUsers = AndroidAPIUtils.getAndroidPluginService() + .getAllEnterpriseDevices(enterpriseConfigs.getEnterpriseId()); + + // Extract the device identifiers of enterprise devices. + List deviceID = new ArrayList<>(); + if (androidEnterpriseUsers != null && !androidEnterpriseUsers.isEmpty()) { + for (AndroidEnterpriseUser userDevice: androidEnterpriseUsers) { + deviceID.add(userDevice.getEmmDeviceId()); + } } - } - List byodDevices = new ArrayList<>(); - List copeDevices = new ArrayList<>(); - // Get all registered device - List devices = AndroidAPIUtils.getDeviceManagementService(). - getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false); - for (Device device : devices) { // Go through all enrolled devices - if (deviceID.contains(device.getDeviceIdentifier())) { // Filter out only enterprise enrolled devices. - if (EnrolmentInfo.OwnerShip.BYOD.equals(device.getEnrolmentInfo().getOwnership())) { - byodDevices.add(device.getDeviceIdentifier()); - } else { - copeDevices.add(device.getDeviceIdentifier()); + List byodDevices = new ArrayList<>(); + List copeDevices = new ArrayList<>(); + // Get all registered device + List devices = AndroidAPIUtils.getDeviceManagementService(). + getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false); + for (Device device : devices) { // Go through all enrolled devices + if (deviceID.contains(device.getDeviceIdentifier())) { // Filter out only enterprise enrolled devices. + if (device.getEnrolmentInfo().getOwnership().equals(EnrolmentInfo.OwnerShip.BYOD)) { + byodDevices.add(device.getDeviceIdentifier()); + } else { + copeDevices.add(device.getDeviceIdentifier()); + } } } - } - CommandOperation operation = new CommandOperation(); - operation.setType(Operation.Type.COMMAND);//TODO: Check if this should be profile - // type when implementing COPE/COSU - if (byodDevices != null && !byodDevices.isEmpty()) { // BYOD devices only needs a data wipe(work profile) - log.warn("Wiping " + byodDevices.size() + " BYOD devices"); - operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE); - } else if (copeDevices != null && copeDevices.size() > 0) { - log.warn("Wiping " + copeDevices.size() + " COPE/COSU devices"); - operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA); + CommandOperation operation = new CommandOperation(); + operation.setType(Operation.Type.COMMAND);//TODO: Check if this should be profile + // type when implementing COPE/COSU + if (byodDevices != null && !byodDevices.isEmpty()) { // BYOD devices only needs a data wipe(work profile) + log.warn("Wiping " + byodDevices.size() + " BYOD devices"); + operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE); + } else if (copeDevices != null && !copeDevices.isEmpty()) { + log.warn("Wiping " + copeDevices.size() + " COPE/COSU devices"); + operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA); + } + AndroidDeviceUtils.getOperationResponse(deviceID, operation); + log.warn("Added wipe to all devices"); + return Response.status(Response.Status.OK).build(); + } catch (EnterpriseServiceException e) { + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage("Error when saving configs").build()).build(); + } catch (OperationManagementException e) { + String errorMessage = "Could not add wipe command to enterprise " + enterpriseConfigs.getEnterpriseId(); + log.error(errorMessage); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (DeviceManagementException e) { + String errorMessage = "Could not add wipe command to enterprise " + enterpriseConfigs.getEnterpriseId() + + " due to an error in device management"; + log.error(errorMessage); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); + } catch (InvalidDeviceException e) { + String errorMessage = "Could not add wipe command to enterprise due to invalid device ids"; + log.error(errorMessage); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } - AndroidDeviceUtils.getOperationResponse(deviceID, operation); - log.warn("Added wipe to all devices"); - return Response.status(Response.Status.OK).build(); - } catch (EnterpriseServiceException e) { - String errorMessage = "Error when saving configs for enterprise " + enterpriseConfigs.getEnterpriseId(); - log.error(errorMessage); + } catch (NotFoundException e) { + String errorMessage = "Not found"; return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); - } catch (OperationManagementException e) { - String errorMessage = "Could not add wipe command to enterprise " + enterpriseConfigs.getEnterpriseId(); - log.error(errorMessage); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); - } catch (DeviceManagementException e) { - String errorMessage = "Could not add wipe command to enterprise " + enterpriseConfigs.getEnterpriseId() + - " due to an error in device management"; - log.error(errorMessage); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Could not add wipe command to enterprise due to invalid device ids"; - log.error(errorMessage); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing wipe enterprice command"; return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java new file mode 100644 index 000000000..bccd9a4ce --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAPIImpl.java @@ -0,0 +1,262 @@ +/* + * 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. + * + * + * Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.api.impl; + +import com.google.api.client.http.HttpStatusCodes; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.mobile.android.api.DeviceManagementAPI; +import org.wso2.carbon.device.mgt.mobile.android.common.Message; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.*; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; + +@Path("/devices") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DeviceManagementAPIImpl implements DeviceManagementAPI { + + private static final Log log = LogFactory.getLog(DeviceManagementAPIImpl.class); + + @PUT + @Path("/{id}/applications") + @Override + public Response updateApplicationList(@PathParam("id") + @NotNull + @Size(min = 2, max = 45) + @Pattern(regexp = "^[A-Za-z0-9]*$") + String id, List androidApplications) { + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Message responseMessage = androidService.updateApplicationList(id, androidApplications); + return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build(); + } catch (ApplicationManagementException e) { + String msg = "Error occurred while modifying the application list."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } + } + + @PUT + @Path("/{id}/pending-operations") + @Override + public Response getPendingOperations(@QueryParam("disableGoogleApps") boolean disableGoogleApps, + @PathParam("id") String id, + @HeaderParam("If-Modified-Since") String ifModifiedSince, + List resultOperations) { + if (id == null || id.isEmpty()) { + String msg = "Device identifier is null or empty, hence returning device not found"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + List pendingOperations = androidService + .getPendingOperations(id, resultOperations, disableGoogleApps); + return Response.status(Response.Status.CREATED).entity(pendingOperations).build(); + } catch (InvalidDeviceException e) { + String msg = "Device identifier is invalid. Device identifier " + id; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (DeviceManagementException e) { + String msg = "Error occurred while getting pending operations of the device."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing get pending operations"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Override + public Response enrollDevice(@Valid AndroidDevice androidDevice) { + if (androidDevice == null) { + String errorMessage = "The payload of the android device enrollment is incorrect."; + log.error(errorMessage); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Message message = androidService.enrollDevice(androidDevice); + return Response.status(Integer.parseInt(message.getResponseCode())) + .entity(message.getResponseMessage()).build(); + } catch (DeviceManagementException e) { + String msg = "Error occurred while enrolling the android, which carries the id '" + + androidDevice.getDeviceIdentifier() + "'"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while enrolling device"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @GET + @Path("/{id}/status") + @Override + public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) { + DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Message responseMessage = androidService.isEnrolled(id, deviceIdentifier); + return Response.status(Integer.parseInt(responseMessage.getResponseCode())).entity(responseMessage).build(); + } catch (DeviceManagementException e) { + String msg = "Error occurred while checking enrollment status of the device."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } + } + + @PUT + @Path("/{id}") + @Override + public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) { + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + if (androidService.modifyEnrollment(id, androidDevice)) { + Message responseMessage = new Message(); + responseMessage.setResponseCode(Response.Status.ACCEPTED.toString()); + responseMessage.setResponseMessage("Enrollment of Android device that " + + "carries the id '" + id + "' has successfully updated"); + return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build(); + } else { + Message responseMessage = new Message(); + responseMessage.setResponseCode(Response.Status.NOT_MODIFIED.toString()); + responseMessage.setResponseMessage("Enrollment of Android device that " + + "carries the id '" + id + "' has not been updated"); + return Response.status(Response.Status.NOT_MODIFIED).entity(responseMessage).build(); + } + } catch (DeviceManagementException e) { + String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" + + id + "'"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "The payload of the android device enrollment is incorrect."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (NotFoundException e) { + String errorMessage = "The device to be modified doesn't exist."; + log.error(errorMessage, e); + return Response.status(Response.Status.NOT_FOUND).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while modifying enrollment"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @DELETE + @Path("/{id}") + @Override + public Response disEnrollDevice(@PathParam("id") String id) { + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + if (androidService.disEnrollDevice(id)) { + String msg = "Android device that carries id '" + id + "' is successfully "; + Message responseMessage = new Message(); + responseMessage.setResponseCode(Response.Status.OK.toString()); + responseMessage.setResponseMessage(msg + "dis-enrolled"); + return Response.status(Response.Status.OK).entity(responseMessage).build(); + } else { + Message responseMessage = new Message(); + responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString()); + responseMessage.setResponseMessage("Android device that carries id '" + id + "' is not available"); + return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build(); + } + } catch (DeviceManagementException e) { + String msg = "Error occurred while %s the Android device that carries the id '" + id + "'"; + msg = String.format(msg, "dis-enrolling"); + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } + } + + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java new file mode 100644 index 000000000..ab0581a99 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java @@ -0,0 +1,1082 @@ +/* + * 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. + * + * + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) 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.device.mgt.mobile.android.api.impl; + +import com.google.api.client.http.HttpStatusCodes; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; +import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; +import org.wso2.carbon.device.mgt.mobile.android.api.DeviceManagementAdminAPI; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationInstallationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationRestrictionBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUninstallationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUpdateBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.BlacklistApplicationsBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.CameraBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.DeviceLockBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.DisplayMessageBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EncryptionBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.FileTransferBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.GlobalProxyBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.LockCodeBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.NotificationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.PasswordPolicyBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.UpgradeFirmwareBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.VpnBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WebClipBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WifiBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WipeDataBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; + +import javax.validation.Valid; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; + +@Path("/admin/devices") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI { + + private static final Log log = LogFactory.getLog(DeviceManagementAdminAPIImpl.class); + + @POST + @Path("/file-transfer") + @Override + public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.fileTransfer(fileTransferBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance for file transfer operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e) { + String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing file tranfer operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/lock-devices") + @Override + public Response configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android device lock operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.configureDeviceLock(deviceLockBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing device lock operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/unlock-devices") + @Override + public Response configureDeviceUnlock(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android device unlock operation."); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.configureDeviceUnlock(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing device unlock operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/location") + @Override + public Response getDeviceLocation(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android device location operation."); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.getDeviceLocation(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while retrieving device location"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/clear-password") + @Override + public Response removePassword(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android clear password operation."); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.removePassword(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance."; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing remove password operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/control-camera") + @Override + public Response configureCamera(CameraBeanWrapper cameraBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android Camera operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.configureCamera(cameraBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing control camera operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/info") + @Override + public Response getDeviceInformation(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking get Android device information operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.getDeviceInformation(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while retrieving device information"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/logcat") + @Override + public Response getDeviceLogcat(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking get Android device logcat operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.getDeviceLogcat(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while retrieving device logcat"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/enterprise-wipe") + @Override + public Response wipeDevice(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking enterprise-wipe device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.wipeDevice(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing enterprice wipe device operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/wipe") + @Override + public Response wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android wipe-data device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.wipeData(wipeDataBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing Android wipe-data device operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/applications") + @Override + public Response getApplications(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android getApplicationList device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.getApplications(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing Android getApplicationList device operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/ring") + @Override + public Response ringDevice(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android ring-device device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.ringDevice(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing Android ring device operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/reboot") + @Override + public Response rebootDevice(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android reboot-device device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.rebootDevice(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing Android reboot device operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/change-LockTask") + @Override + public Response changeLockTask(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android change LockTask mode operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.changeLockTask(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing Android change LockTask mode operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/mute") + @Override + public Response muteDevice(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking mute device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.muteDevice(deviceIDs); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing mute device operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/install-application") + @Override + public Response installApplication( + ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'InstallApplication' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.installApplication(applicationInstallationBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing install application operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/update-application") + @Override + public Response updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'UpdateApplication' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.updateApplication(applicationUpdateBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing update application operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/uninstall-application") + @Override + public Response uninstallApplication( + ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'UninstallApplication' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.uninstallApplication(applicationUninstallationBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing uninstall application operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/blacklist-applications") + @Override + public Response blacklistApplications(@Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'Blacklist-Applications' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.blacklistApplications(blacklistApplicationsBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing blacklist application operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/upgrade-firmware") + @Override + public Response upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android upgrade-firmware device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.upgradeFirmware(upgradeFirmwareBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing upgrade firmware operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/configure-vpn") + @Override + public Response configureVPN(VpnBeanWrapper vpnConfiguration) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android VPN device operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.configureVPN(vpnConfiguration); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing configure vpn operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/send-notification") + @Override + public Response sendNotification(NotificationBeanWrapper notificationBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'notification' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.sendNotification(notificationBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing send notification operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/configure-wifi") + @Override + public Response configureWifi(WifiBeanWrapper wifiBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'configure wifi' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.configureWifi(wifiBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing configure wifi operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/encrypt-storage") + @Override + public Response encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'encrypt' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.encryptStorage(encryptionBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing encrypt operation operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/change-lock-code") + @Override + public Response changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'change lock code' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.changeLockCode(lockCodeBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing change lock code operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/set-password-policy") + @Override + public Response setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'password policy' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.setPasswordPolicy(passwordPolicyBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing set password policy operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("set-webclip") + @Override + public Response setWebClip(WebClipBeanWrapper webClipBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'webclip' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.setWebClip(webClipBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing set webclip operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/configure-global-proxy") + @Override + public Response setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Applying 'configure-global-proxy' operation: " + + globalProxyBeanWrapper.getOperation().toJSON() + " for Devices: [" + + String.join(",", globalProxyBeanWrapper.getDeviceIDs()) + "]"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.setRecommendedGlobalProxy(globalProxyBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while applying 'configure-global-proxy' operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + @POST + @Path("/send-app-conf") + @Override + public Response sendApplicationConfiguration( + ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'send application configuration' operation"); + } + + try{ + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + ProfileOperation operation = androidService.sendApplicationConfiguration(applicationRestrictionBeanWrapper); + Response response = AndroidAPIUtils.getOperationResponse(applicationRestrictionBeanWrapper.getDeviceIDs(), + operation); + return Response.status(Response.Status.CREATED).entity(response).build(); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while sending app configuration"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @POST + @Path("/configure-display-message") + @Override + public Response configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'configure-display-message' operation"); + } + + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Activity activity = androidService.configureDisplayMessage(displayMessageBeanWrapper); + return Response.status(Response.Status.CREATED).entity(activity).build(); + + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (BadRequestException e){ + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing configure-display-message operation"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceTypeConfigurationAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceTypeConfigurationAPIImpl.java new file mode 100644 index 000000000..86cf58963 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceTypeConfigurationAPIImpl.java @@ -0,0 +1,128 @@ +/* + * 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. + * + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.api.impl; + +import com.google.api.client.http.HttpStatusCodes; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.device.mgt.mobile.android.api.DeviceTypeConfigurationAPI; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.AndroidPlatformConfiguration; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; + +import javax.validation.Valid; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/configuration") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class DeviceTypeConfigurationAPIImpl implements DeviceTypeConfigurationAPI { + + private static final Log log = LogFactory.getLog(DeviceTypeConfigurationAPIImpl.class); + + @GET + @Override + public Response getConfiguration( + @HeaderParam("If-Modified-Since") String ifModifiedSince) { + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + PlatformConfiguration platformConfiguration = androidService.getPlatformConfig(); + return Response.status(Response.Status.OK).entity(platformConfiguration).build(); + } catch (DeviceManagementException e) { + String msg = "Error occurred while retrieving the Android tenant configuration"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } + } + + @PUT + @Override + public Response updateConfiguration( + @Valid AndroidPlatformConfiguration androidPlatformConfiguration) { + try { + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + androidService.updateConfiguration(androidPlatformConfiguration); + return Response.status(Response.Status.OK) + .entity("Android platform configuration has been updated successfully.").build(); + } catch (BadRequestException e) { + String msg = "The payload of the android platform configuration is incorrect."; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(msg).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String msg = "Error occurred while modifying configuration settings of Android platform"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } + + } + + @GET + @Path("/license") + @Produces(MediaType.TEXT_PLAIN) + public Response getLicense( + @HeaderParam("If-Modified-Since") String ifModifiedSince) { + try { + License license = AndroidAPIUtils.getDeviceManagementService() + .getLicense(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, + DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); + return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build(); + } catch (DeviceManagementException e) { + String msg = "Error occurred while retrieving the license configured for Android device enrolment"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(msg).build()).build(); + } + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java new file mode 100644 index 000000000..fa60ca476 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java @@ -0,0 +1,114 @@ +/* + * 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.device.mgt.mobile.android.api.impl; + +import com.google.api.client.http.HttpStatusCodes; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.mobile.android.api.EventReceiverAPI; +import org.wso2.carbon.device.mgt.mobile.android.common.Message; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EventBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.*; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; + +import javax.validation.Valid; +import javax.validation.constraints.Size; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import java.util.List; + +@Path("/events") +public class EventReceiverAPIImpl implements EventReceiverAPI { + + private static final Log log = LogFactory.getLog(EventReceiverAPIImpl.class); + + @POST + @Path("/publish") + @Override + public Response publishEvents(@Valid EventBeanWrapper eventBeanWrapper) { + try{ + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + Message message = androidService.publishEvents(eventBeanWrapper); + return Response.status(Integer.parseInt(message.getResponseCode())).entity(message.getResponseMessage()).build(); + } catch (DeviceManagementException e) { + String errorMessage = "Error occurred while checking Operation Analytics is Enabled."; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Error occurred while getting the Data publisher Service instance."; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e){ + String errorMessage = "Error occurred while publishing events."; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } + + @GET + @Override + public Response retrieveAlerts(@QueryParam("id") + @Size(min = 2, max = 45) + String deviceId, + @QueryParam("from") long from, + @QueryParam("to") long to, + @Size(min = 2, max = 45) + @QueryParam("type") String type, + @HeaderParam("If-Modified-Since") String ifModifiedSince) { + try{ + AndroidService androidService = AndroidAPIUtils.getAndroidService(); + List deviceStates = androidService.retrieveAlerts(deviceId, from, to, type, ifModifiedSince); + return Response.status(Response.Status.OK).entity(deviceStates).build(); + } catch (BadRequestException e){ + String errorMessage = "Request must contain " + + "the device identifier. Optionally, both from and to value should be present to get " + + "alerts between times."; + log.error(errorMessage); + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST) + .setMessage(errorMessage).build()).build(); + } catch (NotFoundException e) { + String errorMessage = "Class not found"; + log.error(errorMessage, e); + return Response.status(Response.Status.NOT_FOUND).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND) + .setMessage(errorMessage).build()).build(); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while retrieving alerts"; + log.error(errorMessage, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR) + .setMessage(errorMessage).build()).build(); + } + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java deleted file mode 100644 index 3fdc4e1ba..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.wso2.carbon.mdm.services.android.bean; - -public enum ProxyType { - MANUAL, AUTO -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidOperationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidOperationException.java deleted file mode 100644 index 8c68866d8..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidOperationException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.Message; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * Custom exception class for wrapping Android Operation related exceptions. - */ -public class AndroidOperationException extends WebApplicationException { - - public AndroidOperationException(Message message, MediaType mediaType) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message). - type(mediaType).build()); - } -} - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java deleted file mode 100644 index 5fa5ededc..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.bean.ErrorResponse; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -/** - * Custom exception class for wrapping BadRequest related exceptions. - */ -public class BadRequestException extends WebApplicationException { - - public BadRequestException(ErrorResponse error) { - super(Response.status(Response.Status.BAD_REQUEST).entity(error).build()); - } -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java deleted file mode 100644 index 75113f850..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -/** - * Exception class that is corresponding to 401 Forbidden response - */ - -public class ForbiddenException extends WebApplicationException { - - private String message; - - public ForbiddenException() { - super(Response.status(Response.Status.FORBIDDEN) - .build()); - } - - public ForbiddenException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.FORBIDDEN) - .entity(errorDTO) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - message = errorDTO.getDescription(); - } - - @Override - public String getMessage() { - return message; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java deleted file mode 100644 index 31370bd88..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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."; - if (log.isDebugEnabled()) { - log.debug(errorMessage, e); - } - return AndroidDeviceUtils.buildBadRequestException(errorMessage).getResponse(); - } - if (e instanceof NotFoundException) { - return ((NotFoundException) e).getResponse(); - } - if (e instanceof BadRequestException) { - return ((BadRequestException) e).getResponse(); - } - if (e instanceof UnexpectedServerErrorException) { - if (log.isDebugEnabled()) { - log.debug("Unexpected server error", e); - } - return ((UnexpectedServerErrorException) e).getResponse(); - } - if (e instanceof ConstraintViolationException) { - if (log.isDebugEnabled()) { - log.debug("Constraint violation issue.", e); - return ((ParameterValidationException) e).getResponse(); - } - } - if (e instanceof IllegalArgumentException) { - ErrorDTO errorDetail = new ErrorDTO(); - errorDetail.setCode((long) 400); - errorDetail.setMoreInfo(""); - errorDetail.setMessage(""); - errorDetail.setDescription(e.getMessage()); - return Response - .status(Response.Status.BAD_REQUEST) - .entity(errorDetail) - .build(); - } - if (e instanceof ClientErrorException) { - if (log.isDebugEnabled()) { - log.debug("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) { - if (log.isDebugEnabled()) { - log.debug("Resource forbidden", e); - } - return ((ForbiddenException) e).getResponse(); - } - //unknown exception log and return - log.error("An Unknown exception has been captured by global exception mapper.", e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("Content-Type", "application/json") - .entity(e500).build(); - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java deleted file mode 100644 index 53863c3ac..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -public class NotFoundException extends WebApplicationException { - private String message; - private static final long serialVersionUID = 147943572342342340L; - - public NotFoundException(ErrorResponse error) { - super(Response.status(Response.Status.NOT_FOUND).entity(error).build()); - } - public NotFoundException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.NOT_FOUND) - .entity(errorDTO) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - message = errorDTO.getDescription(); - } - - @Override - public String getMessage() { - return message; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java deleted file mode 100644 index efb38a3d7..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; - -import javax.validation.ConstraintViolation; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import java.util.Set; - -public class ParameterValidationException extends WebApplicationException { - - private String message; - public ParameterValidationException(Set> violations) { - super(Response.status(Response.Status.BAD_REQUEST) - .entity(AndroidDeviceUtils.getConstraintViolationErrorDTO(violations)) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - - //Set the error message - StringBuilder stringBuilder = new StringBuilder(); - for (ConstraintViolation violation : violations) { - stringBuilder.append(violation.getRootBeanClass().getSimpleName()); - stringBuilder.append("."); - stringBuilder.append(violation.getPropertyPath()); - stringBuilder.append(": "); - stringBuilder.append(violation.getMessage()); - stringBuilder.append(", "); - } - message = stringBuilder.toString(); - } - - @Override - public String getMessage() { - return message; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java deleted file mode 100644 index a66c2f506..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -public class UnexpectedServerErrorException extends WebApplicationException { - private String message; - private static final long serialVersionUID = 147943579458906890L; - - public UnexpectedServerErrorException(ErrorResponse error) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); - } - public UnexpectedServerErrorException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR) - .entity(errorDTO) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - message = errorDTO.getDescription(); - } - - @Override - public String getMessage() { - return message; - } - - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java deleted file mode 100644 index 0ed723cce..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java +++ /dev/null @@ -1,1193 +0,0 @@ -/* - * 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. - * - * - * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) 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.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -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.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationRestriction; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; -import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; -import org.wso2.carbon.mdm.services.android.bean.Camera; -import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; -import org.wso2.carbon.mdm.services.android.bean.DeviceLock; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.FileTransfer; -import org.wso2.carbon.mdm.services.android.bean.GlobalProxy; -import org.wso2.carbon.mdm.services.android.bean.LockCode; -import org.wso2.carbon.mdm.services.android.bean.DisplayMessage; -import org.wso2.carbon.mdm.services.android.bean.Notification; -import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; -import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; -import org.wso2.carbon.mdm.services.android.bean.Vpn; -import org.wso2.carbon.mdm.services.android.bean.WebClip; -import org.wso2.carbon.mdm.services.android.bean.Wifi; -import org.wso2.carbon.mdm.services.android.bean.WipeData; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationRestrictionBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.FileTransferBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.GlobalProxyBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.DisplayMessageBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; -import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService; -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.AndroidDeviceUtils; - -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.List; - -@Path("/admin/devices") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminService { - - private static final Log log = LogFactory.getLog(DeviceManagementAdminServiceImpl.class); - private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; - - @POST - @Path("/file-transfer") - @Override - public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { - try { - if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null - || fileTransferBeanWrapper.getDeviceIDs() == null) { - String errorMessage = "The payload of the file transfer operation is incorrect."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - if (log.isDebugEnabled()) { - log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); - } - FileTransfer file = fileTransferBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - if (fileTransferBeanWrapper.isUpload()) { - operation.setCode(AndroidConstants.OperationCodes.FILE_DOWNLOAD); - } else { - operation.setCode(AndroidConstants.OperationCodes.FILE_UPLOAD); - } - operation.setType(Operation.Type.PROFILE); - operation.setEnabled(true); - operation.setPayLoad(file.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(fileTransferBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance for file transfer operation"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/lock-devices") - @Override - public Response configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device lock operation"); - } - - try { - if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) { - String errorMessage = "Lock bean is empty."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - DeviceLock lock = deviceLockBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); - operation.setType(Operation.Type.PROFILE); - operation.setEnabled(true); - operation.setPayLoad(lock.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/unlock-devices") - @Override - public Response configureDeviceUnlock(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device unlock operation."); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(true); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/location") - @Override - public Response getDeviceLocation(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device location operation."); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/clear-password") - @Override - public Response removePassword(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android clear password operation."); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance."; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/control-camera") - @Override - public Response configureCamera(CameraBeanWrapper cameraBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android Camera operation"); - } - - try { - if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the configure camera operation is incorrect."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Camera camera = cameraBeanWrapper.getOperation(); - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.CAMERA); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(camera.isEnabled()); - Activity activity = AndroidDeviceUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/info") - @Override - public Response getDeviceInformation(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking get Android device information operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); - } - } - - @POST - @Path("/logcat") - @Override - public Response getDeviceLogcat(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking get Android device logcat operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.LOGCAT); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); - } - } - - @POST - @Path("/enterprise-wipe") - @Override - public Response wipeDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking enterprise-wipe device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/wipe") - @Override - public Response wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android wipe-data device operation"); - } - - try { - if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) { - String errorMessage = "WipeData bean is empty."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - WipeData wipeData = wipeDataBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(wipeData.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/applications") - @Override - public Response getApplications(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android getApplicationList device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/ring") - @Override - public Response ringDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android ring-device device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/reboot") - @Override - public Response rebootDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android reboot-device device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/change-LockTask") - @Override - public Response changeLockTask(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android change LockTask mode operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/mute") - @Override - public Response muteDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking mute device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(true); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/install-application") - @Override - public Response installApplication( - ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'InstallApplication' operation"); - } - - try { - if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() == - null) { - String errorMessage = "The payload of the application installing operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - - ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation(); - validateApplicationUrl(applicationInstallation.getUrl()); - validateApplicationType(applicationInstallation.getType()); - validateScheduleDate(applicationInstallation.getSchedule()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationInstallation.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/update-application") - @Override - public Response updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'UpdateApplication' operation"); - } - - try { - if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the application update operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation(); - validateApplicationUrl(applicationUpdate.getUrl()); - validateApplicationType(applicationUpdate.getType()); - validateScheduleDate(applicationUpdate.getSchedule()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationUpdate.toJSON()); - - Activity activity = AndroidDeviceUtils - .getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/uninstall-application") - @Override - public Response uninstallApplication( - ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'UninstallApplication' operation"); - } - - try { - if (applicationUninstallationBeanWrapper == null || - applicationUninstallationBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the application uninstalling operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation(); - validateApplicationType(applicationUninstallation.getType()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationUninstallation.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/blacklist-applications") - @Override - public Response blacklistApplications(@Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'Blacklist-Applications' operation"); - } - - try { - if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the blacklisting apps operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(blacklistApplications.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/upgrade-firmware") - @Override - public Response upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android upgrade-firmware device operation"); - } - - try { - if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the upgrade firmware operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation(); - validateScheduleDate(upgradeFirmware.getSchedule()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(upgradeFirmware.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/configure-vpn") - @Override - public Response configureVPN(VpnBeanWrapper vpnConfiguration) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android VPN device operation"); - } - - try { - if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) { - String errorMessage = "The payload of the VPN operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Vpn vpn = vpnConfiguration.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.VPN); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(vpn.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/send-notification") - @Override - public Response sendNotification(NotificationBeanWrapper notificationBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'notification' operation"); - } - - try { - if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the notification operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Notification notification = notificationBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(notification.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/configure-wifi") - @Override - public Response configureWifi(WifiBeanWrapper wifiBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'configure wifi' operation"); - } - - try { - if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the wifi operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Wifi wifi = wifiBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.WIFI); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(wifi.toJSON()); - - Activity activity = AndroidDeviceUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/encrypt-storage") - @Override - public Response encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'encrypt' operation"); - } - - try { - if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the device encryption operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation(); - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(deviceEncryption.isEncrypted()); - Activity activity = AndroidDeviceUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/change-lock-code") - @Override - public Response changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'change lock code' operation"); - } - - try { - if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the change lock code operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - LockCode lockCode = lockCodeBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(lockCode.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/set-password-policy") - @Override - public Response setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'password policy' operation"); - } - - try { - if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the change password policy operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(passcodePolicy.toJSON()); - - Activity activity = AndroidDeviceUtils - .getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("set-webclip") - @Override - public Response setWebClip(WebClipBeanWrapper webClipBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'webclip' operation"); - } - - try { - - if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the add webclip operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - WebClip webClip = webClipBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.WEBCLIP); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(webClip.toJSON()); - - Activity activity = AndroidDeviceUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/configure-global-proxy") - @Override - public Response setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Applying 'configure-global-proxy' operation: " + - globalProxyBeanWrapper.getOperation().toJSON() + " for Devices: [" - + String.join(",", globalProxyBeanWrapper.getDeviceIDs()) + "]"); - } - - try { - if (globalProxyBeanWrapper == null || globalProxyBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the global proxy operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build()); - } - - GlobalProxy globalProxy = globalProxyBeanWrapper.getOperation(); - if (globalProxy.validateRequest()) { - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.GLOBAL_PROXY); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(globalProxy.toJSON()); - - Activity activity = AndroidDeviceUtils - .getOperationResponse(globalProxyBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } else { - String errorMessage = "The payload of the global proxy operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build()); - } - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500L).setMessage(errorMessage).build()); - } - } - @POST - @Path("/send-app-conf") - @Override - public Response sendApplicationConfiguration( - ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'send application configuration' operation"); - } - - try { - if (applicationRestrictionBeanWrapper == null || applicationRestrictionBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the application configuration operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - ApplicationRestriction applicationRestriction = applicationRestrictionBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.REMOTE_APP_CONFIG); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationRestriction.toJSON()); - return (Response) AndroidAPIUtils.getOperationResponse(applicationRestrictionBeanWrapper.getDeviceIDs(), - operation); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } catch (DeviceManagementException e) { - String errorMessage = "Issue in retrieving device management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/configure-display-message") - @Override - public Response configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'configure-display-message' operation"); - } - - try { - if (displayMessageBeanWrapper == null || displayMessageBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the display message operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST). - setMessage(errorMessage).build()); - } - DisplayMessage configureDisplayMessage = displayMessageBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.DISPLAY_MESSAGE_CONFIGURATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(configureDisplayMessage.toJSON()); - - Activity activity = AndroidDeviceUtils.getOperationResponse(displayMessageBeanWrapper. - getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST). - setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder(). - setCode(HttpStatus.SC_INTERNAL_SERVER_ERROR).setMessage(errorMessage).build()); - } - } - - private static void validateApplicationUrl(String apkUrl) { - try { - URL url = new URL(apkUrl); - URLConnection conn = url.openConnection(); - if (((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) { - String errorMessage = "URL is not pointed to a downloadable file."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } catch (MalformedURLException e) { - String errorMessage = "Malformed application url."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (IOException e) { - String errorMessage = "Invalid application url."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } - - private static void validateApplicationType(String type) { - if (type != null) { - if (!"enterprise".equalsIgnoreCase(type) - && !"public".equalsIgnoreCase(type) - && !"webapp".equalsIgnoreCase(type)) { - String errorMessage = "Invalid application type."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } else { - String errorMessage = "Application type is missing."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } - - private static void validateScheduleDate(String dateString) { - try { - if (dateString != null && !dateString.isEmpty()) { - SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); - sdf.setLenient(false); - sdf.parse(dateString); - } - } catch (ParseException e) { - String errorMessage = "Issue in validating the schedule date"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java deleted file mode 100644 index 1ffadb887..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ /dev/null @@ -1,569 +0,0 @@ -/* - * 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. - * - * - * Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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.services.impl; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; -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.policy.mgt.Policy; -import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; -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.bean.wrapper.EnterpriseUser; -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.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; -import org.wso2.carbon.mdm.services.android.util.Message; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -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.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@Path("/devices") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class DeviceManagementServiceImpl implements DeviceManagementService { - - private static final String OPERATION_ERROR_STATUS = "ERROR"; - private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); - public static final String GOOGLE_AFW_EMM_ANDROID_ID = "googleEMMAndroidId"; - public static final String GOOGLE_AFW_DEVICE_ID = "googleEMMDeviceId"; - - @PUT - @Path("/{id}/applications") - @Override - public Response updateApplicationList(@PathParam("id") - @NotNull - @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") - String id, List androidApplications) { - Application application; - List 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(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - try { - AndroidAPIUtils.getApplicationManagerService(). - updateApplicationListInstalledInDevice(deviceIdentifier, applications); - responseMessage.setResponseMessage("Device information has modified successfully."); - return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while modifying the application list."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @PUT - @Path("/{id}/pending-operations") - @Override - public Response getPendingOperations(@QueryParam("disableGoogleApps") boolean disableGoogleApps, - @PathParam("id") String id, - @HeaderParam("If-Modified-Since") String ifModifiedSince, - List resultOperations) { - if (id == null || id.isEmpty()) { - String msg = "Device identifier is null or empty, hence returning device not found"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); - try { - if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) { - String msg = "Device not found for identifier '" + id + "'"; - log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - if (log.isDebugEnabled()) { - log.debug("Invoking Android pending operations:" + id); - } - if (resultOperations != null && !resultOperations.isEmpty()) { - updateOperations(id, resultOperations); - } - } catch (OperationManagementException e) { - String msg = "Issue in retrieving operation management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (PolicyComplianceException e) { - String msg = "Issue in updating Monitoring operation"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (DeviceManagementException e) { - String msg = "Issue in retrieving device management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (ApplicationManagementException e) { - String msg = "Issue in retrieving application management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (NotificationManagementException e) { - String msg = "Issue in retrieving Notification management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - - List pendingOperations; - try { - pendingOperations = AndroidDeviceUtils.getPendingOperations(deviceIdentifier, !disableGoogleApps); - } catch (OperationManagementException e) { - String msg = "Issue in retrieving operation management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.CREATED).entity(pendingOperations).build(); - } - - private void updateOperations(String deviceId, List operations) - throws OperationManagementException, PolicyComplianceException, - ApplicationManagementException, NotificationManagementException, DeviceManagementException { - for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) { - AndroidDeviceUtils.updateOperation(deviceId, operation); - if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) { - org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new - org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); - DeviceIdentifier id = new DeviceIdentifier(); - id.setId(deviceId); - id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName(); - notification.setOperationId(operation.getId()); - notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. - Status.NEW.toString()); - notification.setDescription(operation.getCode() + " operation failed to execute on device " + - deviceName + " (ID: " + deviceId + ")"); - AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification); - } - if (log.isDebugEnabled()) { - log.debug("Updating operation '" + operation.toString() + "'"); - } - } - } - - @POST - @Override - public Response enrollDevice(@Valid AndroidDevice androidDevice) { - if (androidDevice == null) { - String errorMessage = "The payload of the android device enrollment is incorrect."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - try { - String token = null; - 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.setName(androidDevice.getName()); - device.setFeatures(androidDevice.getFeatures()); - device.setProperties(androidDevice.getProperties()); - - String googleEMMAndroidId = null; - String googleEMMDeviceId = null; - if (androidDevice.getProperties() != null) { - for (Device.Property property : androidDevice.getProperties()) { - if (property.getName().equals(GOOGLE_AFW_EMM_ANDROID_ID)) { - googleEMMAndroidId = property.getValue(); - } else if (property.getName().equals(GOOGLE_AFW_DEVICE_ID)) { - googleEMMDeviceId = property.getValue(); - } - } - - if (googleEMMAndroidId != null && googleEMMDeviceId != null) { - EnterpriseUser user = new EnterpriseUser(); - user.setAndroidPlayDeviceId(googleEMMAndroidId); - user.setEmmDeviceIdentifier(googleEMMDeviceId); - AndroidEnterpriseServiceImpl enterpriseService = new AndroidEnterpriseServiceImpl(); - token = enterpriseService.insertUser(user); - } - } - - - boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); - if (status) { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(androidDevice.getDeviceIdentifier(), - device.getType()); - - //Immediately update location information from initial payload - DeviceLocation deviceLocation = extractLocation(deviceIdentifier, androidDevice.getProperties()); - if (deviceLocation != null) { - try { - DeviceInformationManager informationManager = AndroidAPIUtils - .getDeviceInformationManagerService(); - informationManager.addDeviceLocation(deviceLocation); - } catch (DeviceDetailsMgtException e) { - String msg = "Error occurred while updating the device location upon android " + - "', which carries the id '" + androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - //Adding Tasks to get device information - List deviceIdentifiers = new ArrayList<>(); - deviceIdentifiers.add(deviceIdentifier); - - List taskOperaions = new ArrayList<>(); - taskOperaions.add(AndroidConstants.OperationCodes.APPLICATION_LIST); - taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_INFO); - taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_LOCATION); - - for (String str : taskOperaions) { - CommandOperation operation = new CommandOperation(); - operation.setEnabled(true); - operation.setType(Operation.Type.COMMAND); - operation.setCode(str); - AndroidAPIUtils.getDeviceManagementService(). - addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - operation, deviceIdentifiers); - } - PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService(); - Policy effectivePolicy = policyManagerService. - getEffectivePolicy(new DeviceIdentifier(androidDevice.getDeviceIdentifier(), device.getType())); - - if (effectivePolicy != null) { - List effectiveProfileFeatures = effectivePolicy.getProfile(). - getProfileFeaturesList(); - for (ProfileFeature feature : effectiveProfileFeatures) { - if (AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_FEATURE_CODE - .equals(feature.getFeatureCode())) { - AndroidDeviceUtils.installEnrollmentApplications(feature, deviceIdentifier); - break; - } - } - } - - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.OK.toString()); - if (token == null) { - responseMessage.setResponseMessage("Android device, which carries the id '" + - androidDevice.getDeviceIdentifier() + "' has successfully been enrolled"); - } else { - responseMessage.setResponseMessage("Google response token" + token); - } - return Response.status(Response.Status.OK).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); - responseMessage.setResponseMessage("Failed to enroll '" + - device.getType() + "' device, which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while enrolling the android, which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (PolicyManagementException e) { - String msg = "Error occurred while enforcing default enrollment policy upon android " + - "', which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (OperationManagementException e) { - String msg = "Error occurred while enforcing default enrollment policy upon android " + - "', which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (InvalidDeviceException e) { - String msg = "Error occurred while enforcing default enrollment policy upon android " + - "', which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (EnterpriseServiceException e) { - String msg = "Error occurred while adding user via Google Apis '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @GET - @Path("/{id}/status") - @Override - public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) { - DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); - try { - Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device != null) { - String status = String.valueOf(device.getEnrolmentInfo().getStatus()); - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage - .setResponseMessage("Status of android device that carries the id '" + id + "' is " + status); - return Response.status(Response.Status.OK).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString()); - responseMessage.setResponseMessage("No Android device is found upon the id '" + id + "'"); - return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while checking enrollment status of the device."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @PUT - @Path("/{id}") - @Override - public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) { - Device device; - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - try { - device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - } catch (DeviceManagementException e) { - String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" + - id + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - - if (androidDevice == null) { - String errorMessage = "The payload of the android device enrollment is incorrect."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - if (device == null) { - String errorMessage = "The device to be modified doesn't exist."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage(errorMessage).build()); - } - if(androidDevice.getEnrolmentInfo() != null){ - device.setEnrolmentInfo(device.getEnrolmentInfo()); - } - device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); - if(androidDevice.getDeviceInfo() != null) { - device.setDeviceInfo(androidDevice.getDeviceInfo()); - } - device.setDeviceIdentifier(androidDevice.getDeviceIdentifier()); - if(androidDevice.getDescription() != null) { - device.setDescription(androidDevice.getDescription()); - } - if(androidDevice.getName() != null) { - device.setName(androidDevice.getName()); - } - if(androidDevice.getFeatures() != null) { - device.setFeatures(androidDevice.getFeatures()); - } - if(androidDevice.getProperties() != null) { - device.setProperties(androidDevice.getProperties()); - } - boolean result; - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device); - if (result) { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.ACCEPTED.toString()); - responseMessage.setResponseMessage("Enrollment of Android device that " + - "carries the id '" + id + "' has successfully updated"); - return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.NOT_MODIFIED.toString()); - responseMessage.setResponseMessage("Enrollment of Android device that " + - "carries the id '" + id + "' has not been updated"); - return Response.status(Response.Status.NOT_MODIFIED).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" + - id + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @DELETE - @Path("/{id}") - @Override - public Response disEnrollDevice(@PathParam("id") String id) { - boolean result; - DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); - try { - AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier); - result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); - if (result) { - String msg = "Android device that carries id '" + id + "' is successfully "; - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage.setResponseMessage(msg + "dis-enrolled"); - return Response.status(Response.Status.OK).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString()); - responseMessage.setResponseMessage("Android device that carries id '" + id + "' is not available"); - return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while %s the Android device that carries the id '" + id + "'"; - msg = String.format(msg, "dis-enrolling"); - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - /** - * Extracts the device location - * - * @param deviceIdentifier - * @param properties - * @return returns null when location not found - */ - private DeviceLocation extractLocation(DeviceIdentifier deviceIdentifier, List properties) - throws DeviceManagementException { - - DeviceLocation location = null; - String latitude = "", longitude = "", altitude = "", speed = "", bearing = "", distance = ""; - - if (properties == null) return null; - - for (Device.Property property : properties) { - String propertyName = property.getName(); - if (propertyName == null) continue; - if (propertyName.equals("LATITUDE")) { - latitude = property.getValue(); - } - if (propertyName.equals("LONGITUDE")) { - longitude = property.getValue(); - } - if (propertyName.equals("ALTITUDE")) { - altitude = property.getValue(); - } - if (propertyName.equals("SPEED")) { - speed = property.getValue(); - } - if (propertyName.equals("BEARING")) { - bearing = property.getValue(); - } - if (propertyName.equals("DISTANCE")) { - distance = property.getValue(); - } - } - - if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude) && - StringUtils.isNotBlank(altitude) && StringUtils.isNotBlank(speed) && - StringUtils.isNotBlank(bearing) && StringUtils.isNotBlank(distance)) { - location = new DeviceLocation(); - location.setLatitude(Double.valueOf(latitude)); - location.setLongitude(Double.valueOf(longitude)); - location.setAltitude(Double.valueOf(altitude)); - location.setSpeed(Float.valueOf(speed)); - location.setBearing(Float.valueOf(bearing)); - location.setDistance(Double.valueOf(distance)); - location.setDeviceIdentifier(deviceIdentifier); - Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false); - location.setDeviceId(savedDevice.getId()); - } - return location; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceTypeConfigurationServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceTypeConfigurationServiceImpl.java deleted file mode 100644 index 385460e7c..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceTypeConfigurationServiceImpl.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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. - * - * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -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.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -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.NotifierFrequency; -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.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@Path("/configuration") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurationService { - - private static final Log log = LogFactory.getLog(DeviceTypeConfigurationServiceImpl.class); - - @GET - @Override - public Response getConfiguration( - @HeaderParam("If-Modified-Since") String ifModifiedSince) { - String msg; - PlatformConfiguration platformConfiguration; - List configs; - try { - platformConfiguration = AndroidAPIUtils.getDeviceManagementService(). - getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - if (platformConfiguration != null) { - configs = platformConfiguration.getConfiguration(); - } else { - platformConfiguration = new PlatformConfiguration(); - configs = new ArrayList<>(); - } - ConfigurationEntry entry = new ConfigurationEntry(); - License license = AndroidAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants. - TenantConfigProperties.LANGUAGE_US); - - if (configs != null) { - ConfigurationEntry versionEntry = new ConfigurationEntry(); - versionEntry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); - versionEntry.setName(AndroidConstants.TenantConfigProperties.SERVER_VERSION); - versionEntry.setValue(ServerConfiguration.getInstance().getFirstProperty("Version")); - configs.add(versionEntry); - if (license != null) { - entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); - entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); - entry.setValue(license.getText()); - configs.add(entry); - } - platformConfiguration.setConfiguration(configs); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while retrieving the Android tenant configuration"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.OK).entity(platformConfiguration).build(); - } - - @PUT - @Override - public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) { - String msg; - ConfigurationEntry licenseEntry = null; - PlatformConfiguration configuration = new PlatformConfiguration(); - if (androidPlatformConfiguration == null) { - String errorMessage = "The payload of the android platform configuration is incorrect."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - configuration.setConfiguration(androidPlatformConfiguration.getConfiguration()); - try { - configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - List configs = configuration.getConfiguration(); - NotifierFrequency notifierFrequency = new NotifierFrequency(); - for (ConfigurationEntry entry : configs) { - if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { - License license = new License(); - license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); - license.setVersion("1.0.0"); - license.setText(entry.getValue().toString()); - AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); - licenseEntry = entry; - } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) { - if (entry.getValue() != null) { - notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString())); - } else { - return Response.status(Response.Status.BAD_REQUEST) - .entity("No value specified for notifierFrequency.").build(); - } - } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_TYPE.equals(entry.getName())) { - if (entry.getValue() != null) { - notifierFrequency.setType(Integer.parseInt(entry.getValue().toString())); - } else { - return Response.status(Response.Status.BAD_REQUEST) - .entity("No value specified for notifierType.").build(); - } - } - } - - if (licenseEntry != null) { - configs.remove(licenseEntry); - } - configuration.setConfiguration(configs); - AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); - notifyDevices(notifierFrequency); - } catch (DeviceManagementException e) { - msg = "Error occurred while modifying configuration settings of Android platform"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (NumberFormatException e) { - msg = "Error occurred while reading notification frequency."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (OperationManagementException e) { - msg = "Error occurred while modifying configuration settings of Android platform."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (InvalidDeviceException e) { - msg = "Error occurred with the device."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.OK) - .entity("Android platform configuration has been updated successfully.").build(); - } - - private void notifyDevices(NotifierFrequency notifierFrequency) throws DeviceManagementException, - OperationManagementException, InvalidDeviceException { - List deviceList = AndroidAPIUtils. - getDeviceManagementService(). - getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false); - List deviceIdList = new ArrayList<>(); - for (Device device : deviceList) { - if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) { - deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); - } - } - if (!deviceIdList.isEmpty()) { - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY); - operation.setPayLoad(notifierFrequency.toJSON()); - operation.setEnabled(true); - AndroidAPIUtils.getDeviceManagementService().addOperation( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - operation, deviceIdList); - } - } - - @GET - @Path("/license") - @Produces(MediaType.TEXT_PLAIN) - public Response getLicense( - @HeaderParam("If-Modified-Since") String ifModifiedSince) { - License license; - try { - license = - AndroidAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); - } catch (DeviceManagementException e) { - String msg = "Error occurred while retrieving the license configured for Android device enrolment"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build(); - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java deleted file mode 100644 index 20c0f4921..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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.services.impl; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.mdm.services.android.bean.DeviceState; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; -import org.wso2.carbon.mdm.services.android.exception.NotFoundException; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; -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.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; -import org.wso2.carbon.mdm.services.android.util.Message; - -import javax.validation.Valid; -import javax.validation.constraints.Size; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import java.util.List; - -@Path("/events") -public class EventReceiverServiceImpl implements EventReceiverService { - private static final String EVENT_STREAM_DEFINITION = "org.wso2.iot.LocationStream"; - private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class); - private Gson gson = new Gson(); - - private static final String LONGITUDE = "longitude"; - private static final String LATITUDE = "latitude"; - private static final String ALTITUDE = "altitude"; - private static final String SPEED = "speed"; - private static final String DISTANCE = "distance"; - private static final String BEARING = "bearing"; - private static final String TIME_STAMP = "timeStamp"; - private static final String LOCATION_EVENT_TYPE = "location"; - - @POST - @Path("/publish") - @Override - public Response publishEvents(@Valid EventBeanWrapper eventBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device event logging."); - } - Device device; - try { - if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { - return Response.status(Response.Status.ACCEPTED).entity("Event is publishing has not enabled.").build(); - } - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(), - AndroidConstants.DEVICE_TYPE_ANDROID); - device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){ - return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build(); - } else if (device == null){ - return Response.status(Response.Status.ACCEPTED).entity("Device is not enrolled yet.").build(); - } - } catch (DeviceManagementException e) { - log.error("Error occurred while checking Operation Analytics is Enabled.", e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); - } - String eventType = eventBeanWrapper.getType(); - if (!LOCATION_EVENT_TYPE.equals(eventType)) { - String msg = "Dropping Android " + eventType + " Event.Only Location Event Type is supported."; - log.warn(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - Message message = new Message(); - Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), device.getEnrolmentInfo().getOwner(), - AndroidConstants.DEVICE_TYPE_ANDROID}; - String eventPayload = eventBeanWrapper.getPayload(); - JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class); - Object[] payload = { - jsonObject.get(TIME_STAMP).getAsLong(), - jsonObject.get(LATITUDE).getAsDouble(), - jsonObject.get(LONGITUDE).getAsDouble(), - jsonObject.get(ALTITUDE).getAsDouble(), - jsonObject.get(SPEED).getAsFloat(), - jsonObject.get(BEARING).getAsFloat(), - jsonObject.get(DISTANCE).getAsDouble() - }; - try { - if (AndroidAPIUtils.getEventPublisherService().publishEvent( - EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload)) { - message.setResponseCode("Event is published successfully."); - return Response.status(Response.Status.CREATED).entity(message).build(); - } else { - log.warn("Error occurred while trying to publish the event. This could be due to unavailability " + - "of the publishing service. Please make sure that analytics server is running and accessible " + - "by this server"); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(503l).setMessage("Error occurred due to " + - "unavailability of the publishing service.").build()); - } - } catch (DataPublisherConfigurationException e) { - String msg = "Error occurred while getting the Data publisher Service instance."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @GET - @Override - public Response retrieveAlerts(@QueryParam("id") - @Size(min = 2, max = 45) - String deviceId, - @QueryParam("from") long from, - @QueryParam("to") long to, - @Size(min = 2, max = 45) - @QueryParam("type") String type, - @HeaderParam("If-Modified-Since") String ifModifiedSince) { - - if (from != 0l && to != 0l && deviceId != null) { - return retrieveAlertFromDate(deviceId, from, to); - } else if (deviceId != null && type != null) { - return retrieveAlertByType(deviceId, type); - } else if (deviceId != null) { - return retrieveAlert(deviceId); - } else { - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request must contain " + - "the device identifier. Optionally, both from and to value should be present to get " + - "alerts between times.").build()); - } - } - - private Response retrieveAlert(String deviceId) { - if (log.isDebugEnabled()) { - log.debug("Retrieving events for given device Identifier."); - } - String query = "deviceIdentifier:" + deviceId; - List deviceStates; - try { - deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); - if (deviceStates == null) { - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " + - "published for Device: " + deviceId + ".").build()); - } else { - return Response.status(Response.Status.OK).entity(deviceStates).build(); - } - } catch (AnalyticsException e) { - String msg = "Error occurred while getting published events for specific device: " + deviceId + "."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - private Response retrieveAlertFromDate(String deviceId, long from, long to) { - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - if (log.isDebugEnabled()) { - log.debug("Retrieving events for given device Identifier and time period."); - } - - String query = "deviceIdentifier:" + deviceId + " AND _timestamp: [" + fromDate + " TO " + toDate + "]"; - List deviceStates; - try { - deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); - if (deviceStates == null) { - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " + - "published on given date for given Device: " + deviceId + ".").build()); - - } else { - return Response.status(Response.Status.OK).entity(deviceStates).build(); - } - } catch (AnalyticsException e) { - String msg = "Error occurred while getting published events for specific " + - "Device: " + deviceId + " on given Date."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - private Response retrieveAlertByType(String deviceId, String type) { - if (log.isDebugEnabled()) { - log.debug("Retrieving events for given device identifier and type."); - } - String query = "deviceIdentifier:" + deviceId + " AND type:" + type; - List deviceStates; - try { - deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); - if (deviceStates == null) { - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " + - "published for given Device: '" + deviceId + "' and given specific Type.").build()); - - } else { - return Response.status(Response.Status.OK).entity(deviceStates).build(); - } - } catch (AnalyticsException e) { - String msg = "Error occurred while getting published events for specific " + - "Device: " + deviceId + "and given specific Type."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/DeviceIDHolder.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/DeviceIDHolder.java deleted file mode 100644 index 7b09fc700..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/DeviceIDHolder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.util; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; - -import java.util.List; - -/** - * Holder class for storing valid & invalid device-ids. - */ -public class DeviceIDHolder { - - private List errorDeviceIdList; - private List validDeviceIDList; - - public List getErrorDeviceIdList() { - return errorDeviceIdList; - } - - public void setErrorDeviceIdList(List errorDeviceIdList) { - this.errorDeviceIdList = errorDeviceIdList; - } - - public List getValidDeviceIDList() { - return validDeviceIDList; - } - - public void setValidDeviceIDList(List validDeviceIDList) { - this.validDeviceIDList = validDeviceIDList; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 9b8fd84e1..b3afc3e28 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -34,7 +34,7 @@ - + @@ -44,8 +44,7 @@ - - + @@ -60,13 +59,13 @@ - - - - - - - + + + + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml index b62410431..33eca93f1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml @@ -76,7 +76,7 @@ ApiOriginFilter - org.wso2.carbon.mdm.services.android.util.ApiOriginFilter + org.wso2.carbon.device.mgt.mobile.android.addons.ApiOriginFilter ApiOriginFilter diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java deleted file mode 100644 index a8a267beb..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2017, 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; - -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockObjectFactory; -import org.testng.Assert; -import org.testng.IObjectFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.ObjectFactory; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.mdm.services.android.mocks.DeviceManagementProviderServiceMock; -import org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementAdminServiceImpl; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.utils.TestUtils; - -import javax.ws.rs.core.Response; - -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) -@PrepareForTest(AndroidAPIUtils.class) -public class DeviceManagementAdminServiceTests { - - private DeviceManagementAdminServiceImpl deviceManagementAdminService; - - @ObjectFactory - public IObjectFactory getObjectFactory() { - return new PowerMockObjectFactory(); - } - - @BeforeClass - public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - MockitoAnnotations.initMocks(this); - deviceManagementAdminService = new DeviceManagementAdminServiceImpl(); - } - - private void mockDeviceManagementService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService")) - .toReturn(new DeviceManagementProviderServiceMock()); - } - - @Test - public void testConfigureDeviceLock() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureDeviceLock(TestUtils.getDeviceLockBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureDeviceUnlock() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureDeviceUnlock(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetDeviceLocation() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getDeviceLocation(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testRemovePassword() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.removePassword(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureCamera() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureCamera(TestUtils.getCamerabeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetDeviceInformation() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getDeviceInformation(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetDeviceLogcat() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getDeviceLogcat(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testWipeDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.wipeDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testWipeData() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.wipeData(TestUtils.getWipeDataBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetApplications() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getApplications(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testRingDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.ringDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testRebootDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.rebootDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testChangeLockTask() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.changeLockTask(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testMuteDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.muteDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testInstallApplication() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .installApplication(TestUtils.getApplicationInstallationBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUpdateApplication() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.updateApplication(TestUtils.getApplicationUpdateBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUninstallApplicationPublic() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperPublic()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUninstallApplicationWebApp() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperWebApp()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testBlacklistApplications() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .blacklistApplications(TestUtils.getBlacklistApplicationsBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUpgradeFirmware() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.upgradeFirmware(TestUtils.getUpgradeFirmwareBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureVPN() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureVPN(TestUtils.getVpnBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testSendNotification() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.sendNotification(TestUtils.getNotificationBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureWifi() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureWifi(TestUtils.getWifiBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testEncryptStorage() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.encryptStorage(TestUtils.getEncryptionBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testChangeLockCode() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.changeLockCode(TestUtils.getLockCodeBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testSetPasswordPolicy() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.setPasswordPolicy(TestUtils.getPasswordPolicyBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testSetWebClip() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.setWebClip(TestUtils.getWebClipBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - -} - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java deleted file mode 100644 index af08bb863..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2017, 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; - -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockObjectFactory; -import org.testng.Assert; -import org.testng.IObjectFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.ObjectFactory; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; -import org.wso2.carbon.mdm.services.android.mocks.ApplicationManagementProviderServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.DeviceInformationManagerServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.DeviceManagementProviderServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.NotificationManagementServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.PolicyManagerServiceMock; -import org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementServiceImpl; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.utils.TestUtils; - -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) -@PrepareForTest(AndroidAPIUtils.class) -public class DeviceManagementServiceTests { - - private DeviceManagementServiceImpl deviceManagementService; - - @ObjectFactory - public IObjectFactory getObjectFactory() { - return new PowerMockObjectFactory(); - } - - @BeforeClass - public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - MockitoAnnotations.initMocks(this); - deviceManagementService = new DeviceManagementServiceImpl(); - } - - private void mockDeviceManagementService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService")) - .toReturn(new DeviceManagementProviderServiceMock()); - } - - private void mockApplicationManagerService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getApplicationManagerService")) - .toReturn(new ApplicationManagementProviderServiceMock()); - } - - private void mockPolicyManagerService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getPolicyManagerService")) - .toReturn(new PolicyManagerServiceMock()); - } - - private void mockDeviceInformationManagerService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceInformationManagerService")) - .toReturn(new DeviceInformationManagerServiceMock()); - } - - private void mockNotificationManagementService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getNotificationManagementService")) - .toReturn(new NotificationManagementServiceMock()); - } - - private void mockUser() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getAuthenticatedUser")) - .toReturn("admin"); - } - - @Test - public void testUpdateApplicationList() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockApplicationManagerService(); - Response response = deviceManagementService - .updateApplicationList(TestUtils.getDeviceId(), TestUtils.getAndroidApplications()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsForNullDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - Response response = deviceManagementService - .getPendingOperations(true, null, null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); - } - - @Test - public void testGetPendingOperationsInvalidDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService - .getPendingOperations(true, "1234", null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - - @Test - public void testGetPendingOperationsNullResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService - .getPendingOperations(true, TestUtils.getDeviceId(), null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithMonitorResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockPolicyManagerService(); - Response response = deviceManagementService - .getPendingOperations(true, TestUtils.getDeviceId(), null, - TestUtils.getSuccessMonitorOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithApplicationResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockApplicationManagerService(); - Response response = deviceManagementService - .getPendingOperations(true, TestUtils.getDeviceId(), null, - TestUtils.getSuccessApplicationOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithDeviceInfoResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockDeviceInformationManagerService(); - Response response = deviceManagementService - .getPendingOperations(true, TestUtils.getDeviceId(), null, - TestUtils.getSuccessInfoOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithInProgressResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService - .getPendingOperations(true, TestUtils.getDeviceId(), null, - TestUtils.getInProgressOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithErrorResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockNotificationManagementService(); - Response response = deviceManagementService - .getPendingOperations(true, TestUtils.getDeviceId(), null, - TestUtils.getErrorOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testEnrollDeviceWithoutLocationSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockPolicyManagerService(); - mockUser(); - Response response = deviceManagementService.enrollDevice(TestUtils.getBasicAndroidDevice()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testEnrollDeviceWithLocationSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockDeviceInformationManagerService(); - mockPolicyManagerService(); - mockUser(); - AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); - - List properties = new ArrayList<>(); - Device.Property property = new Device.Property(); - property.setName("LATITUDE"); - property.setValue("79.5"); - properties.add(property); - property = new Device.Property(); - property.setName("LONGITUDE"); - property.setValue("6.9"); - properties.add(property); - property = new Device.Property(); - property.setName("ALTITUDE"); - property.setValue("-59.8373726"); - properties.add(property); - property = new Device.Property(); - property.setName("SPEED"); - property.setValue("0.5123423333"); - properties.add(property); - property = new Device.Property(); - property.setName("BEARING"); - property.setValue("44.0"); - properties.add(property); - property = new Device.Property(); - property.setName("DISTANCE"); - property.setValue("44.0"); - properties.add(property); - androidDevice.setProperties(properties); - - Response response = deviceManagementService.enrollDevice(androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testEnrollDeviceUnSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockUser(); - AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); - androidDevice.setDeviceIdentifier("1234"); - Response response = deviceManagementService.enrollDevice(androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } - - @Test - public void testIsEnrolledExists() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.isEnrolled(TestUtils.getDeviceId(), null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testIsEnrolledNonExist() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.isEnrolled("1234", null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - - @Test - public void testIsEnrolledNull() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.isEnrolled(null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - - @Test - public void testModifyEnrollmentSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockUser(); - Response response = deviceManagementService - .modifyEnrollment(TestUtils.getDeviceId(), TestUtils.getBasicAndroidDevice()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode()); - } - - @Test - public void testModifyEnrollmentUnSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockUser(); - AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); - androidDevice.setDeviceIdentifier("1234"); - Response response = deviceManagementService - .modifyEnrollment(TestUtils.getDeviceId(), androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); - } - - @Test - public void testDisEnrollDeviceSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testDisenrollUnSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice("1234"); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - -} - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml new file mode 100644 index 000000000..7d14948c6 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/pom.xml @@ -0,0 +1,167 @@ + + + + + + android-plugin + org.wso2.carbon.devicemgt-plugins + 5.0.7-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.android.common + bundle + WSO2 Carbon - Mobile Device Management Android Common Impl + WSO2 Carbon - Mobile Device Management Android Common Implementation + https://entgra.io/ + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.devicemgt.plugins.version} + Device Management Mobile Android Impl Bundle + + io.swagger.annotations.*;resolution:=optional, + javax.validation.constraints, + javax.xml.bind.annotation.*, + javax.xml, + javax.xml.stream, + javax.xml.bind.*, + javax.xml.parsers; version=0.0.0, + javax.naming, + org.wso2.carbon.context, + org.wso2.carbon.utils.*, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.ndatasource.core, + org.wso2.carbon.policy.mgt.common.*, + org.wso2.carbon.device.mgt.extensions.license.mgt.registry, + com.google.gson.* + + + org.wso2.carbon.device.mgt.mobile.android.common.* + + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.wso2.carbon + org.wso2.carbon.logging + + + com.google.code.gson + gson + + + com.google.apis + google-api-services-androidenterprise + v1-rev186-1.25.0 + + + commons-logging + commons-logging + + + + + io.swagger + swagger-annotations + + + org.hibernate + hibernate-validator + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + provided + + + commons-logging + commons-logging + + + objenesis + org.objenesis + + + guava + com.google.guava + + + + + org.codehaus.jackson + jackson-core-asl + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + + + woodstox-core-asl + org.codehaus.woodstox + + + commons-logging + commons-logging + + + axiom-api + org.apache.ws.commons.axiom + + + geronimo-stax-api_1.0_spec + org.apache.geronimo.specs.wso2 + + + axis2-client + org.apache.axis2.wso2 + + + httpcore + org.apache.httpcomponents + + + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/AndroidConstants.java similarity index 99% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/AndroidConstants.java index e7d618b70..d96c8d0e5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/AndroidConstants.java @@ -50,7 +50,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.common; /** * Defines constants used in Android-REST API bundle. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/AndroidPluginConstants.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/AndroidPluginConstants.java index a0c7a332d..79835c2bb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/AndroidPluginConstants.java @@ -34,7 +34,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.util; +package org.wso2.carbon.device.mgt.mobile.android.common; /** * Defines constants used by android plugin. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GoogleAPIInvoker.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/GoogleAPIInvoker.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GoogleAPIInvoker.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/GoogleAPIInvoker.java index 4e700a7e1..da1cc2023 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GoogleAPIInvoker.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/GoogleAPIInvoker.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.common; +package org.wso2.carbon.device.mgt.mobile.android.common; import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; @@ -49,11 +49,11 @@ import com.google.api.services.androidenterprise.model.User; import com.google.common.collect.ImmutableList; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStoreCluster; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePackages; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseStorePage; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseTokenUrl; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStoreCluster; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePackages; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseStorePage; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseTokenUrl; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/Message.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/Message.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/Message.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/Message.java index 8cb5f6d14..b8168d837 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/Message.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/Message.java @@ -16,9 +16,8 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.common; -import javax.ws.rs.core.MediaType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AndroidOperation.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AndroidOperation.java index 3361b90dc..aeccd384d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AndroidOperation.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import com.google.gson.Gson; /* diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AndroidPlatformConfiguration.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AndroidPlatformConfiguration.java index 9832c3f03..7dc0505ec 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AndroidPlatformConfiguration.java @@ -16,12 +16,11 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.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.Pattern; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApiRegistrationProfile.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApiRegistrationProfile.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApiRegistrationProfile.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApiRegistrationProfile.java index 6b14c0d38..a88a907e7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApiRegistrationProfile.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApiRegistrationProfile.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; public class ApiRegistrationProfile { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AppRestriction.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AppRestriction.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AppRestriction.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AppRestriction.java index 2c8d8c93d..4f82dcc7c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AppRestriction.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/AppRestriction.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationInstallation.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationInstallation.java index 4c90d42cb..3fcfc34a1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationInstallation.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationRestriction.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationRestriction.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationRestriction.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationRestriction.java index b3773376d..1ed7f1243 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationRestriction.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationRestriction.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationUninstallation.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationUninstallation.java index a5356ae59..e8efbdef0 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationUninstallation.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationUpdate.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationUpdate.java index 95241b444..cd9084df1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ApplicationUpdate.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BasicUserInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/BasicUserInfo.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BasicUserInfo.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/BasicUserInfo.java index 6117fb246..1f361b336 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BasicUserInfo.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/BasicUserInfo.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/BlacklistApplications.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/BlacklistApplications.java index b7db28976..cf99c2cf4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/BlacklistApplications.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Camera.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Camera.java index 0dad70364..21ee35f08 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Camera.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceEncryption.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceEncryption.java index 68ab6ae94..0b5473de1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceEncryption.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceLock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceLock.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceLock.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceLock.java index e76ff6f1a..f0475d7c3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceLock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceLock.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceState.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceState.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceState.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceState.java index fb23b0fcc..911fe5f37 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceState.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DeviceState.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Disenrollment.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Disenrollment.java index c591d2ae0..99e329c7d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Disenrollment.java @@ -16,11 +16,11 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; + import java.io.Serializable; @ApiModel(value = "Disenrollment", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DisplayMessage.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DisplayMessage.java index 20531f6f9..eda425738 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/DisplayMessage.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseConfigs.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseConfigs.java similarity index 90% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseConfigs.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseConfigs.java index 41abaa380..81d58ec42 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseConfigs.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseConfigs.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; public class EnterpriseConfigs { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStoreCluster.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStoreCluster.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStoreCluster.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStoreCluster.java index a29e46e1a..59d2eff9c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStoreCluster.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStoreCluster.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePackages.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePackages.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePackages.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePackages.java index a93672892..69dba56d9 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePackages.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePackages.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; public class EnterpriseStorePackages { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePage.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePage.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePage.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePage.java index 841338d52..b6b578897 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePage.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePage.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePageLinks.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePageLinks.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePageLinks.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePageLinks.java index 9fb4f5050..73b514830 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseStorePageLinks.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseStorePageLinks.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseTokenUrl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseTokenUrl.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseTokenUrl.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseTokenUrl.java index e93e20c10..7aaf2739d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/EnterpriseTokenUrl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/EnterpriseTokenUrl.java @@ -17,7 +17,7 @@ * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; public class EnterpriseTokenUrl { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorListItem.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ErrorListItem.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorListItem.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ErrorListItem.java index 1e48b0183..2d8ca0856 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorListItem.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ErrorListItem.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ErrorResponse.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ErrorResponse.java index 457782ade..97b7eb768 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ErrorResponse.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/FileTransfer.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/FileTransfer.java index 2e8af23a7..8677147f5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/FileTransfer.java @@ -15,11 +15,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.AndroidOperation; import java.io.Serializable; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/GlobalProxy.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/GlobalProxy.java index 5414a1407..46fb31c73 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/GlobalProxy.java @@ -17,7 +17,7 @@ * */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GoogleAppSyncResponse.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/GoogleAppSyncResponse.java similarity index 77% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GoogleAppSyncResponse.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/GoogleAppSyncResponse.java index 3eafae848..896eeef08 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GoogleAppSyncResponse.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/GoogleAppSyncResponse.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; public class GoogleAppSyncResponse { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/LockCode.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/LockCode.java index 4c2764dad..0e139e924 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/LockCode.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Notification.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Notification.java index 7cc4d4627..ade05a1a4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Notification.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/NotifierFrequency.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/NotifierFrequency.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/NotifierFrequency.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/NotifierFrequency.java index b38a8b802..f441ffb1e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/NotifierFrequency.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/NotifierFrequency.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java index c2e48ce70..8cd56e51e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ProxyType.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ProxyType.java new file mode 100644 index 000000000..d638b071f --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/ProxyType.java @@ -0,0 +1,5 @@ +package org.wso2.carbon.device.mgt.mobile.android.common.bean; + +public enum ProxyType { + MANUAL, AUTO +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/UpgradeFirmware.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/UpgradeFirmware.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/UpgradeFirmware.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/UpgradeFirmware.java index 748ee0e59..f07a519db 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/UpgradeFirmware.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/UpgradeFirmware.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Vpn.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Vpn.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Vpn.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Vpn.java index 188d44f8f..76be3fc28 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Vpn.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Vpn.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/WebClip.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/WebClip.java index cf39b1070..06b815df4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/WebClip.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Wifi.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Wifi.java index 8cdf3c58b..d8e130987 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/Wifi.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/WipeData.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/WipeData.java index 83efddc12..ff1c05bc0 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/WipeData.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean; +package org.wso2.carbon.device.mgt.mobile.android.common.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidApplication.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidApplication.java index 8dee1a60d..1c1776350 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidApplication.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidDevice.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidDevice.java index 6c5fcec34..274b6ec89 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidDevice.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.Device; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidDeviceInfo.java similarity index 99% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidDeviceInfo.java index 41fbb5857..148d46d56 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AndroidDeviceInfo.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AppRestrictionBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AppRestrictionBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AppRestrictionBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AppRestrictionBeanWrapper.java index 64412336e..70a520b89 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AppRestrictionBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/AppRestrictionBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.AppRestriction; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.AppRestriction; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationInstallationBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationInstallationBeanWrapper.java index b0bd54cf3..688703080 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationInstallationBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationInstallation; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationRestrictionBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationRestrictionBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationRestrictionBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationRestrictionBeanWrapper.java index 147a577da..0f6e8b979 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationRestrictionBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationRestrictionBeanWrapper.java @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationRestriction; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationRestriction; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationUninstallationBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationUninstallationBeanWrapper.java index 28c72c6cd..ad88bbb35 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationUninstallationBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUninstallation; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUpdateBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationUpdateBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUpdateBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationUpdateBeanWrapper.java index b202bf883..241cec506 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUpdateBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/ApplicationUpdateBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUpdate; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/BlacklistApplicationsBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/BlacklistApplicationsBeanWrapper.java index 32b107bf4..19f0e5a36 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/BlacklistApplicationsBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.BlacklistApplications; import javax.validation.Valid; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/CameraBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/CameraBeanWrapper.java index 9f9a014f2..04ac86a90 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/CameraBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Camera; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Camera; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DeviceEnrollmentInfo.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DeviceEnrollmentInfo.java index b2f77cc31..c6882a6e7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DeviceEnrollmentInfo.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceLockBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DeviceLockBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceLockBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DeviceLockBeanWrapper.java index bd668faba..31e5e41aa 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceLockBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DeviceLockBeanWrapper.java @@ -16,11 +16,11 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.DeviceLock; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceLock; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DisenrollmentBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DisenrollmentBeanWrapper.java index fdcab0120..308da5161 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DisenrollmentBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Disenrollment; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Disenrollment; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DisplayMessageBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DisplayMessageBeanWrapper.java index 8ef1fe644..ca1330b3c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/DisplayMessageBeanWrapper.java @@ -16,11 +16,11 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.DisplayMessage; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DisplayMessage; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EncryptionBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EncryptionBeanWrapper.java index aeb01400a..557d39540 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EncryptionBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceEncryption; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseApp.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseApp.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseApp.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseApp.java index e20d1547d..1d12d1d95 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseApp.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseApp.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import com.google.api.services.androidenterprise.model.VariableSet; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseInstallPolicy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseInstallPolicy.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseInstallPolicy.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseInstallPolicy.java index 677e6d33c..fe659659b 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseInstallPolicy.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseInstallPolicy.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import java.io.Serializable; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseUser.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseUser.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseUser.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseUser.java index 990e3fa4e..ff9bc4b38 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EnterpriseUser.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EnterpriseUser.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; public class EnterpriseUser { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EventBeanWrapper.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EventBeanWrapper.java index c4fb13e07..ed4e314d3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/EventBeanWrapper.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/FileTransferBeanWrapper.java similarity index 93% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/FileTransferBeanWrapper.java index d34b00e66..4777c3133 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/FileTransferBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.FileTransfer; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.FileTransfer; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/GlobalProxyBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/GlobalProxyBeanWrapper.java similarity index 92% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/GlobalProxyBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/GlobalProxyBeanWrapper.java index 1063ee260..09c3bc0e3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/GlobalProxyBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/GlobalProxyBeanWrapper.java @@ -17,11 +17,11 @@ * */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.GlobalProxy; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.GlobalProxy; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/LockCodeBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/LockCodeBeanWrapper.java index 364fd39d2..4cf164d46 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/LockCodeBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.LockCode; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.LockCode; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/NotificationBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/NotificationBeanWrapper.java index eb82e49ee..97bb7f706 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/NotificationBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Notification; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Notification; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/PasswordPolicyBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/PasswordPolicyBeanWrapper.java index e47ece1c5..b9e728624 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/PasswordPolicyBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.PasscodePolicy; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/TokenWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/TokenWrapper.java similarity index 72% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/TokenWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/TokenWrapper.java index a3a706efa..7bf731e18 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/TokenWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/TokenWrapper.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; public class TokenWrapper { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/UpgradeFirmwareBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/UpgradeFirmwareBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/UpgradeFirmwareBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/UpgradeFirmwareBeanWrapper.java index b881422c2..ed0231d6a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/UpgradeFirmwareBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/UpgradeFirmwareBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.UpgradeFirmware; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/VpnBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/VpnBeanWrapper.java index e71270d22..1a2d67a59 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/VpnBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Vpn; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Vpn; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WebClipBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WebClipBeanWrapper.java index fb2edc239..6f8667311 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WebClipBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.WebClip; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.WebClip; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WifiBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WifiBeanWrapper.java index 2d63a27d9..85e6df2d3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WifiBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Wifi; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Wifi; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WipeDataBeanWrapper.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WipeDataBeanWrapper.java index b7ebb2903..fe753bd3f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/wrapper/WipeDataBeanWrapper.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.WipeData; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.WipeData; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/AndroidDataSourceConfigurations.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/AndroidDataSourceConfigurations.java index 9409bab13..a0d3fbbd7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/AndroidDataSourceConfigurations.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.common.config.datasource; import javax.xml.bind.annotation.XmlElement; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/DataSourceConfigAdapter.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/DataSourceConfigAdapter.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/DataSourceConfigAdapter.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/DataSourceConfigAdapter.java index 75a95c7c7..5b0aa5713 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/DataSourceConfigAdapter.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/DataSourceConfigAdapter.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.common.config.datasource; import javax.xml.bind.annotation.adapters.XmlAdapter; import java.util.HashMap; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/JNDILookupDefinition.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/JNDILookupDefinition.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/JNDILookupDefinition.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/JNDILookupDefinition.java index d98022058..770963989 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/JNDILookupDefinition.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/JNDILookupDefinition.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.common.config.datasource; import javax.xml.bind.annotation.*; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/MobileDataSourceConfig.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfig.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/MobileDataSourceConfig.java index cb0e78fb2..09bb84de4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfig.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/MobileDataSourceConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.common.config.datasource; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfigurations.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/MobileDataSourceConfigurations.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfigurations.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/MobileDataSourceConfigurations.java index c698e7800..b4613bd99 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfigurations.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/datasource/MobileDataSourceConfigurations.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.common.config.datasource; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/task/TaskConfiguration.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/task/TaskConfiguration.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/task/TaskConfiguration.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/task/TaskConfiguration.java index 9c98306fb..56b873c34 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/task/TaskConfiguration.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/config/task/TaskConfiguration.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.config.task; +package org.wso2.carbon.device.mgt.mobile.android.common.config.task; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/AndroidEnterpriseManagedConfig.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/AndroidEnterpriseManagedConfig.java index 687327d6d..30e717dc7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/AndroidEnterpriseManagedConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; public class AndroidEnterpriseManagedConfig { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/AndroidEnterpriseUser.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/AndroidEnterpriseUser.java index 48bddbb03..afd64a12e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/AndroidEnterpriseUser.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; public class AndroidEnterpriseUser { String emmUsername; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/ErrorDTO.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/ErrorDTO.java index ebd5ec8fc..44e3385ca 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/ErrorDTO.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.exception; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; import java.util.ArrayList; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileDevice.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileDevice.java index 2b064452a..7644cb3cc 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileDevice.java @@ -16,10 +16,9 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; import java.io.Serializable; -import java.util.Date; import java.util.HashMap; import java.util.Map; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDeviceOperationMapping.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileDeviceOperationMapping.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDeviceOperationMapping.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileDeviceOperationMapping.java index ae855e2ab..279f93883 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDeviceOperationMapping.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileDeviceOperationMapping.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; /** * DTO of Mobile Device Operation Mappings. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeature.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileFeature.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeature.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileFeature.java index 1778f8560..576fd92c7 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeature.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileFeature.java @@ -34,7 +34,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; import java.io.Serializable; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileOperation.java similarity index 96% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperation.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileOperation.java index fa9723484..5f1571394 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileOperation.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperationProperty.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileOperationProperty.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperationProperty.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileOperationProperty.java index 5147bb004..04f7b58d5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperationProperty.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/dto/MobileOperationProperty.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dto; +package org.wso2.carbon.device.mgt.mobile.android.common.dto; /** * DTO of Mobile Operation property. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceMgtPluginException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/AndroidDeviceMgtPluginException.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceMgtPluginException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/AndroidDeviceMgtPluginException.java index 4a0b6a1c7..117c42905 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceMgtPluginException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/AndroidDeviceMgtPluginException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl; +package org.wso2.carbon.device.mgt.mobile.android.common.exception; public class AndroidDeviceMgtPluginException extends Exception{ diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/BadRequestException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/BadRequestException.java new file mode 100644 index 000000000..3ca97f7f6 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/BadRequestException.java @@ -0,0 +1,32 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.common.exception; + +/** + * Represents the exception thrown during validating the request. + */ +public class BadRequestException extends AndroidDeviceMgtPluginException { + + public BadRequestException(String message, Throwable ex) { + super(message, ex); + } + + public BadRequestException(String message) { + super(message); + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/EnterpriseManagementDAOException.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/EnterpriseManagementDAOException.java index 86af32e80..4b8c17276 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/EnterpriseManagementDAOException.java @@ -33,7 +33,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao; +package org.wso2.carbon.device.mgt.mobile.android.common.exception; /** * Custom exception class for enterprise specific data access related exceptions. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/EnterpriseServiceException.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/EnterpriseServiceException.java index d8b5e80df..9153f5948 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/EnterpriseServiceException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl; +package org.wso2.carbon.device.mgt.mobile.android.common.exception; /** * Custom exception class for enterprise specific data access related exceptions. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/MobileDeviceManagementDAOException.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/MobileDeviceManagementDAOException.java index f87ddbfec..395da6acd 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/MobileDeviceManagementDAOException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao; +package org.wso2.carbon.device.mgt.mobile.android.common.exception; /** * Custom exception class for mobile device specific data access related exceptions. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/NotFoundException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/NotFoundException.java new file mode 100644 index 000000000..0a9679f61 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/NotFoundException.java @@ -0,0 +1,32 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.common.exception; + +/** + * Represents the exception thrown during validating the request. + */ +public class NotFoundException extends AndroidDeviceMgtPluginException { + + public NotFoundException(String message, Throwable ex) { + super(message, ex); + } + + public NotFoundException(String message) { + super(message); + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/OperationConfigurationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/OperationConfigurationException.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/OperationConfigurationException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/OperationConfigurationException.java index 1300b1481..93f677aa4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/OperationConfigurationException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/OperationConfigurationException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.exception; +package org.wso2.carbon.device.mgt.mobile.android.common.exception; /** * diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/UnexpectedServerErrorException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/UnexpectedServerErrorException.java new file mode 100644 index 000000000..d6490f761 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/exception/UnexpectedServerErrorException.java @@ -0,0 +1,12 @@ +package org.wso2.carbon.device.mgt.mobile.android.common.exception; + +public class UnexpectedServerErrorException extends AndroidDeviceMgtPluginException{ + + public UnexpectedServerErrorException(String message, Throwable ex) { + super(message, ex); + } + + public UnexpectedServerErrorException(String message) { + super(message); + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidGoogleEnterpriseService.java similarity index 80% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidGoogleEnterpriseService.java index 371eecaa9..d964ab6bd 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidGoogleEnterpriseService.java @@ -16,15 +16,15 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android; +package org.wso2.carbon.device.mgt.mobile.android.common.spi; -import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException; import java.util.List; -public interface AndroidPluginService { +public interface AndroidGoogleEnterpriseService { void addEnterpriseUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseServiceException; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java new file mode 100644 index 000000000..9467460ef --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java @@ -0,0 +1,477 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.common.spi; + +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; +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.core.operation.mgt.ProfileOperation; +import org.wso2.carbon.device.mgt.mobile.android.common.Message; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.AndroidPlatformConfiguration; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.*; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; + +import javax.ws.rs.core.Response; +import java.util.List; + +public interface AndroidService { + + /** + * Method to retrieve platform configurations + * + * @return {@link PlatformConfiguration} + * @throws {@link DeviceManagementException} If some unusual behaviour is observed while getting platform configurations + */ + PlatformConfiguration getPlatformConfig() throws DeviceManagementException; + + /** + * Method to update configurations + * + * @param androidPlatformConfiguration + * @throws {@link AndroidDeviceMgtPluginException} + */ + void updateConfiguration(AndroidPlatformConfiguration androidPlatformConfiguration) + throws AndroidDeviceMgtPluginException; + + /** + * Method for file transfer operation + * + * @param fileTransferBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} If some unusual behaviour is observed while executing file transfer operation + */ + Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) + throws AndroidDeviceMgtPluginException, OperationManagementException; + + /** + * Method for device lock operation + * + * @param deviceLockBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} If some unusual behaviour is observed while executing device lock operation + */ + Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for device unlock operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity configureDeviceUnlock(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for get device location operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity getDeviceLocation(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for remove password operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity removePassword(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for configure camera operation + * + * @param cameraBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity configureCamera(CameraBeanWrapper cameraBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method to get device information + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity getDeviceInformation(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method to get device logcat + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity getDeviceLogcat(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for wipe device operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity wipeDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for wipe data operation + * + * @param wipeDataBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for get applications operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity getApplications(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for ring device operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity ringDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for reboot device operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity rebootDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for change lock task operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity changeLockTask(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for mute device operation + * + * @param deviceIDs A list of device IDs + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity muteDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for install application operation + * + * @param applicationInstallationBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for update application operation + * + * @param applicationUpdateBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for uninstall application operation + * + * @param applicationUninstallationBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for blacklist application operation + * + * @param blacklistApplicationsBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity blacklistApplications(BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for upgrade firmware operation + * + * @param upgradeFirmwareBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for configure vpn operation + * + * @param vpnConfiguration + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity configureVPN(VpnBeanWrapper vpnConfiguration) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for send notification operation + * + * @param notificationBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity sendNotification(NotificationBeanWrapper notificationBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for configure wifi operation + * + * @param wifiBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity configureWifi(WifiBeanWrapper wifiBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for encypt storage operation + * + * @param encryptionBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for change lock code operation + * + * @param lockCodeBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for set password policy operation + * + * @param passwordPolicyBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for set webclip operation + * + * @param webClipBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity setWebClip(WebClipBeanWrapper webClipBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for set recommended global proxy operation + * + * @param globalProxyBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for send application configuration operation + * + * @param applicationRestrictionBeanWrapper + * @return + * @throws {@link AndroidDeviceMgtPluginException} + */ + ProfileOperation sendApplicationConfiguration( + ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper) + throws AndroidDeviceMgtPluginException; + + /** + * method for configure display message operation + * + * @param displayMessageBeanWrapper + * @return {@link Activity} + * @throws {@link AndroidDeviceMgtPluginException} + * @throws {@link OperationManagementException} + */ + Activity configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException; + + /** + * Method for update application list + * + * @param id Id of the device to update application list + * @param androidApplications List of AndroidApplication objects to update + * @return {@link Message} + * @throws {@link ApplicationManagementException} + */ + Message updateApplicationList(String id, List androidApplications) + throws ApplicationManagementException; + + /** + * Method for get pending operations + * + * @param id Id of the device to get pending operations + * @param resultOperations Result operations list + * @param disableGoogleApps Check whether google apps are disabled + * @return + * @throws {@link DeviceManagementException} + * @throws {@link InvalidDeviceException} + */ + List getPendingOperations + (String id, List resultOperations, boolean disableGoogleApps) + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException; + + /** + * Method to enroll device + * + * @param androidDevice Instance of AndroidDevice to enroll + * @return {@link Response} + * @throws {@link DeviceManagementException} + */ + Message enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException, AndroidDeviceMgtPluginException; + + /** + * Method to check if a device is enrolled + * + * @param id Id of the device to check + * @param deviceIdentifier Device Identifier of the device to check + * @return {@link Message} + * @throws {@link DeviceManagementException} + */ + Message isEnrolled(String id, DeviceIdentifier deviceIdentifier) throws DeviceManagementException; + + /** + * Method to modify enrollment + * + * @param id Id of the device to modify enrollement + * @param androidDevice AndroidDevice object of the device to modify enrollment + * @return + * @throws {@link DeviceManagementException} + * @throws {@link AndroidDeviceMgtPluginException} + */ + boolean modifyEnrollment(String id, AndroidDevice androidDevice) + throws DeviceManagementException, AndroidDeviceMgtPluginException; + + /** + * Method to disenroll a device + * + * @param id Id of the device to disenroll + * @return + * @throws {@link DeviceManagementException} + */ + boolean disEnrollDevice(String id) throws DeviceManagementException; + + /** + * Method to publish events + * + * @param eventBeanWrapper + * @return {@link Device} + * @throws {@link DeviceManagementException} + */ + Message publishEvents(EventBeanWrapper eventBeanWrapper) + throws DeviceManagementException, AndroidDeviceMgtPluginException; + + /** + * Method to retrieve alerts + * + * @param deviceId Id of the device to retrieve alerts + * @param from Start date to retrieve alerts + * @param to End date to retrieve alerts + * @param type Type to retrieve alerts + * @param ifModifiedSince + * @return {@link Response} + * @throws {@link AndroidDeviceMgtPluginException} + */ + List retrieveAlerts(String deviceId, long from, long to, String type, String ifModifiedSince) + throws AndroidDeviceMgtPluginException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml new file mode 100644 index 000000000..8d07d4532 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/pom.xml @@ -0,0 +1,424 @@ + + + + + + + android-plugin + org.wso2.carbon.devicemgt-plugins + 5.0.7-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.mobile.android.core + bundle + WSO2 Carbon - Mobile Device Management Android Core Impl + WSO2 Carbon - Mobile Device Management Android Core Implementation + http://wso2.org + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.devicemgt.plugins.version} + Device Management Mobile Android Impl Bundle + org.wso2.carbon.device.mgt.mobile.android.core.internal + + org.osgi.framework, + org.osgi.service.component, + org.apache.commons.logging, + javax.xml, + javax.xml.stream, + javax.xml.bind.*, + javax.sql, + javax.xml.parsers; version=0.0.0, + org.w3c.dom, + javax.naming, + org.wso2.carbon.context, + org.wso2.carbon.utils.*, + org.wso2.carbon.device.mgt.mobile.android.common.*, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.core.*, + org.wso2.carbon.ndatasource.core, + org.wso2.carbon.policy.mgt.common.*, + org.wso2.carbon.policy.mgt.core.*, + org.wso2.carbon.registry.core, + org.wso2.carbon.registry.core.session, + org.wso2.carbon.registry.core.service, + org.wso2.carbon.registry.api, + org.wso2.carbon.device.mgt.extensions.license.mgt.registry, + org.wso2.carbon.apimgt.application.extension.*, + org.wso2.carbon.analytics.datasource.commons.*, + org.wso2.carbon.base, + com.google.gson.*, + org.wso2.carbon.device.application.mgt.common.*, + org.wso2.carbon.user.core.*, + org.wso2.carbon.user.api.*, + org.apache.commons.httpclient, + org.apache.http, + org.apache.http.client.methods, + org.wso2.carbon.device.mgt.analytics.data.publisher.* + + + !org.wso2.carbon.device.mgt.mobile.android.core.internal, + org.wso2.carbon.device.mgt.mobile.android.core.* + + + + + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.extensions + + + woodstox-core-asl + org.codehaus.woodstox + + + + + org.wso2.carbon + org.wso2.carbon.ndatasource.core + + + commons-logging + commons-logging + + + + + org.wso2.carbon + org.wso2.carbon.registry.api + + + org.wso2.carbon + org.wso2.carbon.registry.core + + + org.apache.tomcat.wso2 + jdbc-pool + + + com.google.code.gson + gson + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + + + org.slf4j + slf4j-api + + + axis2-client + org.apache.axis2.wso2 + + + axiom-api + org.apache.ws.commons.axiom + + + httpcore + org.apache.httpcomponents + + + commons-logging + commons-logging + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.mgt.core + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.application.extension + + + commons-logging + commons-logging + + + slf4j-api + org.slf4j + + + geronimo-stax-api_1.0_spec + org.apache.geronimo.specs.wso2 + + + xml-apis + xml-apis + + + jackson-core + com.fasterxml.jackson.core + + + validation-api + javax.validation + + + jackson-mapper-asl + org.codehaus.jackson + + + axiom-api + org.apache.ws.commons.axiom + + + axiom-impl + org.apache.ws.commons.axiom + + + xercesImpl + xerces + + + commons-httpclient + commons-httpclient + + + jackson-databind + com.fasterxml.jackson.core + + + commons-beanutils + commons-beanutils + + + org.eclipse.core.runtime + org.eclipse.core + + + commons-pool + commons-pool + + + XmlSchema + org.apache.ws.commons.schema + + + tomcat + org.wso2.tomcat + + + guava + com.google.guava + + + codemodel + com.sun.codemodel + + + hibernate + org.hibernate + + + asm + asm + + + geronimo-jta_1.1_spec + org.apache.geronimo.specs + + + wstx-asl + org.codehaus.woodstox + + + wsdl4j + wsdl4j.wso2 + + + commons-fileupload + commons-fileupload + + + org.wso2.carbon.ntask.core + org.wso2.carbon.commons + + + org.wso2.securevault + org.wso2.securevault + + + maven-scm-provider-svnexe + org.apache.maven.scm + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + guava + com.google.guava + + + objenesis + org.objenesis + + + commons-logging + commons-logging + + + org.wso2.carbon.feature.mgt.core + org.wso2.carbon + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + + + org.testng + testng + test + + + org.powermock + powermock-module-testng + test + + + objenesis + org.objenesis + + + + + org.powermock + powermock-api-mockito + test + + + com.h2database.wso2 + h2-database-engine + test + + + org.wso2.carbon + org.wso2.carbon.queuing + test + + + commons-dbcp.wso2 + commons-dbcp + test + + + commons-pool.wso2 + commons-pool + test + + + org.wso2.carbon + javax.cache.wso2 + test + + + javassist + javassist + test + + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/AbstractMobileDeviceManagementDAOFactory.java similarity index 90% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/AbstractMobileDeviceManagementDAOFactory.java index 634951826..e22bfabcc 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/AbstractMobileDeviceManagementDAOFactory.java @@ -16,14 +16,14 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao; +package org.wso2.carbon.device.mgt.mobile.android.core.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.android.common.config.datasource.JNDILookupDefinition; +import org.wso2.carbon.device.mgt.mobile.android.common.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.util.MobileDeviceManagementDAOUtil; import javax.sql.DataSource; import java.util.HashMap; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/AndroidDAOFactory.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/AndroidDAOFactory.java index 2ccd09374..d18cc0f8a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/AndroidDAOFactory.java @@ -16,12 +16,13 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao; +package org.wso2.carbon.device.mgt.mobile.android.core.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.EnterpriseDAOImpl; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.impl.EnterpriseDAOImpl; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/EnterpriseDAO.java similarity index 85% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/EnterpriseDAO.java index 284e64cf8..931f184f8 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/EnterpriseDAO.java @@ -16,10 +16,11 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao; +package org.wso2.carbon.device.mgt.mobile.android.core.dao; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseManagementDAOException; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/MobileDeviceManagementDAOFactory.java similarity index 92% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/MobileDeviceManagementDAOFactory.java index d4746f623..6ba69f723 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/MobileDeviceManagementDAOFactory.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao; +package org.wso2.carbon.device.mgt.mobile.android.core.dao; public interface MobileDeviceManagementDAOFactory { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/impl/EnterpriseDAOImpl.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/impl/EnterpriseDAOImpl.java index 9b767a6bc..4e4f47e03 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/impl/EnterpriseDAOImpl.java @@ -16,19 +16,16 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl; +package org.wso2.carbon.device.mgt.mobile.android.core.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseDAO; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.AndroidDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.EnterpriseDAO; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.util.MobileDeviceManagementDAOUtil; import java.sql.Connection; import java.sql.PreparedStatement; @@ -37,9 +34,7 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Implements EnterpriseDAO for Android Devices. @@ -291,7 +286,6 @@ public class EnterpriseDAOImpl implements EnterpriseDAO { return status; } - public List getAllEnterpriseDevices(int tenantId, String enterpriseId) throws EnterpriseManagementDAOException { Connection conn; @@ -330,5 +324,4 @@ public class EnterpriseDAOImpl implements EnterpriseDAO { return enterpriseUsers; } - } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/util/MobileDeviceManagementDAOUtil.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/util/MobileDeviceManagementDAOUtil.java index 1892ddecb..decfbdb3b 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/dao/util/MobileDeviceManagementDAOUtil.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.dao.util; +package org.wso2.carbon.device.mgt.mobile.android.core.dao.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidGoogleEnterpriseServiceImpl.java similarity index 91% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidGoogleEnterpriseServiceImpl.java index 58d819f97..c6e4a8da4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidGoogleEnterpriseServiceImpl.java @@ -32,29 +32,30 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl; +package org.wso2.carbon.device.mgt.mobile.android.core.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseDAO; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidGoogleEnterpriseService; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.AndroidDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.EnterpriseDAO; import java.util.List; /** * This represents the Android implementation of DeviceManagerService. */ -public class AndroidPluginServiceImpl implements AndroidPluginService { +public class AndroidGoogleEnterpriseServiceImpl implements AndroidGoogleEnterpriseService { - private static final Log log = LogFactory.getLog(AndroidPluginServiceImpl.class); + private static final Log log = LogFactory.getLog(AndroidGoogleEnterpriseServiceImpl.class); private EnterpriseDAO enterpriseDAO; - public AndroidPluginServiceImpl() { + public AndroidGoogleEnterpriseServiceImpl() { enterpriseDAO = AndroidDAOFactory.getEnterpriseDAO(); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java new file mode 100644 index 000000000..a70324eb9 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java @@ -0,0 +1,1522 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.core.impl; + +import com.google.api.client.http.HttpStatusCodes; +import com.google.api.services.androidenterprise.model.ProductsListResponse; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; +import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; + +import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.app.mgt.Application; +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.device.details.DeviceLocation; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; +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.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; +import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; +import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.GoogleAPIInvoker; +import org.wso2.carbon.device.mgt.mobile.android.common.Message; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.*; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.*; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.*; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidEnterpriseUtils; +import org.wso2.carbon.policy.mgt.common.PolicyManagementException; +import org.wso2.carbon.policy.mgt.core.PolicyManagerService; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +import static com.hazelcast.aws.impl.Constants.DATE_FORMAT; + +public class AndroidServiceImpl implements AndroidService { + + private static final Log log = LogFactory.getLog(AndroidServiceImpl.class); + + private static final String OPERATION_ERROR_STATUS = "ERROR"; + public static final String GOOGLE_AFW_EMM_ANDROID_ID = "googleEMMAndroidId"; + public static final String GOOGLE_AFW_DEVICE_ID = "googleEMMDeviceId"; + private static final String EVENT_STREAM_DEFINITION = "org.wso2.iot.LocationStream"; + + private Gson gson = new Gson(); + private static final String LONGITUDE = "longitude"; + private static final String LATITUDE = "latitude"; + private static final String ALTITUDE = "altitude"; + private static final String SPEED = "speed"; + private static final String DISTANCE = "distance"; + private static final String BEARING = "bearing"; + private static final String TIME_STAMP = "timeStamp"; + private static final String LOCATION_EVENT_TYPE = "location"; + + @Override + public PlatformConfiguration getPlatformConfig() throws DeviceManagementException { + List configs; + PlatformConfiguration platformConfiguration; + + DeviceManagementProviderService deviceManagementProviderService = AndroidAPIUtils.getDeviceManagementService(); + platformConfiguration = deviceManagementProviderService. + getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + if (platformConfiguration != null) { + configs = platformConfiguration.getConfiguration(); + } else { + platformConfiguration = new PlatformConfiguration(); + configs = new ArrayList<>(); + } + + if (configs != null) { + ConfigurationEntry versionEntry = new ConfigurationEntry(); + versionEntry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); + versionEntry.setName(AndroidConstants.TenantConfigProperties.SERVER_VERSION); + versionEntry.setValue(ServerConfiguration.getInstance().getFirstProperty("Version")); + configs.add(versionEntry); + + License license = deviceManagementProviderService + .getLicense(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, + AndroidConstants. + TenantConfigProperties.LANGUAGE_US); + if (license != null) { + ConfigurationEntry entry = new ConfigurationEntry(); + entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); + entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); + entry.setValue(license.getText()); + configs.add(entry); + } + platformConfiguration.setConfiguration(configs); + } + return platformConfiguration; + } + + @Override + public void updateConfiguration(AndroidPlatformConfiguration androidPlatformConfiguration) throws + AndroidDeviceMgtPluginException { + ConfigurationEntry licenseEntry = null; + PlatformConfiguration configuration = new PlatformConfiguration(); + if (androidPlatformConfiguration == null) { + String errorMessage = "The payload of the android platform configuration is null."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + configuration.setConfiguration(androidPlatformConfiguration.getConfiguration()); + try { + DeviceManagementProviderService deviceManagementProviderService = AndroidAPIUtils + .getDeviceManagementService(); + configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + List configs = configuration.getConfiguration(); + NotifierFrequency notifierFrequency = new NotifierFrequency(); + for (ConfigurationEntry entry : configs) { + if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { + License license = new License(); + license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); + license.setVersion("1.0.0"); + license.setText(entry.getValue().toString()); + deviceManagementProviderService.addLicense(DeviceManagementConstants. + MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); + licenseEntry = entry; + } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) { + if (entry.getValue() != null) { + notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString())); + } else { + String msg = "No value specified for notifierFrequency."; + log.error(msg); + throw new BadRequestException(msg); + } + } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_TYPE.equals(entry.getName())) { + if (entry.getValue() != null) { + notifierFrequency.setType(Integer.parseInt(entry.getValue().toString())); + } else { + String msg = "No value specified for notifierType."; + log.error(msg); + throw new BadRequestException(msg); + } + } + } + + if (licenseEntry != null) { + configs.remove(licenseEntry); + } + configuration.setConfiguration(configs); + deviceManagementProviderService.saveConfiguration(configuration); + notifyDevices(notifierFrequency); + } catch (DeviceManagementException e) { + String msg = "Error occurred while getting device management service to modify Android config settings"; + log.error(msg, e); + throw new AndroidDeviceMgtPluginException(msg, e); + } catch (NumberFormatException e) { + String msg = "Error occurred while reading notification frequency."; + log.error(msg, e); + throw new AndroidDeviceMgtPluginException(msg, e); + } catch (OperationManagementException e) { + String msg = "Error occurred while modifying configuration settings of Android platform."; + log.error(msg, e); + throw new AndroidDeviceMgtPluginException(msg, e); + } catch (InvalidDeviceException e) { + String msg = "Error occurred with the device."; + log.error(msg, e); + throw new AndroidDeviceMgtPluginException(msg, e); + } + } + + private void notifyDevices(NotifierFrequency notifierFrequency) throws DeviceManagementException, + OperationManagementException, InvalidDeviceException { + List deviceList = AndroidAPIUtils. + getDeviceManagementService(). + getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false); + List deviceIdList = new ArrayList<>(); + for (Device device : deviceList) { + if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) { + deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); + } + } + if (!deviceIdList.isEmpty()) { + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY); + operation.setPayLoad(notifierFrequency.toJSON()); + operation.setEnabled(true); + AndroidAPIUtils.getDeviceManagementService().addOperation( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, + operation, deviceIdList); + } + } + + @Override + public Message isEnrolled(String id, DeviceIdentifier deviceIdentifier) throws DeviceManagementException { + Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + if (device != null) { + String status = String.valueOf(device.getEnrolmentInfo().getStatus()); + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_OK)); + responseMessage + .setResponseMessage("Status of android device that carries the id '" + id + "' is " + status); + return responseMessage; + } else { + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_NOT_FOUND)); + responseMessage.setResponseMessage("No Android device is found upon the id '" + id + "'"); + return responseMessage; + } + } + + @Override + public Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null + || fileTransferBeanWrapper.getDeviceIDs() == null) { + String errorMessage = "The payload of the file transfer operation is incorrect."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + if (log.isDebugEnabled()) { + log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); + } + FileTransfer file = fileTransferBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + if (fileTransferBeanWrapper.isUpload()) { + operation.setCode(AndroidConstants.OperationCodes.FILE_DOWNLOAD); + } else { + operation.setCode(AndroidConstants.OperationCodes.FILE_UPLOAD); + } + operation.setType(Operation.Type.PROFILE); + operation.setEnabled(true); + operation.setPayLoad(file.toJSON()); + + try { + return AndroidDeviceUtils + .getOperationResponse(fileTransferBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) { + String errorMessage = "Lock bean is empty."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + DeviceLock lock = deviceLockBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); + operation.setType(Operation.Type.PROFILE); + operation.setEnabled(true); + operation.setPayLoad(lock.toJSON()); + + try { + return AndroidDeviceUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity configureDeviceUnlock(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK); + operation.setType(Operation.Type.COMMAND); + operation.setEnabled(true); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity getDeviceLocation(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException{ + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity removePassword(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity configureCamera(CameraBeanWrapper cameraBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the configure camera operation is incorrect."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + Camera camera = cameraBeanWrapper.getOperation(); + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.CAMERA); + operation.setType(Operation.Type.COMMAND); + operation.setEnabled(camera.isEnabled()); + return AndroidDeviceUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity getDeviceInformation(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity getDeviceLogcat(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.LOGCAT); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity wipeDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) { + String errorMessage = "WipeData bean is empty."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + WipeData wipeData = wipeDataBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(wipeData.toJSON()); + return AndroidDeviceUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity getApplications(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity ringDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity rebootDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity changeLockTask(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE); + operation.setType(Operation.Type.COMMAND); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity muteDevice(List deviceIDs) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE); + operation.setType(Operation.Type.COMMAND); + operation.setEnabled(true); + return AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() == + null) { + String errorMessage = "The payload of the application installing operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + + ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation(); + validateApplicationUrl(applicationInstallation.getUrl()); + validateApplicationType(applicationInstallation.getType()); + validateScheduleDate(applicationInstallation.getSchedule()); + + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(applicationInstallation.toJSON()); + return AndroidDeviceUtils + .getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the application update operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation(); + validateApplicationUrl(applicationUpdate.getUrl()); + validateApplicationType(applicationUpdate.getType()); + validateScheduleDate(applicationUpdate.getSchedule()); + + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(applicationUpdate.toJSON()); + + return AndroidDeviceUtils + .getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (applicationUninstallationBeanWrapper == null || + applicationUninstallationBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the application uninstalling operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation(); + validateApplicationType(applicationUninstallation.getType()); + + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(applicationUninstallation.toJSON()); + return AndroidDeviceUtils + .getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity blacklistApplications(BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the blacklisting apps operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(blacklistApplications.toJSON()); + return AndroidDeviceUtils + .getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the upgrade firmware operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation(); + validateScheduleDate(upgradeFirmware.getSchedule()); + + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(upgradeFirmware.toJSON()); + return AndroidDeviceUtils + .getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity configureVPN(VpnBeanWrapper vpnConfiguration) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) { + String errorMessage = "The payload of the VPN operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + Vpn vpn = vpnConfiguration.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.VPN); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(vpn.toJSON()); + return AndroidDeviceUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity sendNotification(NotificationBeanWrapper notificationBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException{ + try { + if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the notification operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + Notification notification = notificationBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(notification.toJSON()); + return AndroidDeviceUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity configureWifi(WifiBeanWrapper wifiBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the wifi operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + Wifi wifi = wifiBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.WIFI); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(wifi.toJSON()); + + return AndroidDeviceUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException{ + try { + if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the device encryption operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation(); + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE); + operation.setType(Operation.Type.COMMAND); + operation.setEnabled(deviceEncryption.isEncrypted()); + return AndroidDeviceUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the change lock code operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + LockCode lockCode = lockCodeBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(lockCode.toJSON()); + return AndroidDeviceUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the change password policy operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(passcodePolicy.toJSON()); + + return AndroidDeviceUtils + .getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity setWebClip(WebClipBeanWrapper webClipBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + + if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the add webclip operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + WebClip webClip = webClipBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.WEBCLIP); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(webClip.toJSON()); + + return AndroidDeviceUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(), operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public Activity setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (globalProxyBeanWrapper == null || globalProxyBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the global proxy operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + + GlobalProxy globalProxy = globalProxyBeanWrapper.getOperation(); + if (globalProxy.validateRequest()) { + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.GLOBAL_PROXY); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(globalProxy.toJSON()); + + return AndroidDeviceUtils + .getOperationResponse(globalProxyBeanWrapper.getDeviceIDs(), operation); + } else { + String errorMessage = "The payload of the global proxy operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + @Override + public ProfileOperation sendApplicationConfiguration(ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper) + throws AndroidDeviceMgtPluginException { + try { + if (applicationRestrictionBeanWrapper == null || applicationRestrictionBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the application configuration operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + ApplicationRestriction applicationRestriction = applicationRestrictionBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.REMOTE_APP_CONFIG); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(applicationRestriction.toJSON()); + return operation; + } catch (BadRequestException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + + @Override + public Activity configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) + throws OperationManagementException, AndroidDeviceMgtPluginException { + try { + if (displayMessageBeanWrapper == null || displayMessageBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the display message operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + DisplayMessage configureDisplayMessage = displayMessageBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.DISPLAY_MESSAGE_CONFIGURATION); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(configureDisplayMessage.toJSON()); + + return AndroidDeviceUtils.getOperationResponse(displayMessageBeanWrapper. + getDeviceIDs(), operation); + + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException(errorMessage, e); + } + } + + + + @Override + public Message updateApplicationList(String id, List androidApplications) + throws org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { + Application application; + List 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); + } + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + + AndroidAPIUtils.getApplicationManagerService(). + updateApplicationListInstalledInDevice(deviceIdentifier, applications); + Message responseMessage = new Message(); + responseMessage.setResponseMessage("Device information has modified successfully."); + return responseMessage; + } + + @Override + public List getPendingOperations(String deviceId, List resultOperations, + boolean disableGoogleApps) + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(deviceId); + try { + if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) { + String msg = "Device not found for identifier '" + deviceId + "'"; + log.error(msg); + throw new InvalidDeviceException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Invoking Android pending operations:" + deviceId); + } + if (resultOperations != null && !resultOperations.isEmpty()) { + updateOperations(deviceId, resultOperations); + } + } catch (OperationManagementException e) { + String msg = "Issue in retrieving operation management service instance"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (PolicyComplianceException e) { + String msg = "Issue in updating Monitoring operation"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (NotificationManagementException e) { + String msg = "Issue in retrieving Notification management service instance"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) { + String msg = "Issue in retrieving application management service instance"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + try { + return AndroidDeviceUtils.getPendingOperations(deviceIdentifier, !disableGoogleApps); + } catch (OperationManagementException e) { + String msg = "Issue in retrieving operation management service instance"; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + } + + private void updateOperations(String deviceId, List operations) + throws OperationManagementException, PolicyComplianceException, NotificationManagementException, + DeviceManagementException, org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { + for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) { + AndroidDeviceUtils.updateOperation(deviceId, operation); + if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) { + org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new + org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); + DeviceIdentifier id = new DeviceIdentifier(); + id.setId(deviceId); + id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); + String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName(); + notification.setOperationId(operation.getId()); + notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. + Status.NEW.toString()); + notification.setDescription(operation.getCode() + " operation failed to execute on device " + + deviceName + " (ID: " + deviceId + ")"); + AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification); + } + if (log.isDebugEnabled()) { + log.debug("Updating operation '" + operation.toString() + "'"); + } + } + } + + + @Override + public Message enrollDevice(AndroidDevice androidDevice) + throws DeviceManagementException, AndroidDeviceMgtPluginException { + try { + String token = null; + 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.setName(androidDevice.getName()); + device.setFeatures(androidDevice.getFeatures()); + device.setProperties(androidDevice.getProperties()); + + String googleEMMAndroidId = null; + String googleEMMDeviceId = null; + if (androidDevice.getProperties() != null) { + for (Device.Property property : androidDevice.getProperties()) { + if (property.getName().equals(GOOGLE_AFW_EMM_ANDROID_ID)) { + googleEMMAndroidId = property.getValue(); + } else if (property.getName().equals(GOOGLE_AFW_DEVICE_ID)) { + googleEMMDeviceId = property.getValue(); + } + } + + if (googleEMMAndroidId != null && googleEMMDeviceId != null) { + EnterpriseUser user = new EnterpriseUser(); + user.setAndroidPlayDeviceId(googleEMMAndroidId); + user.setEmmDeviceIdentifier(googleEMMDeviceId); + try { + token = insertUser(user); + } catch (EnterpriseServiceException e) { + + } + } + } + + + boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); + if (status) { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(androidDevice.getDeviceIdentifier(), + device.getType()); + + //Immediately update location information from initial payload + DeviceLocation deviceLocation = extractLocation(deviceIdentifier, androidDevice.getProperties()); + if (deviceLocation != null) { + try { + DeviceInformationManager informationManager = AndroidAPIUtils + .getDeviceInformationManagerService(); + informationManager.addDeviceLocation(deviceLocation); + } catch (DeviceDetailsMgtException e) { + String msg = "Error occurred while updating the device location upon android " + + "', which carries the id '" + androidDevice.getDeviceIdentifier() + "'"; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + } + + //Adding Tasks to get device information + List deviceIdentifiers = new ArrayList<>(); + deviceIdentifiers.add(deviceIdentifier); + + List taskOperaions = new ArrayList<>(); + taskOperaions.add(AndroidConstants.OperationCodes.APPLICATION_LIST); + taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_INFO); + taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_LOCATION); + + for (String str : taskOperaions) { + CommandOperation operation = new CommandOperation(); + operation.setEnabled(true); + operation.setType(Operation.Type.COMMAND); + operation.setCode(str); + AndroidAPIUtils.getDeviceManagementService(). + addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, + operation, deviceIdentifiers); + } + PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService(); + Policy effectivePolicy = policyManagerService. + getEffectivePolicy(new DeviceIdentifier(androidDevice.getDeviceIdentifier(), device.getType())); + + if (effectivePolicy != null) { + List effectiveProfileFeatures = effectivePolicy.getProfile(). + getProfileFeaturesList(); + for (ProfileFeature feature : effectiveProfileFeatures) { + if (AndroidConstants.ApplicationInstall.ENROLLMENT_APP_INSTALL_FEATURE_CODE + .equals(feature.getFeatureCode())) { + AndroidDeviceUtils.installEnrollmentApplications(feature, deviceIdentifier); + break; + } + } + } + + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_OK)); + if (token == null) { + responseMessage.setResponseMessage("Android device, which carries the id '" + + androidDevice.getDeviceIdentifier() + "' has successfully been enrolled"); + } else { + responseMessage.setResponseMessage("Google response token" + token); + } + return responseMessage; + } else { + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)); + responseMessage.setResponseMessage("Failed to enroll '" + + device.getType() + "' device, which carries the id '" + + androidDevice.getDeviceIdentifier() + "'"); + return responseMessage; + } + } catch (PolicyManagementException | InvalidDeviceException | OperationManagementException e) { + String msg = "Error occurred while enforcing default enrollment policy upon android " + + "', which carries the id '" + + androidDevice.getDeviceIdentifier() + "'"; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + } + + @Override + public boolean modifyEnrollment(String id, AndroidDevice androidDevice) + throws DeviceManagementException, AndroidDeviceMgtPluginException { + Device device; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(id); + deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID); + try { + device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + } catch (DeviceManagementException e) { + String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" + + id + "'"; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + + if (androidDevice == null) { + String errorMessage = "The payload of the android device enrollment is incorrect."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + if (device == null) { + String errorMessage = "The device to be modified doesn't exist."; + log.error(errorMessage); + throw new NotFoundException(errorMessage); + } + if(androidDevice.getEnrolmentInfo() != null){ + device.setEnrolmentInfo(device.getEnrolmentInfo()); + } + device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); + if(androidDevice.getDeviceInfo() != null) { + device.setDeviceInfo(androidDevice.getDeviceInfo()); + } + device.setDeviceIdentifier(androidDevice.getDeviceIdentifier()); + if(androidDevice.getDescription() != null) { + device.setDescription(androidDevice.getDescription()); + } + if(androidDevice.getName() != null) { + device.setName(androidDevice.getName()); + } + if(androidDevice.getFeatures() != null) { + device.setFeatures(androidDevice.getFeatures()); + } + if(androidDevice.getProperties() != null) { + device.setProperties(androidDevice.getProperties()); + } + return AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device); + } + + @Override + public boolean disEnrollDevice(String id) throws DeviceManagementException{ + DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); + AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier); + return AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); + } + + @Override + public Message publishEvents(EventBeanWrapper eventBeanWrapper) throws AndroidDeviceMgtPluginException { + if (log.isDebugEnabled()) { + log.debug("Invoking Android device event logging."); + } + Device device; + try { + if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_ACCEPTED)); + responseMessage.setResponseMessage("Event is publishing has not enabled."); + return responseMessage; + } + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(), + AndroidConstants.DEVICE_TYPE_ANDROID); + device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); + if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){ + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_ACCEPTED)); + responseMessage.setResponseMessage("Device is not in Active state."); + return responseMessage; + } else if (device == null){ + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_ACCEPTED)); + responseMessage.setResponseMessage("Device is not enrolled yet."); + return responseMessage; + } + } catch (DeviceManagementException e) { + log.error("Error occurred while checking Operation Analytics is Enabled.", e); + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)); + responseMessage.setResponseMessage(e.getMessage()); + return responseMessage; + } + String eventType = eventBeanWrapper.getType(); + if (!LOCATION_EVENT_TYPE.equals(eventType)) { + String msg = "Dropping Android " + eventType + " Event.Only Location Event Type is supported."; + log.warn(msg); + Message responseMessage = new Message(); + responseMessage.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_BAD_REQUEST)); + responseMessage.setResponseMessage(msg); + return responseMessage; + } + Message message = new Message(); + Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), device.getEnrolmentInfo().getOwner(), + AndroidConstants.DEVICE_TYPE_ANDROID}; + String eventPayload = eventBeanWrapper.getPayload(); + JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class); + Object[] payload = { + jsonObject.get(TIME_STAMP).getAsLong(), + jsonObject.get(LATITUDE).getAsDouble(), + jsonObject.get(LONGITUDE).getAsDouble(), + jsonObject.get(ALTITUDE).getAsDouble(), + jsonObject.get(SPEED).getAsFloat(), + jsonObject.get(BEARING).getAsFloat(), + jsonObject.get(DISTANCE).getAsDouble() + }; + try { + if (AndroidAPIUtils.getEventPublisherService().publishEvent( + EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload)) { + message.setResponseCode("Event is published successfully."); + return message; + } else { + log.warn("Error occurred while trying to publish the event. This could be due to unavailability " + + "of the publishing service. Please make sure that analytics server is running and accessible " + + "by this server"); + String errorMessage = "Error occurred due to " + + "unavailability of the publishing service."; + message.setResponseCode(String.valueOf(HttpStatusCodes.STATUS_CODE_SERVICE_UNAVAILABLE)); + return message; + } + } catch (DataPublisherConfigurationException e) { + String msg = "Error occurred while getting the Data publisher Service instance."; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg); + } + + } + + @Override + public List retrieveAlerts(String deviceId, + long from, + long to, + String type, + String ifModifiedSince) throws AndroidDeviceMgtPluginException { + if (from != 0l && to != 0l && deviceId != null){ + return retrieveAlertFromDate(deviceId, from, to); + } else if (deviceId != null && type != null) { + return retrieveAlertByType(deviceId, type); + } else if (deviceId != null) { + return retrieveAlert(deviceId); + } else { + String errorMessage = "Request must contain " + + "the device identifier. Optionally, both from and to value should be present to get " + + "alerts between times."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } + + private List retrieveAlert(String deviceId) throws NotFoundException, UnexpectedServerErrorException { + if (log.isDebugEnabled()) { + log.debug("Retrieving events for given device Identifier."); + } + String query = "deviceIdentifier:" + deviceId; + List deviceStates; + try { + deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); + if (deviceStates == null) { + String errorMessage = "No any alerts are " + + "published for Device: " + deviceId + "."; + throw new NotFoundException(errorMessage); + } else { + return deviceStates; + } + } catch (AnalyticsException e) { + String msg = "Error occurred while getting published events for specific device: " + deviceId + "."; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + } + + private List retrieveAlertFromDate(String deviceId, long from, long to) throws NotFoundException, + UnexpectedServerErrorException { + String fromDate = String.valueOf(from); + String toDate = String.valueOf(to); + if (log.isDebugEnabled()) { + log.debug("Retrieving events for given device Identifier and time period."); + } + + String query = "deviceIdentifier:" + deviceId + " AND _timestamp: [" + fromDate + " TO " + toDate + "]"; + List deviceStates; + try { + deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); + if (deviceStates == null) { + String errorMessage = "No any alerts are " + + "published on given date for given Device: " + deviceId + "."; + throw new NotFoundException(errorMessage); + + } else { + return deviceStates; + } + } catch (AnalyticsException e) { + String msg = "Error occurred while getting published events for specific " + + "Device: " + deviceId + " on given Date."; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + } + + private List retrieveAlertByType(String deviceId, String type) + throws NotFoundException, UnexpectedServerErrorException { + if (log.isDebugEnabled()) { + log.debug("Retrieving events for given device identifier and type."); + } + String query = "deviceIdentifier:" + deviceId + " AND type:" + type; + List deviceStates; + try { + deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); + if (deviceStates == null) { + String errorMessage = "No any alerts are " + + "published for given Device: '" + deviceId + "' and given specific Type."; + throw new NotFoundException(errorMessage); + + } else { + return deviceStates; + } + } catch (AnalyticsException e) { + String msg = "Error occurred while getting published events for specific " + + "Device: " + deviceId + "and given specific Type."; + log.error(msg, e); + throw new UnexpectedServerErrorException(msg, e); + } + } + + /** + * Extracts the device location + * + * @param deviceIdentifier + * @param properties + * @return returns null when location not found + */ + private DeviceLocation extractLocation(DeviceIdentifier deviceIdentifier, List properties) + throws DeviceManagementException { + + DeviceLocation location = null; + String latitude = "", longitude = "", altitude = "", speed = "", bearing = "", distance = ""; + + if (properties == null) return null; + + for (Device.Property property : properties) { + String propertyName = property.getName(); + if (propertyName == null) continue; + if (propertyName.equals("LATITUDE")) { + latitude = property.getValue(); + } + if (propertyName.equals("LONGITUDE")) { + longitude = property.getValue(); + } + if (propertyName.equals("ALTITUDE")) { + altitude = property.getValue(); + } + if (propertyName.equals("SPEED")) { + speed = property.getValue(); + } + if (propertyName.equals("BEARING")) { + bearing = property.getValue(); + } + if (propertyName.equals("DISTANCE")) { + distance = property.getValue(); + } + } + + if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude) && + StringUtils.isNotBlank(altitude) && StringUtils.isNotBlank(speed) && + StringUtils.isNotBlank(bearing) && StringUtils.isNotBlank(distance)) { + location = new DeviceLocation(); + location.setLatitude(Double.valueOf(latitude)); + location.setLongitude(Double.valueOf(longitude)); + location.setAltitude(Double.valueOf(altitude)); + location.setSpeed(Float.valueOf(speed)); + location.setBearing(Float.valueOf(bearing)); + location.setDistance(Double.valueOf(distance)); + location.setDeviceIdentifier(deviceIdentifier); + Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false); + location.setDeviceId(savedDevice.getId()); + } + return location; + } + + private int recursiveSync(GoogleAPIInvoker googleAPIInvoker, String enterpriseId, ProductsListResponse + productsListResponse) throws EnterpriseServiceException, ApplicationManagementException { + // Are there more pages + if (productsListResponse == null || productsListResponse.getTokenPagination() == null + || productsListResponse.getTokenPagination().getNextPageToken() == null) { + return 0; + } + + // Get next page + ProductsListResponse productsListResponseNext = googleAPIInvoker.listProduct(enterpriseId, + productsListResponse.getTokenPagination().getNextPageToken()); + AndroidEnterpriseUtils.persistApp(productsListResponseNext); + if (productsListResponseNext != null && productsListResponseNext.getTokenPagination() != null && + productsListResponseNext.getTokenPagination().getNextPageToken() != null) { + return recursiveSync(googleAPIInvoker, enterpriseId, productsListResponseNext) + + productsListResponseNext.getProduct().size(); + } else { + return productsListResponseNext.getProduct().size(); + } + } + + public String insertUser(EnterpriseUser enterpriseUser) + throws EnterpriseServiceException, AndroidDeviceMgtPluginException { + try { + EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs(); + + String token; + boolean deviceIdExist = false; + + String googleUserId; + List androidEnterpriseUsers = AndroidAPIUtils.getAndroidPluginService() + .getEnterpriseUser(CarbonContext.getThreadLocalCarbonContext().getUsername()); + GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); + if (androidEnterpriseUsers != null && !androidEnterpriseUsers.isEmpty()) { + googleUserId = androidEnterpriseUsers.get(0).getGoogleUserId(); + // If this device is also present, only need to provide a token for this request. + for (AndroidEnterpriseUser enterprise : androidEnterpriseUsers) { + if (enterprise.getEmmDeviceId() != null + && enterprise.getEmmDeviceId().equals(enterpriseUser.getAndroidPlayDeviceId())) { + deviceIdExist = true; + } + } + } else { + googleUserId = googleAPIInvoker.insertUser(enterpriseConfigs.getEnterpriseId(), CarbonContext + .getThreadLocalCarbonContext() + .getUsername()); + } + // Fetching an auth token from Google EMM API + token = googleAPIInvoker.getToken(enterpriseConfigs.getEnterpriseId(), googleUserId); + + if (!deviceIdExist) { + AndroidEnterpriseUser androidEnterpriseUser = new AndroidEnterpriseUser(); + androidEnterpriseUser.setEmmUsername(CarbonContext.getThreadLocalCarbonContext().getUsername()); + androidEnterpriseUser.setTenantId(CarbonContext.getThreadLocalCarbonContext().getTenantId()); + androidEnterpriseUser.setAndroidPlayDeviceId(enterpriseUser.getAndroidPlayDeviceId()); + androidEnterpriseUser.setEnterpriseId(enterpriseConfigs.getEnterpriseId()); + androidEnterpriseUser.setEmmDeviceId(enterpriseUser.getEmmDeviceIdentifier()); + androidEnterpriseUser.setGoogleUserId(googleUserId); + + AndroidAPIUtils.getAndroidPluginService().addEnterpriseUser(androidEnterpriseUser); + } + return token; + } catch (NotFoundException e) { + String errorMessage = "Not found"; + log.error(errorMessage); + throw new NotFoundException(errorMessage); + } catch (UnexpectedServerErrorException e) { + String errorMessage = "Unexpected server error"; + log.error(errorMessage); + throw new UnexpectedServerErrorException(errorMessage); + } catch (AndroidDeviceMgtPluginException e) { + String errorMessage = "Error occured while executing wipe enterprice command"; + log.error(errorMessage); + throw new AndroidDeviceMgtPluginException(errorMessage); + } + } + + + private static void validateApplicationUrl(String apkUrl) throws BadRequestException { + try { + URL url = new URL(apkUrl); + URLConnection conn = url.openConnection(); + if (((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) { + String errorMessage = "URL is not pointed to a downloadable file."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } catch (MalformedURLException e) { + String errorMessage = "Malformed application url."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } catch (IOException e) { + String errorMessage = "Invalid application url."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } + + private static void validateApplicationType(String type) throws BadRequestException { + if (type != null) { + if (!"enterprise".equalsIgnoreCase(type) + && !"public".equalsIgnoreCase(type) + && !"webapp".equalsIgnoreCase(type)) { + String errorMessage = "Invalid application type."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } else { + String errorMessage = "Application type is missing."; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } + + private static void validateScheduleDate(String dateString) throws BadRequestException { + try { + if (dateString != null && !dateString.isEmpty()) { + SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); + sdf.setLenient(false); + sdf.parse(dateString); + } + } catch (ParseException e) { + String errorMessage = "Issue in validating the schedule date"; + log.error(errorMessage); + throw new BadRequestException(errorMessage); + } + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/DeviceTypeCommonServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/DeviceTypeCommonServiceImpl.java new file mode 100644 index 000000000..24aac46fd --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/DeviceTypeCommonServiceImpl.java @@ -0,0 +1,75 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.device.mgt.mobile.android.core.impl; + +import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.MDMAppConstants; +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.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.license.mgt.License; +import org.wso2.carbon.device.mgt.common.spi.DeviceTypeCommonService; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class DeviceTypeCommonServiceImpl implements DeviceTypeCommonService { + + @Override + public Map getEnrollmentQRCode() throws DeviceManagementException { + return null; + } + +// private void getPlatformConfig() { +// PlatformConfiguration platformConfiguration; +// List configs; +// try { +// platformConfiguration = AndroidAPIUtils.getDeviceManagementService(). +// getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); +// if (platformConfiguration != null) { +// configs = platformConfiguration.getConfiguration(); +// } else { +// platformConfiguration = new PlatformConfiguration(); +// configs = new ArrayList<>(); +// } +// ConfigurationEntry entry = new ConfigurationEntry(); +// License license = AndroidAPIUtils.getDeviceManagementService().getLicense( +// DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, MDMAppConstants.AndroidConstants. +// TenantConfigProperties.LANGUAGE_US); +// +// if (configs != null) { +// ConfigurationEntry versionEntry = new ConfigurationEntry(); +// versionEntry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); +// versionEntry.setName(AndroidConstants.TenantConfigProperties.SERVER_VERSION); +// versionEntry.setValue(ServerConfiguration.getInstance().getFirstProperty("Version")); +// configs.add(versionEntry); +// if (license != null) { +// entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); +// entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); +// entry.setValue(license.getText()); +// configs.add(entry); +// } +// platformConfiguration.setConfiguration(configs); +// } +// } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidDeviceManagementDataHolder.java similarity index 69% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidDeviceManagementDataHolder.java index 09d111fca..9f4740313 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidDeviceManagementDataHolder.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.internal; +package org.wso2.carbon.device.mgt.mobile.android.core.internal; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidGoogleEnterpriseService; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; import org.wso2.carbon.registry.core.service.RegistryService; /** @@ -28,7 +28,8 @@ import org.wso2.carbon.registry.core.service.RegistryService; public class AndroidDeviceManagementDataHolder { private RegistryService registryService; - private AndroidPluginService androidDeviceManagementService; + private AndroidGoogleEnterpriseService androidDeviceManagementService; + private AndroidService androidService; private static AndroidDeviceManagementDataHolder thisInstance = new AndroidDeviceManagementDataHolder(); @@ -47,13 +48,20 @@ public class AndroidDeviceManagementDataHolder { this.registryService = registryService; } - public AndroidPluginService getAndroidDeviceManagementService() { + public AndroidGoogleEnterpriseService getAndroidDeviceManagementService() { return androidDeviceManagementService; } public void setAndroidDeviceManagementService( - AndroidPluginService androidDeviceManagementService) { + AndroidGoogleEnterpriseService androidDeviceManagementService) { this.androidDeviceManagementService = androidDeviceManagementService; } + public AndroidService getAndroidService() { + return androidService; + } + + public void setAndroidService(AndroidService androidService) { + this.androidService = androidService; + } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java similarity index 80% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java index 08f0c1c95..0465449d2 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/internal/AndroidPluginServiceComponent.java @@ -16,16 +16,18 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.internal; +package org.wso2.carbon.device.mgt.mobile.android.core.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; -import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPluginServiceImpl; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidGoogleEnterpriseService; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; +import org.wso2.carbon.device.mgt.mobile.android.core.dao.AbstractMobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.core.impl.AndroidGoogleEnterpriseServiceImpl; +import org.wso2.carbon.device.mgt.mobile.android.core.impl.AndroidServiceImpl; +import org.wso2.carbon.device.mgt.mobile.android.core.util.MobileDeviceManagementUtil; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; @@ -58,15 +60,19 @@ public class AndroidPluginServiceComponent { try { BundleContext bundleContext = ctx.getBundleContext(); - MobileDeviceManagementUtil.initConfig(); AbstractMobileDeviceManagementDAOFactory.init("android", MobileDeviceManagementUtil .getIosDataSourceConfigurations().getIosDataSourceConfiguration()); - AndroidPluginService androidPluginService = new AndroidPluginServiceImpl(); + AndroidService androidService = new AndroidServiceImpl(); + AndroidDeviceManagementDataHolder.getInstance().setAndroidService( + androidService); + bundleContext.registerService(AndroidService.class.getName(), androidService, null); + + AndroidGoogleEnterpriseService androidPluginService = new AndroidGoogleEnterpriseServiceImpl(); AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( androidPluginService); - bundleContext.registerService(AndroidPluginService.class.getName(), androidPluginService, null); + bundleContext.registerService(AndroidGoogleEnterpriseService.class.getName(), androidPluginService, null); if (log.isDebugEnabled()) { log.debug("Android Mobile Device Management Service Component has been successfully activated"); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java similarity index 84% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java index f91e67424..dae74b5f5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidAPIUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.core.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -25,7 +25,6 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; @@ -34,9 +33,11 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidGoogleEnterpriseService; +import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; @@ -55,10 +56,10 @@ public class AndroidAPIUtils { throw new IllegalStateException("Utility class"); } - public static AndroidPluginService getAndroidPluginService() { + public static AndroidGoogleEnterpriseService getAndroidPluginService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - AndroidPluginService androidPluginService = - (AndroidPluginService) ctx.getOSGiService(AndroidPluginService.class, null); + AndroidGoogleEnterpriseService androidPluginService = + (AndroidGoogleEnterpriseService) ctx.getOSGiService(AndroidGoogleEnterpriseService.class, null); if (androidPluginService == null) { String msg = "Android plugin service has not initialized."; log.error(msg); @@ -67,6 +68,17 @@ public class AndroidAPIUtils { return androidPluginService; } + public static AndroidService getAndroidService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + AndroidService androidService = (AndroidService) ctx.getOSGiService(AndroidService.class, null); + if (androidService == null) { + String msg = "Android service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return androidService; + } + public static String getAuthenticatedUser() { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); @@ -163,12 +175,11 @@ public class AndroidAPIUtils { } public static Response getOperationResponse(List deviceIDs, Operation operation) - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - if (deviceIDs == null || deviceIDs.size() == 0) { + throws AndroidDeviceMgtPluginException, OperationManagementException, InvalidDeviceException { + if (deviceIDs == null || deviceIDs.isEmpty()) { String errorMessage = "Device identifier list is empty"; log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + throw new BadRequestException(errorMessage); } DeviceIdentifier deviceIdentifier; List deviceIdentifiers = new ArrayList<>(); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java similarity index 93% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java index a7e745382..be73152c6 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidDeviceUtils.java @@ -33,7 +33,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.core.util; import com.google.gson.Gson; import com.google.gson.JsonArray; @@ -62,13 +62,13 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.SubAction; import org.wso2.carbon.device.application.mgt.common.SubscriptionType; +import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; 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.device.details.DeviceInfo; @@ -85,17 +85,19 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtExcept import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils; -import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.GoogleAPIInvoker; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseConfigs; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorListItem; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseApp; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseInstallPolicy; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.mdm.services.android.bean.DeviceState; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseConfigs; -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.bean.wrapper.EnterpriseApp; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseInstallPolicy; -import org.wso2.carbon.mdm.services.android.common.GoogleAPIInvoker; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; @@ -139,12 +141,11 @@ public class AndroidDeviceUtils { } public static Activity getOperationResponse(List deviceIDs, Operation operation) - throws OperationManagementException, InvalidDeviceException { + throws OperationManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { if (deviceIDs == null || deviceIDs.isEmpty()) { String errorMessage = "Device identifier list is empty"; log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + throw new BadRequestException(errorMessage); } DeviceIdentifier deviceIdentifier; List deviceIdentifiers = new ArrayList<>(); @@ -207,7 +208,8 @@ public class AndroidDeviceUtils { } public static void updateOperation(String deviceId, Operation operation) - throws OperationManagementException, PolicyComplianceException, ApplicationManagementException { + throws OperationManagementException, PolicyComplianceException, + org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(deviceId); deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); @@ -325,8 +327,6 @@ public class AndroidDeviceUtils { for (JsonElement appElement : appListArray) { JsonElement googlePolicyPayload = appElement.getAsJsonObject(). get(AndroidConstants.ApplicationInstall.GOOGLE_POLICY_PAYLOAD); - - if (googlePolicyPayload != null) { String uuid = appElement.getAsJsonObject().get("uuid").toString(); containsGoogleAppPolicy = true;// breaking out of outer for loop @@ -355,41 +355,34 @@ public class AndroidDeviceUtils { * Sends the app install policy to Google * @param payload policy profile * @param deviceIdentifier device to apply policy - * @param requireSendingToGoogle */ private static void sendPayloadToGoogle(String uuid, String payload, DeviceIdentifier deviceIdentifier, - boolean requireSendingToGoogle) - throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException { + boolean requireSendingToGoogle) throws ApplicationManagementException { try { EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigsFromGoogle(); - if (enterpriseConfigs != null && enterpriseConfigs.getErrorResponse() == null) { + if (enterpriseConfigs.getErrorResponse() == null) { GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa()); AndroidEnterpriseUser userDetail = AndroidAPIUtils.getAndroidPluginService() .getEnterpriseUserByDevice(deviceIdentifier.getId()); if (userDetail != null && userDetail.getEnterpriseId() != null && !userDetail.getEnterpriseId() - .isEmpty() && userDetail.getEmmUsername() != null) { - - if (payload != null) { -// ProfileFeature feature = AndroidDeviceUtils.getEnrollmentPolicy(deviceIdentifier); - EnterpriseInstallPolicy enterpriseInstallPolicy = AndroidEnterpriseUtils - .getDeviceAppPolicy(payload, null, userDetail); - - List apps = new ArrayList<>(); - for (EnterpriseApp enterpriseApp : enterpriseInstallPolicy.getApps()) { - apps.add(enterpriseApp.getProductId()); - } - if (requireSendingToGoogle) { - googleAPIInvoker.approveAppsForUser(enterpriseConfigs.getEnterpriseId(), userDetail - .getGoogleUserId(), apps, enterpriseInstallPolicy.getProductSetBehavior()); - googleAPIInvoker.updateAppsForUser(enterpriseConfigs.getEnterpriseId(), userDetail.getGoogleUserId(), - AndroidEnterpriseUtils.convertToDeviceInstance(enterpriseInstallPolicy)); - } - AndroidEnterpriseUtils.getAppSubscriptionService() - .performEntAppSubscription(uuid, - Arrays.asList(CarbonContext.getThreadLocalCarbonContext().getUsername()), - SubscriptionType.USER.toString(), SubAction.INSTALL.toString(), false); + .isEmpty() && userDetail.getEmmUsername() != null && payload != null) { + EnterpriseInstallPolicy enterpriseInstallPolicy = AndroidEnterpriseUtils + .getDeviceAppPolicy(payload, null, userDetail); + List apps = new ArrayList<>(); + for (EnterpriseApp enterpriseApp : enterpriseInstallPolicy.getApps()) { + apps.add(enterpriseApp.getProductId()); + } + if (requireSendingToGoogle) { + googleAPIInvoker.approveAppsForUser(enterpriseConfigs.getEnterpriseId(), userDetail + .getGoogleUserId(), apps, enterpriseInstallPolicy.getProductSetBehavior()); + googleAPIInvoker.updateAppsForUser(enterpriseConfigs.getEnterpriseId(), userDetail.getGoogleUserId(), + AndroidEnterpriseUtils.convertToDeviceInstance(enterpriseInstallPolicy)); } + AndroidEnterpriseUtils.getAppSubscriptionService().performEntAppSubscription(uuid, + Arrays.asList(CarbonContext.getThreadLocalCarbonContext().getUsername()), + SubscriptionType.USER.toString(), SubAction.INSTALL.toString(), false); + } } @@ -400,7 +393,7 @@ public class AndroidDeviceUtils { } private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier) - throws ApplicationManagementException { + throws org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { // Parsing json string to get applications list. if (operation.getOperationResponse() != null) { if (operation.getOperationResponse().equals("SAME_APPLICATION_LIST")) { @@ -643,10 +636,10 @@ public class AndroidDeviceUtils { * @param description description of the exception * @return a new BadRequestException with the specified details as a response DTO */ - public static BadRequestException buildBadRequestException(String description) { + public static ErrorResponse buildBadRequestException(String description) { ErrorResponse errorResponse = getErrorResponse(AndroidConstants. ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT, 400l, description); - return new BadRequestException(errorResponse); + return errorResponse; } /** diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidEnterpriseUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidEnterpriseUtils.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidEnterpriseUtils.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidEnterpriseUtils.java index d0d88d1fa..dd516ba77 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidEnterpriseUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/AndroidEnterpriseUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.core.util; import com.google.api.services.androidenterprise.model.AppVersion; import com.google.api.services.androidenterprise.model.AutoInstallConstraint; @@ -51,16 +51,15 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; -import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; -import org.wso2.carbon.mdm.services.android.bean.BasicUserInfo; -import org.wso2.carbon.mdm.services.android.bean.EnterpriseConfigs; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseApp; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EnterpriseInstallPolicy; -import org.wso2.carbon.mdm.services.android.exception.NotFoundException; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.BasicUserInfo; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseConfigs; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseApp; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseInstallPolicy; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.*; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.user.core.service.RealmService; @@ -141,13 +140,12 @@ public class AndroidEnterpriseUtils { variableSets.add(variableSet); } - if (variableSets != null && variableSets.size() > 0) { + if (!variableSets.isEmpty()) { configurationVariables.setVariableSet(variableSets); } managedConfiguration.setConfigurationVariables(configurationVariables); productPolicy.setManagedConfiguration(managedConfiguration); } - policyList.add(productPolicy); } @@ -223,13 +221,13 @@ public class AndroidEnterpriseUtils { return userInfo; } - public static EnterpriseConfigs getEnterpriseConfigs() { + public static EnterpriseConfigs getEnterpriseConfigs() throws AndroidDeviceMgtPluginException { EnterpriseConfigs enterpriseConfigs = getEnterpriseConfigsFromGoogle(); if (enterpriseConfigs.getErrorResponse() != null) { if (enterpriseConfigs.getErrorResponse().getCode() == 500l) { - throw new UnexpectedServerErrorException(enterpriseConfigs.getErrorResponse()); + throw new UnexpectedServerErrorException(enterpriseConfigs.getErrorResponse().getMessage()); } else if (enterpriseConfigs.getErrorResponse().getCode() == 500l) { - throw new NotFoundException(enterpriseConfigs.getErrorResponse()); + throw new NotFoundException(enterpriseConfigs.getErrorResponse().getMessage()); } } return enterpriseConfigs; @@ -282,11 +280,8 @@ public class AndroidEnterpriseUtils { if (productListResponse != null && productListResponse.getProduct() != null && !productListResponse.getProduct().isEmpty()) { - List packageNamesOfApps = new ArrayList<>(); - for (Product product1 : productListResponse.getProduct()) { - String s = (product1.getProductId().replaceFirst("app:", "")); - packageNamesOfApps.add(s); - } + List packageNamesOfApps = productListResponse.getProduct().stream() + .map(product -> (product.getProductId().replaceFirst("app:", ""))).collect(Collectors.toList()); List existingApps = applicationManager.getApplications(packageNamesOfApps); List products = productListResponse.getProduct(); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/MobileDeviceManagementUtil.java similarity index 94% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/MobileDeviceManagementUtil.java index 1ea1543a4..240043aad 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/MobileDeviceManagementUtil.java @@ -34,7 +34,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.util; +package org.wso2.carbon.device.mgt.mobile.android.core.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -45,16 +45,15 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.AndroidDataSourceConfigurations; -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfigurations; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDeviceOperationMapping; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileOperation; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileOperationProperty; -import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagementDataHolder; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidPluginConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.config.datasource.AndroidDataSourceConfigurations; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.MobileDeviceOperationMapping; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.MobileOperation; +import org.wso2.carbon.device.mgt.mobile.android.common.dto.MobileOperationProperty; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.core.internal.AndroidDeviceManagementDataHolder; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/OAuthUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/OAuthUtils.java similarity index 95% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/OAuthUtils.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/OAuthUtils.java index 53e0832c3..d4a6064aa 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/OAuthUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/util/OAuthUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.util; +package org.wso2.carbon.device.mgt.mobile.android.core.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -24,7 +24,8 @@ import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.mdm.services.android.bean.ApiRegistrationProfile; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApiRegistrationProfile; import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementAdminServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementAdminServiceTests.java new file mode 100644 index 000000000..f2400f153 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementAdminServiceTests.java @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2017, 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.device.mgt.mobile.android.core; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.testng.PowerMockObjectFactory; +import org.testng.IObjectFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.ObjectFactory; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; +import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.core.impl.AndroidServiceImpl; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceManagementProviderServiceMock; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils.TestUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; + +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PrepareForTest(AndroidAPIUtils.class) +public class DeviceManagementAdminServiceTests { + + private AndroidServiceImpl androidService; + + @ObjectFactory + public IObjectFactory getObjectFactory() { + return new PowerMockObjectFactory(); + } + + @BeforeClass + public void init() { + MockitoAnnotations.initMocks(this); + androidService = new AndroidServiceImpl(); + } + + private void mockDeviceManagementService() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService")) + .toReturn(new DeviceManagementProviderServiceMock()); + } + + @Test + public void testConfigureDeviceLock() throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.configureDeviceLock(TestUtils.getDeviceLockBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testConfigureDeviceUnlock() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.configureDeviceUnlock(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testGetDeviceLocation() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.getDeviceLocation(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testRemovePassword() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.removePassword(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testConfigureCamera() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.configureCamera(TestUtils.getCamerabeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testGetDeviceInformation() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.getDeviceInformation(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testGetDeviceLogcat() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.getDeviceLogcat(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testWipeDevice() throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.wipeDevice(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testWipeData() throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.wipeData(TestUtils.getWipeDataBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testGetApplications() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.getApplications(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testRingDevice() throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.ringDevice(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testRebootDevice() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.rebootDevice(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testChangeLockTask() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.changeLockTask(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testMuteDevice() throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.muteDevice(TestUtils.getDeviceIds()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testInstallApplication() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService + .installApplication(TestUtils.getApplicationInstallationBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testUpdateApplication() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.updateApplication(TestUtils.getApplicationUpdateBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testUninstallApplicationPublic() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService + .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperPublic()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testUninstallApplicationWebApp() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService + .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperWebApp()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testBlacklistApplications() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService + .blacklistApplications(TestUtils.getBlacklistApplicationsBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testUpgradeFirmware() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.upgradeFirmware(TestUtils.getUpgradeFirmwareBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testConfigureVPN() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.configureVPN(TestUtils.getVpnBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testSendNotification() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.sendNotification(TestUtils.getNotificationBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testConfigureWifi() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.configureWifi(TestUtils.getWifiBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testEncryptStorage() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.encryptStorage(TestUtils.getEncryptionBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testChangeLockCode() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.changeLockCode(TestUtils.getLockCodeBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testSetPasswordPolicy() + throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.setPasswordPolicy(TestUtils.getPasswordPolicyBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } + + @Test + public void testSetWebClip() throws OperationManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + Activity activity = androidService.setWebClip(TestUtils.getWebClipBeanWrapper()); + Assert.assertNotNull(activity); + Assert.assertNotNull(activity.getActivityId()); + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java new file mode 100644 index 000000000..2a5b818e4 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/DeviceManagementServiceTests.java @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2017, 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.device.mgt.mobile.android.core; + +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.testng.PowerMockObjectFactory; +import org.testng.Assert; +import org.testng.IObjectFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.ObjectFactory; +import org.testng.annotations.Test; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; +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.mobile.android.common.Message; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice; +import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.core.impl.AndroidServiceImpl; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.ApplicationManagementProviderServiceMock; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceInformationManagerServiceMock; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.DeviceManagementProviderServiceMock; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.NotificationManagementServiceMock; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.PolicyManagerServiceMock; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils.TestUtils; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PrepareForTest(AndroidAPIUtils.class) +public class DeviceManagementServiceTests { + + private AndroidServiceImpl androidService; + + @ObjectFactory + public IObjectFactory getObjectFactory() { + return new PowerMockObjectFactory(); + } + + @BeforeClass + public void init() { + MockitoAnnotations.initMocks(this); + androidService = new AndroidServiceImpl(); + } + + private void mockDeviceManagementService() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService")) + .toReturn(new DeviceManagementProviderServiceMock()); + } + + private void mockApplicationManagerService() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getApplicationManagerService")) + .toReturn(new ApplicationManagementProviderServiceMock()); + } + + private void mockPolicyManagerService() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getPolicyManagerService")) + .toReturn(new PolicyManagerServiceMock()); + } + + private void mockDeviceInformationManagerService() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceInformationManagerService")) + .toReturn(new DeviceInformationManagerServiceMock()); + } + + private void mockNotificationManagementService() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getNotificationManagementService")) + .toReturn(new NotificationManagementServiceMock()); + } + + private void mockUser() { + PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getAuthenticatedUser")) + .toReturn("admin"); + } + + @Test + public void testUpdateApplicationList() + throws ApplicationManagementException { + mockApplicationManagerService(); + Message message = androidService + .updateApplicationList(TestUtils.getDeviceId(), TestUtils.getAndroidApplications()); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.ACCEPTED.toString()); + } + + @Test (expectedExceptions = {InvalidDeviceException.class}) + public void testGetPendingOperationsForNullDevice() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + List resultOperations = new ArrayList<>(); + androidService.getPendingOperations(null, resultOperations, true); + } + + @Test (expectedExceptions = {InvalidDeviceException.class}) + public void testGetPendingOperationsForInvalidDevice() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + List resultOperations = new ArrayList<>(); + androidService.getPendingOperations("1234", resultOperations, true); + } + + @Test + public void testGetPendingOperationsNullResponse() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + List pendingOperations = androidService + .getPendingOperations(TestUtils.getDeviceId(), null, true); + Assert.assertNotNull(pendingOperations); + Assert.assertFalse((pendingOperations.isEmpty())); + } + + @Test + public void testGetPendingOperationsWithMonitorResponse() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockPolicyManagerService(); + List pendingOperations = androidService + .getPendingOperations(TestUtils.getDeviceId(), TestUtils.getSuccessMonitorOperationResponse(), true); + Assert.assertNotNull(pendingOperations); + Assert.assertFalse((pendingOperations.isEmpty())); + } + + @Test + public void testGetPendingOperationsWithApplicationResponse() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockApplicationManagerService(); + List pendingOperations = androidService + .getPendingOperations(TestUtils.getDeviceId(), TestUtils.getSuccessApplicationOperationResponse(), + true); + Assert.assertNotNull(pendingOperations); + Assert.assertFalse((pendingOperations.isEmpty())); + } + + @Test + public void testGetPendingOperationsWithDeviceInfoResponse() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockDeviceInformationManagerService(); + List pendingOperations = androidService + .getPendingOperations(TestUtils.getDeviceId(), + TestUtils.getSuccessInfoOperationResponse(), true); + Assert.assertNotNull(pendingOperations); + Assert.assertFalse((pendingOperations.isEmpty())); + } + + @Test + public void testGetPendingOperationsWithInProgressResponse() + throws DeviceManagementException, OperationManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + List pendingOperations = androidService + .getPendingOperations(TestUtils.getDeviceId(), + TestUtils.getInProgressOperationResponse(), true); + Assert.assertNotNull(pendingOperations); + Assert.assertFalse((pendingOperations.isEmpty())); + } + + @Test + public void testGetPendingOperationsWithErrorResponse() + throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockNotificationManagementService(); + List pendingOperations = androidService + .getPendingOperations(TestUtils.getDeviceId(), + TestUtils.getErrorOperationResponse(), true); + Assert.assertNotNull(pendingOperations); + Assert.assertFalse((pendingOperations.isEmpty())); + } + + @Test + public void testEnrollDeviceWithoutLocationSuccess() + throws DeviceManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockPolicyManagerService(); + mockUser(); + Message message = androidService.enrollDevice(TestUtils.getBasicAndroidDevice()); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.OK.getStatusCode()); + } + + @Test + public void testEnrollDeviceWithLocationSuccess() + throws DeviceManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockDeviceInformationManagerService(); + mockPolicyManagerService(); + mockUser(); + AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); + + List properties = new ArrayList<>(); + Device.Property property = new Device.Property(); + property.setName("LATITUDE"); + property.setValue("79.5"); + properties.add(property); + property = new Device.Property(); + property.setName("LONGITUDE"); + property.setValue("6.9"); + properties.add(property); + property = new Device.Property(); + property.setName("ALTITUDE"); + property.setValue("-59.8373726"); + properties.add(property); + property = new Device.Property(); + property.setName("SPEED"); + property.setValue("0.5123423333"); + properties.add(property); + property = new Device.Property(); + property.setName("BEARING"); + property.setValue("44.0"); + properties.add(property); + property = new Device.Property(); + property.setName("DISTANCE"); + property.setValue("44.0"); + properties.add(property); + androidDevice.setProperties(properties); + + Message message = androidService.enrollDevice(androidDevice); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.OK.getStatusCode()); + } + + @Test + public void testEnrollDeviceUnSuccess() + throws DeviceManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockUser(); + AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); + androidDevice.setDeviceIdentifier("1234"); + Message message = androidService.enrollDevice(androidDevice); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + @Test + public void testIsEnrolledExists() + throws DeviceManagementException { + mockDeviceManagementService(); + Message message = androidService.isEnrolled(TestUtils.getDeviceId(), null); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.OK.toString()); + } + + @Test + public void testIsEnrolledNonExist() + throws DeviceManagementException { + mockDeviceManagementService(); + Message message = androidService.isEnrolled("1234", null); + Assert.assertNotNull(message); + Assert.assertEquals(message.getResponseCode(), Response.Status.NOT_FOUND.toString()); + } + + @Test + public void testIsEnrolledNull() + throws DeviceManagementException { + mockDeviceManagementService(); + Message response = androidService.isEnrolled(null, null); + Assert.assertNotNull(response); + Assert.assertEquals(response.getResponseCode(), Response.Status.NOT_FOUND.toString()); + } + + @Test + public void testModifyEnrollmentSuccess() + throws DeviceManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockUser(); + boolean status = androidService.modifyEnrollment(TestUtils.getDeviceId(), TestUtils.getBasicAndroidDevice()); + Assert.assertTrue(status); + } + + @Test + public void testModifyEnrollmentUnSuccess() + throws DeviceManagementException, AndroidDeviceMgtPluginException { + mockDeviceManagementService(); + mockUser(); + AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); + androidDevice.setDeviceIdentifier("1234"); + boolean status = androidService + .modifyEnrollment(TestUtils.getDeviceId(), androidDevice); + Assert.assertFalse(status); + } + + @Test + public void testDisEnrollDeviceSuccess() + throws DeviceManagementException { + mockDeviceManagementService(); + boolean status = androidService.disEnrollDevice(TestUtils.getDeviceId()); + Assert.assertTrue(status); + } + + @Test + public void testDisEnrollUnSuccess() + throws DeviceManagementException { + mockDeviceManagementService(); + boolean status = androidService.disEnrollDevice("1234"); + Assert.assertFalse(status); + } +} + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/ApplicationManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/ApplicationManagementProviderServiceMock.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/ApplicationManagementProviderServiceMock.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/ApplicationManagementProviderServiceMock.java index 563258b3c..29de8de79 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/ApplicationManagementProviderServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/ApplicationManagementProviderServiceMock.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.mocks; +package org.wso2.carbon.device.mgt.mobile.android.core.mokcs; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.app.mgt.Application; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceInformationManagerServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceInformationManagerServiceMock.java similarity index 93% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceInformationManagerServiceMock.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceInformationManagerServiceMock.java index 2be212e52..37a5ac425 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceInformationManagerServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceInformationManagerServiceMock.java @@ -1,6 +1,5 @@ -package org.wso2.carbon.mdm.services.android.mocks; +package org.wso2.carbon.device.mgt.mobile.android.core.mokcs; -import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java similarity index 99% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java index 5540b2c87..50dd05d54 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java @@ -33,7 +33,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.mocks; +package org.wso2.carbon.device.mgt.mobile.android.core.mokcs; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; @@ -70,7 +70,7 @@ import org.wso2.carbon.device.mgt.core.geo.GeoCluster; import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo; -import org.wso2.carbon.mdm.services.android.utils.TestUtils; +import org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils.TestUtils; import java.util.Date; import java.util.HashMap; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/NotificationManagementServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/NotificationManagementServiceMock.java similarity index 97% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/NotificationManagementServiceMock.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/NotificationManagementServiceMock.java index 4fd989de6..1f9cafbd3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/NotificationManagementServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/NotificationManagementServiceMock.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.mocks; +package org.wso2.carbon.device.mgt.mobile.android.core.mokcs; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.PaginationRequest; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/PolicyManagerServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/PolicyManagerServiceMock.java similarity index 98% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/PolicyManagerServiceMock.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/PolicyManagerServiceMock.java index a71dafebf..36283e5d3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/PolicyManagerServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/PolicyManagerServiceMock.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.mocks; +package org.wso2.carbon.device.mgt.mobile.android.core.mokcs; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/utils/TestUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/utils/TestUtils.java similarity index 87% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/utils/TestUtils.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/utils/TestUtils.java index 994cb9423..61169ecfa 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/utils/TestUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/utils/TestUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.mdm.services.android.utils; +package org.wso2.carbon.device.mgt.mobile.android.core.mokcs.utils; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; @@ -26,40 +26,40 @@ import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; -import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; -import org.wso2.carbon.mdm.services.android.bean.Camera; -import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; -import org.wso2.carbon.mdm.services.android.bean.DeviceLock; -import org.wso2.carbon.mdm.services.android.bean.LockCode; -import org.wso2.carbon.mdm.services.android.bean.Notification; -import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; -import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; -import org.wso2.carbon.mdm.services.android.bean.Vpn; -import org.wso2.carbon.mdm.services.android.bean.WebClip; -import org.wso2.carbon.mdm.services.android.bean.Wifi; -import org.wso2.carbon.mdm.services.android.bean.WipeData; -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.bean.wrapper.ApplicationInstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; +import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationInstallation; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUninstallation; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUpdate; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.BlacklistApplications; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Camera; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceEncryption; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceLock; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.LockCode; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Notification; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.PasscodePolicy; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.UpgradeFirmware; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Vpn; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.WebClip; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.Wifi; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.WipeData; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationInstallationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUninstallationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUpdateBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.BlacklistApplicationsBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.CameraBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.DeviceLockBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EncryptionBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.LockCodeBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.NotificationBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.PasswordPolicyBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.UpgradeFirmwareBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.VpnBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WebClipBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WifiBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WipeDataBeanWrapper; +import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; import java.util.ArrayList; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/resources/log4j.properties b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/resources/log4j.properties similarity index 100% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/resources/log4j.properties rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/resources/log4j.properties diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/resources/testng.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/resources/testng.xml similarity index 80% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/resources/testng.xml rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/resources/testng.xml index 865a1e85b..edecf75b9 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/resources/testng.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/resources/testng.xml @@ -23,8 +23,8 @@ - - + + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml deleted file mode 100644 index 97e023a72..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - android-plugin - org.wso2.carbon.devicemgt-plugins - 5.0.7-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.mobile.android - bundle - WSO2 Carbon - Mobile Device Management Android Impl - WSO2 Carbon - Mobile Device Management Android Implementation - http://wso2.org - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.felix - maven-scr-plugin - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.devicemgt.plugins.version} - Device Management Mobile Android Impl Bundle - org.wso2.carbon.device.mgt.mobile.android.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.xml, - javax.xml.stream, - javax.xml.bind.*, - javax.sql, - javax.xml.parsers; version=0.0.0, - org.w3c.dom, - javax.naming, - org.wso2.carbon.context, - org.wso2.carbon.utils.*, - org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.ndatasource.core, - org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.session, - org.wso2.carbon.registry.core.service, - org.wso2.carbon.registry.api, - org.wso2.carbon.device.mgt.extensions.license.mgt.registry, - com.google.gson.* - - - !org.wso2.carbon.device.mgt.mobile.android.internal, - org.wso2.carbon.device.mgt.mobile.android.* - - - - - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.extensions - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.common - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.core - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - org.wso2.carbon - org.wso2.carbon.registry.core - - - org.testng - testng - - - org.apache.tomcat.wso2 - jdbc-pool - - - com.h2database.wso2 - h2-database-engine - test - - - com.google.code.gson - gson - - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java deleted file mode 100644 index ded87ad71..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2014, 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.device.mgt.mobile.android.impl.config; - -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; -import java.io.File; - -/** - * Class responsible for the mobile device manager configuration initialization. - */ -public class MobileDeviceConfigurationManager { - - private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml"; - private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile"; - private static final String DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY = "device-mgt-plugin-configs"; - private MobileDeviceManagementConfig currentMobileDeviceConfig; - private static MobileDeviceConfigurationManager mobileDeviceConfigManager; - - private final String mobileDeviceMgtConfigXMLPath = - CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + - DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY + - File.separator + - MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME; - - public static MobileDeviceConfigurationManager getInstance() { - if (mobileDeviceConfigManager == null) { - synchronized (MobileDeviceConfigurationManager.class) { - if (mobileDeviceConfigManager == null) { - mobileDeviceConfigManager = new MobileDeviceConfigurationManager(); - } - } - } - return mobileDeviceConfigManager; - } - - public synchronized void initConfig() throws DeviceManagementException { - try { - File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath); - Document doc = MobileDeviceManagementUtil.convertToDocument(mobileDeviceMgtConfig); - JAXBContext mobileDeviceMgmtContext = - JAXBContext.newInstance(MobileDeviceManagementConfig.class); - Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller(); - this.currentMobileDeviceConfig = - (MobileDeviceManagementConfig) unmarshaller.unmarshal(doc); - } catch (Exception e) { - throw new DeviceManagementException( - "Error occurred while initializing Mobile Device Management config", e); - } - } - - public MobileDeviceManagementConfig getMobileDeviceManagementConfig() { - return currentMobileDeviceConfig; - } - - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementConfig.java deleted file mode 100644 index 2c65375c7..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014, 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.device.mgt.mobile.android.impl.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents Mobile Device Mgt configuration. - */ -@XmlRootElement(name = "MobileDeviceMgtConfiguration") -public final class MobileDeviceManagementConfig { - - private MobileDeviceManagementRepository mobileDeviceMgtRepository; - - @XmlElement(name = "ManagementRepository", nillable = false) - public MobileDeviceManagementRepository getMobileDeviceMgtRepository() { - return mobileDeviceMgtRepository; - } - - public void setMobileDeviceMgtRepository( - MobileDeviceManagementRepository mobileDeviceMgtRepository) { - this.mobileDeviceMgtRepository = mobileDeviceMgtRepository; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementRepository.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementRepository.java deleted file mode 100644 index e40202acf..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014, 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.device.mgt.mobile.android.impl.config; - -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.DataSourceConfigAdapter; -import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.List; -import java.util.Map; - -/** - * Class for holding management repository data. - */ -@XmlRootElement(name = "ManagementRepository") -public class MobileDeviceManagementRepository { - - private Map mobileDataSourceConfigMap; - private List mobileDataSourceConfigs; - - public MobileDataSourceConfig getMobileDataSourceConfig(String provider) { - return mobileDataSourceConfigMap.get(provider); - } - - @XmlElement(name = "DataSourceConfigurations") - @XmlJavaTypeAdapter(DataSourceConfigAdapter.class) - public Map getMobileDataSourceConfigMap() { - return mobileDataSourceConfigMap; - } - - public void setMobileDataSourceConfigMap(Map mobileDataSourceConfigMap) { - this.mobileDataSourceConfigMap = mobileDataSourceConfigMap; - } - - public List getMobileDataSourceConfigs() { - return (List) mobileDataSourceConfigMap.values(); - } - -} diff --git a/components/mobile-plugins/android-plugin/pom.xml b/components/mobile-plugins/android-plugin/pom.xml index 4813cdc09..efd6356b3 100644 --- a/components/mobile-plugins/android-plugin/pom.xml +++ b/components/mobile-plugins/android-plugin/pom.xml @@ -33,7 +33,9 @@ http://wso2.org - org.wso2.carbon.device.mgt.mobile.android + org.wso2.carbon.device.mgt.mobile.android.common + org.wso2.carbon.device.mgt.mobile.android.addons + org.wso2.carbon.device.mgt.mobile.android.core org.wso2.carbon.device.mgt.mobile.android.api org.wso2.carbon.device.mgt.mobile.android.emulator org.wso2.carbon.device.mgt.mobile.android.ui diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index 3281e9e36..d1b13a76a 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -39,7 +39,11 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.android + org.wso2.carbon.device.mgt.mobile.android.core + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.common com.h2database.wso2 @@ -243,7 +247,10 @@ - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android.core:${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android.common:${carbon.devicemgt.plugins.version} diff --git a/pom.xml b/pom.xml index e46e0d8d3..45eaf3f9a 100644 --- a/pom.xml +++ b/pom.xml @@ -549,7 +549,17 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.android + org.wso2.carbon.device.mgt.mobile.android.common + ${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.addons + ${carbon.devicemgt.plugins.version} + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.mobile.android.core ${carbon.devicemgt.plugins.version} @@ -1350,7 +1360,7 @@ 7.0.85 1.0 - 2.0 + 2.0.1 github-scm