forked from community/device-mgt-plugins
Merge branch 'master' of https://gitlab.com/entgra/carbon-device-mgt-plugins
commit
757bca2da0
@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (pvt) Ltd. (http://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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>android-plugin</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||||
|
<version>5.0.7-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.mobile.android.addons</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>WSO2 Carbon - Mobile Device Management Android Addons Impl</name>
|
||||||
|
<description>WSO2 Carbon - Mobile Device Management Android Addons Implementation</description>
|
||||||
|
<url>https://entgra.io/</url>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-scr-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
|
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
|
||||||
|
<Bundle-Description>Device Management Mobile Android addons Impl Bundle</Bundle-Description>
|
||||||
|
<Import-Package>
|
||||||
|
com.google.gson.*
|
||||||
|
</Import-Package>
|
||||||
|
<Export-Package>
|
||||||
|
org.wso2.carbon.device.mgt.mobile.android.addons.*
|
||||||
|
</Export-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-transports-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
2
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 → 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
2
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 → 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
9
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 → 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
9
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 → 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
4
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 → 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
4
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
8
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 → 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
8
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 → 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
71
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 → 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
71
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 → 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
24
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 → 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
24
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 → 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
78
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 → 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
78
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 → 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
21
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 → 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
21
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 → 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
22
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 → 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
22
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 → 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
489
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 → 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
489
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 → 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
@ -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<AndroidApplication> 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<? extends Operation> 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<? extends Operation> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<DeviceState> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
package org.wso2.carbon.mdm.services.android.bean;
|
|
||||||
|
|
||||||
public enum ProxyType {
|
|
||||||
MANUAL, AUTO
|
|
||||||
}
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 <T> ParameterValidationException(Set<ConstraintViolation<T>> violations) {
|
|
||||||
super(Response.status(Response.Status.BAD_REQUEST)
|
|
||||||
.entity(AndroidDeviceUtils.getConstraintViolationErrorDTO(violations))
|
|
||||||
.header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON)
|
|
||||||
.build());
|
|
||||||
|
|
||||||
//Set the error message
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
for (ConstraintViolation violation : violations) {
|
|
||||||
stringBuilder.append(violation.getRootBeanClass().getSimpleName());
|
|
||||||
stringBuilder.append(".");
|
|
||||||
stringBuilder.append(violation.getPropertyPath());
|
|
||||||
stringBuilder.append(": ");
|
|
||||||
stringBuilder.append(violation.getMessage());
|
|
||||||
stringBuilder.append(", ");
|
|
||||||
}
|
|
||||||
message = stringBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -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<AndroidApplication> androidApplications) {
|
|
||||||
Application application;
|
|
||||||
List<Application> applications = new ArrayList<>();
|
|
||||||
for (AndroidApplication androidApplication : androidApplications) {
|
|
||||||
application = new Application();
|
|
||||||
application.setPlatform(androidApplication.getPlatform());
|
|
||||||
application.setCategory(androidApplication.getCategory());
|
|
||||||
application.setName(androidApplication.getName());
|
|
||||||
application.setLocationUrl(androidApplication.getLocationUrl());
|
|
||||||
application.setImageUrl(androidApplication.getImageUrl());
|
|
||||||
application.setVersion(androidApplication.getVersion());
|
|
||||||
application.setType(androidApplication.getType());
|
|
||||||
application.setAppProperties(androidApplication.getAppProperties());
|
|
||||||
application.setApplicationIdentifier(androidApplication.getApplicationIdentifier());
|
|
||||||
application.setMemoryUsage(androidApplication.getMemoryUsage());
|
|
||||||
applications.add(application);
|
|
||||||
}
|
|
||||||
Message responseMessage = new Message();
|
|
||||||
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<? extends Operation> 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<? extends Operation> 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<? extends Operation> 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<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
|
||||||
deviceIdentifiers.add(deviceIdentifier);
|
|
||||||
|
|
||||||
List<String> 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<ProfileFeature> 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<Device.Property> 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<ConfigurationEntry> 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<ConfigurationEntry> 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<Device> deviceList = AndroidAPIUtils.
|
|
||||||
getDeviceManagementService().
|
|
||||||
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false);
|
|
||||||
List<DeviceIdentifier> 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<DeviceState> 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<DeviceState> 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<DeviceState> 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> errorDeviceIdList;
|
|
||||||
private List<DeviceIdentifier> validDeviceIDList;
|
|
||||||
|
|
||||||
public List<String> getErrorDeviceIdList() {
|
|
||||||
return errorDeviceIdList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setErrorDeviceIdList(List<String> errorDeviceIdList) {
|
|
||||||
this.errorDeviceIdList = errorDeviceIdList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DeviceIdentifier> getValidDeviceIDList() {
|
|
||||||
return validDeviceIDList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidDeviceIDList(List<DeviceIdentifier> validDeviceIDList) {
|
|
||||||
this.validDeviceIDList = validDeviceIDList;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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<Device.Property> 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,167 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2019, Entgra (pvt) Ltd. (http://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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>android-plugin</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||||
|
<version>5.0.7-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.mobile.android.common</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>WSO2 Carbon - Mobile Device Management Android Common Impl</name>
|
||||||
|
<description>WSO2 Carbon - Mobile Device Management Android Common Implementation</description>
|
||||||
|
<url>https://entgra.io/</url>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-scr-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
|
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
|
||||||
|
<Bundle-Description>Device Management Mobile Android Impl Bundle</Bundle-Description>
|
||||||
|
<Import-Package>
|
||||||
|
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.*
|
||||||
|
</Import-Package>
|
||||||
|
<Export-Package>
|
||||||
|
org.wso2.carbon.device.mgt.mobile.android.common.*
|
||||||
|
</Export-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.apis</groupId>
|
||||||
|
<artifactId>google-api-services-androidenterprise</artifactId>
|
||||||
|
<version>v1-rev186-1.25.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>objenesis</artifactId>
|
||||||
|
<groupId>org.objenesis</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-core-asl</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>woodstox-core-asl</artifactId>
|
||||||
|
<groupId>org.codehaus.woodstox</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>axiom-api</artifactId>
|
||||||
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>geronimo-stax-api_1.0_spec</artifactId>
|
||||||
|
<groupId>org.apache.geronimo.specs.wso2</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>axis2-client</artifactId>
|
||||||
|
<groupId>org.apache.axis2.wso2</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
12
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 → 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
12
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 → 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
3
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 → 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
3
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 → 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
2
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 → 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
2
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 → 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
3
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 → 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
3
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
4
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 → 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
4
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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 {
|
public class EnterpriseConfigs {
|
||||||
|
|
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
3
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 → 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
3
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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 {
|
public class GoogleAppSyncResponse {
|
||||||
|
|
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
@ -0,0 +1,5 @@
|
|||||||
|
package org.wso2.carbon.device.mgt.mobile.android.common.bean;
|
||||||
|
|
||||||
|
public enum ProxyType {
|
||||||
|
MANUAL, AUTO
|
||||||
|
}
|
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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;
|
import io.swagger.annotations.ApiModel;
|
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
2
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 → 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
2
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
2
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
4
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 → 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
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue