Replace BadRequestException in Android APIs

revert-dabc3590
shamalka 5 years ago
parent acbfdad962
commit 70c980f46f

@ -47,7 +47,9 @@ 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.ErrorResponse;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidApplication;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.AndroidDevice;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestExceptionDup;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; 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.AndroidAPIUtils;
@ -193,6 +195,18 @@ public class DeviceManagementAPIImpl implements DeviceManagementAPI {
log.error(msg, e); log.error(msg, e);
throw new UnexpectedServerErrorException( throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured";
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();
} }
} }

@ -35,6 +35,7 @@
*/ */
package org.wso2.carbon.device.mgt.mobile.android.api.impl; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
@ -86,7 +87,9 @@ import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.VpnBeanWrap
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WebClipBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WebClipBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WifiBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WifiBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WipeDataBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WipeDataBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestExceptionDup;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; 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.AndroidAPIUtils;
@ -127,8 +130,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance for file transfer operation"; String errorMessage = "Issue in retrieving operation management service instance for file transfer operation";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e) {
String msg = "Invalid request";
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 errorMessage = "Error occured while executing file tranfer operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -147,8 +163,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing device lock operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -167,8 +196,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing device unlock operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -187,8 +229,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while retrieving device location";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -207,8 +262,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance."; String errorMessage = "Issue in retrieving operation management service instance.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing remove password operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -227,8 +295,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing control camera operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -248,6 +329,18 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while retrieving device information";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -267,6 +360,18 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while retrieving device logcat";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -285,8 +390,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing enterprice wipe device operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -305,8 +423,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing Android wipe-data device operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -325,8 +456,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing Android getApplicationList device operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -345,8 +489,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing Android ring device operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -365,8 +522,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing Android reboot device operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -385,8 +555,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing Android change LockTask mode operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -405,8 +588,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing mute device operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -426,8 +622,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing install application operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -446,8 +655,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing update application operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -467,8 +689,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing uninstall application operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -487,8 +722,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing blacklist application operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -507,8 +755,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing upgrade firmware operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -527,8 +788,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing configure vpn operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -547,8 +821,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing send notification operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -567,8 +854,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing configure wifi operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -587,8 +887,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing encrypt operation operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -607,8 +920,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing change lock code operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -627,8 +953,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing set password policy operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -647,8 +986,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing set webclip operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -669,8 +1021,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500L).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while applying 'configure-global-proxy' operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@POST @POST
@ -683,34 +1048,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} }
try{ try{
if (applicationRestrictionBeanWrapper == null || applicationRestrictionBeanWrapper.getOperation() == null) { AndroidService androidService = AndroidAPIUtils.getAndroidService();
String errorMessage = "The payload of the application configuration operation is incorrect"; Response response = androidService.sendApplicationConfiguration(applicationRestrictionBeanWrapper);
log.error(errorMessage); return Response.status(Response.Status.CREATED).entity(response).build();
throw new BadRequestException( } catch (BadRequestExceptionDup e){
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); String msg = "Invalid request";
} log.error(msg, e);
ApplicationRestriction applicationRestriction = applicationRestrictionBeanWrapper.getOperation(); return Response.status(Response.Status.BAD_REQUEST).entity(
ProfileOperation operation = new ProfileOperation(); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_BAD_REQUEST)
operation.setCode(AndroidConstants.OperationCodes.REMOTE_APP_CONFIG); .setMessage(msg).build()).build();
operation.setType(Operation.Type.PROFILE); } catch (AndroidDeviceMgtPluginException e) {
operation.setPayLoad(applicationRestriction.toJSON()); String errorMessage = "Error occured while sending app configuration";
return (Response) AndroidAPIUtils.getOperationResponse(applicationRestrictionBeanWrapper.getDeviceIDs(),
operation);
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }
@ -730,9 +1082,21 @@ public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new UnexpectedServerErrorException( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder(). new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
setCode(HttpStatus.SC_INTERNAL_SERVER_ERROR).setMessage(errorMessage).build()); .setMessage(errorMessage).build()).build();
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 errorMessage = "Error occured while executing configure-display-message operation";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build()).build();
} }
} }

