|
|
@ -42,6 +42,7 @@ import org.wso2.carbon.device.application.mgt.common.dto.TagDTO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException;
|
|
|
@ -162,12 +163,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
filter.setLimit(1);
|
|
|
|
filter.setLimit(1);
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
// todo resolve following comment
|
|
|
|
|
|
|
|
/*check is there an application release with same package name, if there is an application release
|
|
|
|
|
|
|
|
throw an error and request to delete the existing application or add this as new application release
|
|
|
|
|
|
|
|
for existing application*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationList applicationList = applicationDAO.getApplications(filter, tenantId);
|
|
|
|
ApplicationList applicationList = applicationDAO.getApplications(filter, tenantId);
|
|
|
|
if (!applicationList.getApplications().isEmpty()) {
|
|
|
|
if (!applicationList.getApplications().isEmpty()) {
|
|
|
|
String msg =
|
|
|
|
String msg =
|
|
|
@ -265,18 +260,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Creating a new release. App Id:" + appId);
|
|
|
|
log.debug("Creating a new release. App Id:" + appId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String initialLifecycleState = lifecycleStateManager.getInitialState();
|
|
|
|
applicationReleaseDTO = applicationDTO.getApplicationReleases().get(0);
|
|
|
|
applicationReleaseDTO = applicationDTO.getApplicationReleases().get(0);
|
|
|
|
applicationReleaseDTO.setCurrentState(AppLifecycleState.CREATED.toString());
|
|
|
|
applicationReleaseDTO.setCurrentState(initialLifecycleState);
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
|
|
|
|
applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
|
|
|
|
|
|
|
|
LifecycleStateDTO lifecycleStateDTO = getLifecycleStateInstance(initialLifecycleState,
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
initialLifecycleState);
|
|
|
|
log.debug("Changing lifecycle state. App Id:" + appId);
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
}
|
|
|
|
.addLifecycleState(lifecycleStateDTO, appId, applicationReleaseDTO.getUuid(), tenantId);
|
|
|
|
//todo get initial state from lifecycle manager and set current state to Release object
|
|
|
|
|
|
|
|
LifecycleStateDTO lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(),
|
|
|
|
|
|
|
|
AppLifecycleState.CREATED.toString());
|
|
|
|
|
|
|
|
this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationReleaseDTO.getUuid(), tenantId);
|
|
|
|
|
|
|
|
applicationReleaseDTO.setCurrentState(AppLifecycleState.CREATED.toString());
|
|
|
|
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
applicationReleaseEntities.add(applicationReleaseDTO);
|
|
|
|
applicationDTO.setApplicationReleases(applicationReleaseEntities);
|
|
|
|
applicationDTO.setApplicationReleases(applicationReleaseEntities);
|
|
|
|
application = appDtoToAppResponse(applicationDTO);
|
|
|
|
application = appDtoToAppResponse(applicationDTO);
|
|
|
@ -291,9 +282,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
String msg =
|
|
|
|
String msg = "Error occurred while adding application or application release. application name: "
|
|
|
|
"Error occurred while adding application or application release. application name: " + applicationWrapper
|
|
|
|
+ applicationWrapper.getName() + " application type: " + applicationWrapper.getType();
|
|
|
|
.getName() + " application type: " + applicationWrapper.getType();
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch(LifecycleManagementException e){
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
String msg = "Error occurred when getting initial lifecycle state. application name: " + applicationWrapper
|
|
|
|
|
|
|
|
.getName() + " application type: is " + applicationWrapper.getType();
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
}catch (DBConnectionException e) {
|
|
|
|
}catch (DBConnectionException e) {
|
|
|
@ -345,8 +341,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
String packagename = applicationInstaller.getPackageName();
|
|
|
|
String packagename = applicationInstaller.getPackageName();
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
if (applicationReleaseDAO.isAppExisitForPackageName(packagename, tenantId)) {
|
|
|
|
if (applicationReleaseDAO.isActiveReleaseExisitForPackageName(packagename, tenantId)) {
|
|
|
|
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 "
|
|
|
|
|
|
|
|
+ "you can add this app release as an new application release, under the existing "
|
|
|
|
|
|
|
|
+ "application.";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new ApplicationManagementException(msg);
|
|
|
|
throw new ApplicationManagementException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -655,7 +654,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
|
|
|
|
|
|
|
private String[] getRolesOfUser(String userName) throws UserStoreException {
|
|
|
|
private String[] getRolesOfUser(String userName) throws UserStoreException {
|
|
|
|
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
|
|
|
|
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
|
|
|
|
String[] roleList = {};
|
|
|
|
String[] roleList;
|
|
|
|
if (userRealm != null) {
|
|
|
|
if (userRealm != null) {
|
|
|
|
userRealm.getUserStoreManager().getRoleNames();
|
|
|
|
userRealm.getUserStoreManager().getRoleNames();
|
|
|
|
roleList = userRealm.getUserStoreManager().getRoleListOfUser(userName);
|
|
|
|
roleList = userRealm.getUserStoreManager().getRoleListOfUser(userName);
|
|
|
|