mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Add tenant application artifact deletion configuration
Fix code errors Remove spaces Refactor code
This commit is contained in:
parent
c51b3c49fa
commit
8e33eebbf6
@ -547,4 +547,5 @@ public interface ApplicationManager {
|
||||
*/
|
||||
void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException;
|
||||
void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException;
|
||||
void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException;
|
||||
}
|
||||
|
||||
@ -4424,7 +4424,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId);
|
||||
spApplicationDAO.deleteIdentityServerByTenant(tenantId);
|
||||
applicationDAO.deleteApplicationsByTenant(tenantId);
|
||||
APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
|
||||
|
||||
ConnectionManagerUtil.commitDBTransaction();
|
||||
} catch (DBConnectionException e) {
|
||||
@ -4449,12 +4448,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
+ " of tenant ID: " + tenantId ;
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} catch (ApplicationStorageManagementException e) {
|
||||
ConnectionManagerUtil.rollbackDBTransaction();
|
||||
String msg = "Error occurred while deleting App folder of tenant"
|
||||
+ " of tenant ID: " + tenantId ;
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} finally {
|
||||
ConnectionManagerUtil.closeDBConnection();
|
||||
}
|
||||
@ -4499,7 +4492,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId);
|
||||
spApplicationDAO.deleteIdentityServerByTenant(tenantId);
|
||||
applicationDAO.deleteApplicationsByTenant(tenantId);
|
||||
APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
|
||||
|
||||
ConnectionManagerUtil.commitDBTransaction();
|
||||
} catch (DBConnectionException e) {
|
||||
@ -4524,15 +4516,32 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
||||
+ " of tenant ID: " + tenantId ;
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} catch (ApplicationStorageManagementException e) {
|
||||
ConnectionManagerUtil.rollbackDBTransaction();
|
||||
String msg = "Error occurred while deleting App folder of tenant"
|
||||
+ " of tenant ID: " + tenantId ;
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} finally {
|
||||
ConnectionManagerUtil.closeDBConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException {
|
||||
int tenantId;
|
||||
try{
|
||||
TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService();
|
||||
TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain);
|
||||
tenantId = tenantInfoBean.getTenantId();
|
||||
|
||||
} catch (Exception e) {
|
||||
String msg = "Error getting tenant ID from domain: "
|
||||
+ tenantDomain + "when trying to delete application artifacts of tenant";
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
}
|
||||
try {
|
||||
APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
|
||||
} catch (ApplicationStorageManagementException e) {
|
||||
String msg = "Error occurred while deleting Application folders of tenant"
|
||||
+ " of tenant ID: " + tenantId ;
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,8 +298,13 @@ public interface UserManagementAdminService {
|
||||
name = "tenantDomain",
|
||||
value = "The domain of the tenant to be deleted.",
|
||||
required = true)
|
||||
|
||||
@PathParam("tenantDomain")
|
||||
String tenantDomain);
|
||||
|
||||
String tenantDomain,
|
||||
@ApiParam(
|
||||
name = "deleteAppArtifacts",
|
||||
value = "Flag to indicate whether to delete application artifacts.",
|
||||
required = false)
|
||||
@QueryParam("deleteAppArtifacts")
|
||||
@DefaultValue("false")
|
||||
boolean deleteAppArtifacts);
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic
|
||||
@DELETE
|
||||
@Path("/domain/{tenantDomain}")
|
||||
@Override
|
||||
public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain) {
|
||||
public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain, @QueryParam("deleteAppArtifacts") boolean deleteAppArtifacts) {
|
||||
try {
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
if (tenantId != MultitenantConstants.SUPER_TENANT_ID){
|
||||
@ -99,6 +99,9 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic
|
||||
log.error(msg);
|
||||
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
|
||||
} else {
|
||||
if(deleteAppArtifacts){
|
||||
DeviceMgtAPIUtils.getApplicationManager().deleteApplicationArtifactsByTenantDomain(tenantDomain);
|
||||
}
|
||||
DeviceMgtAPIUtils.getApplicationManager().deleteApplicationDataByTenantDomain(tenantDomain);
|
||||
DeviceMgtAPIUtils.getDeviceManagementService().deleteDeviceDataByTenantDomain(tenantDomain);
|
||||
TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user