@ -18,6 +18,7 @@
*/ */
package org.wso2.carbon.device.mgt.mobile.android.api.impl; package org.wso2.carbon.device.mgt.mobile.android.api.impl;
import com.google.api.client.http.HttpStatusCodes;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -35,9 +36,7 @@ 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.DeviceState;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; 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.bean.wrapper.EventBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.*;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.NotFoundException;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; 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.AndroidAPIUtils;
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils;
@ -133,9 +132,22 @@ public class EventReceiverAPIImpl implements EventReceiverAPI {
@Size(min = 2, max = 45) @Size(min = 2, max = 45)
@QueryParam("type") String type, @QueryParam("type") String type,
@HeaderParam("If-Modified-Since") String ifModifiedSince) { @HeaderParam("If-Modified-Since") String ifModifiedSince) {
try{
AndroidService androidService = AndroidAPIUtils.getAndroidService(); AndroidService androidService = AndroidAPIUtils.getAndroidService();
Response response = androidService.retrieveAlerts(deviceId, from, to, type, ifModifiedSince); Response response = androidService.retrieveAlerts(deviceId, from, to, type, ifModifiedSince);
return response; return response;
} catch (BadRequestExceptionDup e){
String msg = "Invalid request";
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 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();
}
} }
} }

@ -35,6 +35,7 @@ import org.wso2.carbon.device.mgt.mobile.android.common.bean.EnterpriseTokenUrl;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.GoogleAppSyncResponse; import org.wso2.carbon.device.mgt.mobile.android.common.bean.GoogleAppSyncResponse;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.*; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.*;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestExceptionDup;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException;
import javax.validation.Valid; import javax.validation.Valid;
@ -47,95 +48,438 @@ import java.util.List;
public interface AndroidService { public interface AndroidService {
/**
* Method to retrieve platform configurations
*
* @return {@link PlatformConfiguration}
* @throws {@link DeviceManagementException}
*/
PlatformConfiguration getPlatformConfig() throws DeviceManagementException; PlatformConfiguration getPlatformConfig() throws DeviceManagementException;
/**
* Method to update configurations
*
* @param androidPlatformConfiguration
* @throws {@link AndroidDeviceMgtPluginException}
*/
void updateConfiguration(AndroidPlatformConfiguration androidPlatformConfiguration) void updateConfiguration(AndroidPlatformConfiguration androidPlatformConfiguration)
throws AndroidDeviceMgtPluginException; throws AndroidDeviceMgtPluginException;
Message isEnrolled(String id, DeviceIdentifier deviceIdentifier) throws DeviceManagementException; /**
* Method for file transfer operation
Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) throws OperationManagementException; *
* @param fileTransferBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper)
throws AndroidDeviceMgtPluginException, OperationManagementException;
Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) throws OperationManagementException; /**
* Method for device lock operation
*
* @param deviceLockBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity configureDeviceUnlock(List<String> deviceIDs) throws OperationManagementException; /**
* Method for device unlock operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity configureDeviceUnlock(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity getDeviceLocation(List<String> deviceIDs) throws OperationManagementException; /**
* Method for get device location operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity getDeviceLocation(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity removePassword(List<String> deviceIDs) throws OperationManagementException; /**
* Method for remove password operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity removePassword(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity configureCamera(CameraBeanWrapper cameraBeanWrapper) throws OperationManagementException; /**
* Method for configure camera operation
*
* @param cameraBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity configureCamera(CameraBeanWrapper cameraBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity getDeviceInformation(List<String> deviceIDs) throws OperationManagementException; /**
* Method to get device information
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity getDeviceInformation(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity getDeviceLogcat(List<String> deviceIDs) throws OperationManagementException; /**
* Method to get device logcat
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity getDeviceLogcat(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity wipeDevice(List<String> deviceIDs) throws OperationManagementException; /**
* Method for wipe device operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity wipeDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) throws OperationManagementException; /**
* Method for wipe data operation
*
* @param wipeDataBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity wipeData(WipeDataBeanWrapper wipeDataBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity getApplications(List<String> deviceIDs) throws OperationManagementException; /**
* Method for get applications operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity getApplications(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity ringDevice(List<String> deviceIDs) throws OperationManagementException; /**
* Method for ring device operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity ringDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity rebootDevice(List<String> deviceIDs) throws OperationManagementException; /**
* Method for reboot device operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity rebootDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity changeLockTask(List<String> deviceIDs) throws OperationManagementException; /**
* Method for change lock task operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity changeLockTask(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity muteDevice(List<String> deviceIDs) throws OperationManagementException; /**
* Method for mute device operation
*
* @param deviceIDs
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity muteDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for install application operation
*
* @param applicationInstallationBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) Activity installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper)
throws OperationManagementException; throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for update application operation
*
* @param applicationUpdateBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) Activity updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper)
throws OperationManagementException; throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for uninstall application operation
*
* @param applicationUninstallationBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) Activity uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper)
throws OperationManagementException; throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for blacklist application operation
*
* @param blacklistApplicationsBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity blacklistApplications(@Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) Activity blacklistApplications(@Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper)
throws OperationManagementException; throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for upgrade firmware operation
*
* @param upgradeFirmwareBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) Activity upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper)
throws OperationManagementException; throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity configureVPN(VpnBeanWrapper vpnConfiguration) throws OperationManagementException; /**
* Method for configure vpn operation
*
* @param vpnConfiguration
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity configureVPN(VpnBeanWrapper vpnConfiguration)
throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for send notification operation
*
* @param notificationBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity sendNotification(NotificationBeanWrapper notificationBeanWrapper) Activity sendNotification(NotificationBeanWrapper notificationBeanWrapper)
throws OperationManagementException; throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity configureWifi(WifiBeanWrapper wifiBeanWrapper) throws OperationManagementException; /**
* Method for configure wifi operation
*
* @param wifiBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity configureWifi(WifiBeanWrapper wifiBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) throws OperationManagementException; /**
* Method for encypt storage operation
*
* @param encryptionBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) throws OperationManagementException; /**
* Method for change lock code operation
*
* @param lockCodeBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) throws OperationManagementException; /**
* Method for set password policy operation
*
* @param passwordPolicyBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity setWebClip(WebClipBeanWrapper webClipBeanWrapper) throws OperationManagementException; /**
* Method for set webclip operation
*
* @param webClipBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity setWebClip(WebClipBeanWrapper webClipBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) throws OperationManagementException; /**
* Method for set recommended global proxy operation
*
* @param globalProxyBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
Activity configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) throws OperationManagementException; /**
* Method for send application configuration operation
*
* @param applicationRestrictionBeanWrapper
* @return
* @throws {@link AndroidDeviceMgtPluginException}
*/
Response sendApplicationConfiguration(
ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper)
throws AndroidDeviceMgtPluginException;
//DeviceManagementAPIImpl /**
Message updateApplicationList(String id, List<AndroidApplication> androidApplications) throws ApplicationManagementException; * method for configure display message operation
*
* @param displayMessageBeanWrapper
* @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException}
*/
Activity configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException;
/**
* Method for update application list
*
* @param id
* @param androidApplications
* @return {@link Message}
* @throws {@link ApplicationManagementException}
*/
Message updateApplicationList(String id, List<AndroidApplication> androidApplications)
throws ApplicationManagementException;
List<? extends Operation> getPendingOperations(String id, List<? extends Operation> resultOperations, boolean disableGoogleApps) /**
* Method for get pending operations
*
* @param id
* @param resultOperations
* @param disableGoogleApps
* @return
* @throws {@link DeviceManagementException}
* @throws {@link InvalidDeviceException}
*/
List<? extends Operation> getPendingOperations
(String id, List<? extends Operation> resultOperations, boolean disableGoogleApps)
throws DeviceManagementException, InvalidDeviceException; throws DeviceManagementException, InvalidDeviceException;
/**
* Method to enroll device
*
* @param androidDevice
* @return {@link Response}
* @throws {@link DeviceManagementException}
*/
Response enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException; Response enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException;
boolean modifyEnrollment(String id, AndroidDevice androidDevice) throws DeviceManagementException; /**
* Method to check if a device is enrolled
*
* @param id
* @param deviceIdentifier
* @return {@link Message}
* @throws {@link DeviceManagementException}
*/
Message isEnrolled(String id, DeviceIdentifier deviceIdentifier) throws DeviceManagementException;
/**
* Method to modify enrollment
*
* @param id
* @param androidDevice
* @return
* @throws {@link DeviceManagementException}
* @throws {@link AndroidDeviceMgtPluginException}
*/
boolean modifyEnrollment(String id, AndroidDevice androidDevice)
throws DeviceManagementException, AndroidDeviceMgtPluginException;
/**
* Method to disenroll a device
*
* @param id
* @return
* @throws {@link DeviceManagementException}
*/
boolean disEnrollDevice(String id) throws DeviceManagementException; boolean disEnrollDevice(String id) throws DeviceManagementException;
//EventReceiverAPI /**
* Method to publish events
*
* @param eventBeanWrapper
* @return {@link Device}
* @throws {@link DeviceManagementException}
*/
Device publishEvents(EventBeanWrapper eventBeanWrapper) throws DeviceManagementException; Device publishEvents(EventBeanWrapper eventBeanWrapper) throws DeviceManagementException;
Response retrieveAlerts(String deviceId, /**
long from, * Method to retrieve alerts
long to, *
String type, * @param deviceId
String ifModifiedSince); * @param from
* @param to
* @param type
* @param ifModifiedSince
* @return {@link Response}
* @throws {@link AndroidDeviceMgtPluginException}
*/
Response retrieveAlerts(String deviceId, long from, long to, String type, String ifModifiedSince)
throws AndroidDeviceMgtPluginException;
} }

