mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix minor issues in APPM publisher
This commit is contained in:
parent
3c9ba37bfb
commit
9dc885e888
@ -551,12 +551,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
|
|
||||||
|
|
||||||
if (application == null) {
|
if (application == null) {
|
||||||
throw new ApplicationManagementException("Invalid Application");
|
throw new NotFoundException("Couldn't found an application for Application ID: " + applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION) && !application
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION) && !application
|
||||||
.getUnrestrictedRoles().isEmpty() && isRoleExists(application.getUnrestrictedRoles(), userName)) {
|
.getUnrestrictedRoles().isEmpty() && isRoleExists(application.getUnrestrictedRoles(), userName)) {
|
||||||
throw new ApplicationManagementException(
|
throw new ForbiddenException(
|
||||||
"You don't have permission to delete this application. In order to delete an application you "
|
"You don't have permission to delete this application. In order to delete an application you "
|
||||||
+ "need to have required permission. Application ID: " + applicationId);
|
+ "need to have required permission. Application ID: " + applicationId);
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"Can't delete the application release, You have to move the "
|
"Can't delete the application release, You have to move the "
|
||||||
+ "lifecycle state from " + currentState + " to acceptable state");
|
+ "lifecycle state from " + currentState + " to " + nextState);
|
||||||
}
|
}
|
||||||
currentState = nextState;
|
currentState = nextState;
|
||||||
}
|
}
|
||||||
@ -740,7 +740,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
throw new ApplicationManagementDAOException(
|
throw new ApplicationManagementDAOException(
|
||||||
"Error ocured when getting application data or application release data for application id of "
|
"Error ocured when getting application data or application release data for application id of "
|
||||||
+ applicationId + " application release UUID of the " + releaseUuid);
|
+ applicationId + " application release UUID of the " + releaseUuid);
|
||||||
|
|
||||||
} catch (LifeCycleManagementDAOException e) {
|
} catch (LifeCycleManagementDAOException e) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
@ -1123,7 +1122,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
isExistingAppRestricted = true;
|
isExistingAppRestricted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo check whether user is application owner
|
|
||||||
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION) && !(
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION) && !(
|
||||||
isExistingAppRestricted && isRoleExists(existingApplication.getUnrestrictedRoles(), userName))) {
|
isExistingAppRestricted && isRoleExists(existingApplication.getUnrestrictedRoles(), userName))) {
|
||||||
ConnectionManagerUtil.rollbackDBTransaction();
|
ConnectionManagerUtil.rollbackDBTransaction();
|
||||||
|
|||||||
@ -504,6 +504,11 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
+ " and application release UUID " + applicationUUID;
|
+ " and application release UUID " + applicationUUID;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (ForbiddenException e) {
|
||||||
|
String msg = "You don't have require permission to update the application release which has UUID "
|
||||||
|
+ applicationUUID;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
|
||||||
}
|
}
|
||||||
catch (ApplicationManagementException e) {
|
catch (ApplicationManagementException e) {
|
||||||
String msg = "Error while updating the application release of the application with UUID " + applicationUUID;
|
String msg = "Error while updating the application release of the application with UUID " + applicationUUID;
|
||||||
@ -527,14 +532,23 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
applicationStorageManager.deleteAllApplicationReleaseArtifacts(storedLocations);
|
applicationStorageManager.deleteAllApplicationReleaseArtifacts(storedLocations);
|
||||||
String responseMsg = "Successfully deleted the application and application releases: " + applicationId;
|
String responseMsg = "Successfully deleted the application and application releases: " + applicationId;
|
||||||
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg =
|
||||||
|
"Couldn't found application for application id: " + applicationId + " to delete the application";
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (ForbiddenException e) {
|
||||||
|
String msg = "You don't have require permission to delete the application which has ID " + applicationId;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while deleting the application: " + applicationId;
|
String msg = "Error occurred while deleting the application: " + applicationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
} catch (ApplicationStorageManagementException e) {
|
} catch (ApplicationStorageManagementException e) {
|
||||||
String msg = "Error occurred while deleting the application storage: " + applicationId;
|
String msg = "Error occurred while deleting the application storage: " + applicationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,14 +564,25 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
applicationStorageManager.deleteApplicationReleaseArtifacts(storedLocation);
|
applicationStorageManager.deleteApplicationReleaseArtifacts(storedLocation);
|
||||||
String responseMsg = "Successfully deleted the application release of: " + applicationId + "";
|
String responseMsg = "Successfully deleted the application release of: " + applicationId + "";
|
||||||
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
String msg = "Couldn't found application release which is having application id: " + applicationId
|
||||||
|
+ " and application release UUID:" + releaseUuid;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||||
|
} catch (ForbiddenException e) {
|
||||||
|
String msg =
|
||||||
|
"You don't have require permission to delete the application release which has UUID " + releaseUuid
|
||||||
|
+ " and application ID " + applicationId;
|
||||||
|
log.error(msg, e);
|
||||||
|
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
|
||||||
}catch (ApplicationManagementException e) {
|
}catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while deleting the application: " + applicationId;
|
String msg = "Error occurred while deleting the application: " + applicationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
} catch (ApplicationStorageManagementException e) {
|
} catch (ApplicationStorageManagementException e) {
|
||||||
String msg = "Error occurred while deleting the application storage: " + applicationId;
|
String msg = "Error occurred while deleting the application storage: " + applicationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user