Fix issues in lifecycle management feature

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 6d4252a5dd
commit 38006c8ff0

@ -144,7 +144,6 @@ public interface ApplicationManager {
/** /**
* To get all the releases of a particular ApplicationDTO. * To get all the releases of a particular ApplicationDTO.
* *
* @param applicationId ID of the ApplicationDTO.
* @param releaseUuid UUID of the ApplicationDTO Release. * @param releaseUuid UUID of the ApplicationDTO Release.
* @param stateName Lifecycle state to change the app * @param stateName Lifecycle state to change the app
* @throws ApplicationManagementException ApplicationDTO Management Exception. * @throws ApplicationManagementException ApplicationDTO Management Exception.

@ -129,6 +129,7 @@ public class Util {
*/ */
public static ApplicationReleaseDTO loadAppRelease(ResultSet rs) throws SQLException { public static ApplicationReleaseDTO loadAppRelease(ResultSet rs) throws SQLException {
ApplicationReleaseDTO appRelease = new ApplicationReleaseDTO(); ApplicationReleaseDTO appRelease = new ApplicationReleaseDTO();
appRelease.setId(rs.getInt("RELEASE_ID"));
appRelease.setDescription(rs.getString("RELEASE_DESCRIPTION")); appRelease.setDescription(rs.getString("RELEASE_DESCRIPTION"));
appRelease.setUuid(rs.getString("RELEASE_UUID")); appRelease.setUuid(rs.getString("RELEASE_UUID"));
appRelease.setReleaseType(rs.getString("RELEASE_TYPE")); appRelease.setReleaseType(rs.getString("RELEASE_TYPE"));

@ -144,6 +144,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "AP_APP.CURRENCY AS APP_CURRENCY, " + "AP_APP.CURRENCY AS APP_CURRENCY, "
+ "AP_APP.RATING AS APP_RATING, " + "AP_APP.RATING AS APP_RATING, "
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, " + "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, " + "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, " + "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, " + "AP_APP_RELEASE.UUID AS RELEASE_UUID, "
@ -502,6 +503,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "AP_APP.CURRENCY AS APP_CURRENCY, " + "AP_APP.CURRENCY AS APP_CURRENCY, "
+ "AP_APP.RATING AS APP_RATING, " + "AP_APP.RATING AS APP_RATING, "
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, " + "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, " + "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, " + "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, " + "AP_APP_RELEASE.UUID AS RELEASE_UUID, "

@ -226,7 +226,8 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
public ApplicationReleaseDTO getReleaseByUUID( String uuid, int tenantId) throws ApplicationManagementDAOException { public ApplicationReleaseDTO getReleaseByUUID( String uuid, int tenantId) throws ApplicationManagementDAOException {
Connection connection; Connection connection;
String sql = String sql =
"SELECT AR.DESCRIPTION AS RELEASE_DESCRIPTION, " "SELECT AR.ID AS RELEASE_ID, "
+ "AR.DESCRIPTION AS RELEASE_DESCRIPTION, "
+ "AR.VERSION AS RELEASE_VERSION, " + "AR.VERSION AS RELEASE_VERSION, "
+ "AR.UUID AS RELEASE_UUID, " + "AR.UUID AS RELEASE_UUID, "
+ "AR.RELEASE_TYPE AS RELEASE_TYPE, " + "AR.RELEASE_TYPE AS RELEASE_TYPE, "

@ -1625,6 +1625,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationReleaseDTO.setCurrentState(stateName); applicationReleaseDTO.setCurrentState(stateName);
this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId); this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId);
this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId); this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
ConnectionManagerUtil.commitDBTransaction();
} else { } else {
String msg = "Invalid lifecycle state transition from '" + applicationReleaseDTO.getCurrentState() + "'" String msg = "Invalid lifecycle state transition from '" + applicationReleaseDTO.getCurrentState() + "'"
+ " to '" + stateName + "'"; + " to '" + stateName + "'";

@ -47,7 +47,7 @@ public class LifecycleStateManager {
if (lifecycleState.getProceedingStates() != null) { if (lifecycleState.getProceedingStates() != null) {
lifecycleState.getProceedingStates().replaceAll(String::toUpperCase); lifecycleState.getProceedingStates().replaceAll(String::toUpperCase);
} }
lifecycleStates.put(lifecycleState.getName(), lifecycleState); lifecycleStates.put(lifecycleState.getName().toUpperCase(), lifecycleState);
try { try {
PermissionUtils.putPermission(lifecycleState.getPermission()); PermissionUtils.putPermission(lifecycleState.getPermission());
} catch (PermissionManagementException e) { } catch (PermissionManagementException e) {
@ -123,15 +123,10 @@ public class LifecycleStateManager {
} }
private String getPermissionForStateChange(String nextState) { private String getPermissionForStateChange(String nextState) {
Iterator it = lifecycleStates.entrySet().iterator(); for (Map.Entry<String, LifecycleState> lifecycyleState : lifecycleStates.entrySet()) {
LifecycleState nextLifecycleState; if (lifecycyleState.getKey().equalsIgnoreCase(nextState)) {
while (it.hasNext()) { return lifecycyleState.getValue().getPermission();
Map.Entry pair = (Map.Entry) it.next(); }
if (pair.getKey().toString().equalsIgnoreCase(nextState)) {
nextLifecycleState = lifecycleStates.get(nextState);
return nextLifecycleState.getPermission();
}
it.remove();
} }
return null; return null;
} }

Loading…
Cancel
Save