|
|
|
@ -18,11 +18,16 @@
|
|
|
|
|
|
|
|
|
|
package io.entgra.device.mgt.core.application.mgt.core.impl;
|
|
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.exception.FileDownloaderServiceException;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.exception.FileTransferServiceException;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.*;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.exception.*;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Base64File;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata;
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
@ -75,11 +80,6 @@ import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.LifecycleStateDAO;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.VisibilityDAO;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException;
|
|
|
|
@ -95,6 +95,8 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementEx
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
|
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
|
|
|
|
|
import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService;
|
|
|
|
|
import org.wso2.carbon.user.api.UserRealm;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
|
|
|
|
@ -102,6 +104,8 @@ import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
@ -127,6 +131,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
private SubscriptionDAO subscriptionDAO;
|
|
|
|
|
private LifecycleStateManager lifecycleStateManager;
|
|
|
|
|
private SPApplicationDAO spApplicationDAO;
|
|
|
|
|
private VppApplicationDAO vppApplicationDAO;
|
|
|
|
|
private ReviewDAO reviewDAO;
|
|
|
|
|
|
|
|
|
|
public ApplicationManagerImpl() {
|
|
|
|
|
initDataAccessObjects();
|
|
|
|
@ -140,10 +146,61 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
this.applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
|
|
|
|
|
this.subscriptionDAO = ApplicationManagementDAOFactory.getSubscriptionDAO();
|
|
|
|
|
this.spApplicationDAO = ApplicationManagementDAOFactory.getSPApplicationDAO();
|
|
|
|
|
this.vppApplicationDAO = ApplicationManagementDAOFactory.getVppApplicationDAO();
|
|
|
|
|
this.reviewDAO = ApplicationManagementDAOFactory.getCommentDAO();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public <T> Application createApplication(T app, boolean isPublished) throws ApplicationManagementException {
|
|
|
|
|
return createApplicationBasedOnRemoteStatus(app, isPublished);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the application based on the release wrapper's remote status. If the remote status is true, then
|
|
|
|
|
* the application creation will take place asynchronously.
|
|
|
|
|
* @param app Application release wrapper
|
|
|
|
|
* @param isPublished Publish status
|
|
|
|
|
* @return {@link Application}
|
|
|
|
|
* @throws ApplicationManagementException Throws when error occurred while application creation
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private <T> Application createApplicationBasedOnRemoteStatus(T app, boolean isPublished) throws ApplicationManagementException {
|
|
|
|
|
if (ApplicationManagementUtil.getRemoteStatus(app)) {
|
|
|
|
|
List<?> releaseWrappers = ApplicationManagementUtil.deriveApplicationWithoutRelease(app);
|
|
|
|
|
Application createdApplication = triggerApplicationCreation(app, isPublished);
|
|
|
|
|
if (createdApplication == null) {
|
|
|
|
|
throw new ApplicationManagementException("Null retrieved for created application.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
if (releaseWrappers != null && !releaseWrappers.isEmpty()) {
|
|
|
|
|
if (app instanceof ApplicationWrapper) {
|
|
|
|
|
((ApplicationWrapper) app).setEntAppReleaseWrappers((List<EntAppReleaseWrapper>) releaseWrappers);
|
|
|
|
|
createApplicationReleaseBasedOnRemoteStatus(createdApplication.getId(),
|
|
|
|
|
((ApplicationWrapper) app).getEntAppReleaseWrappers().get(0), isPublished);
|
|
|
|
|
} else if (app instanceof CustomAppWrapper) {
|
|
|
|
|
((CustomAppWrapper) app).setCustomAppReleaseWrappers((List<CustomAppReleaseWrapper>) releaseWrappers);
|
|
|
|
|
createApplicationReleaseBasedOnRemoteStatus(createdApplication.getId(),
|
|
|
|
|
((CustomAppWrapper) app).getCustomAppReleaseWrappers().get(0), isPublished);
|
|
|
|
|
} else {
|
|
|
|
|
throw new ApplicationManagementException("Unsupported release wrapper received");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return createdApplication;
|
|
|
|
|
} catch (ResourceManagementException e) {
|
|
|
|
|
throw new ApplicationManagementException("Error encountered while creating deploying artifact", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return triggerApplicationCreation(app, isPublished);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Trigger the application creation process
|
|
|
|
|
* @param app Application release wrapper
|
|
|
|
|
* @param isPublished Publish status
|
|
|
|
|
* @return {@link Application}
|
|
|
|
|
* @throws ApplicationManagementException Throws when error occurred while creating the application
|
|
|
|
|
*/
|
|
|
|
|
private <T> Application triggerApplicationCreation(T app, boolean isPublished) throws ApplicationManagementException {
|
|
|
|
|
ApplicationDTO applicationDTO = uploadReleaseArtifactIfExist(app);
|
|
|
|
|
try {
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
@ -171,22 +228,110 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create application release based on remote status. If the remote status is true, then the
|
|
|
|
|
* application release creation will take place asynchronously.
|
|
|
|
|
* @param appId Application id
|
|
|
|
|
* @param releaseWrapper Release wrapper
|
|
|
|
|
* @param isPublished Publish status
|
|
|
|
|
* @return {@link Application}
|
|
|
|
|
* @throws ApplicationManagementException Throws when error occurred while deploying the release
|
|
|
|
|
* @throws ResourceManagementException Throws when error occurred while deploying the release
|
|
|
|
|
*/
|
|
|
|
|
private <T> ApplicationRelease createApplicationReleaseBasedOnRemoteStatus(int appId, T releaseWrapper, boolean isPublished)
|
|
|
|
|
throws ApplicationManagementException, ResourceManagementException {
|
|
|
|
|
if (ApplicationManagementUtil.getRemoteStatusFromWrapper(releaseWrapper)) {
|
|
|
|
|
triggerReleaseAsynchronously(appId, releaseWrapper, isPublished);
|
|
|
|
|
} else {
|
|
|
|
|
if (releaseWrapper instanceof EntAppReleaseWrapper) {
|
|
|
|
|
return triggerEntAppRelease(appId, (EntAppReleaseWrapper) releaseWrapper, isPublished);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (releaseWrapper instanceof CustomAppReleaseWrapper) {
|
|
|
|
|
return triggerCustomAppRelease(appId, (CustomAppReleaseWrapper) releaseWrapper, isPublished);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ApplicationManagementException("Unsupported release wrapper received");
|
|
|
|
|
}
|
|
|
|
|
return new ApplicationRelease();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Trigger release creation asynchronously
|
|
|
|
|
* @param appId Application id
|
|
|
|
|
* @param releaseWrapper Release wrapper
|
|
|
|
|
* @param isPublished Publish status
|
|
|
|
|
*/
|
|
|
|
|
private <T> void triggerReleaseAsynchronously(int appId, T releaseWrapper, boolean isPublished) {
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
try {
|
|
|
|
|
PrivilegedCarbonContext.startTenantFlow();
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true);
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
|
|
|
|
|
if (releaseWrapper instanceof EntAppReleaseWrapper &&
|
|
|
|
|
((EntAppReleaseWrapper) releaseWrapper).isRemoteStatus()) {
|
|
|
|
|
triggerEntAppRelease(appId, (EntAppReleaseWrapper) releaseWrapper, isPublished);
|
|
|
|
|
}else if (releaseWrapper instanceof CustomAppReleaseWrapper &&
|
|
|
|
|
((CustomAppReleaseWrapper) releaseWrapper).isRemoteStatus()) {
|
|
|
|
|
triggerCustomAppRelease(appId, (CustomAppReleaseWrapper) releaseWrapper, isPublished);
|
|
|
|
|
} else {
|
|
|
|
|
throw new ApplicationManagementException("Unsupported release wrapper received");
|
|
|
|
|
}
|
|
|
|
|
} catch (ApplicationManagementException | ResourceManagementException e) {
|
|
|
|
|
log.error("Error encountered while deploying remote application release", e);
|
|
|
|
|
} finally {
|
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Trigger enterprise application creation
|
|
|
|
|
* @param appId Application id
|
|
|
|
|
* @param releaseWrapper Release wrapper
|
|
|
|
|
* @param isPublished Publish status
|
|
|
|
|
* @return {@link ApplicationRelease}
|
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while creating enterprise application
|
|
|
|
|
*/
|
|
|
|
|
private ApplicationRelease triggerEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
|
throws ApplicationManagementException{
|
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
|
try {
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
releaseWrapper.getArtifactLink(), releaseWrapper.getBannerLink());
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName(), true);
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.ENTERPRISE, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating ent app release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
String msg = "Malformed URL link received as a downloadable link";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
String msg = "Error encountered while downloading application release artifacts for app id " + appId;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease createEntAppRelease(int appId, EntAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(), releaseWrapper.getScreenshots(),
|
|
|
|
|
releaseWrapper.getBinaryFile(), releaseWrapper.getBanner());
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName(), true);
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.ENTERPRISE, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating ent app release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
return createApplicationReleaseBasedOnRemoteStatus(appId, releaseWrapper, isPublished);
|
|
|
|
|
} catch (ResourceManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating enterprise app release for the app id " + appId;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -195,17 +340,27 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
public ApplicationRelease createWebAppRelease(int appId, WebAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
|
throws ApplicationManagementException, ResourceManagementException {
|
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), null, releaseWrapper.getBanner());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact);
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.WEB_CLIP, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating web app release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
null, releaseWrapper.getBannerLink());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact);
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.WEB_CLIP, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating web app release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
String msg = "Malformed URL link received as a downloadable link";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
String msg = "Error encountered while downloading application release artifacts";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -214,38 +369,69 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
public ApplicationRelease createPubAppRelease(int appId, PublicAppReleaseWrapper releaseWrapper, boolean isPublished) throws
|
|
|
|
|
ResourceManagementException, ApplicationManagementException {
|
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), null, releaseWrapper.getBanner());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.PUBLIC, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating ent public release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
null, releaseWrapper.getBannerLink());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.PUBLIC, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating ent public release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
String msg = "Malformed URL link received as a downloadable link";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
String msg = "Error encountered while downloading application release artifacts";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease createCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
try {
|
|
|
|
|
return createApplicationReleaseBasedOnRemoteStatus(appId, releaseWrapper, isPublished);
|
|
|
|
|
} catch (ResourceManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating enterprise app release";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ApplicationRelease triggerCustomAppRelease(int appId, CustomAppReleaseWrapper releaseWrapper, boolean isPublished)
|
|
|
|
|
throws ResourceManagementException, ApplicationManagementException {
|
|
|
|
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), releaseWrapper.getBinaryFile(), releaseWrapper.getBanner());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.CUSTOM, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating custom app release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
ApplicationDTO applicationDTO = applicationManager.getApplication(appId);
|
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
|
ApplicationArtifact artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
releaseWrapper.getArtifactLink(), releaseWrapper.getBannerLink());
|
|
|
|
|
ApplicationReleaseDTO releaseDTO = APIUtil.releaseWrapperToReleaseDTO(releaseWrapper);
|
|
|
|
|
releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, deviceType.getName());
|
|
|
|
|
try {
|
|
|
|
|
return createRelease(applicationDTO, releaseDTO, ApplicationType.CUSTOM, isPublished);
|
|
|
|
|
} catch (ApplicationManagementException e) {
|
|
|
|
|
String msg = "Error occurred while creating custom app release for application with the name: " + applicationDTO.getName();
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
String msg = "Malformed URL link received as a downloadable link";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
String msg = "Error encountered while downloading application release artifacts";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
deleteApplicationArtifacts(Collections.singletonList(releaseDTO.getAppHashValue()));
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -278,27 +464,27 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
if (app instanceof ApplicationWrapper) {
|
|
|
|
|
ApplicationWrapper wrapper = (ApplicationWrapper) app;
|
|
|
|
|
EntAppReleaseWrapper releaseWrapper = wrapper.getEntAppReleaseWrappers().get(0);
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), releaseWrapper.getBinaryFile(), releaseWrapper.getBanner());
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
releaseWrapper.getArtifactLink(), releaseWrapper.getBannerLink());
|
|
|
|
|
releaseDTO = uploadEntAppReleaseArtifacts(releaseDTO,
|
|
|
|
|
artifact, wrapper.getDeviceType(), false);
|
|
|
|
|
} else if (app instanceof PublicAppWrapper) {
|
|
|
|
|
PublicAppWrapper wrapper = (PublicAppWrapper) app;
|
|
|
|
|
PublicAppReleaseWrapper releaseWrapper = wrapper.getPublicAppReleaseWrappers().get(0);
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), null, releaseWrapper.getBanner());
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
null, releaseWrapper.getBannerLink());
|
|
|
|
|
releaseDTO = uploadPubAppReleaseArtifacts(releaseDTO, artifact, wrapper.getDeviceType());
|
|
|
|
|
} else if (app instanceof WebAppWrapper) {
|
|
|
|
|
WebAppWrapper wrapper = (WebAppWrapper) app;
|
|
|
|
|
WebAppReleaseWrapper releaseWrapper = wrapper.getWebAppReleaseWrappers().get(0);
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), null, releaseWrapper.getBanner());
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
null, releaseWrapper.getBannerLink());
|
|
|
|
|
releaseDTO = uploadWebAppReleaseArtifacts(releaseDTO, artifact);
|
|
|
|
|
} else if (app instanceof CustomAppWrapper) {
|
|
|
|
|
CustomAppWrapper wrapper = (CustomAppWrapper) app;
|
|
|
|
|
CustomAppReleaseWrapper releaseWrapper = wrapper.getCustomAppReleaseWrappers().get(0);
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIcon(),
|
|
|
|
|
releaseWrapper.getScreenshots(), releaseWrapper.getBinaryFile(), releaseWrapper.getBanner());
|
|
|
|
|
artifact = ApplicationManagementUtil.constructApplicationArtifact(releaseWrapper.getIconLink(), releaseWrapper.getScreenshotLinks(),
|
|
|
|
|
releaseWrapper.getArtifactLink(), releaseWrapper.getBannerLink());
|
|
|
|
|
try {
|
|
|
|
|
releaseDTO = uploadCustomAppReleaseArtifacts(releaseDTO, artifact, wrapper.getDeviceType());
|
|
|
|
|
} catch (ResourceManagementException e) {
|
|
|
|
@ -315,7 +501,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
String msg = "Error Occurred when uploading artifacts of the web clip: " + applicationDTO.getName();
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
String msg = "Malformed URL link received as a downloadable link";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
String msg = "Error encountered while downloading application release artifacts";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
// TODO: artifact URLs are not working for Windows AppX installations https://roadmap.entgra.net/issues/11010
|
|
|
|
|
//ApplicationManagementUtil.addInstallerPathToMetadata(releaseDTO);
|
|
|
|
|
applicationDTO.getApplicationReleaseDTOs().clear();
|
|
|
|
|
applicationDTO.getApplicationReleaseDTOs().add(releaseDTO);
|
|
|
|
|
return applicationDTO;
|
|
|
|
@ -2421,21 +2617,25 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
|
ApplicationDTO applicationDTO = getApplication(applicationId);
|
|
|
|
|
String sanitizedName = "";
|
|
|
|
|
if (!StringUtils.isEmpty(applicationUpdateWrapper.getName())) {
|
|
|
|
|
sanitizedName = ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
|
|
|
|
|
Constants.ApplicationProperties.NAME );
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
if (!StringUtils.isEmpty(applicationUpdateWrapper.getName()) && !applicationDTO.getName()
|
|
|
|
|
.equals(applicationUpdateWrapper.getName())) {
|
|
|
|
|
if (!StringUtils.isEmpty(sanitizedName) && !applicationDTO.getName()
|
|
|
|
|
.equals(sanitizedName)) {
|
|
|
|
|
if (applicationDAO
|
|
|
|
|
.isExistingAppName(applicationUpdateWrapper.getName().trim(), applicationDTO.getDeviceTypeId(),
|
|
|
|
|
.isExistingAppName(sanitizedName.trim(), applicationDTO.getDeviceTypeId(),
|
|
|
|
|
tenantId)) {
|
|
|
|
|
String msg = "Already an application registered with same name " + applicationUpdateWrapper.getName()
|
|
|
|
|
String msg = "Already an application registered with same name " + sanitizedName
|
|
|
|
|
+ ". Hence you can't update the application name from " + applicationDTO.getName() + " to "
|
|
|
|
|
+ applicationUpdateWrapper.getName();
|
|
|
|
|
+ sanitizedName;
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
}
|
|
|
|
|
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
|
|
|
|
|
Constants.ApplicationProperties.NAME));
|
|
|
|
|
applicationDTO.setName(sanitizedName);
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(applicationUpdateWrapper.getSubMethod()) && !applicationDTO.getSubType()
|
|
|
|
|
.equals(applicationUpdateWrapper.getSubMethod())) {
|
|
|
|
@ -3131,11 +3331,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updateEntAppRelease(String releaseUuid, EntAppReleaseWrapper entAppReleaseWrapper,
|
|
|
|
|
ApplicationArtifact applicationArtifact) throws ApplicationManagementException {
|
|
|
|
|
public ApplicationRelease updateEntAppRelease(String releaseUuid, EntAppReleaseWrapper entAppReleaseWrapper) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
try {
|
|
|
|
|
ApplicationArtifact applicationArtifact = ApplicationManagementUtil.
|
|
|
|
|
constructApplicationArtifact(entAppReleaseWrapper.getIconLink(), entAppReleaseWrapper.getScreenshotLinks(),
|
|
|
|
|
entAppReleaseWrapper.getArtifactLink(), entAppReleaseWrapper.getBannerLink());
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
|
|
|
|
DeviceType deviceTypeObj = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
@ -3202,17 +3404,25 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
+ "UUID:" + releaseUuid;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
throw new ApplicationManagementException("Malformed downloadable URL received for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
throw new ApplicationManagementException("Error encountered while downloading artifact for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} finally {
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updatePubAppRelease(String releaseUuid, PublicAppReleaseWrapper publicAppReleaseWrapper,
|
|
|
|
|
ApplicationArtifact applicationArtifact) throws ApplicationManagementException {
|
|
|
|
|
public ApplicationRelease updatePubAppRelease(String releaseUuid, PublicAppReleaseWrapper publicAppReleaseWrapper) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
try {
|
|
|
|
|
ApplicationArtifact applicationArtifact = ApplicationManagementUtil.
|
|
|
|
|
constructApplicationArtifact(publicAppReleaseWrapper.getIconLink(), publicAppReleaseWrapper.getScreenshotLinks(),
|
|
|
|
|
null, publicAppReleaseWrapper.getBannerLink());
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
|
|
|
|
validateAppReleaseUpdating(publicAppReleaseWrapper, applicationDTO, applicationArtifact,
|
|
|
|
@ -3271,17 +3481,25 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
+ "release UUID:" + releaseUuid;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
throw new ApplicationManagementException("Malformed downloadable URL received for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
throw new ApplicationManagementException("Error encountered while downloading artifact for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} finally {
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updateWebAppRelease(String releaseUuid, WebAppReleaseWrapper webAppReleaseWrapper,
|
|
|
|
|
ApplicationArtifact applicationArtifact) throws ApplicationManagementException {
|
|
|
|
|
public ApplicationRelease updateWebAppRelease(String releaseUuid, WebAppReleaseWrapper webAppReleaseWrapper) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
try {
|
|
|
|
|
ApplicationArtifact applicationArtifact = ApplicationManagementUtil.
|
|
|
|
|
constructApplicationArtifact(webAppReleaseWrapper.getIconLink(), webAppReleaseWrapper.getScreenshotLinks(),
|
|
|
|
|
null, webAppReleaseWrapper.getBannerLink());
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
|
|
|
|
validateAppReleaseUpdating(webAppReleaseWrapper, applicationDTO, applicationArtifact,
|
|
|
|
@ -3336,18 +3554,27 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
+ "release UUID:" + releaseUuid;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
throw new ApplicationManagementException("Malformed downloadable URL received for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
throw new ApplicationManagementException("Error encountered while downloading artifact for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} finally {
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ApplicationRelease updateCustomAppRelease(String releaseUuid,
|
|
|
|
|
CustomAppReleaseWrapper customAppReleaseWrapper, ApplicationArtifact applicationArtifact)
|
|
|
|
|
public ApplicationRelease updateCustomAppRelease(String releaseUuid, CustomAppReleaseWrapper customAppReleaseWrapper)
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
|
|
|
|
try {
|
|
|
|
|
ApplicationArtifact applicationArtifact = ApplicationManagementUtil.
|
|
|
|
|
constructApplicationArtifact(customAppReleaseWrapper.getIconLink(),
|
|
|
|
|
customAppReleaseWrapper.getScreenshotLinks(), customAppReleaseWrapper.getArtifactLink(),
|
|
|
|
|
customAppReleaseWrapper.getBannerLink());
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
|
|
|
|
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
|
|
|
@ -3466,6 +3693,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
+ "UUID:" + releaseUuid;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
throw new ApplicationManagementException("Malformed downloadable URL received for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} catch (FileDownloaderServiceException e) {
|
|
|
|
|
throw new ApplicationManagementException("Error encountered while downloading artifact for the Public app " +
|
|
|
|
|
"release UUID: " + releaseUuid);
|
|
|
|
|
} finally {
|
|
|
|
|
ConnectionManagerUtil.closeDBConnection();
|
|
|
|
|
}
|
|
|
|
@ -3901,30 +4134,24 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
public void validateEntAppReleaseCreatingRequest(EntAppReleaseWrapper releaseWrapper, String deviceType)
|
|
|
|
|
throws RequestValidatingException, ApplicationManagementException {
|
|
|
|
|
validateReleaseCreatingRequest(releaseWrapper, deviceType);
|
|
|
|
|
validateBinaryArtifact(releaseWrapper.getBinaryFile());
|
|
|
|
|
validateImageArtifacts(releaseWrapper.getIcon(), releaseWrapper.getScreenshots());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void validateCustomAppReleaseCreatingRequest(CustomAppReleaseWrapper releaseWrapper, String deviceType)
|
|
|
|
|
throws RequestValidatingException, ApplicationManagementException {
|
|
|
|
|
validateReleaseCreatingRequest(releaseWrapper, deviceType);
|
|
|
|
|
validateBinaryArtifact(releaseWrapper.getBinaryFile());
|
|
|
|
|
validateImageArtifacts(releaseWrapper.getIcon(), releaseWrapper.getScreenshots());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void validateWebAppReleaseCreatingRequest(WebAppReleaseWrapper releaseWrapper)
|
|
|
|
|
throws RequestValidatingException, ApplicationManagementException {
|
|
|
|
|
validateReleaseCreatingRequest(releaseWrapper, Constants.ANY);
|
|
|
|
|
validateImageArtifacts(releaseWrapper.getIcon(), releaseWrapper.getScreenshots());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void validatePublicAppReleaseCreatingRequest(PublicAppReleaseWrapper releaseWrapper, String deviceType)
|
|
|
|
|
throws RequestValidatingException, ApplicationManagementException {
|
|
|
|
|
validateReleaseCreatingRequest(releaseWrapper, deviceType);
|
|
|
|
|
validateImageArtifacts(releaseWrapper.getIcon(), releaseWrapper.getScreenshots());
|
|
|
|
|
validatePublicAppReleasePackageName(releaseWrapper.getPackageName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -4165,4 +4392,145 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Request is received to delete application related data of tenant with ID: " + tenantId);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
|
|
vppApplicationDAO.deleteAssociationByTenant(tenantId);
|
|
|
|
|
vppApplicationDAO.deleteVppUserByTenant(tenantId);
|
|
|
|
|
vppApplicationDAO.deleteAssetsByTenant(tenantId);
|
|
|
|
|
reviewDAO.deleteReviewsByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteOperationMappingByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteDeviceSubscriptionByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteGroupSubscriptionByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteRoleSubscriptionByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteUserSubscriptionByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteAppFavouritesByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationTagsMappingByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationTagsByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationCategoryMappingByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationCategoriesByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteScheduledSubscriptionByTenant(tenantId);
|
|
|
|
|
lifecycleStateDAO.deleteAppLifecycleStatesByTenant(tenantId);
|
|
|
|
|
applicationReleaseDAO.deleteReleasesByTenant(tenantId);
|
|
|
|
|
visibilityDAO.deleteAppUnrestrictedRolesByTenant(tenantId);
|
|
|
|
|
spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId);
|
|
|
|
|
spApplicationDAO.deleteIdentityServerByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationsByTenant(tenantId);
|
|
|
|
|
APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while observing the database connection to delete applications for tenant with ID: "
|
|
|
|
|
+ tenantId;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
String msg = "Database access error is occurred when getting applications for tenant with ID: " + tenantId;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (LifeCycleManagementDAOException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
String msg = "Error occurred while deleting life-cycle state data of application releases of the tenant"
|
|
|
|
|
+ " of ID: " + tenantId ;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
String msg = "Error occurred while deleting reviews of application releases of the applications"
|
|
|
|
|
+ " 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 deleteApplicationDataByTenantDomain(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;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
|
|
vppApplicationDAO.deleteAssociationByTenant(tenantId);
|
|
|
|
|
vppApplicationDAO.deleteVppUserByTenant(tenantId);
|
|
|
|
|
vppApplicationDAO.deleteAssetsByTenant(tenantId);
|
|
|
|
|
reviewDAO.deleteReviewsByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteOperationMappingByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteDeviceSubscriptionByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteGroupSubscriptionByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteRoleSubscriptionByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteUserSubscriptionByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteAppFavouritesByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationTagsMappingByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationTagsByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationCategoryMappingByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationCategoriesByTenant(tenantId);
|
|
|
|
|
subscriptionDAO.deleteScheduledSubscriptionByTenant(tenantId);
|
|
|
|
|
lifecycleStateDAO.deleteAppLifecycleStatesByTenant(tenantId);
|
|
|
|
|
applicationReleaseDAO.deleteReleasesByTenant(tenantId);
|
|
|
|
|
visibilityDAO.deleteAppUnrestrictedRolesByTenant(tenantId);
|
|
|
|
|
spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId);
|
|
|
|
|
spApplicationDAO.deleteIdentityServerByTenant(tenantId);
|
|
|
|
|
applicationDAO.deleteApplicationsByTenant(tenantId);
|
|
|
|
|
APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
|
String msg = "Error occurred while observing the database connection to delete applications for tenant with ID: "
|
|
|
|
|
+ tenantId;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
String msg = "Database access error is occurred when getting applications for tenant with ID: " + tenantId;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (LifeCycleManagementDAOException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
String msg = "Error occurred while deleting life-cycle state data of application releases of the tenant"
|
|
|
|
|
+ " of ID: " + tenantId ;
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
String msg = "Error occurred while deleting reviews of application releases of the applications"
|
|
|
|
|
+ " 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|