use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method isUpdatedOrNew.
@Override
@ValidateParams
public boolean isUpdatedOrNew(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path) {
path = FilenameUtils.normalize(path, true);
ItemState state = getObjectState(site, path);
if (state != null) {
return State.isUpdateOrNew(State.valueOf(state.getState()));
} else {
return false;
}
}
use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method insertNewEntry.
@Override
@ValidateParams
public void insertNewEntry(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path) {
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 state = itemStateMapper.getObjectStateBySiteAndPath(params);
if (state == null) {
ItemState newEntry = new ItemState();
newEntry.setObjectId(UUID.randomUUID().toString());
newEntry.setSite(site);
newEntry.setPath(itemPath);
newEntry.setSystemProcessing(0);
newEntry.setState(State.NEW_UNPUBLISHED_UNLOCKED.name());
itemStateMapper.insertEntry(newEntry);
}
} finally {
generalLockService.unlock(lockKey);
}
}
use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method getObjectState.
@Override
@ValidateParams
public ItemState getObjectState(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, boolean insert) {
String cleanPath = FilenameUtils.normalize(path, true);
String lockId = site + ":" + cleanPath;
ItemState state = null;
Map<String, String> params = new HashMap<String, String>();
params.put("site", site);
params.put("path", cleanPath);
state = itemStateMapper.getObjectStateBySiteAndPath(params);
if (state == null && insert) {
if (contentService.contentExists(site, cleanPath)) {
ContentItemTO item = contentService.getContentItem(site, cleanPath, 0);
if (!item.isFolder()) {
insertNewEntry(site, item);
state = itemStateMapper.getObjectStateBySiteAndPath(params);
}
}
}
return state;
}
use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method isInWorkflow.
@Override
@ValidateParams
public boolean isInWorkflow(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path) {
path = FilenameUtils.normalize(path, true);
ItemState state = getObjectState(site, path);
if (state != null) {
return State.isInWorkflow(State.valueOf(state.getState()));
} else {
return false;
}
}
use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method isSubmitted.
@Override
@ValidateParams
public boolean isSubmitted(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path) {
path = FilenameUtils.normalize(path, true);
ItemState state = getObjectState(site, path);
if (state != null) {
return State.isSubmitted(State.valueOf(state.getState()));
} else {
return false;
}
}
Aggregations