@ -240,13 +240,13 @@ public class AndroidServiceImpl implements AndroidService {
} }
@Override @Override
public Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) throws OperationManagementException { public Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null
|| fileTransferBeanWrapper.getDeviceIDs() == null) { || fileTransferBeanWrapper.getDeviceIDs() == null) {
String errorMessage = "The payload of the file transfer operation is incorrect."; String errorMessage = "The payload of the file transfer operation is incorrect.";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs());
@ -268,13 +268,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found."; String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) throws OperationManagementException { public Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) { if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) {
String errorMessage = "Lock bean is empty."; String errorMessage = "Lock bean is empty.";
log.error(errorMessage); log.error(errorMessage);
@ -293,13 +293,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity configureDeviceUnlock(List<String> deviceIDs) throws OperationManagementException { public Activity configureDeviceUnlock(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK); operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK);
@ -309,13 +309,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity getDeviceLocation(List<String> deviceIDs) throws OperationManagementException { public Activity getDeviceLocation(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException{
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION); operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION);
@ -324,13 +324,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity removePassword(List<String> deviceIDs) throws OperationManagementException { public Activity removePassword(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD); operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD);
@ -339,13 +339,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity configureCamera(CameraBeanWrapper cameraBeanWrapper) throws OperationManagementException { public Activity configureCamera(CameraBeanWrapper cameraBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) { if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the configure camera operation is incorrect."; String errorMessage = "The payload of the configure camera operation is incorrect.";
@ -362,13 +362,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity getDeviceInformation(List<String> deviceIDs) throws OperationManagementException { public Activity getDeviceInformation(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
@ -377,13 +377,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity getDeviceLogcat(List<String> deviceIDs) throws OperationManagementException { public Activity getDeviceLogcat(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.LOGCAT); operation.setCode(AndroidConstants.OperationCodes.LOGCAT);
@ -392,13 +392,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity wipeDevice(List<String> deviceIDs) throws OperationManagementException { public Activity wipeDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE); operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE);
@ -407,19 +407,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) throws OperationManagementException { public Activity wipeData(WipeDataBeanWrapper wipeDataBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) { if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) {
String errorMessage = "WipeData bean is empty."; String errorMessage = "WipeData bean is empty.";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
WipeData wipeData = wipeDataBeanWrapper.getOperation(); WipeData wipeData = wipeDataBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -430,13 +429,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity getApplications(List<String> deviceIDs) throws OperationManagementException { public Activity getApplications(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST); operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
@ -445,13 +444,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity ringDevice(List<String> deviceIDs) throws OperationManagementException { public Activity ringDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING); operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING);
@ -460,13 +459,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity rebootDevice(List<String> deviceIDs) throws OperationManagementException { public Activity rebootDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT); operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT);
@ -475,13 +474,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity changeLockTask(List<String> deviceIDs) throws OperationManagementException { public Activity changeLockTask(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE); operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE);
@ -490,13 +489,13 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity muteDevice(List<String> deviceIDs) throws OperationManagementException { public Activity muteDevice(List<String> deviceIDs)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE); operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE);
@ -506,21 +505,19 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) public Activity installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper)
throws OperationManagementException { throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() == if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() ==
null) { null) {
String errorMessage = "The payload of the application installing operation is incorrect"; String errorMessage = "The payload of the application installing operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation(); ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation();
@ -537,19 +534,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) throws OperationManagementException { public Activity updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) { if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the application update operation is incorrect"; String errorMessage = "The payload of the application update operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation(); ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation();
validateApplicationUrl(applicationUpdate.getUrl()); validateApplicationUrl(applicationUpdate.getUrl());
@ -566,20 +562,19 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) throws OperationManagementException { public Activity uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (applicationUninstallationBeanWrapper == null || if (applicationUninstallationBeanWrapper == null ||
applicationUninstallationBeanWrapper.getOperation() == null) { applicationUninstallationBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the application uninstalling operation is incorrect"; String errorMessage = "The payload of the application uninstalling operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation(); ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation();
validateApplicationType(applicationUninstallation.getType()); validateApplicationType(applicationUninstallation.getType());
@ -593,19 +588,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity blacklistApplications(BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) throws OperationManagementException { public Activity blacklistApplications(BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) { if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the blacklisting apps operation is incorrect"; String errorMessage = "The payload of the blacklisting apps operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation(); BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -617,19 +611,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) throws OperationManagementException { public Activity upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) { if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the upgrade firmware operation is incorrect"; String errorMessage = "The payload of the upgrade firmware operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation(); UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation();
validateScheduleDate(upgradeFirmware.getSchedule()); validateScheduleDate(upgradeFirmware.getSchedule());
@ -643,19 +636,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity configureVPN(VpnBeanWrapper vpnConfiguration) throws OperationManagementException { public Activity configureVPN(VpnBeanWrapper vpnConfiguration)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) { if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) {
String errorMessage = "The payload of the VPN operation is incorrect"; String errorMessage = "The payload of the VPN operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
Vpn vpn = vpnConfiguration.getOperation(); Vpn vpn = vpnConfiguration.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -666,19 +658,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity sendNotification(NotificationBeanWrapper notificationBeanWrapper) throws OperationManagementException { public Activity sendNotification(NotificationBeanWrapper notificationBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException{
try { try {
if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) { if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the notification operation is incorrect"; String errorMessage = "The payload of the notification operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
Notification notification = notificationBeanWrapper.getOperation(); Notification notification = notificationBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -689,19 +680,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity configureWifi(WifiBeanWrapper wifiBeanWrapper) throws OperationManagementException { public Activity configureWifi(WifiBeanWrapper wifiBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) { if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the wifi operation is incorrect"; String errorMessage = "The payload of the wifi operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
Wifi wifi = wifiBeanWrapper.getOperation(); Wifi wifi = wifiBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -713,19 +703,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) throws OperationManagementException { public Activity encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException{
try { try {
if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) { if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the device encryption operation is incorrect"; String errorMessage = "The payload of the device encryption operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation(); DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation();
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
@ -736,19 +725,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) throws OperationManagementException { public Activity changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) { if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the change lock code operation is incorrect"; String errorMessage = "The payload of the change lock code operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
LockCode lockCode = lockCodeBeanWrapper.getOperation(); LockCode lockCode = lockCodeBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -759,19 +747,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) throws OperationManagementException { public Activity setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) { if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the change password policy operation is incorrect"; String errorMessage = "The payload of the change password policy operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation(); PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -784,20 +771,19 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity setWebClip(WebClipBeanWrapper webClipBeanWrapper) throws OperationManagementException { public Activity setWebClip(WebClipBeanWrapper webClipBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) { if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the add webclip operation is incorrect"; String errorMessage = "The payload of the add webclip operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
WebClip webClip = webClipBeanWrapper.getOperation(); WebClip webClip = webClipBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -809,19 +795,18 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper) throws OperationManagementException { public Activity setRecommendedGlobalProxy(GlobalProxyBeanWrapper globalProxyBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (globalProxyBeanWrapper == null || globalProxyBeanWrapper.getOperation() == null) { if (globalProxyBeanWrapper == null || globalProxyBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the global proxy operation is incorrect"; String errorMessage = "The payload of the global proxy operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build());
} }
GlobalProxy globalProxy = globalProxyBeanWrapper.getOperation(); GlobalProxy globalProxy = globalProxyBeanWrapper.getOperation();
@ -836,27 +821,62 @@ public class AndroidServiceImpl implements AndroidService {
} else { } else {
String errorMessage = "The payload of the global proxy operation is incorrect"; String errorMessage = "The payload of the global proxy operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build());
} }
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage(errorMessage).build()); }
}
@Override
public Response sendApplicationConfiguration(ApplicationRestrictionBeanWrapper applicationRestrictionBeanWrapper)
throws AndroidDeviceMgtPluginException {
try {
if (applicationRestrictionBeanWrapper == null || applicationRestrictionBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the application configuration operation is incorrect";
log.error(errorMessage);
throw new BadRequestExceptionDup(errorMessage);
}
ApplicationRestriction applicationRestriction = applicationRestrictionBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.REMOTE_APP_CONFIG);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(applicationRestriction.toJSON());
Response response = AndroidAPIUtils.getOperationResponse(applicationRestrictionBeanWrapper.getDeviceIDs(),
operation);
return response;
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestExceptionDup(errorMessage, e);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build());
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
log.error(errorMessage, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
.setMessage(errorMessage).build());
} }
} }
@Override @Override
public Activity configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) throws OperationManagementException { public Activity configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException {
try { try {
if (displayMessageBeanWrapper == null || displayMessageBeanWrapper.getOperation() == null) { if (displayMessageBeanWrapper == null || displayMessageBeanWrapper.getOperation() == null) {
String errorMessage = "The payload of the display message operation is incorrect"; String errorMessage = "The payload of the display message operation is incorrect";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).
setMessage(errorMessage).build());
} }
DisplayMessage configureDisplayMessage = displayMessageBeanWrapper.getOperation(); DisplayMessage configureDisplayMessage = displayMessageBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
@ -870,9 +890,7 @@ public class AndroidServiceImpl implements AndroidService {
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found."; String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e); log.error(errorMessage, e);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage, e);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).
setMessage(errorMessage).build());
} }
} }
@ -1107,7 +1125,8 @@ public class AndroidServiceImpl implements AndroidService {
} }
@Override @Override
public boolean modifyEnrollment(String id, AndroidDevice androidDevice) throws DeviceManagementException { public boolean modifyEnrollment(String id, AndroidDevice androidDevice)
throws DeviceManagementException, AndroidDeviceMgtPluginException {
Device device; Device device;
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(id); deviceIdentifier.setId(id);
@ -1125,8 +1144,7 @@ public class AndroidServiceImpl implements AndroidService {
if (androidDevice == null) { if (androidDevice == null) {
String errorMessage = "The payload of the android device enrollment is incorrect."; String errorMessage = "The payload of the android device enrollment is incorrect.";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestExceptionDup(errorMessage);
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
if (device == null) { if (device == null) {
String errorMessage = "The device to be modified doesn't exist."; String errorMessage = "The device to be modified doesn't exist.";
@ -1192,7 +1210,7 @@ public class AndroidServiceImpl implements AndroidService {
long from, long from,
long to, long to,
String type, String type,
String ifModifiedSince) { String ifModifiedSince) throws AndroidDeviceMgtPluginException {
if (from != 0l && to != 0l && deviceId != null){ if (from != 0l && to != 0l && deviceId != null){
return retrieveAlertFromDate(deviceId, from, to); return retrieveAlertFromDate(deviceId, from, to);
} else if (deviceId != null && type != null) { } else if (deviceId != null && type != null) {
@ -1200,10 +1218,11 @@ public class AndroidServiceImpl implements AndroidService {
} else if (deviceId != null) { } else if (deviceId != null) {
return retrieveAlert(deviceId); return retrieveAlert(deviceId);
} else { } else {
throw new BadRequestException( String errorMessage = "Request must contain " +
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request must contain " +
"the device identifier. Optionally, both from and to value should be present to get " + "the device identifier. Optionally, both from and to value should be present to get " +
"alerts between times.").build()); "alerts between times.";
log.error(errorMessage);
throw new BadRequestExceptionDup(errorMessage);
} }
} }

Loading…
Cancel
Save