use of org.craftercms.studio.api.v2.annotation.RetryingOperation in project studio by craftercms.
the class PublishingManagerImpl method markItemsReady.
@RetryingOperation
@Override
@ValidateParams
public void markItemsReady(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "environment") String environment, List<PublishRequest> copyToEnvironmentItems) throws DeploymentException {
for (PublishRequest item : copyToEnvironmentItems) {
item.setState(READY_FOR_LIVE);
publishRequestMapper.updateItemDeploymentState(item);
}
}
use of org.craftercms.studio.api.v2.annotation.RetryingOperation in project studio by craftercms.
the class PublishingManagerImpl method markItemsProcessing.
@RetryingOperation
@Override
@ValidateParams
public void markItemsProcessing(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "environment") String environment, List<PublishRequest> itemsToDeploy) throws DeploymentException {
for (PublishRequest item : itemsToDeploy) {
item.setState(PublishRequest.State.PROCESSING);
publishRequestMapper.updateItemDeploymentState(item);
}
}
use of org.craftercms.studio.api.v2.annotation.RetryingOperation in project studio by craftercms.
the class PublishingManagerImpl method markItemsBlocked.
@RetryingOperation
@Override
@ValidateParams
public void markItemsBlocked(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "environment") String environment, List<PublishRequest> copyToEnvironmentItems) throws DeploymentException {
for (PublishRequest item : copyToEnvironmentItems) {
item.setState(PublishRequest.State.BLOCKED);
publishRequestMapper.updateItemDeploymentState(item);
}
}
use of org.craftercms.studio.api.v2.annotation.RetryingOperation in project studio by craftercms.
the class ObjectStateServiceImpl method transition.
@RetryingOperation
@Override
@ValidateParams
public void transition(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, TransitionEvent event) {
String itemPath = FilenameUtils.normalize(path, true);
String lockKey = site + ":" + path;
generalLockService.lock(lockKey);
try {
Map<String, String> params = new HashMap<String, String>();
params.put("site", site);
params.put("path", itemPath);
ItemState currentState = itemStateMapper.getObjectStateBySiteAndPath(params);
State nextState = null;
if (currentState == null) {
logger.debug("Preforming transition event " + event.name() + " on object " + lockKey + " without current state");
switch(event) {
case SAVE:
nextState = State.NEW_UNPUBLISHED_UNLOCKED;
break;
case SAVE_FOR_PREVIEW:
nextState = State.NEW_UNPUBLISHED_LOCKED;
break;
default:
nextState = State.NEW_UNPUBLISHED_UNLOCKED;
}
} else {
logger.debug("Preforming transition event " + event + " on object " + lockKey + " with " + currentState.getState() + " state");
State currentStateValue = State.valueOf(currentState.getState());
nextState = transitionTable[currentStateValue.ordinal()][event.ordinal()];
}
if (currentState == null) {
ItemState newEntry = new ItemState();
newEntry.setObjectId(UUID.randomUUID().toString());
newEntry.setSite(site);
newEntry.setPath(itemPath);
newEntry.setSystemProcessing(0);
newEntry.setState(nextState.name());
itemStateMapper.insertEntry(newEntry);
} else if (nextState.toString() != currentState.getState() && nextState != State.NOOP) {
currentState.setState(nextState.name());
itemStateMapper.setObjectState(currentState);
} else if (nextState == State.NOOP) {
logger.warn("Transition not defined for event " + event.name() + " and current state " + currentState.getState() + " [object id: " + currentState.getObjectId() + "]");
}
} catch (Exception e) {
logger.error("Transition not defined for event", e);
} finally {
generalLockService.unlock(lockKey);
}
logger.debug("Transition finished for " + event.name() + " on object " + lockKey);
}
use of org.craftercms.studio.api.v2.annotation.RetryingOperation in project studio by craftercms.
the class ObjectStateServiceImpl method setObjectState.
@RetryingOperation
@Override
@ValidateParams
public String setObjectState(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, @ValidateStringParam(name = "state") String state, boolean systemProcessing) {
path = FilenameUtils.normalize(path, true);
Map<String, String> params = new HashMap<String, String>();
params.put("site", site);
params.put("path", path);
ItemState objectState = itemStateMapper.getObjectStateBySiteAndPath(params);
if (objectState == null) {
insertNewEntry(site, path);
objectState = itemStateMapper.getObjectStateBySiteAndPath(params);
}
objectState.setState(state);
objectState.setSystemProcessing(systemProcessing ? 1 : 0);
itemStateMapper.setObjectState(objectState);
return "Success";
}
Aggregations