|
|
|
@ -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.dto.AndroidEnterpriseManagedConfig;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.dto.AndroidEnterpriseUser;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.EnterpriseServiceException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.common.exception.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.AndroidDeviceUtils;
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidEnterpriseUtils;
|
|
|
|
@ -117,11 +120,24 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
} catch (EnterpriseServiceException e) {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String insertUser(EnterpriseUser enterpriseUser) throws EnterpriseServiceException {
|
|
|
|
|
public String insertUser(EnterpriseUser enterpriseUser)
|
|
|
|
|
throws EnterpriseServiceException, AndroidDeviceMgtPluginException {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
String token;
|
|
|
|
|
boolean deviceIdExist = false;
|
|
|
|
@ -171,9 +187,9 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
public Response updateUser(EnterpriseInstallPolicy device) {
|
|
|
|
|
|
|
|
|
|
boolean sentToDevice = false;
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
List<AndroidEnterpriseUser> enterpriseUserInstances = AndroidAPIUtils.getAndroidPluginService()
|
|
|
|
|
.getEnterpriseUser(device.getUsername());
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
@ -193,6 +209,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND)
|
|
|
|
|
.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) {
|
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
@ -213,8 +241,9 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
@QueryParam("isOrganizeAppPageVisible") boolean isOrganizeAppPageVisible,
|
|
|
|
|
@QueryParam("isManagedConfigEnabled") boolean isManagedConfigEnabled,
|
|
|
|
|
@QueryParam("host") String host) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
EnterpriseTokenUrl enterpriseTokenUrl = new EnterpriseTokenUrl();
|
|
|
|
|
if (enterpriseConfigs == null || enterpriseConfigs.getEnterpriseId() == null) {
|
|
|
|
@ -229,7 +258,7 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
enterpriseTokenUrl.setOrganizeAppPageVisible(isOrganizeAppPageVisible);
|
|
|
|
|
enterpriseTokenUrl.setParentHost(host);
|
|
|
|
|
enterpriseTokenUrl.setManagedConfigEnabled(isManagedConfigEnabled);
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
String token = googleAPIInvoker.getAdministratorWebToken(enterpriseTokenUrl);
|
|
|
|
|
TokenWrapper tokenWrapper = new TokenWrapper();
|
|
|
|
|
tokenWrapper.setToken(token);
|
|
|
|
@ -238,6 +267,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when calling get web token").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
|
|
|
|
|
@Path("/products/sync")
|
|
|
|
|
public Response syncApps() {
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
ProductsListResponse productsListResponse = googleAPIInvoker
|
|
|
|
|
.listProduct(enterpriseConfigs.getEnterpriseId(), null);
|
|
|
|
|
AndroidEnterpriseUtils.persistApp(productsListResponse);
|
|
|
|
@ -265,6 +307,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when persisting app").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())
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.insertPage(enterpriseConfigs.getEnterpriseId(), page);
|
|
|
|
|
page.setPageId(id);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(page).build();
|
|
|
|
@ -312,6 +367,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting page "
|
|
|
|
|
+ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.updatePage(enterpriseConfigs.getEnterpriseId(), page);
|
|
|
|
|
page.setPageId(id);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(page).build();
|
|
|
|
@ -339,6 +407,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page "
|
|
|
|
|
+ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
googleAPIInvoker.deletePage(enterpriseConfigs.getEnterpriseId(), id);
|
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -366,6 +447,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating page "
|
|
|
|
|
+ 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")
|
|
|
|
|
@Override
|
|
|
|
|
public Response getPages() {
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
StoreLayoutPagesListResponse pages = googleAPIInvoker.listPages(enterpriseConfigs.getEnterpriseId());
|
|
|
|
|
return Response.status(Response.Status.OK).entity(pages).build();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -386,6 +480,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page "
|
|
|
|
|
+ " , 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())
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
StoreLayout layout = googleAPIInvoker.setStoreLayout(enterpriseConfigs.getEnterpriseId(), id);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(layout).build();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -412,6 +519,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when inserting home page "
|
|
|
|
|
+ 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")
|
|
|
|
|
@Override
|
|
|
|
|
public Response getHome() {
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
StoreLayout layout = googleAPIInvoker.getStoreLayout(enterpriseConfigs.getEnterpriseId());
|
|
|
|
|
return Response.status(Response.Status.OK).entity(layout).build();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -431,6 +551,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching home page.").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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.insertCluster(enterpriseConfigs.getEnterpriseId(), storeCluster);
|
|
|
|
|
storeCluster.setClusterId(id);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(storeCluster).build();
|
|
|
|
@ -467,6 +600,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster "
|
|
|
|
|
+ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
String id = googleAPIInvoker.updateCluster(enterpriseConfigs.getEnterpriseId(), storeCluster);
|
|
|
|
|
storeCluster.setClusterId(id);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(storeCluster).build();
|
|
|
|
@ -503,6 +649,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when updating cluster "
|
|
|
|
|
+ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
googleAPIInvoker.deleteCluster(enterpriseConfigs.getEnterpriseId(), pageId, clusterId);
|
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -532,6 +691,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when deleting cluster "
|
|
|
|
|
+ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
StoreLayoutClustersListResponse response = googleAPIInvoker.getClusters(enterpriseConfigs.getEnterpriseId(), pageId);
|
|
|
|
|
if (response == null || response.getCluster() == null) {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
@ -601,6 +773,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching all details in PageId "
|
|
|
|
|
+ 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")
|
|
|
|
|
@Override
|
|
|
|
|
public Response updateLinks(EnterpriseStorePageLinks link) {
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
googleAPIInvoker.addLinks(enterpriseConfigs.getEnterpriseId(),
|
|
|
|
|
link.getPageId(), link.getLinks());
|
|
|
|
|
return Response.status(Response.Status.OK).build();
|
|
|
|
@ -622,6 +807,18 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage("Error when fetching page "
|
|
|
|
|
+ " , 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) {
|
|
|
|
|
|
|
|
|
|
boolean sentToDevice = false;
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (DeviceIdentifier deviceIdentifier : applicationPolicyDTO.getDeviceIdentifierList()) {
|
|
|
|
|
try {
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
GoogleAPIInvoker googleAPIInvoker = new GoogleAPIInvoker(enterpriseConfigs.getEsa());
|
|
|
|
|
|
|
|
|
|
AndroidEnterpriseUser userDetail = AndroidAPIUtils.getAndroidPluginService()
|
|
|
|
|
.getEnterpriseUserByDevice(deviceIdentifier.getId());
|
|
|
|
@ -791,7 +989,20 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
log.error(errorMessage);
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
|
|
|
|
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) {
|
|
|
|
@ -809,6 +1020,7 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
@Path("/wipe-device")
|
|
|
|
|
public Response wipeEnterprise() {
|
|
|
|
|
log.warn("Wiping all devices!!!");
|
|
|
|
|
try{
|
|
|
|
|
EnterpriseConfigs enterpriseConfigs = AndroidEnterpriseUtils.getEnterpriseConfigs();
|
|
|
|
|
try {
|
|
|
|
|
// Take all enterprise devices in the DB.
|
|
|
|
@ -871,7 +1083,19 @@ public class AndroidEnterpriseAPIImpl implements AndroidEnterpriseAPI {
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|