|
|
@ -73,6 +73,7 @@ import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
@ -141,8 +142,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
+ userName);
|
|
|
|
+ userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
applicationDTO = addApplicationReleaseArtifacts(appWrapperToAppDTO(applicationWrapper),
|
|
|
|
applicationDTO = appWrapperToAppDTO(applicationWrapper);
|
|
|
|
applicationArtifact);
|
|
|
|
ApplicationReleaseDTO initialApplicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
|
|
|
|
|
|
|
|
applicationDTO.getApplicationReleaseDTOs().clear();
|
|
|
|
|
|
|
|
applicationDTO.getApplicationReleaseDTOs()
|
|
|
|
|
|
|
|
.add(addApplicationReleaseArtifacts(applicationDTO.getType(), applicationDTO.getDeviceTypeName(),
|
|
|
|
|
|
|
|
initialApplicationReleaseDTO, applicationArtifact));
|
|
|
|
} catch (UnexpectedServerErrorException e) {
|
|
|
|
} catch (UnexpectedServerErrorException e) {
|
|
|
|
String msg = "Error occurred when getting Device Type data.";
|
|
|
|
String msg = "Error occurred when getting Device Type data.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
@ -263,7 +268,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
log.debug("Creating a new release. App Id:" + appId);
|
|
|
|
log.debug("Creating a new release. App Id:" + appId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String initialLifecycleState = lifecycleStateManager.getInitialState();
|
|
|
|
String initialLifecycleState = lifecycleStateManager.getInitialState();
|
|
|
|
applicationReleaseDTO = applicationDTO.getApplicationReleases().get(0);
|
|
|
|
applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
|
|
|
|
applicationReleaseDTO.setCurrentState(initialLifecycleState);
|
|
|
|
applicationReleaseDTO.setCurrentState(initialLifecycleState);
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
|
|
|
|
LifecycleStateDTO lifecycleStateDTO = getLifecycleStateInstance(initialLifecycleState,
|
|
|
|
LifecycleStateDTO lifecycleStateDTO = getLifecycleStateInstance(initialLifecycleState,
|
|
|
@ -271,7 +276,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
.addLifecycleState(lifecycleStateDTO, appId, applicationReleaseDTO.getUuid(), tenantId);
|
|
|
|
.addLifecycleState(lifecycleStateDTO, appId, applicationReleaseDTO.getUuid(), tenantId);
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
applicationDTO.setApplicationReleases(applicationReleaseEntities);
|
|
|
|
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
|
|
|
|
application = appDtoToAppResponse(applicationDTO);
|
|
|
|
application = appDtoToAppResponse(applicationDTO);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -318,20 +323,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ApplicationDTO addApplicationReleaseArtifacts(ApplicationDTO applicationDTO,
|
|
|
|
private ApplicationReleaseDTO addApplicationReleaseArtifacts(String applicationType, String deviceType,
|
|
|
|
ApplicationArtifact applicationArtifact) throws ResourceManagementException,
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact)
|
|
|
|
ApplicationManagementException {
|
|
|
|
throws ResourceManagementException, ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager();
|
|
|
|
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager();
|
|
|
|
List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>();
|
|
|
|
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO;
|
|
|
|
|
|
|
|
applicationReleaseDTO = applicationDTO.getApplicationReleases().get(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
applicationReleaseDTO.setUuid(uuid);
|
|
|
|
applicationReleaseDTO.setUuid(uuid);
|
|
|
|
|
|
|
|
|
|
|
|
// The application executable artifacts such as apks are uploaded.
|
|
|
|
// The application executable artifacts such as apks are uploaded.
|
|
|
|
if (ApplicationType.ENTERPRISE.toString().equals(applicationDTO.getType())) {
|
|
|
|
if (ApplicationType.ENTERPRISE.toString().equals(applicationType)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream());
|
|
|
|
byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream());
|
|
|
|
|
|
|
|
|
|
|
@ -339,11 +341,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
|
|
|
|
|
|
|
try (ByteArrayInputStream binary = new ByteArrayInputStream(content)) {
|
|
|
|
try (ByteArrayInputStream binary = new ByteArrayInputStream(content)) {
|
|
|
|
ApplicationInstaller applicationInstaller = applicationStorageManager
|
|
|
|
ApplicationInstaller applicationInstaller = applicationStorageManager
|
|
|
|
.getAppInstallerData(binary, applicationDTO.getDeviceTypeName());
|
|
|
|
.getAppInstallerData(binary, deviceType);
|
|
|
|
String packagename = applicationInstaller.getPackageName();
|
|
|
|
String packagename = applicationInstaller.getPackageName();
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
if (applicationReleaseDAO.isActiveReleaseExisitForPackageName(packagename, tenantId)) {
|
|
|
|
if (applicationReleaseDAO.isActiveReleaseExisitForPackageName(packagename, tenantId,
|
|
|
|
|
|
|
|
lifecycleStateManager.getEndState())) {
|
|
|
|
String msg = "Application release is already exist for the package name: " + packagename +
|
|
|
|
String msg = "Application release is already exist for the package name: " + packagename +
|
|
|
|
". Either you can delete all application releases for package " + packagename + " or "
|
|
|
|
". Either you can delete all application releases for package " + packagename + " or "
|
|
|
|
+ "you can add this app release as an new application release, under the existing "
|
|
|
|
+ "you can add this app release as an new application release, under the existing "
|
|
|
@ -353,10 +356,27 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationReleaseDTO.setVersion(applicationInstaller.getVersion());
|
|
|
|
applicationReleaseDTO.setVersion(applicationInstaller.getVersion());
|
|
|
|
applicationReleaseDTO.setPackageName(packagename);
|
|
|
|
applicationReleaseDTO.setPackageName(packagename);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String md5OfApp = StorageManagementUtil.getMD5(new ByteArrayInputStream(content));
|
|
|
|
|
|
|
|
if (md5OfApp == null) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while md5sum value retrieving process: application UUID "
|
|
|
|
|
|
|
|
+ applicationReleaseDTO.getUuid();
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationStorageManagementException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.applicationReleaseDAO
|
|
|
|
|
|
|
|
.verifyReleaseExistenceByHash(md5OfApp, tenantId)) {
|
|
|
|
|
|
|
|
throw new BadRequestException(
|
|
|
|
|
|
|
|
"Application release exists for the uploaded binary file. Application Type: "
|
|
|
|
|
|
|
|
+ applicationType + " Device Tyep: " + deviceType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applicationReleaseDTO.setAppHashValue(md5OfApp);
|
|
|
|
|
|
|
|
|
|
|
|
try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) {
|
|
|
|
try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) {
|
|
|
|
applicationReleaseDTO = applicationStorageManager
|
|
|
|
applicationReleaseDTO = applicationStorageManager
|
|
|
|
.uploadReleaseArtifact(applicationReleaseDTO, applicationDTO.getType(),
|
|
|
|
.uploadReleaseArtifact(applicationReleaseDTO,applicationType,
|
|
|
|
applicationDTO.getDeviceTypeName(), binaryDuplicate);
|
|
|
|
deviceType, binaryDuplicate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
@ -377,7 +397,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
|
|
|
} else if (ApplicationType.WEB_CLIP.toString().equals(applicationType)) {
|
|
|
|
applicationReleaseDTO.setVersion(Constants.DEFAULT_VERSION);
|
|
|
|
applicationReleaseDTO.setVersion(Constants.DEFAULT_VERSION);
|
|
|
|
applicationReleaseDTO.setInstallerName(applicationReleaseDTO.getUrl());
|
|
|
|
applicationReleaseDTO.setInstallerName(applicationReleaseDTO.getUrl());
|
|
|
|
// Since WEB CLIP doesn't have an installer, set uuid as has value for WEB CLIP
|
|
|
|
// Since WEB CLIP doesn't have an installer, set uuid as has value for WEB CLIP
|
|
|
@ -407,9 +427,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
applicationReleaseDTO = applicationStorageManager
|
|
|
|
applicationReleaseDTO = applicationStorageManager
|
|
|
|
.uploadImageArtifacts(applicationReleaseDTO, applicationArtifact.getIconStream(),
|
|
|
|
.uploadImageArtifacts(applicationReleaseDTO, applicationArtifact.getIconStream(),
|
|
|
|
applicationArtifact.getBannerStream(), new ArrayList<>(screenshots.values()));
|
|
|
|
applicationArtifact.getBannerStream(), new ArrayList<>(screenshots.values()));
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
return applicationReleaseDTO;
|
|
|
|
applicationDTO.setApplicationReleases(applicationReleaseEntities);
|
|
|
|
|
|
|
|
return applicationDTO;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -528,50 +546,36 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override public ApplicationReleaseDTO createRelease(int applicationId, ApplicationReleaseDTO applicationRelease)
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public ApplicationRelease createRelease(int applicationId,
|
|
|
|
|
|
|
|
ApplicationReleaseWrapper applicationReleaseWrapper, ApplicationArtifact applicationArtifact)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
ApplicationRelease applicationRelease;
|
|
|
|
// validateAppReleasePayload(applicationRelease);
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("ApplicationDTO release request is received for the application id: " + applicationId);
|
|
|
|
log.debug("ApplicationDTO release request is received for the application id: " + applicationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ApplicationDTO existingApplication = this.applicationDAO.getApplicationById(applicationId, tenantId);
|
|
|
|
ApplicationDTO applicationDTO = this.applicationDAO.getApplicationById(applicationId, tenantId);
|
|
|
|
if (existingApplication == null) {
|
|
|
|
if (applicationDTO == null) {
|
|
|
|
throw new NotFoundException("Couldn't find application for the application Id: " + applicationId);
|
|
|
|
String msg = "Couldn't find application for the application Id: " + applicationId;
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new NotFoundException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationReleaseDTO applicationReleaseDTO = addApplicationReleaseArtifacts(applicationDTO.getType(),
|
|
|
|
|
|
|
|
applicationDTO.getDeviceTypeName(), releaseWrapperToReleaseDTO(applicationReleaseWrapper),
|
|
|
|
|
|
|
|
applicationArtifact);
|
|
|
|
|
|
|
|
|
|
|
|
// todo check whether admin or app creator.
|
|
|
|
String initialstate = lifecycleStateManager.getInitialState();
|
|
|
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
applicationReleaseDTO.setCurrentState(initialstate);
|
|
|
|
String msg = "You don't have permission to create application release for the application id: "
|
|
|
|
LifecycleStateDTO lifecycleState = getLifecycleStateInstance(initialstate, initialstate);
|
|
|
|
+ applicationId
|
|
|
|
|
|
|
|
+ ". In order to create ann new application realse, you should be either ADMIN user or the application created user.";
|
|
|
|
|
|
|
|
throw new ForbiddenException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!existingApplication.getUnrestrictedRoles().isEmpty() && !isRoleExists(
|
|
|
|
|
|
|
|
existingApplication.getUnrestrictedRoles(), userName)) {
|
|
|
|
|
|
|
|
String msg = "ApplicationDTO is visible to limited roles and those roles are not assigned to " + userName;
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.applicationReleaseDAO
|
|
|
|
|
|
|
|
.verifyReleaseExistenceByHash(applicationId, applicationRelease.getAppHashValue(), tenantId)) {
|
|
|
|
|
|
|
|
throw new BadRequestException("ApplicationDTO release exists for the application Id: " + applicationId
|
|
|
|
|
|
|
|
+ " and uploaded binary file");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String packageName = this.applicationReleaseDAO.getPackageName(applicationId, tenantId);
|
|
|
|
|
|
|
|
if (packageName != null && !packageName.equals(applicationRelease.getPackageName())) {
|
|
|
|
|
|
|
|
throw new BadRequestException(
|
|
|
|
|
|
|
|
"Package name in the payload is different from the existing package name of other application" +
|
|
|
|
|
|
|
|
" releases.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
applicationRelease = this.applicationReleaseDAO
|
|
|
|
|
|
|
|
.createRelease(applicationRelease, existingApplication.getId(), tenantId);
|
|
|
|
|
|
|
|
LifecycleStateDTO lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(),
|
|
|
|
|
|
|
|
AppLifecycleState.CREATED.toString());
|
|
|
|
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), tenantId);
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationReleaseDTO.getUuid(), tenantId);
|
|
|
|
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO
|
|
|
|
|
|
|
|
.createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId);
|
|
|
|
|
|
|
|
applicationRelease = releaseDtoToRelease(applicationReleaseDTO);
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
return applicationRelease;
|
|
|
|
return applicationRelease;
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
@ -592,36 +596,43 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
"Error occurred while adding new application release for application " + applicationId, e);
|
|
|
|
"Error occurred while adding new application release for application " + applicationId, e);
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (ResourceManagementException e) {
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
String msg =
|
|
|
|
"Error occurred whecn checking whether user is admin user or not. ApplicationDTO release: "
|
|
|
|
"Error occurred while uploading application release artifacts. Application ID: " + applicationId;
|
|
|
|
+ applicationId, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override public ApplicationDTO getApplicationById(int appId, String state) throws ApplicationManagementException {
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public ApplicationDTO getApplicationById(int appId, String state) throws ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
ApplicationDTO application;
|
|
|
|
ApplicationDTO application;
|
|
|
|
boolean isAppAllowed = false;
|
|
|
|
boolean isAppAllowed = false;
|
|
|
|
List<ApplicationReleaseDTO> applicationReleases;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
application = this.applicationDAO.getApplicationById(appId, tenantId);
|
|
|
|
application = this.applicationDAO.getApplicationById(appId, tenantId);
|
|
|
|
if (application == null) {
|
|
|
|
if (application == null) {
|
|
|
|
throw new NotFoundException("Couldn't find an application for application Id: " + appId);
|
|
|
|
throw new NotFoundException("Couldn't find an application for application Id: " + appId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> tags = this.applicationDAO.getAppTags(appId, tenantId);
|
|
|
|
|
|
|
|
List<String> categories = this.applicationDAO.getAppCategories(appId, tenantId);
|
|
|
|
|
|
|
|
application.setTags(tags);
|
|
|
|
|
|
|
|
//todo when support to add multiple categories this has to be changed
|
|
|
|
|
|
|
|
if (!categories.isEmpty()){
|
|
|
|
|
|
|
|
application.setAppCategory(categories.get(0));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
applicationReleases = getReleases(application, state);
|
|
|
|
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!application.getUnrestrictedRoles().isEmpty()) {
|
|
|
|
List<String> unrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(appId, tenantId);
|
|
|
|
if (isRoleExists(application.getUnrestrictedRoles(), userName)) {
|
|
|
|
if (!unrestrictedRoles.isEmpty()) {
|
|
|
|
|
|
|
|
if (isRoleExists(unrestrictedRoles, userName)) {
|
|
|
|
isAppAllowed = true;
|
|
|
|
isAppAllowed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -629,10 +640,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!isAppAllowed) {
|
|
|
|
if (!isAppAllowed) {
|
|
|
|
return null;
|
|
|
|
String msg = "You are trying to access visibility restricted application. You don't have required "
|
|
|
|
|
|
|
|
+ "roles to view this application,";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ForbiddenException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationReleases = getReleases(application, state);
|
|
|
|
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
throw new ApplicationManagementException(
|
|
|
@ -657,7 +669,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
applicationReleases = getReleases(application, state);
|
|
|
|
applicationReleases = getReleases(application, state);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleaseDTOs(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -673,7 +685,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationReleases = getReleases(application, state);
|
|
|
|
applicationReleases = getReleases(application, state);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleaseDTOs(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
throw new ApplicationManagementException(
|
|
|
@ -737,7 +749,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
application = this.applicationDAO.getApplication(appName, appType, tenantId);
|
|
|
|
application = this.applicationDAO.getApplication(appName, appType, tenantId);
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
applicationReleases = getReleases(application, null);
|
|
|
|
applicationReleases = getReleases(application, null);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleaseDTOs(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -754,7 +766,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
applicationReleases = getReleases(application, null);
|
|
|
|
applicationReleases = getReleases(application, null);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleaseDTOs(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new ApplicationManagementException(
|
|
|
|
throw new ApplicationManagementException(
|
|
|
@ -1713,6 +1725,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
public void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper,
|
|
|
|
public void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper,
|
|
|
|
String applicationType) throws RequestValidatingException {
|
|
|
|
String applicationType) throws RequestValidatingException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (applicationReleaseWrapper == null){
|
|
|
|
|
|
|
|
String msg = "Application Release shouldn't be null.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new RequestValidatingException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ApplicationType.WEB_CLIP.toString().equals(applicationType)) {
|
|
|
|
if (ApplicationType.WEB_CLIP.toString().equals(applicationType)) {
|
|
|
|
UrlValidator urlValidator = new UrlValidator();
|
|
|
|
UrlValidator urlValidator = new UrlValidator();
|
|
|
|
if (StringUtils
|
|
|
|
if (StringUtils
|
|
|
@ -1784,7 +1802,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
applicationDTO.setDeviceTypeName(deviceType.getName());
|
|
|
|
applicationDTO.setDeviceTypeName(deviceType.getName());
|
|
|
|
List<ApplicationReleaseDTO> applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers()
|
|
|
|
List<ApplicationReleaseDTO> applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers()
|
|
|
|
.stream().map(this::releaseWrapperToReleaseDTO).collect(Collectors.toList());
|
|
|
|
.stream().map(this::releaseWrapperToReleaseDTO).collect(Collectors.toList());
|
|
|
|
applicationDTO.setApplicationReleases(applicationReleaseEntities);
|
|
|
|
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
|
|
|
|
return applicationDTO;
|
|
|
|
return applicationDTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1813,7 +1831,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
application.setTags(applicationDTO.getTags());
|
|
|
|
application.setTags(applicationDTO.getTags());
|
|
|
|
application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles());
|
|
|
|
application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles());
|
|
|
|
application.setDeviceType(applicationDTO.getDeviceTypeName());
|
|
|
|
application.setDeviceType(applicationDTO.getDeviceTypeName());
|
|
|
|
List<ApplicationRelease> applicationReleases = applicationDTO.getApplicationReleases()
|
|
|
|
List<ApplicationRelease> applicationReleases = applicationDTO.getApplicationReleaseDTOs()
|
|
|
|
.stream().map(this::releaseDtoToRelease).collect(Collectors.toList());
|
|
|
|
.stream().map(this::releaseDtoToRelease).collect(Collectors.toList());
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|