mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #1185 from lasanthaDLPDS/application-mgt-new
Added Life-cycle management into application management
This commit is contained in:
commit
a0fa98d57b
@ -16,21 +16,13 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface manages all the operations related with lifecycle state.
|
* States of the Application.
|
||||||
*/
|
*/
|
||||||
public interface LifecycleStateManager {
|
public enum AppLifecycleState {
|
||||||
|
CREATED, IN_REVIEW, PUBLISHED, APPROVED, UNPUBLISHED, REJECTED, DEPRECATED, REMOVED
|
||||||
List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifecycleManagementException;
|
|
||||||
|
|
||||||
void addLifecycleState(LifecycleState state) throws LifecycleManagementException;
|
|
||||||
|
|
||||||
void deleteLifecycleState(int identifier) throws LifecycleManagementException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +19,7 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LifecycleState {
|
public class LifecycleState {
|
||||||
|
|
||||||
@ -28,6 +29,8 @@ public class LifecycleState {
|
|||||||
|
|
||||||
private String previousState;
|
private String previousState;
|
||||||
|
|
||||||
|
private List<String> nextStates;
|
||||||
|
|
||||||
private String updatedBy;
|
private String updatedBy;
|
||||||
|
|
||||||
private Timestamp updatedAt;
|
private Timestamp updatedAt;
|
||||||
@ -102,4 +105,11 @@ public class LifecycleState {
|
|||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getNextStates() {
|
||||||
|
return nextStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextStates(List<String> nextStates) {
|
||||||
|
this.nextStates = nextStates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.common.services;
|
|||||||
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.*;
|
import org.wso2.carbon.device.application.mgt.common.*;
|
||||||
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.LifecycleManagementException;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,6 +32,7 @@ public interface ApplicationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an application.
|
* Creates an application.
|
||||||
|
*
|
||||||
* @param application Application that need to be created.
|
* @param application Application that need to be created.
|
||||||
* @return Created application
|
* @return Created application
|
||||||
* @throws ApplicationManagementException Application Management Exception
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
@ -39,6 +41,7 @@ public interface ApplicationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an already existing application.
|
* Updates an already existing application.
|
||||||
|
*
|
||||||
* @param application Application that need to be updated.
|
* @param application Application that need to be updated.
|
||||||
* @return Updated Application
|
* @return Updated Application
|
||||||
* @throws ApplicationManagementException Application Management Exception
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
@ -47,13 +50,24 @@ public interface ApplicationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an application identified by the unique ID.
|
* Delete an application identified by the unique ID.
|
||||||
* @param uuid Unique ID for tha application
|
*
|
||||||
|
* @param applicationId ID for tha application
|
||||||
* @throws ApplicationManagementException Application Management Exception
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
*/
|
*/
|
||||||
void deleteApplication(String uuid) throws ApplicationManagementException;
|
void deleteApplication(int applicationId) throws ApplicationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an application identified by the unique ID.
|
||||||
|
*
|
||||||
|
* @param applicationId ID of tha application
|
||||||
|
* @param releaseUuid UUID of tha application release
|
||||||
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
|
*/
|
||||||
|
void deleteApplicationRelease(int applicationId, String releaseUuid) throws ApplicationManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the applications based on the search filter.
|
* To get the applications based on the search filter.
|
||||||
|
*
|
||||||
* @param filter Search filter
|
* @param filter Search filter
|
||||||
* @return Applications that matches the given filter criteria.
|
* @return Applications that matches the given filter criteria.
|
||||||
* @throws ApplicationManagementException Application Management Exception
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
@ -62,6 +76,7 @@ public interface ApplicationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the applications based on the search filter.
|
* To get the applications based on the search filter.
|
||||||
|
*
|
||||||
* @param appId id of the application
|
* @param appId id of the application
|
||||||
* @return Application release which is published and release of the Application(appId).
|
* @return Application release which is published and release of the Application(appId).
|
||||||
* @throws ApplicationManagementException Application Management Exception
|
* @throws ApplicationManagementException Application Management Exception
|
||||||
@ -135,5 +150,9 @@ public interface ApplicationManager {
|
|||||||
*/
|
*/
|
||||||
List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException;
|
List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException;
|
||||||
|
|
||||||
|
LifecycleState getLifecycleState(int appReleaseId, String applicationUuid) throws LifecycleManagementException;
|
||||||
|
|
||||||
|
void addLifecycleState(int applicationId, String applicationUuid, LifecycleState state) throws LifecycleManagementException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface LifecycleStateDAO {
|
public interface LifecycleStateDAO {
|
||||||
|
|
||||||
LifecycleState getLatestLifeCycleStateByReleaseID(int identifier) throws ApplicationManagementDAOException;
|
LifecycleState getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws ApplicationManagementDAOException;
|
||||||
|
|
||||||
List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException;
|
List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException;
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
public class GenericLifecycleStateImpl extends AbstractDAOImpl implements LifecycleStateDAO {
|
public class GenericLifecycleStateImpl extends AbstractDAOImpl implements LifecycleStateDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LifecycleState getLatestLifeCycleStateByReleaseID(int identifier) throws ApplicationManagementDAOException {
|
public LifecycleState getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws ApplicationManagementDAOException {
|
||||||
|
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -50,7 +50,7 @@ public class GenericLifecycleStateImpl extends AbstractDAOImpl implements Lifecy
|
|||||||
+ "AP_APP_LIFECYCLE_STATE WHERE AP_APP_RELEASE_ID=? ORDER BY UPDATED_AT DESC;";
|
+ "AP_APP_LIFECYCLE_STATE WHERE AP_APP_RELEASE_ID=? ORDER BY UPDATED_AT DESC;";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, identifier);
|
stmt.setInt(1, applicationReleaseId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
LifecycleState lifecycleState = null;
|
LifecycleState lifecycleState = null;
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,15 @@ import org.wso2.carbon.context.CarbonContext;
|
|||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.application.mgt.common.*;
|
import org.wso2.carbon.device.application.mgt.common.*;
|
||||||
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.DBConnectionException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
|
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.LifeCycleManagementDAOException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.ValidationException;
|
import org.wso2.carbon.device.application.mgt.core.exception.ValidationException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
|
import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
|
||||||
@ -67,7 +71,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
|
this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Application createApplication(Application application) throws ApplicationManagementException {
|
@Override
|
||||||
|
public Application createApplication(Application application) throws ApplicationManagementException {
|
||||||
|
|
||||||
User loggedInUser = new User(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(),
|
User loggedInUser = new User(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(),
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
||||||
@ -130,7 +135,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
|
@Override
|
||||||
|
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
ApplicationList applicationList;
|
ApplicationList applicationList;
|
||||||
@ -159,7 +165,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getUuidOfLatestRelease(int appId) throws ApplicationManagementException {
|
@Override
|
||||||
|
public String getUuidOfLatestRelease(int appId) throws ApplicationManagementException {
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.openDBConnection();
|
||||||
return applicationDAO.getUuidOfLatestRelease(appId);
|
return applicationDAO.getUuidOfLatestRelease(appId);
|
||||||
@ -172,7 +179,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
private boolean isRoleExists(List<UnrestrictedRole> unrestrictedRoleList, String userName)
|
private boolean isRoleExists(List<UnrestrictedRole> unrestrictedRoleList, String userName)
|
||||||
throws UserStoreException {
|
throws UserStoreException {
|
||||||
String[] roleList;
|
String[] roleList;
|
||||||
roleList = getRoleOfUser(userName);
|
roleList = getRolesOfUser(userName);
|
||||||
for (UnrestrictedRole unrestrictedRole : unrestrictedRoleList) {
|
for (UnrestrictedRole unrestrictedRole : unrestrictedRoleList) {
|
||||||
for (String role : roleList) {
|
for (String role : roleList) {
|
||||||
if (unrestrictedRole.getRole().equals(role)) {
|
if (unrestrictedRole.getRole().equals(role)) {
|
||||||
@ -183,7 +190,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getRoleOfUser(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) {
|
||||||
@ -194,7 +201,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
return roleList;
|
return roleList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Application getApplication(String appType, String appName) throws ApplicationManagementException {
|
@Override
|
||||||
|
public Application getApplication(String appType, String appName) throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
Application application;
|
Application application;
|
||||||
@ -231,7 +239,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Application getApplicationById(int applicationId) throws ApplicationManagementException {
|
@Override
|
||||||
|
public Application getApplicationById(int applicationId) throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
Application application;
|
Application application;
|
||||||
@ -285,7 +294,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException {
|
@Override
|
||||||
|
public List<ApplicationRelease> getReleases(int applicationId) throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
|
|
||||||
Application application = validateApplication(applicationId);
|
Application application = validateApplication(applicationId);
|
||||||
@ -300,7 +310,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
applicationReleases = ApplicationManagementDAOFactory.getApplicationReleaseDAO()
|
applicationReleases = ApplicationManagementDAOFactory.getApplicationReleaseDAO()
|
||||||
.getApplicationReleases(application.getName(), application.getType(), tenantId);
|
.getApplicationReleases(application.getName(), application.getType(), tenantId);
|
||||||
for (ApplicationRelease applicationRelease : applicationReleases) {
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
||||||
if (!"REMOVED".equals(ApplicationManagementDAOFactory.getLifecycleStateDAO().
|
if (!AppLifecycleState.REMOVED.toString().equals(ApplicationManagementDAOFactory.getLifecycleStateDAO().
|
||||||
getLatestLifeCycleStateByReleaseID(applicationRelease.getId()).getCurrentState())) {
|
getLatestLifeCycleStateByReleaseID(applicationRelease.getId()).getCurrentState())) {
|
||||||
filteredApplicationReleases.add(applicationRelease);
|
filteredApplicationReleases.add(applicationRelease);
|
||||||
}
|
}
|
||||||
@ -311,32 +321,52 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* To check whether current user is application owner or admin.
|
public void deleteApplication(int applicationId) throws ApplicationManagementException {
|
||||||
*
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
* @param applicationUUID UUID of the Application.
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
* @return true if the current user is application owner or admin, unless false.
|
|
||||||
* @throws ApplicationManagementException Application Management Exception.
|
if (validateApplication(applicationId) == null) {
|
||||||
*/
|
throw new ApplicationManagementException("Invalid Application");
|
||||||
private boolean isApplicationOwnerOrAdmin(String applicationUUID, String userName, int tenantId)
|
}
|
||||||
throws ApplicationManagementException {
|
List<ApplicationRelease> applicationReleases = getReleases(applicationId);
|
||||||
// try {
|
if (log.isDebugEnabled()) {
|
||||||
// if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
log.debug("Request is received to delete applications which are related with the application id " +
|
||||||
// return true;
|
applicationId);
|
||||||
// }
|
}
|
||||||
// } catch (UserStoreException e) {
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
||||||
// throw new ApplicationManagementException("Userstore exception while checking whether user is an admin", e);
|
LifecycleState appLifecycleState = getLifecycleState(applicationId, applicationRelease.getUuid());
|
||||||
// }
|
LifecycleState newAppLifecycleState = new LifecycleState();
|
||||||
// try {
|
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
|
||||||
// ConnectionManagerUtil.openDBConnection();
|
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
|
||||||
// Application application = ApplicationManagementDAOFactory.getApplicationDAO()
|
newAppLifecycleState.setTenantId(tenantId);
|
||||||
// .getApplication(applicationUUID, tenantId, userName);
|
newAppLifecycleState.setUpdatedBy(userName);
|
||||||
// return application.getUser().getUserName().equals(userName)
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
||||||
// && application.getUser().getTenantId() == tenantId;
|
}
|
||||||
// } finally {
|
//todo add column into application and move application into removed state
|
||||||
// ConnectionManagerUtil.closeDBConnection();
|
}
|
||||||
// }
|
|
||||||
return false;
|
@Override
|
||||||
|
public void deleteApplicationRelease(int applicationId, String releaseUuid) throws ApplicationManagementException {
|
||||||
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
|
Application application = validateApplication(applicationId);
|
||||||
|
|
||||||
|
if (application == null) {
|
||||||
|
throw new ApplicationManagementException("Invalid Application ID is received");
|
||||||
|
}
|
||||||
|
ApplicationRelease applicationRelease = validateApplicationRelease(releaseUuid);
|
||||||
|
if (applicationRelease == null) {
|
||||||
|
throw new ApplicationManagementException("Invalid Application Release UUID is received");
|
||||||
|
}
|
||||||
|
|
||||||
|
LifecycleState appLifecycleState = getLifecycleState(applicationId, applicationRelease.getUuid());
|
||||||
|
LifecycleState newAppLifecycleState = new LifecycleState();
|
||||||
|
newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState());
|
||||||
|
newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString());
|
||||||
|
newAppLifecycleState.setTenantId(tenantId);
|
||||||
|
newAppLifecycleState.setUpdatedBy(userName);
|
||||||
|
addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -381,6 +411,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To validate the application existence
|
||||||
|
*
|
||||||
|
* @param application Application that need to be validated
|
||||||
|
* @throws ValidationException Validation Exception
|
||||||
|
*/
|
||||||
private void validateApplicationExistence(Application application) throws ApplicationManagementException {
|
private void validateApplicationExistence(Application application) throws ApplicationManagementException {
|
||||||
Filter filter = new Filter();
|
Filter filter = new Filter();
|
||||||
filter.setFullMatch(true);
|
filter.setFullMatch(true);
|
||||||
@ -415,6 +451,26 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To validate the pre-request of the ApplicationRelease.
|
||||||
|
*
|
||||||
|
* @param applicationUuid UUID of the Application.
|
||||||
|
* @return Application related with the UUID
|
||||||
|
*/
|
||||||
|
private ApplicationRelease validateApplicationRelease(String applicationUuid) throws ApplicationManagementException {
|
||||||
|
if (applicationUuid == null) {
|
||||||
|
throw new ApplicationManagementException("Application UUID is null. Application UUID is a required "
|
||||||
|
+ "parameter to get the relevant application.");
|
||||||
|
}
|
||||||
|
ApplicationRelease applicationRelease = DataHolder.getInstance().getApplicationReleaseManager()
|
||||||
|
.getReleaseByUuid(applicationUuid);
|
||||||
|
if (applicationRelease == null) {
|
||||||
|
throw new NotFoundException(
|
||||||
|
"Application with UUID " + applicationUuid + " does not exist.");
|
||||||
|
}
|
||||||
|
return applicationRelease;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get role restricted application list.
|
* To get role restricted application list.
|
||||||
*
|
*
|
||||||
@ -470,7 +526,146 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Application editApplication(Application application) throws ApplicationManagementException {
|
@Override
|
||||||
|
public LifecycleState getLifecycleState(int applicationId, String applicationUuid) throws LifecycleManagementException {
|
||||||
|
LifecycleState lifecycleState;
|
||||||
|
try {
|
||||||
|
ConnectionManagerUtil.openDBConnection();
|
||||||
|
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
||||||
|
Application application = validateApplication(applicationId);
|
||||||
|
//todo applicationUuid and applicationId should be passed and util method has to be changed
|
||||||
|
ApplicationRelease applicationRelease = validateApplicationRelease(applicationUuid);
|
||||||
|
lifecycleState = lifecycleStateDAO.getLatestLifeCycleStateByReleaseID(applicationRelease.getId());
|
||||||
|
lifecycleState.setNextStates(getNextLifecycleStates(lifecycleState.getCurrentState()));
|
||||||
|
} catch (ApplicationManagementDAOException e) {
|
||||||
|
throw new LifecycleManagementException("Failed to get lifecycle state", e);
|
||||||
|
} catch (DBConnectionException e) {
|
||||||
|
throw new LifecycleManagementException("Failed to connect with Database", e);
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
throw new LifecycleManagementException("Failed to get application and application management", e);
|
||||||
|
} finally {
|
||||||
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
|
}
|
||||||
|
return lifecycleState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addLifecycleState(int applicationId, String applicationUuid, LifecycleState state) throws LifecycleManagementException {
|
||||||
|
try {
|
||||||
|
ConnectionManagerUtil.openDBConnection();
|
||||||
|
Application application = validateApplication(applicationId);
|
||||||
|
//todo applicationUuid and applicationId should be passed and util method has to be changed
|
||||||
|
ApplicationRelease applicationRelease = validateApplicationRelease(applicationUuid);
|
||||||
|
LifecycleStateDAO lifecycleStateDAO;
|
||||||
|
|
||||||
|
if (application != null) {
|
||||||
|
state.setAppId(applicationId);
|
||||||
|
}
|
||||||
|
if (applicationRelease != null) {
|
||||||
|
state.setReleaseId(applicationRelease.getId());
|
||||||
|
}
|
||||||
|
if (state.getCurrentState() != null && state.getPreviousState() != null && state.getUpdatedBy() != null) {
|
||||||
|
validateLifecycleState(state);
|
||||||
|
lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
||||||
|
lifecycleStateDAO.addLifecycleState(state);
|
||||||
|
}
|
||||||
|
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
||||||
|
throw new LifecycleManagementException("Failed to add lifecycle state", e);
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
throw new LifecycleManagementException("Lifecycle State Validation failed", e);
|
||||||
|
} finally {
|
||||||
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getNextLifecycleStates(String currentLifecycleState) {
|
||||||
|
List<String> nextLifecycleStates = new ArrayList<>();
|
||||||
|
if (AppLifecycleState.CREATED.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.IN_REVIEW.toString());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.IN_REVIEW.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.APPROVED.toString());
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.REJECTED.toString());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.REJECTED.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.IN_REVIEW.toString());
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.REMOVED.toString());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.APPROVED.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.PUBLISHED.toString());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.PUBLISHED.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.UNPUBLISHED.toString());
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.DEPRECATED.toString());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.UNPUBLISHED.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.PUBLISHED.toString());
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.REMOVED.toString());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.DEPRECATED.toString().equals(currentLifecycleState)) {
|
||||||
|
nextLifecycleStates.add(AppLifecycleState.REMOVED.toString());
|
||||||
|
}
|
||||||
|
return nextLifecycleStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLifecycleState(LifecycleState state) throws LifecycleManagementException {
|
||||||
|
|
||||||
|
if (AppLifecycleState.CREATED.toString().equals(state.getCurrentState())) {
|
||||||
|
throw new LifecycleManagementException("Current State Couldn't be " + state.getCurrentState());
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.IN_REVIEW.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.CREATED.toString().equals(state.getPreviousState()) &&
|
||||||
|
!AppLifecycleState.REJECTED.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be either " + AppLifecycleState.CREATED.toString() + " or " +
|
||||||
|
AppLifecycleState.REJECTED.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.APPROVED.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.IN_REVIEW.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be " + AppLifecycleState.IN_REVIEW.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.PUBLISHED.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.APPROVED.toString().equals(state.getPreviousState()) &&
|
||||||
|
!AppLifecycleState.UNPUBLISHED.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be either " + AppLifecycleState.APPROVED.toString() + " or " +
|
||||||
|
AppLifecycleState.UNPUBLISHED.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.UNPUBLISHED.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.PUBLISHED.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be " + AppLifecycleState.PUBLISHED.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.REJECTED.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.IN_REVIEW.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be " + AppLifecycleState.IN_REVIEW.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.DEPRECATED.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.PUBLISHED.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be " + AppLifecycleState.PUBLISHED.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (AppLifecycleState.REMOVED.toString().equals(state.getCurrentState())) {
|
||||||
|
if (!AppLifecycleState.DEPRECATED.toString().equals(state.getPreviousState()) &&
|
||||||
|
!AppLifecycleState.REJECTED.toString().equals(state.getPreviousState()) &&
|
||||||
|
!AppLifecycleState.UNPUBLISHED.toString().equals(state.getPreviousState())) {
|
||||||
|
throw new LifecycleManagementException("If Current State is " + state.getCurrentState() +
|
||||||
|
"Previous State should be either " + AppLifecycleState.DEPRECATED.toString() + " or " +
|
||||||
|
AppLifecycleState.REJECTED.toString() + " or " + AppLifecycleState.UNPUBLISHED.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Application editApplication(Application application) throws ApplicationManagementException {
|
||||||
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
// if (application.getUuid() == null) {
|
// if (application.getUuid() == null) {
|
||||||
@ -531,34 +726,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void deleteApplication(String uuid) throws ApplicationManagementException {
|
@Override
|
||||||
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
public void changeLifecycle(String applicationUuid, String lifecycleIdentifier)
|
||||||
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
||||||
// if (!isApplicationOwnerOrAdmin(uuid, userName, tenantId)) {
|
|
||||||
// throw new ApplicationManagementException("User '" + userName + "' of tenant - " + tenantId + " does have"
|
|
||||||
// + " the permission to delete the application with UUID " + uuid);
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// ApplicationDAO applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
|
|
||||||
// ConnectionManagerUtil.beginDBTransaction();
|
|
||||||
// int appId = applicationDAO.getApplicationId(uuid, tenantId);
|
|
||||||
// if (appId != -1) {
|
|
||||||
// applicationDAO.deleteTags(appId);
|
|
||||||
// applicationDAO.deleteProperties(appId);
|
|
||||||
// DataHolder.getInstance().getVisibilityManager().remove(appId);
|
|
||||||
// applicationDAO.deleteApplication(uuid, tenantId);
|
|
||||||
// }
|
|
||||||
// ConnectionManagerUtil.commitDBTransaction();
|
|
||||||
// } catch (ApplicationManagementDAOException e) {
|
|
||||||
// ConnectionManagerUtil.rollbackDBTransaction();
|
|
||||||
// String msg = "Failed to delete application: " + uuid;
|
|
||||||
// throw new ApplicationManagementException(msg, e);
|
|
||||||
// } finally {
|
|
||||||
// ConnectionManagerUtil.closeDBConnection();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void changeLifecycle(String applicationUuid, String lifecycleIdentifier)
|
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
// boolean isAvailableNextState = false;
|
// boolean isAvailableNextState = false;
|
||||||
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
@ -593,7 +762,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<LifecycleStateTransition> getLifeCycleStates(String applicationUUID)
|
@Override
|
||||||
|
public List<LifecycleStateTransition> getLifeCycleStates(String applicationUUID)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
// String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
@ -649,4 +819,32 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To check whether current user is application owner or admin.
|
||||||
|
*
|
||||||
|
* @param applicationUUID UUID of the Application.
|
||||||
|
* @return true if the current user is application owner or admin, unless false.
|
||||||
|
* @throws ApplicationManagementException Application Management Exception.
|
||||||
|
*/
|
||||||
|
private boolean isApplicationOwnerOrAdmin(String applicationUUID, String userName, int tenantId)
|
||||||
|
throws ApplicationManagementException {
|
||||||
|
// try {
|
||||||
|
// if (isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// } catch (UserStoreException e) {
|
||||||
|
// throw new ApplicationManagementException("Userstore exception while checking whether user is an admin", e);
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// ConnectionManagerUtil.openDBConnection();
|
||||||
|
// Application application = ApplicationManagementDAOFactory.getApplicationDAO()
|
||||||
|
// .getApplication(applicationUUID, tenantId, userName);
|
||||||
|
// return application.getUser().getUserName().equals(userName)
|
||||||
|
// && application.getUser().getTenantId() == tenantId;
|
||||||
|
// } finally {
|
||||||
|
// ConnectionManagerUtil.closeDBConnection();
|
||||||
|
// }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,8 +68,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease uploadImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream,
|
public ApplicationRelease uploadImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream,
|
||||||
InputStream bannerFileStream,List<InputStream> screenShotStreams) throws ResourceManagementException {
|
InputStream bannerFileStream, List<InputStream> screenShotStreams)
|
||||||
|
throws ResourceManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
String artifactDirectoryPath = null;
|
String artifactDirectoryPath = null;
|
||||||
String iconStoredLocation;
|
String iconStoredLocation;
|
||||||
@ -77,26 +77,22 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
String scStoredLocation;
|
String scStoredLocation;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
artifactDirectoryPath = storagePath + applicationRelease.getAppHashValue();
|
artifactDirectoryPath = storagePath + applicationRelease.getAppHashValue();
|
||||||
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
|
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
|
||||||
iconStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[0];
|
iconStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[0];
|
||||||
bannerStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[1];
|
bannerStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[1];
|
||||||
|
|
||||||
if (iconFileStream != null){
|
if (iconFileStream != null) {
|
||||||
saveFile(iconFileStream, iconStoredLocation);
|
saveFile(iconFileStream, iconStoredLocation);
|
||||||
applicationRelease.setIconLoc(iconStoredLocation);
|
applicationRelease.setIconLoc(iconStoredLocation);
|
||||||
}
|
}
|
||||||
|
if (bannerFileStream != null) {
|
||||||
if (bannerFileStream != null){
|
|
||||||
saveFile(bannerFileStream, bannerStoredLocation);
|
saveFile(bannerFileStream, bannerStoredLocation);
|
||||||
applicationRelease.setBannerLoc(bannerStoredLocation);
|
applicationRelease.setBannerLoc(bannerStoredLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (screenShotStreams.size() > screenShotMaxCount) {
|
if (screenShotStreams.size() > screenShotMaxCount) {
|
||||||
throw new ApplicationStorageManagementException("Maximum limit for the screen-shot exceeds");
|
throw new ApplicationStorageManagementException("Maximum limit for the screen-shot exceeds");
|
||||||
}else if(!screenShotStreams.isEmpty() && screenShotStreams.size() <= screenShotMaxCount){
|
} else if (!screenShotStreams.isEmpty() && screenShotStreams.size() <= screenShotMaxCount) {
|
||||||
int count = 1;
|
int count = 1;
|
||||||
for (InputStream screenshotStream : screenShotStreams) {
|
for (InputStream screenshotStream : screenShotStreams) {
|
||||||
scStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[2] + count;
|
scStoredLocation = artifactDirectoryPath + File.separator + Constants.IMAGE_ARTIFACTS[2] + count;
|
||||||
@ -125,7 +121,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
+ "update the screen-shot count for the application " + applicationRelease.getUuid() +
|
+ "update the screen-shot count for the application " + applicationRelease.getUuid() +
|
||||||
" for the tenant id " + tenantId, e);
|
" for the tenant id " + tenantId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,7 +149,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationRelease uploadReleaseArtifacts(ApplicationRelease applicationRelease , InputStream binaryFile)
|
public ApplicationRelease uploadReleaseArtifacts(ApplicationRelease applicationRelease, InputStream binaryFile)
|
||||||
throws ResourceManagementException {
|
throws ResourceManagementException {
|
||||||
|
|
||||||
String artifactDirectoryPath;
|
String artifactDirectoryPath;
|
||||||
@ -162,7 +157,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
md5OfApp = getMD5(binaryFile);
|
md5OfApp = getMD5(binaryFile);
|
||||||
//todo validate binary file.
|
//todo validate binary file.
|
||||||
|
|
||||||
if(md5OfApp != null){
|
if (md5OfApp != null) {
|
||||||
artifactDirectoryPath = storagePath + md5OfApp;
|
artifactDirectoryPath = storagePath + md5OfApp;
|
||||||
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
|
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
@ -179,10 +174,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
+ applicationRelease.getUuid(), e);
|
+ applicationRelease.getUuid(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
log.error("Verify application existence and md5sum value retrieving process");
|
log.error("Verify application existence and md5sum value retrieving process");
|
||||||
}
|
}
|
||||||
|
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +189,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
ApplicationRelease applicationRelease = null;
|
ApplicationRelease applicationRelease = null;
|
||||||
try {
|
try {
|
||||||
applicationRelease = validateApplicationRelease(applicationUuid);
|
applicationRelease = validateApplicationRelease(applicationUuid);
|
||||||
applicationRelease = uploadReleaseArtifacts(applicationRelease,binaryFile);
|
applicationRelease = uploadReleaseArtifacts(applicationRelease, binaryFile);
|
||||||
return applicationRelease;
|
return applicationRelease;
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
throw new ApplicationStorageManagementException("Application Management exception while trying to"
|
throw new ApplicationStorageManagementException("Application Management exception while trying to"
|
||||||
@ -310,6 +304,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* To validate the image artifact names.
|
* To validate the image artifact names.
|
||||||
|
*
|
||||||
* @param name Name of the image artifact.
|
* @param name Name of the image artifact.
|
||||||
* @throws ApplicationStorageManagementException Application Storage Management Exception
|
* @throws ApplicationStorageManagementException Application Storage Management Exception
|
||||||
*/
|
*/
|
||||||
@ -339,7 +334,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
|
|||||||
isAppExist = DataHolder.getInstance().getApplicationManager().verifyApplicationExistenceById(appId);
|
isAppExist = DataHolder.getInstance().getApplicationManager().verifyApplicationExistenceById(appId);
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
throw new ApplicationStorageManagementException(
|
throw new ApplicationStorageManagementException(
|
||||||
"Exception while verifing the application existence for the application with ID "+ appId);
|
"Exception while verifing the application existence for the application with ID " + appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isAppExist;
|
return isAppExist;
|
||||||
|
|||||||
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.wso2.carbon.device.application.mgt.core.impl;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
|
|
||||||
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.services.LifecycleStateManager;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.LifeCycleManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Concrete implementation of Lifecycle state management.
|
|
||||||
*/
|
|
||||||
public class LifecycleStateManagerImpl implements LifecycleStateManager {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(LifecycleStateManagerImpl.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LifecycleState> getLifecycleStates(int appReleaseId) throws LifecycleManagementException {
|
|
||||||
List<LifecycleState> lifecycleStates = null;
|
|
||||||
try {
|
|
||||||
ConnectionManagerUtil.openDBConnection();
|
|
||||||
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
|
||||||
lifecycleStates = lifecycleStateDAO.getLifecycleStates(appReleaseId);
|
|
||||||
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
|
||||||
throw new LifecycleManagementException("Failed get lifecycle states.", e);
|
|
||||||
} finally {
|
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
|
||||||
}
|
|
||||||
return lifecycleStates;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLifecycleState(LifecycleState state) throws LifecycleManagementException {
|
|
||||||
try {
|
|
||||||
ConnectionManagerUtil.openDBConnection();
|
|
||||||
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
|
||||||
lifecycleStateDAO.addLifecycleState(state);
|
|
||||||
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
|
||||||
throw new LifecycleManagementException("Failed to add lifecycle state", e);
|
|
||||||
} finally {
|
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteLifecycleState(int identifier) throws LifecycleManagementException {
|
|
||||||
|
|
||||||
try {
|
|
||||||
ConnectionManagerUtil.openDBConnection();
|
|
||||||
LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO();
|
|
||||||
lifecycleStateDAO.deleteLifecycleState(identifier);
|
|
||||||
} catch (LifeCycleManagementDAOException | DBConnectionException e) {
|
|
||||||
throw new LifecycleManagementException("Failed to add lifecycle state: " + identifier, e);
|
|
||||||
} finally {
|
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -22,7 +22,6 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager
|
|||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager;
|
import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
@ -43,8 +42,6 @@ public class DataHolder {
|
|||||||
|
|
||||||
private CommentsManager commentsManager;
|
private CommentsManager commentsManager;
|
||||||
|
|
||||||
private LifecycleStateManager lifecycleStateManager;
|
|
||||||
|
|
||||||
private SubscriptionManager subscriptionManager;
|
private SubscriptionManager subscriptionManager;
|
||||||
|
|
||||||
private UnrestrictedRoleManager unrestrictedRoleManager;
|
private UnrestrictedRoleManager unrestrictedRoleManager;
|
||||||
@ -93,14 +90,6 @@ public class DataHolder {
|
|||||||
this.commentsManager = commentsManager;
|
this.commentsManager = commentsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LifecycleStateManager getLifecycleStateManager() {
|
|
||||||
return lifecycleStateManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLifecycleStateManager(LifecycleStateManager lifecycleStateManager) {
|
|
||||||
this.lifecycleStateManager = lifecycleStateManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionManager getSubscriptionManager() {
|
public SubscriptionManager getSubscriptionManager() {
|
||||||
return subscriptionManager;
|
return subscriptionManager;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager
|
|||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager;
|
import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager;
|
||||||
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
||||||
@ -85,10 +84,6 @@ public class ServiceComponent {
|
|||||||
DataHolder.getInstance().setCommentsManager(commentsManager);
|
DataHolder.getInstance().setCommentsManager(commentsManager);
|
||||||
bundleContext.registerService(CommentsManager.class.getName(), commentsManager, null);
|
bundleContext.registerService(CommentsManager.class.getName(), commentsManager, null);
|
||||||
|
|
||||||
LifecycleStateManager lifecycleStateManager = ApplicationManagementUtil.getLifecycleStateManagerInstance();
|
|
||||||
DataHolder.getInstance().setLifecycleStateManager(lifecycleStateManager);
|
|
||||||
bundleContext.registerService(LifecycleStateManager.class.getName(), lifecycleStateManager, null);
|
|
||||||
|
|
||||||
SubscriptionManager subscriptionManager = ApplicationManagementUtil.getSubscriptionManagerInstance();
|
SubscriptionManager subscriptionManager = ApplicationManagementUtil.getSubscriptionManagerInstance();
|
||||||
DataHolder.getInstance().setSubscriptionManager(subscriptionManager);
|
DataHolder.getInstance().setSubscriptionManager(subscriptionManager);
|
||||||
bundleContext.registerService(SubscriptionManager.class.getName(), subscriptionManager, null);
|
bundleContext.registerService(SubscriptionManager.class.getName(), subscriptionManager, null);
|
||||||
|
|||||||
@ -25,7 +25,6 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager
|
|||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager;
|
import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager;
|
||||||
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
||||||
@ -60,12 +59,6 @@ public class ApplicationManagementUtil {
|
|||||||
return getInstance(extension, CommentsManager.class);
|
return getInstance(extension, CommentsManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LifecycleStateManager getLifecycleStateManagerInstance() throws InvalidConfigurationException {
|
|
||||||
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
|
|
||||||
Extension extension = configurationManager.getExtension(Extension.Name.LifecycleStateManager);
|
|
||||||
return getInstance(extension, LifecycleStateManager.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UnrestrictedRoleManager getVisibilityManagerInstance() throws InvalidConfigurationException {
|
public static UnrestrictedRoleManager getVisibilityManagerInstance() throws InvalidConfigurationException {
|
||||||
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
|
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
|
||||||
Extension extension = configurationManager.getExtension(Extension.Name.VisibilityManager);
|
Extension extension = configurationManager.getExtension(Extension.Name.VisibilityManager);
|
||||||
|
|||||||
@ -35,7 +35,6 @@ public class APIUtil {
|
|||||||
private static Log log = LogFactory.getLog(APIUtil.class);
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||||
|
|
||||||
private static ApplicationManager applicationManager;
|
private static ApplicationManager applicationManager;
|
||||||
private static LifecycleStateManager lifecycleStateManager;
|
|
||||||
private static ApplicationReleaseManager applicationReleaseManager;
|
private static ApplicationReleaseManager applicationReleaseManager;
|
||||||
private static ApplicationStorageManager applicationStorageManager;
|
private static ApplicationStorageManager applicationStorageManager;
|
||||||
private static SubscriptionManager subscriptionManager;
|
private static SubscriptionManager subscriptionManager;
|
||||||
@ -61,24 +60,6 @@ public class APIUtil {
|
|||||||
return applicationManager;
|
return applicationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LifecycleStateManager getLifecycleStateManager() {
|
|
||||||
if (lifecycleStateManager == null) {
|
|
||||||
synchronized (APIUtil.class) {
|
|
||||||
if (lifecycleStateManager == null) {
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
lifecycleStateManager =
|
|
||||||
(LifecycleStateManager) ctx.getOSGiService(LifecycleStateManager.class, null);
|
|
||||||
if (lifecycleStateManager == null) {
|
|
||||||
String msg = "Lifecycle Manager service has not initialized.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lifecycleStateManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the Application Release Manager from the osgi context.
|
* To get the Application Release Manager from the osgi context.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -91,8 +91,8 @@ import javax.ws.rs.core.Response;
|
|||||||
permissions = {"/device-mgt/application/update"}
|
permissions = {"/device-mgt/application/update"}
|
||||||
),
|
),
|
||||||
@Scope(
|
@Scope(
|
||||||
name = "Create an Application",
|
name = "Login to Application Management",
|
||||||
description = "Create an application",
|
description = "Login to Application Management",
|
||||||
key = "perm:application-mgt:login",
|
key = "perm:application-mgt:login",
|
||||||
permissions = {"/device-mgt/application-mgt/login"}
|
permissions = {"/device-mgt/application-mgt/login"}
|
||||||
),
|
),
|
||||||
@ -101,21 +101,7 @@ import javax.ws.rs.core.Response;
|
|||||||
description = "Delete an application",
|
description = "Delete an application",
|
||||||
key = "perm:application:delete",
|
key = "perm:application:delete",
|
||||||
permissions = {"/device-mgt/application/delete"}
|
permissions = {"/device-mgt/application/delete"}
|
||||||
),
|
|
||||||
@Scope(
|
|
||||||
name = "Create an application category",
|
|
||||||
description = "Create an application category",
|
|
||||||
key = "perm:application-category:create",
|
|
||||||
permissions = {"/device-mgt/application/category/create"}
|
|
||||||
),
|
|
||||||
@Scope(
|
|
||||||
name = "Delete an Application category",
|
|
||||||
description = "Delete an application category",
|
|
||||||
key = "perm:application-category:delete",
|
|
||||||
permissions = {"/device-mgt/application/category/delete"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@Path("/publisher/applications")
|
@Path("/publisher/applications")
|
||||||
@ -315,7 +301,7 @@ public interface ApplicationManagementAPI {
|
|||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@Path("/{appuuid}")
|
@Path("/{appid}")
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
consumes = MediaType.APPLICATION_JSON,
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
produces = MediaType.APPLICATION_JSON,
|
produces = MediaType.APPLICATION_JSON,
|
||||||
@ -345,7 +331,7 @@ public interface ApplicationManagementAPI {
|
|||||||
name = "UUID",
|
name = "UUID",
|
||||||
value = "Unique identifier of the Application",
|
value = "Unique identifier of the Application",
|
||||||
required = true)
|
required = true)
|
||||||
@PathParam("appuuid") String applicationUUID);
|
@PathParam("appid") int applicationId);
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@ -459,7 +445,7 @@ public interface ApplicationManagementAPI {
|
|||||||
Response updateApplicationArtifact(
|
Response updateApplicationArtifact(
|
||||||
@ApiParam(name = "id", value = "Id of the application", required = true) @PathParam("uuid") int applicationId,
|
@ApiParam(name = "id", value = "Id of the application", required = true) @PathParam("uuid") int applicationId,
|
||||||
@ApiParam(name = "uuid", value = "UUID of the application", required = true) @PathParam("uuid") String applicationUUID,
|
@ApiParam(name = "uuid", value = "UUID of the application", required = true) @PathParam("uuid") String applicationUUID,
|
||||||
@Multipart("binaryFile") Attachment binaryFile );
|
@Multipart("binaryFile") Attachment binaryFile);
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/{appId}/{uuid}")
|
@Path("/{appId}/{uuid}")
|
||||||
@ -489,7 +475,6 @@ public interface ApplicationManagementAPI {
|
|||||||
message = "Internal Server Error. \n Error occurred while releasing the application.",
|
message = "Internal Server Error. \n Error occurred while releasing the application.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
|
|
||||||
Response updateApplicationRelease(
|
Response updateApplicationRelease(
|
||||||
@ApiParam(name = "appId", value = "Identifier of the Application", required = true) @PathParam("appId") int applicationId,
|
@ApiParam(name = "appId", value = "Identifier of the Application", required = true) @PathParam("appId") int applicationId,
|
||||||
@ApiParam(name = "UUID", value = "Unique identifier of the Application Release", required = true) @PathParam("uuid") String applicationUUID,
|
@ApiParam(name = "UUID", value = "Unique identifier of the Application Release", required = true) @PathParam("uuid") String applicationUUID,
|
||||||
|
|||||||
@ -103,7 +103,8 @@ public interface LifecycleManagementAPI {
|
|||||||
message = "Internal Server Error. \n Error occurred while getting the lifecycle list.",
|
message = "Internal Server Error. \n Error occurred while getting the lifecycle list.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
Response getLifecycleStates();
|
Response getLifecycleState(@PathParam("appId") int applicationId,
|
||||||
|
@PathParam("uuid") String applicationUuid);
|
||||||
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ -136,7 +137,9 @@ public interface LifecycleManagementAPI {
|
|||||||
message = "Internal Server Error. \n Error occurred adding a lifecycle state.",
|
message = "Internal Server Error. \n Error occurred adding a lifecycle state.",
|
||||||
response = ErrorResponse.class)
|
response = ErrorResponse.class)
|
||||||
})
|
})
|
||||||
Response addLifecycleState(LifecycleState state);
|
Response addLifecycleState(@PathParam("appId") int applicationId,
|
||||||
|
@PathParam("uuid") String applicationUuid,
|
||||||
|
LifecycleState state);
|
||||||
|
|
||||||
@Path("/{identifier}")
|
@Path("/{identifier}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
|||||||
@ -23,27 +23,21 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||||
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.APIUtil;
|
import org.wso2.carbon.device.application.mgt.publisher.api.APIUtil;
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.FileStreamingOutput;
|
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementAPI;
|
import org.wso2.carbon.device.application.mgt.publisher.api.services.ApplicationManagementAPI;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Application;
|
import org.wso2.carbon.device.application.mgt.common.Application;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
|
||||||
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.ImageArtifact;
|
|
||||||
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.ResourceManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -56,7 +50,6 @@ import javax.ws.rs.Path;
|
|||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,22 +134,26 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
if (iconFile == null) {
|
if (iconFile == null) {
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"Icon file is not uploaded for the application release of " + application.getName() +
|
"Icon file is not uploaded for the application release of " + application.getName() +
|
||||||
" of application type " + application.getType()); }
|
" of application type " + application.getType());
|
||||||
|
}
|
||||||
|
|
||||||
if (bannerFile == null) {
|
if (bannerFile == null) {
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"Banner file is not uploaded for the application release of " + application.getName() +
|
"Banner file is not uploaded for the application release of " + application.getName() +
|
||||||
" of application type " + application.getType()); }
|
" of application type " + application.getType());
|
||||||
|
}
|
||||||
|
|
||||||
if (attachmentList == null || attachmentList.isEmpty()) {
|
if (attachmentList == null || attachmentList.isEmpty()) {
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"Screenshots are not uploaded for the application release of " + application.getName() +
|
"Screenshots are not uploaded for the application release of " + application.getName() +
|
||||||
" of application type " + application.getType()); }
|
" of application type " + application.getType());
|
||||||
|
}
|
||||||
|
|
||||||
if (binaryFile == null){
|
if (binaryFile == null) {
|
||||||
throw new ApplicationManagementException(
|
throw new ApplicationManagementException(
|
||||||
"Binary file is not uploaded for the application release of " + application.getName() +
|
"Binary file is not uploaded for the application release of " + application.getName() +
|
||||||
" of application type " + application.getType()); }
|
" of application type " + application.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
iconFileStream = iconFile.getDataHandler().getInputStream();
|
iconFileStream = iconFile.getDataHandler().getInputStream();
|
||||||
@ -169,7 +166,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
applicationRelease = applicationStorageManager.uploadReleaseArtifacts(applicationRelease,
|
applicationRelease = applicationStorageManager.uploadReleaseArtifacts(applicationRelease,
|
||||||
binaryFile.getDataHandler().getInputStream());
|
binaryFile.getDataHandler().getInputStream());
|
||||||
|
|
||||||
if(applicationRelease.getAppStoredLoc() == null || applicationRelease.getAppHashValue() == null){
|
if (applicationRelease.getAppStoredLoc() == null || applicationRelease.getAppHashValue() == null) {
|
||||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
}
|
}
|
||||||
applicationRelease = applicationStorageManager.uploadImageArtifacts(applicationRelease, iconFileStream,
|
applicationRelease = applicationStorageManager.uploadImageArtifacts(applicationRelease, iconFileStream,
|
||||||
@ -178,13 +175,13 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
applicationRelease.setUuid(UUID.randomUUID().toString());
|
applicationRelease.setUuid(UUID.randomUUID().toString());
|
||||||
Application createdApplication = applicationManager.createApplication(application);
|
Application createdApplication = applicationManager.createApplication(application);
|
||||||
|
|
||||||
if (application != null){
|
if (application != null) {
|
||||||
return Response.status(Response.Status.CREATED).entity(createdApplication).build();
|
return Response.status(Response.Status.CREATED).entity(createdApplication).build();
|
||||||
}else{
|
} else {
|
||||||
log.error("Given device type is not matched with existing device types");
|
log.error("Given device type is not matched with existing device types");
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
}
|
}
|
||||||
}catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while creating the application";
|
String msg = "Error occurred while creating the application";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
@ -311,50 +308,38 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
return Response.status(Response.Status.OK).entity(application).build();
|
return Response.status(Response.Status.OK).entity(application).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo this need to be rethink and fix --- > This is somthing change lifecycle
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{appuuid}")
|
@Path("/{appid}")
|
||||||
public Response deleteApplication(@PathParam("appuuid") String uuid) {
|
public Response deleteApplication(@PathParam("appid") int applicationId) {
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||||
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
|
|
||||||
try {
|
try {
|
||||||
applicationReleaseManager.deleteApplicationReleases(uuid);
|
applicationManager.deleteApplication(applicationId);
|
||||||
applicationStorageManager.deleteApplicationArtifacts(uuid);
|
// todo delete storage details
|
||||||
applicationManager.deleteApplication(uuid);
|
// applicationStorageManager.deleteApplicationArtifacts(uuid);
|
||||||
String responseMsg = "Successfully deleted the application: " + uuid;
|
String responseMsg = "Successfully deleted the application: " + applicationId;
|
||||||
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
||||||
} catch (NotFoundException e) {
|
|
||||||
return APIUtil.getResponse(e, Response.Status.NOT_FOUND);
|
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while deleting the application: " + uuid;
|
String msg = "Error occurred while deleting the application: " + applicationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
} catch (ApplicationStorageManagementException e) {
|
|
||||||
log.error("Error occurred while deleteing the image artifacts of the application with the uuid " + uuid, e);
|
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo I think we must remove this
|
@DELETE
|
||||||
@Override
|
@Path("/{appid}/{uuid}")
|
||||||
@PUT
|
public Response deleteApplicationRelease(@PathParam("appid") int applicationId, @PathParam("uuid") String releaseUuid) {
|
||||||
@Consumes("application/json")
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
@Path("/{uuid}/{version}/{channel}")
|
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
|
||||||
public Response updateDefaultVersion(@PathParam("uuid") String applicationUUID, @PathParam("version") String
|
|
||||||
version, @PathParam("channel") String channel, @QueryParam("isDefault") boolean isDefault) {
|
|
||||||
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
|
|
||||||
try {
|
try {
|
||||||
applicationReleaseManager.changeDefaultRelease(applicationUUID, version, isDefault, channel);
|
applicationManager.deleteApplication(applicationId);
|
||||||
return Response.status(Response.Status.OK)
|
// todo delete release storage details
|
||||||
.entity("Successfully changed the default version for the " + "release channel " + channel
|
// applicationStorageManager.deleteApplicationArtifacts(uuid);
|
||||||
+ " for the application UUID " + applicationUUID).build();
|
String responseMsg = "Successfully deleted the application release of: " + applicationId + "";
|
||||||
} catch (NotFoundException e) {
|
return Response.status(Response.Status.OK).entity(responseMsg).build();
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
log.error("Application Release Management Exception while changing the default release for the release "
|
String msg = "Error occurred while deleting the application: " + applicationId;
|
||||||
+ "channel " + channel + " for the application with UUID " + applicationUUID + " for the version "
|
log.error(msg, e);
|
||||||
+ version);
|
|
||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,4 +407,28 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
|
|||||||
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// todo I think we must remove this
|
||||||
|
@Override
|
||||||
|
@PUT
|
||||||
|
@Consumes("application/json")
|
||||||
|
@Path("/{uuid}/{version}/{channel}")
|
||||||
|
public Response updateDefaultVersion(@PathParam("uuid") String applicationUUID, @PathParam("version") String
|
||||||
|
version, @PathParam("channel") String channel, @QueryParam("isDefault") boolean isDefault) {
|
||||||
|
ApplicationReleaseManager applicationReleaseManager = APIUtil.getApplicationReleaseManager();
|
||||||
|
try {
|
||||||
|
applicationReleaseManager.changeDefaultRelease(applicationUUID, version, isDefault, channel);
|
||||||
|
return Response.status(Response.Status.OK)
|
||||||
|
.entity("Successfully changed the default version for the " + "release channel " + channel
|
||||||
|
+ " for the application UUID " + applicationUUID).build();
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).build();
|
||||||
|
} catch (ApplicationManagementException e) {
|
||||||
|
log.error("Application Release Management Exception while changing the default release for the release "
|
||||||
|
+ "channel " + channel + " for the application with UUID " + applicationUUID + " for the version "
|
||||||
|
+ version);
|
||||||
|
return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,50 +27,57 @@ import org.wso2.carbon.device.application.mgt.publisher.api.APIUtil;
|
|||||||
import org.wso2.carbon.device.application.mgt.publisher.api.services.LifecycleManagementAPI;
|
import org.wso2.carbon.device.application.mgt.publisher.api.services.LifecycleManagementAPI;
|
||||||
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.exception.LifecycleManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lifecycle Management related jax-rs APIs.
|
* Lifecycle Management related jax-rs APIs.
|
||||||
*/
|
*/
|
||||||
@Path("/lifecycles")
|
@Path("/lifecycle")
|
||||||
public class LifecycleManagementAPIImpl implements LifecycleManagementAPI {
|
public class LifecycleManagementAPIImpl implements LifecycleManagementAPI {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(LifecycleManagementAPIImpl.class);
|
private static Log log = LogFactory.getLog(LifecycleManagementAPIImpl.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
public Response getLifecycleStates() {
|
@Path("/{appId}/{uuid}")
|
||||||
return null;
|
public Response getLifecycleState(
|
||||||
// LifecycleStateManager lifecycleStateManager = APIUtil.getLifecycleStateManager();
|
@PathParam("appId") int applicationId,
|
||||||
// List<LifecycleState> lifecycleStates = new ArrayList<>();
|
@PathParam("uuid") String applicationUuid) {
|
||||||
// try {
|
LifecycleState lifecycleState;
|
||||||
// lifecycleStates = lifecycleStateManager.getLifecycleStates();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
// } catch (LifecycleManagementException e) {
|
try {
|
||||||
// String msg = "Error occurred while retrieving lifecycle states.";
|
lifecycleState = applicationManager.getLifecycleState(applicationId, applicationUuid);
|
||||||
// log.error(msg, e);
|
} catch (LifecycleManagementException e) {
|
||||||
// return Response.status(Response.Status.BAD_REQUEST).build();
|
String msg = "Error occurred while getting lifecycle state.";
|
||||||
// }
|
log.error(msg, e);
|
||||||
// return Response.status(Response.Status.OK).entity(lifecycleStates).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
|
}
|
||||||
|
return Response.status(Response.Status.OK).entity(lifecycleState).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
public Response addLifecycleState(LifecycleState state) {
|
@Path("/{appId}/{uuid}")
|
||||||
LifecycleStateManager lifecycleStateManager = APIUtil.getLifecycleStateManager();
|
public Response addLifecycleState(
|
||||||
|
@PathParam("appId") int applicationId,
|
||||||
|
@PathParam("uuid") String applicationUuid,
|
||||||
|
LifecycleState state) {
|
||||||
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
try {
|
try {
|
||||||
lifecycleStateManager.addLifecycleState(state);
|
applicationManager.addLifecycleState(applicationId, applicationUuid, state);
|
||||||
} catch (LifecycleManagementException e) {
|
} catch (LifecycleManagementException e) {
|
||||||
String msg = "Error occurred while adding lifecycle state.";
|
String msg = "Error occurred while adding lifecycle state.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity("Lifecycle state added successfully.").build();
|
return Response.status(Response.Status.CREATED).entity("Lifecycle state added successfully.").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//todo remove below part
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/{identifier}")
|
@Path("/{identifier}")
|
||||||
public Response deleteLifecycleState(@PathParam("identifier") String identifier) {
|
public Response deleteLifecycleState(@PathParam("identifier") String identifier) {
|
||||||
|
|||||||
@ -32,19 +32,19 @@
|
|||||||
|
|
||||||
<!-- Application related permissions -->
|
<!-- Application related permissions -->
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Get Application</name>
|
<name>Get Application Details</name>
|
||||||
<path>/device-mgt/application/get</path>
|
<path>/device-mgt/application/get</path>
|
||||||
<url>/application-mgt/applications</url>
|
<url>/application-mgt/applications</url>
|
||||||
<method>GET</method>
|
<method>GET</method>
|
||||||
</Permission>
|
</Permission>
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Create Application</name>
|
<name>Create an Application</name>
|
||||||
<path>/device-mgt/application/create</path>
|
<path>/device-mgt/application/create</path>
|
||||||
<url>/application-mgt/applications</url>
|
<url>/application-mgt/applications</url>
|
||||||
<method>POST</method>
|
<method>POST</method>
|
||||||
</Permission>
|
</Permission>
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Edit Application</name>
|
<name>Update an Application</name>
|
||||||
<path>/device-mgt/application/update</path>
|
<path>/device-mgt/application/update</path>
|
||||||
<url>/application-mgt/applications</url>
|
<url>/application-mgt/applications</url>
|
||||||
<method>PUT</method>
|
<method>PUT</method>
|
||||||
@ -56,55 +56,10 @@
|
|||||||
<method>PUT</method>
|
<method>PUT</method>
|
||||||
</Permission>
|
</Permission>
|
||||||
<Permission>
|
<Permission>
|
||||||
<name>Login to Application Management</name>
|
<name>Delete an Application</name>
|
||||||
<path>device-mgt/application/delete</path>
|
<path>device-mgt/application/delete</path>
|
||||||
<url>/application-mgt/applications/*</url>
|
<url>/application-mgt/applications/*</url>
|
||||||
<method>DELETE</method>
|
<method>DELETE</method>
|
||||||
</Permission>
|
</Permission>
|
||||||
|
|
||||||
<!-- Platform related permissions -->
|
|
||||||
<Permission>
|
|
||||||
<name>Get Platform</name>
|
|
||||||
<path>/device-mgt/platform/get</path>
|
|
||||||
<url>/application-mgt/platforms/*</url>
|
|
||||||
<method>GET</method>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Add Platform</name>
|
|
||||||
<path>/device-mgt/platform/add</path>
|
|
||||||
<url>/application-mgt/platforms</url>
|
|
||||||
<method>POST</method>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Update Platform</name>
|
|
||||||
<path>/device-mgt/platform/update</path>
|
|
||||||
<url>/application-mgt/platforms/*</url>
|
|
||||||
<method>PUT</method>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Remove Platform</name>
|
|
||||||
<path>/device-mgt/platform/remove</path>
|
|
||||||
<url>/application-mgt/platforms/*</url>
|
|
||||||
<method>DELETE</method>
|
|
||||||
</Permission>
|
|
||||||
|
|
||||||
<!-- Subscription related permissions -->
|
|
||||||
<Permission>
|
|
||||||
<name>Install Application</name>
|
|
||||||
<path>/device-mgt/subscription/install</path>
|
|
||||||
<url>/application-mgt/subscription</url>
|
|
||||||
<method>POST</method>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Uninstall Application</name>
|
|
||||||
<path>/device-mgt/subscription/uninstall</path>
|
|
||||||
<url>/application-mgt/subscription</url>
|
|
||||||
<method>POST</method>
|
|
||||||
</Permission>
|
|
||||||
<Permission>
|
|
||||||
<name>Get Application</name>
|
|
||||||
<path>/device-mgt/subscription/getApplication</path>
|
|
||||||
<url>/application-mgt/subscription</url>
|
|
||||||
<method>GET</method>
|
|
||||||
</Permission>
|
|
||||||
</PermissionConfiguration>
|
</PermissionConfiguration>
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
|
||||||
@ -39,7 +38,6 @@ public class APIUtil {
|
|||||||
private static Log log = LogFactory.getLog(APIUtil.class);
|
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||||
|
|
||||||
private static ApplicationManager applicationManager;
|
private static ApplicationManager applicationManager;
|
||||||
private static LifecycleStateManager lifecycleStateManager;
|
|
||||||
private static ApplicationReleaseManager applicationReleaseManager;
|
private static ApplicationReleaseManager applicationReleaseManager;
|
||||||
private static ApplicationStorageManager applicationStorageManager;
|
private static ApplicationStorageManager applicationStorageManager;
|
||||||
private static SubscriptionManager subscriptionManager;
|
private static SubscriptionManager subscriptionManager;
|
||||||
@ -55,18 +53,6 @@ public class APIUtil {
|
|||||||
return applicationManager;
|
return applicationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LifecycleStateManager getLifecycleStateManager() {
|
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
||||||
LifecycleStateManager lifecycleStateManager = (LifecycleStateManager) ctx
|
|
||||||
.getOSGiService(LifecycleStateManager.class, null);
|
|
||||||
if (lifecycleStateManager == null) {
|
|
||||||
String msg = "Lifecycle Manager service has not initialized.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new IllegalStateException(msg);
|
|
||||||
}
|
|
||||||
return lifecycleStateManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To get the Application Release Manager from the osgi context.
|
* To get the Application Release Manager from the osgi context.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user