|
|
@ -58,7 +58,10 @@ import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EnterpriseU
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.TokenWrapper;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.TokenWrapper;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseManagedConfig;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.NotFoundExceptionDup;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorExceptionDup;
|
|
|
|
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;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidEnterpriseUtils;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidEnterpriseUtils;
|
|
|
@ -117,11 +120,24 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
} catch (EnterpriseServiceException e) {
|
|
|
|
} catch (EnterpriseServiceException e) {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when saving user").build()).build();
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when saving user").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while adding user";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Response.status(Response.Status.OK).entity(token).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(token).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String insertUser(EnterpriseUser enterpriseUser) throws EnterpriseServiceException {
|
|
|
|
public String insertUser(EnterpriseUser enterpriseUser)
|
|
|
|
|
|
|
|
throws EnterpriseServiceException, AndroidDeviceMgtPluginException {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
String token;
|
|
|
|
String token;
|
|
|
|
boolean deviceIdExist = false;
|
|
|
|
boolean deviceIdExist = false;
|
|
|
@ -171,9 +187,9 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
public Response updateUser(EnterpriseInstallPolicy device) {
|
|
|
|
public Response updateUser(EnterpriseInstallPolicy device) {
|
|
|
|
|
|
|
|
|
|
|
|
boolean sentToDevice = false;
|
|
|
|
boolean sentToDevice = false;
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
List<AndroidEnterpriseUser> enterpriseUserInstances = AndroidAPIUtils.getAndroidPluginService()
|
|
|
|
List<AndroidEnterpriseUser> enterpriseUserInstances = AndroidAPIUtils.getAndroidPluginService()
|
|
|
|
.getEnterpriseUser(device.getUsername());
|
|
|
|
.getEnterpriseUser(device.getUsername());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
@ -193,6 +209,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND)
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND)
|
|
|
|
.setMessage(errorMessage).build()).build();
|
|
|
|
.setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while updating user";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sentToDevice) {
|
|
|
|
if (sentToDevice) {
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
@ -213,8 +241,9 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
@QueryParam("isOrganizeAppPageVisible") boolean isOrganizeAppPageVisible,
|
|
|
|
@QueryParam("isOrganizeAppPageVisible") boolean isOrganizeAppPageVisible,
|
|
|
|
@QueryParam("isManagedConfigEnabled") boolean isManagedConfigEnabled,
|
|
|
|
@QueryParam("isManagedConfigEnabled") boolean isManagedConfigEnabled,
|
|
|
|
@QueryParam("host") String host) {
|
|
|
|
@QueryParam("host") String host) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
|
|
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
EnterpriseTokenUrl enterpriseTokenUrl = new EnterpriseTokenUrl();
|
|
|
|
EnterpriseTokenUrl enterpriseTokenUrl = new EnterpriseTokenUrl();
|
|
|
|
if (enterpriseConfigs == null || enterpriseConfigs.getEnterpriseId() == null) {
|
|
|
|
if (enterpriseConfigs == null || enterpriseConfigs.getEnterpriseId() == null) {
|
|
|
@ -229,7 +258,7 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
enterpriseTokenUrl.setOrganizeAppPageVisible(isOrganizeAppPageVisible);
|
|
|
|
enterpriseTokenUrl.setOrganizeAppPageVisible(isOrganizeAppPageVisible);
|
|
|
|
enterpriseTokenUrl.setParentHost(host);
|
|
|
|
enterpriseTokenUrl.setParentHost(host);
|
|
|
|
enterpriseTokenUrl.setManagedConfigEnabled(isManagedConfigEnabled);
|
|
|
|
enterpriseTokenUrl.setManagedConfigEnabled(isManagedConfigEnabled);
|
|
|
|
try {
|
|
|
|
|
|
|
|
String token = googleAPIInvoker.getAdministratorWebToken(enterpriseTokenUrl);
|
|
|
|
String token = googleAPIInvoker.getAdministratorWebToken(enterpriseTokenUrl);
|
|
|
|
TokenWrapper tokenWrapper = new TokenWrapper();
|
|
|
|
TokenWrapper tokenWrapper = new TokenWrapper();
|
|
|
|
tokenWrapper.setToken(token);
|
|
|
|
tokenWrapper.setToken(token);
|
|
|
@ -238,6 +267,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when calling get web token").build())
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when calling get web token").build())
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while getting store url";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -245,9 +286,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
@GET
|
|
|
|
@GET
|
|
|
|
@Path("/products/sync")
|
|
|
|
@Path("/products/sync")
|
|
|
|
public Response syncApps() {
|
|
|
|
public Response syncApps() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
ProductsListResponse productsListResponse = googleAPIInvoker
|
|
|
|
ProductsListResponse productsListResponse = googleAPIInvoker
|
|
|
|
.listProduct(enterpriseConfigs.getEnterpriseId(), null);
|
|
|
|
.listProduct(enterpriseConfigs.getEnterpriseId(), null);
|
|
|
|
AndroidEnterpriseUtils.persistApp(productsListResponse);
|
|
|
|
AndroidEnterpriseUtils.persistApp(productsListResponse);
|
|
|
@ -265,6 +307,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when persisting app").build())
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when persisting app").build())
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while syncing apps";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -298,9 +352,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Message body is empty or incorrect").build())
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Message body is empty or incorrect").build())
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.insertPage(enterpriseConfigs.getEnterpriseId(), page);
|
|
|
|
String id = googleAPIInvoker.insertPage(enterpriseConfigs.getEnterpriseId(), page);
|
|
|
|
page.setPageId(id);
|
|
|
|
page.setPageId(id);
|
|
|
|
return Response.status(Response.Status.OK).entity(page).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(page).build();
|
|
|
@ -312,6 +367,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting page "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting page "
|
|
|
|
+ page.getPageName() + " , due to an error with ESA").build() ).build();
|
|
|
|
+ page.getPageName() + " , due to an error with ESA").build() ).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while adding page";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -325,9 +392,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.updatePage(enterpriseConfigs.getEnterpriseId(), page);
|
|
|
|
String id = googleAPIInvoker.updatePage(enterpriseConfigs.getEnterpriseId(), page);
|
|
|
|
page.setPageId(id);
|
|
|
|
page.setPageId(id);
|
|
|
|
return Response.status(Response.Status.OK).entity(page).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(page).build();
|
|
|
@ -339,6 +407,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page "
|
|
|
|
+ page.getPageName() + " , due to an error with ESA").build()).build();
|
|
|
|
+ page.getPageName() + " , due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while updating page";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -353,9 +433,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
googleAPIInvoker.deletePage(enterpriseConfigs.getEnterpriseId(), id);
|
|
|
|
googleAPIInvoker.deletePage(enterpriseConfigs.getEnterpriseId(), id);
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -366,6 +447,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page "
|
|
|
|
+ id + " , Due to an error with ESA").build()).build();
|
|
|
|
+ id + " , Due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while deleting page";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -373,9 +466,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
@Path("/store-layout/page")
|
|
|
|
@Path("/store-layout/page")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Response getPages() {
|
|
|
|
public Response getPages() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
StoreLayoutPagesListResponse pages = googleAPIInvoker.listPages(enterpriseConfigs.getEnterpriseId());
|
|
|
|
StoreLayoutPagesListResponse pages = googleAPIInvoker.listPages(enterpriseConfigs.getEnterpriseId());
|
|
|
|
return Response.status(Response.Status.OK).entity(pages).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(pages).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -386,6 +480,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page "
|
|
|
|
+ " , Due to an error with ESA").build()).build();
|
|
|
|
+ " , Due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while getting pages";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -399,9 +505,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Id cannot be empty").build())
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Id cannot be empty").build())
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
StoreLayout layout = googleAPIInvoker.setStoreLayout(enterpriseConfigs.getEnterpriseId(), id);
|
|
|
|
StoreLayout layout = googleAPIInvoker.setStoreLayout(enterpriseConfigs.getEnterpriseId(), id);
|
|
|
|
return Response.status(Response.Status.OK).entity(layout).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(layout).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -412,6 +519,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting home page "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting home page "
|
|
|
|
+ id + " , due to an error with ESA").build() ).build();
|
|
|
|
+ id + " , due to an error with ESA").build() ).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while setting home";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -419,9 +538,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
@Path("/store-layout/home-page")
|
|
|
|
@Path("/store-layout/home-page")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Response getHome() {
|
|
|
|
public Response getHome() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
StoreLayout layout = googleAPIInvoker.getStoreLayout(enterpriseConfigs.getEnterpriseId());
|
|
|
|
StoreLayout layout = googleAPIInvoker.getStoreLayout(enterpriseConfigs.getEnterpriseId());
|
|
|
|
return Response.status(Response.Status.OK).entity(layout).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(layout).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -431,6 +551,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching home page.").build() )
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching home page.").build() )
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while getting home";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -453,9 +585,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Cluster order cannot be empty").build()).build();
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Cluster order cannot be empty").build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.insertCluster(enterpriseConfigs.getEnterpriseId(), storeCluster);
|
|
|
|
String id = googleAPIInvoker.insertCluster(enterpriseConfigs.getEnterpriseId(), storeCluster);
|
|
|
|
storeCluster.setClusterId(id);
|
|
|
|
storeCluster.setClusterId(id);
|
|
|
|
return Response.status(Response.Status.OK).entity(storeCluster).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(storeCluster).build();
|
|
|
@ -467,6 +600,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster "
|
|
|
|
+ storeCluster.getName() + " , due to an error with ESA").build()).build();
|
|
|
|
+ storeCluster.getName() + " , due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while adding cluster";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -489,9 +634,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Cluster order cannot be empty").build()).build();
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Cluster order cannot be empty").build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.updateCluster(enterpriseConfigs.getEnterpriseId(), storeCluster);
|
|
|
|
String id = googleAPIInvoker.updateCluster(enterpriseConfigs.getEnterpriseId(), storeCluster);
|
|
|
|
storeCluster.setClusterId(id);
|
|
|
|
storeCluster.setClusterId(id);
|
|
|
|
return Response.status(Response.Status.OK).entity(storeCluster).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(storeCluster).build();
|
|
|
@ -503,6 +649,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster "
|
|
|
|
+ storeCluster.getName() + " , due to an error with ESA").build()).build();
|
|
|
|
+ storeCluster.getName() + " , due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while updating cluster";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -519,9 +677,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Page id cannot be empty").build()).build();
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Page id cannot be empty").build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
googleAPIInvoker.deleteCluster(enterpriseConfigs.getEnterpriseId(), pageId, clusterId);
|
|
|
|
googleAPIInvoker.deleteCluster(enterpriseConfigs.getEnterpriseId(), pageId, clusterId);
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -532,6 +691,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when deleting cluster "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when deleting cluster "
|
|
|
|
+ clusterId + " , due to an error with ESA").build()).build();
|
|
|
|
+ clusterId + " , due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while deleting cluster";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -544,9 +715,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Page id cannot be empty").build()).build();
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Page id cannot be empty").build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
StoreLayoutClustersListResponse response = googleAPIInvoker.getClusters(enterpriseConfigs.getEnterpriseId(), pageId);
|
|
|
|
StoreLayoutClustersListResponse response = googleAPIInvoker.getClusters(enterpriseConfigs.getEnterpriseId(), pageId);
|
|
|
|
if (response == null || response.getCluster() == null) {
|
|
|
|
if (response == null || response.getCluster() == null) {
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
@ -601,6 +773,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching all details in PageId "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching all details in PageId "
|
|
|
|
+ pageId).build()).build();
|
|
|
|
+ pageId).build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while getting clusters in page";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -608,9 +792,10 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
@Path("/store-layout/page-link")
|
|
|
|
@Path("/store-layout/page-link")
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Response updateLinks(EnterpriseStorePageLinks link) {
|
|
|
|
public Response updateLinks(EnterpriseStorePageLinks link) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
try {
|
|
|
|
|
|
|
|
googleAPIInvoker.addLinks(enterpriseConfigs.getEnterpriseId(),
|
|
|
|
googleAPIInvoker.addLinks(enterpriseConfigs.getEnterpriseId(),
|
|
|
|
link.getPageId(), link.getLinks());
|
|
|
|
link.getPageId(), link.getLinks());
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
@ -622,6 +807,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page "
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page "
|
|
|
|
+ " , Due to an error with ESA").build()).build();
|
|
|
|
+ " , Due to an error with ESA").build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while updating links";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -725,11 +922,12 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
public Response updateUser(ApplicationPolicyDTO applicationPolicyDTO) {
|
|
|
|
public Response updateUser(ApplicationPolicyDTO applicationPolicyDTO) {
|
|
|
|
|
|
|
|
|
|
|
|
boolean sentToDevice = false;
|
|
|
|
boolean sentToDevice = false;
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (DeviceIdentifier deviceIdentifier : applicationPolicyDTO.getDeviceIdentifierList()) {
|
|
|
|
for (DeviceIdentifier deviceIdentifier : applicationPolicyDTO.getDeviceIdentifierList()) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
|
|
|
|
|
|
|
AndroidEnterpriseUser userDetail = AndroidAPIUtils.getAndroidPluginService()
|
|
|
|
AndroidEnterpriseUser userDetail = AndroidAPIUtils.getAndroidPluginService()
|
|
|
|
.getEnterpriseUserByDevice(deviceIdentifier.getId());
|
|
|
|
.getEnterpriseUserByDevice(deviceIdentifier.getId());
|
|
|
@ -791,7 +989,20 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
log.error(errorMessage);
|
|
|
|
log.error(errorMessage);
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND)
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND)
|
|
|
|
.setMessage(errorMessage).build()).build(); }
|
|
|
|
.setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while updating user";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sentToDevice) {
|
|
|
|
if (sentToDevice) {
|
|
|
@ -809,6 +1020,7 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
@Path("/wipe-device")
|
|
|
|
@Path("/wipe-device")
|
|
|
|
public Response wipeEnterprise() {
|
|
|
|
public Response wipeEnterprise() {
|
|
|
|
log.warn("Wiping all devices!!!");
|
|
|
|
log.warn("Wiping all devices!!!");
|
|
|
|
|
|
|
|
try{
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Take all enterprise devices in the DB.
|
|
|
|
// Take all enterprise devices in the DB.
|
|
|
@ -871,7 +1083,19 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
return Response.serverError().entity(
|
|
|
|
return Response.serverError().entity(
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (NotFoundExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Not found";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (UnexpectedServerErrorExceptionDup e) {
|
|
|
|
|
|
|
|
String errorMessage = "Unexpected server error";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
} catch (AndroidDeviceMgtPluginException e) {
|
|
|
|
|
|
|
|
String errorMessage = "Error occured while executing wipe enterprice command";
|
|
|
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|