|
|
@ -126,7 +126,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
if (deviceType == null) {
|
|
|
|
if (deviceType == null) {
|
|
|
|
log.error("Device type is not matched with application type");
|
|
|
|
log.error("Device type is not matched with application type");
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!application.getUnrestrictedRoles().isEmpty()) {
|
|
|
|
if (!application.getUnrestrictedRoles().isEmpty()) {
|
|
|
@ -166,7 +165,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Changing lifecycle state. App Id:" + appId);
|
|
|
|
log.debug("Changing lifecycle state. App Id:" + appId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstant(AppLifecycleState.CREATED.toString(),
|
|
|
|
//todo get initial state from lifecycle manager and set current state to Release object
|
|
|
|
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(),
|
|
|
|
AppLifecycleState.CREATED.toString());
|
|
|
|
AppLifecycleState.CREATED.toString());
|
|
|
|
this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationRelease.getUuid(), tenantId);
|
|
|
|
this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationRelease.getUuid(), tenantId);
|
|
|
|
applicationRelease.setLifecycleState(lifecycleState);
|
|
|
|
applicationRelease.setLifecycleState(lifecycleState);
|
|
|
@ -305,7 +305,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationRelease = this.applicationReleaseDAO
|
|
|
|
applicationRelease = this.applicationReleaseDAO
|
|
|
|
.createRelease(applicationRelease, existingApplication.getId(), tenantId);
|
|
|
|
.createRelease(applicationRelease, existingApplication.getId(), tenantId);
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstant(AppLifecycleState.CREATED.toString(),
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(),
|
|
|
|
AppLifecycleState.CREATED.toString());
|
|
|
|
AppLifecycleState.CREATED.toString());
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), tenantId);
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), tenantId);
|
|
|
@ -583,7 +583,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
for (ApplicationRelease applicationRelease : applicationReleases) {
|
|
|
|
LifecycleState appLifecycleState = this.lifecycleStateDAO
|
|
|
|
LifecycleState appLifecycleState = this.lifecycleStateDAO
|
|
|
|
.getLatestLifeCycleState(applicationId, applicationRelease.getUuid());
|
|
|
|
.getLatestLifeCycleState(applicationId, applicationRelease.getUuid());
|
|
|
|
LifecycleState newAppLifecycleState = getLifecycleStateInstant(AppLifecycleState.REMOVED.toString(),
|
|
|
|
LifecycleState newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(),
|
|
|
|
appLifecycleState.getCurrentState());
|
|
|
|
appLifecycleState.getCurrentState());
|
|
|
|
if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(),
|
|
|
|
if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(),
|
|
|
|
newAppLifecycleState.getCurrentState())) {
|
|
|
|
newAppLifecycleState.getCurrentState())) {
|
|
|
@ -595,7 +595,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
List<String> lifecycleFlow = searchLifecycleStateFlow(currentState,
|
|
|
|
List<String> lifecycleFlow = searchLifecycleStateFlow(currentState,
|
|
|
|
AppLifecycleState.REMOVED.toString());
|
|
|
|
AppLifecycleState.REMOVED.toString());
|
|
|
|
for (String nextState : lifecycleFlow) {
|
|
|
|
for (String nextState : lifecycleFlow) {
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstant(nextState, currentState);
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(nextState, currentState);
|
|
|
|
if (lifecycleStateManger.isValidStateChange(currentState, nextState)) {
|
|
|
|
if (lifecycleStateManger.isValidStateChange(currentState, nextState)) {
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(),
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(),
|
|
|
@ -712,7 +712,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
String currentState = appLifecycleState.getCurrentState();
|
|
|
|
String currentState = appLifecycleState.getCurrentState();
|
|
|
|
if (AppLifecycleState.DEPRECATED.toString().equals(currentState) || AppLifecycleState.REJECTED.toString()
|
|
|
|
if (AppLifecycleState.DEPRECATED.toString().equals(currentState) || AppLifecycleState.REJECTED.toString()
|
|
|
|
.equals(currentState) || AppLifecycleState.UNPUBLISHED.toString().equals(currentState)) {
|
|
|
|
.equals(currentState) || AppLifecycleState.UNPUBLISHED.toString().equals(currentState)) {
|
|
|
|
LifecycleState newAppLifecycleState = getLifecycleStateInstant(AppLifecycleState.REMOVED.toString(),
|
|
|
|
LifecycleState newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(),
|
|
|
|
appLifecycleState.getCurrentState());
|
|
|
|
appLifecycleState.getCurrentState());
|
|
|
|
if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(),
|
|
|
|
if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(),
|
|
|
|
newAppLifecycleState.getCurrentState())) {
|
|
|
|
newAppLifecycleState.getCurrentState())) {
|
|
|
@ -724,7 +724,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
List<String> lifecycleFlow = searchLifecycleStateFlow(currentState,
|
|
|
|
List<String> lifecycleFlow = searchLifecycleStateFlow(currentState,
|
|
|
|
AppLifecycleState.REMOVED.toString());
|
|
|
|
AppLifecycleState.REMOVED.toString());
|
|
|
|
for (String nextState : lifecycleFlow) {
|
|
|
|
for (String nextState : lifecycleFlow) {
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstant(nextState, currentState);
|
|
|
|
LifecycleState lifecycleState = getLifecycleStateInstance(nextState, currentState);
|
|
|
|
if (lifecycleStateManger.isValidStateChange(currentState, nextState)) {
|
|
|
|
if (lifecycleStateManger.isValidStateChange(currentState, nextState)) {
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
this.lifecycleStateDAO
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(),
|
|
|
|
.addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(),
|
|
|
@ -1237,7 +1237,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
* @param previousState Previouse state of the Lifecycle
|
|
|
|
* @param previousState Previouse state of the Lifecycle
|
|
|
|
* @return {@link LifecycleState}
|
|
|
|
* @return {@link LifecycleState}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private LifecycleState getLifecycleStateInstant(String currentState, String previousState) {
|
|
|
|
private LifecycleState getLifecycleStateInstance(String currentState, String previousState) {
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
LifecycleState lifecycleState = new LifecycleState();
|
|
|
|
LifecycleState lifecycleState = new LifecycleState();
|
|
|
|
lifecycleState.setCurrentState(currentState);
|
|
|
|
lifecycleState.setCurrentState(currentState);
|
|
|
|