|
|
@ -31,7 +31,6 @@ import org.wso2.carbon.device.application.mgt.common.ApplicationSubscriptionType
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.SortingOrder;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Tag;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.Tag;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.User;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.User;
|
|
|
@ -51,7 +50,6 @@ import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger;
|
|
|
|
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.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.user.api.UserRealm;
|
|
|
|
import org.wso2.carbon.user.api.UserRealm;
|
|
|
@ -214,13 +212,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
applicationList = applicationDAO.getApplications(filter, tenantId);
|
|
|
|
applicationList = applicationDAO.getApplications(filter, tenantId);
|
|
|
|
if(applicationList != null && applicationList.getApplications() != null && applicationList
|
|
|
|
if(applicationList != null && applicationList.getApplications() != null && !applicationList
|
|
|
|
.getApplications().isEmpty()) {
|
|
|
|
.getApplications().isEmpty()) {
|
|
|
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
applicationList = getRoleRestrictedApplicationList(applicationList, userName);
|
|
|
|
applicationList = getRoleRestrictedApplicationList(applicationList, userName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Application application : applicationList.getApplications()) {
|
|
|
|
for (Application application : applicationList.getApplications()) {
|
|
|
|
applicationReleases = getReleases(application.getId());
|
|
|
|
applicationReleases = getReleases(application, false);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -288,7 +286,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
application = ApplicationManagementDAOFactory.getApplicationDAO()
|
|
|
|
application = ApplicationManagementDAOFactory.getApplicationDAO()
|
|
|
|
.getApplicationById(id, tenantId);
|
|
|
|
.getApplicationById(id, tenantId);
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
applicationReleases = getReleases(application.getId());
|
|
|
|
applicationReleases = getReleases(application, false);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -305,7 +303,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
applicationReleases = getReleases(application.getId());
|
|
|
|
applicationReleases = getReleases(application, false);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
@ -352,7 +350,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
application = ApplicationManagementDAOFactory.getApplicationDAO()
|
|
|
|
application = ApplicationManagementDAOFactory.getApplicationDAO()
|
|
|
|
.getApplication(appName, appType, tenantId);
|
|
|
|
.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.getId());
|
|
|
|
applicationReleases = getReleases(application, false);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -369,7 +367,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
applicationReleases = getReleases(application.getId());
|
|
|
|
applicationReleases = getReleases(application, false);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
application.setApplicationReleases(applicationReleases);
|
|
|
|
return application;
|
|
|
|
return application;
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
@ -424,11 +422,38 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
// todo
|
|
|
|
public List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException {
|
|
|
|
// public List<ApplicationRelease> getinstallableReleases(int applicationId) throws ApplicationManagementException {
|
|
|
|
|
|
|
|
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Application application = getApplicationIfAccessible(applicationId);
|
|
|
|
|
|
|
|
// List<ApplicationRelease> applicationReleases;
|
|
|
|
|
|
|
|
// List<ApplicationRelease> filteredApplicationReleases = new ArrayList<>();
|
|
|
|
|
|
|
|
// if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
// log.debug("Request is received to retrieve all the releases related with the application " + application
|
|
|
|
|
|
|
|
// .toString());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ConnectionManagerUtil.getDBConnection();
|
|
|
|
|
|
|
|
// applicationReleases = this.applicationReleaseDAO.getReleases(application.getName(), application.getType(), tenantId);
|
|
|
|
|
|
|
|
// for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
|
|
|
|
// LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO().
|
|
|
|
|
|
|
|
// getLatestLifeCycleStateByReleaseID(applicationRelease.getId());
|
|
|
|
|
|
|
|
// if (lifecycleState != null) {
|
|
|
|
|
|
|
|
// applicationRelease.setLifecycleState(lifecycleState);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (!AppLifecycleState.REMOVED.toString()
|
|
|
|
|
|
|
|
// .equals(applicationRelease.getLifecycleState().getCurrentState())) {
|
|
|
|
|
|
|
|
// filteredApplicationReleases.add(applicationRelease);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return filteredApplicationReleases;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<ApplicationRelease> getReleases(Application application, boolean requirePublishedRelease)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
|
|
|
|
|
|
|
|
Application application = getApplicationIfAccessible(applicationId);
|
|
|
|
|
|
|
|
List<ApplicationRelease> applicationReleases;
|
|
|
|
List<ApplicationRelease> applicationReleases;
|
|
|
|
List<ApplicationRelease> filteredApplicationReleases = new ArrayList<>();
|
|
|
|
List<ApplicationRelease> filteredApplicationReleases = new ArrayList<>();
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -436,7 +461,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
.toString());
|
|
|
|
.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
ConnectionManagerUtil.getDBConnection();
|
|
|
|
applicationReleases = this.applicationReleaseDAO.getReleases(application.getName(), application.getType(), tenantId);
|
|
|
|
applicationReleases = this.applicationReleaseDAO.getReleases(application.getId(), tenantId);
|
|
|
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO().
|
|
|
|
LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO().
|
|
|
|
getLatestLifeCycleStateByReleaseID(applicationRelease.getId());
|
|
|
|
getLatestLifeCycleStateByReleaseID(applicationRelease.getId());
|
|
|
@ -445,19 +470,34 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
|
|
|
|
|
|
|
|
if (!AppLifecycleState.REMOVED.toString()
|
|
|
|
if (!AppLifecycleState.REMOVED.toString()
|
|
|
|
.equals(applicationRelease.getLifecycleState().getCurrentState())) {
|
|
|
|
.equals(applicationRelease.getLifecycleState().getCurrentState())) {
|
|
|
|
|
|
|
|
if (requirePublishedRelease){
|
|
|
|
|
|
|
|
if (AppLifecycleState.PUBLISHED.toString()
|
|
|
|
|
|
|
|
.equals(applicationRelease.getLifecycleState().getCurrentState())){
|
|
|
|
|
|
|
|
filteredApplicationReleases.add(applicationRelease);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
filteredApplicationReleases.add(applicationRelease);
|
|
|
|
filteredApplicationReleases.add(applicationRelease);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (requirePublishedRelease && filteredApplicationReleases.size() > 1) {
|
|
|
|
|
|
|
|
log.error("There are more than one published application releases for application ID: " + application
|
|
|
|
|
|
|
|
.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
return filteredApplicationReleases;
|
|
|
|
return filteredApplicationReleases;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<String> deleteApplication(int applicationId) throws ApplicationManagementException {
|
|
|
|
public List<String> deleteApplication(int applicationId) throws ApplicationManagementException {
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
List<String> storedLocations = new ArrayList<>();
|
|
|
|
List<String> storedLocations = new ArrayList<>();
|
|
|
|
|
|
|
|
Application application;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
|
if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
|
|
@ -466,10 +506,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
"need to have admin permission");
|
|
|
|
"need to have admin permission");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (getApplicationIfAccessible(applicationId) == null) {
|
|
|
|
application = getApplicationIfAccessible(applicationId);
|
|
|
|
|
|
|
|
if ( application == null) {
|
|
|
|
throw new ApplicationManagementException("Invalid Application");
|
|
|
|
throw new ApplicationManagementException("Invalid Application");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<ApplicationRelease> applicationReleases = getReleases(applicationId);
|
|
|
|
List<ApplicationRelease> applicationReleases = getReleases(application, false);
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request is received to delete applications which are related with the application id " +
|
|
|
|
log.debug("Request is received to delete applications which are related with the application id " +
|
|
|
|
applicationId);
|
|
|
|
applicationId);
|
|
|
|