|
|
@ -896,49 +896,50 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ApplicationRelease getApplicationReleaseByUUID(String uuid) throws ApplicationManagementException{
|
|
|
|
public Application getApplicationByUuid(String uuid) throws ApplicationManagementException{
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
boolean isVisibleAppRelease = false;
|
|
|
|
boolean isVisibleApp = false;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO.getReleaseByUUID(uuid, tenantId);
|
|
|
|
ApplicationDTO applicationDTO = applicationDAO.getApplicationByUUID(uuid, tenantId);
|
|
|
|
if (applicationReleaseDTO == null) {
|
|
|
|
|
|
|
|
String msg = "Couldn't find an application release for the UUID: " + uuid;
|
|
|
|
if (applicationDTO == null) {
|
|
|
|
|
|
|
|
String msg = "Couldn't found an application for application release UUID: " + uuid;
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new NotFoundException(msg);
|
|
|
|
throw new NotFoundException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (applicationReleaseDTO.getCurrentState().equals(lifecycleStateManager.getEndState())) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> unrestrictedRoles = this.visibilityDAO.getUnrestrictedRolesByUUID(uuid, tenantId);
|
|
|
|
List<String> tags = this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
List<String> categories = this.applicationDAO.getAppCategories(applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
applicationDTO.setTags(tags);
|
|
|
|
|
|
|
|
applicationDTO.setAppCategories(categories);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> unrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId);
|
|
|
|
if (!unrestrictedRoles.isEmpty()) {
|
|
|
|
if (!unrestrictedRoles.isEmpty()) {
|
|
|
|
if (hasUserRole(unrestrictedRoles, userName)) {
|
|
|
|
if (hasUserRole(unrestrictedRoles, userName)) {
|
|
|
|
isVisibleAppRelease = true;
|
|
|
|
isVisibleApp = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
isVisibleAppRelease = true;
|
|
|
|
isVisibleApp = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!isVisibleAppRelease) {
|
|
|
|
if (!isVisibleApp) {
|
|
|
|
String msg = "You are trying to access release of visibility restricted application. You don't have "
|
|
|
|
String msg = "You are trying to access visibility restricted application. You don't have required "
|
|
|
|
+ "required roles to view this application,";
|
|
|
|
+ "roles to view this application,";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ForbiddenException(msg);
|
|
|
|
throw new ForbiddenException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return APIUtil.releaseDtoToRelease(applicationReleaseDTO);
|
|
|
|
return APIUtil.appDtoToAppResponse(applicationDTO);
|
|
|
|
} catch (LifecycleManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred when getting the end state of the application lifecycle flow";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "User-store exception while getting application with the application release UUID: " + uuid;
|
|
|
|
String msg = "User-store exception occurred while getting application for application release UUID " + uuid;
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
//todo
|
|
|
|
String msg = "Error occurred while getting dta which are related to Application.";
|
|
|
|
throw new ApplicationManagementException("");
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(msg);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|