use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class DeploymentServiceImpl method createDeploymentTask.
/**
* create WcmDeploymentTask
*
* @param deployedLabel
* @param item
* @return deployment task
*/
protected DmDeploymentTaskTO createDeploymentTask(String deployedLabel, ContentItemTO item) {
// otherwise just add as the last task
DmDeploymentTaskTO task = new DmDeploymentTaskTO();
task.setInternalName(deployedLabel);
List<ContentItemTO> taskItems = task.getChildren();
if (taskItems == null) {
taskItems = new ArrayList<ContentItemTO>();
task.setChildren(taskItems);
}
taskItems.add(item);
task.setNumOfChildren(taskItems.size());
return task;
}
use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class DeploymentServiceImpl method getScheduledItems.
@Override
@ValidateParams
public List<ContentItemTO> getScheduledItems(@ValidateStringParam(name = "site") String site, @ValidateStringParam(name = "sort") String sort, boolean ascending, @ValidateStringParam(name = "subSort") String subSort, boolean subAscending, @ValidateStringParam(name = "filterType") String filterType) throws ServiceLayerException {
if (StringUtils.isEmpty(sort)) {
sort = DmContentItemComparator.SORT_EVENT_DATE;
}
DmContentItemComparator comparator = new DmContentItemComparator(sort, ascending, true, true);
DmContentItemComparator subComparator = new DmContentItemComparator(subSort, subAscending, true, true);
List<ContentItemTO> items = null;
items = getScheduledItems(site, comparator, subComparator, filterType);
return items;
}
use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class DeploymentServiceImpl method createDateItem.
protected ContentItemTO createDateItem(String name, ContentItemTO itemToAdd, DmContentItemComparator comparator, String timeZone) {
ContentItemTO dateItem = new ContentItemTO();
dateItem.name = name;
dateItem.internalName = name;
dateItem.eventDate = itemToAdd.scheduledDate;
dateItem.scheduledDate = itemToAdd.scheduledDate;
dateItem.timezone = timeZone;
dateItem.addChild(itemToAdd, comparator, false);
return dateItem;
}
use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class DeploymentServiceImpl method getDeploymentHistory.
@Override
@ValidateParams
public List<DmDeploymentTaskTO> getDeploymentHistory(@ValidateStringParam(name = "site") String site, @ValidateIntegerParam(name = "daysFromToday") int daysFromToday, @ValidateIntegerParam(name = "numberOfItems") int numberOfItems, @ValidateStringParam(name = "sort") String sort, boolean ascending, @ValidateStringParam(name = "filterType") String filterType) throws SiteNotFoundException {
// get the filtered list of attempts in a specific date range
ZonedDateTime toDate = ZonedDateTime.now(ZoneOffset.UTC);
ZonedDateTime fromDate = toDate.minusDays(daysFromToday);
List<DeploymentSyncHistory> deployReports = deploymentHistoryProvider.getDeploymentHistory(site, getEnvironmentNames(site), fromDate, toDate, dmFilterWrapper, filterType, numberOfItems);
List<DmDeploymentTaskTO> tasks = new ArrayList<DmDeploymentTaskTO>();
if (deployReports != null) {
int count = 0;
String timezone = servicesConfig.getDefaultTimezone(site);
Map<String, Set<String>> processedItems = new HashMap<String, Set<String>>();
for (int index = 0; index < deployReports.size() && count < numberOfItems; index++) {
DeploymentSyncHistory entry = deployReports.get(index);
String env = entry.getEnvironment();
if (!processedItems.containsKey(env)) {
processedItems.put(env, new HashSet<String>());
}
if (!processedItems.get(env).contains(entry.getPath())) {
ContentItemTO deployedItem = getDeployedItem(entry.getSite(), entry.getPath());
if (deployedItem != null) {
deployedItem.eventDate = entry.getSyncDate();
deployedItem.endpoint = entry.getTarget();
deployedItem.setUser(entry.getUser());
deployedItem.setEndpoint(entry.getEnvironment());
String deployedLabel = entry.getSyncDate().withZoneSameInstant(ZoneId.of(timezone)).format(ISO_OFFSET_DATE);
if (tasks.size() > 0) {
DmDeploymentTaskTO lastTask = tasks.get(tasks.size() - 1);
String lastDeployedLabel = lastTask.getInternalName();
if (lastDeployedLabel.equals(deployedLabel)) {
// add to the last task if it is deployed on the same day
lastTask.setNumOfChildren(lastTask.getNumOfChildren() + 1);
lastTask.getChildren().add(deployedItem);
} else {
tasks.add(createDeploymentTask(deployedLabel, deployedItem));
}
} else {
tasks.add(createDeploymentTask(deployedLabel, deployedItem));
}
processedItems.get(env).add(entry.getPath());
}
}
}
}
return tasks;
}
use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class WorkflowServiceImpl method rejectThisAndReferences.
protected void rejectThisAndReferences(String site, DmDependencyTO dmDependencyTO, DependencyRules rule, String approver, String reason) {
_reject(site, dmDependencyTO, approver, true, reason);
Set<DmDependencyTO> dependencyTOSet = rule.applyRejectRule(dmDependencyTO);
for (DmDependencyTO dependencyTO : dependencyTOSet) {
boolean lsendEmail = true;
try {
ContentItemTO contentItem = contentService.getContentItem(site, dependencyTO.getUri());
lsendEmail = !contentItem.isDocument() && !contentItem.isComponent() && !contentItem.isAsset();
} catch (Exception e) {
logger.error("during rejection, content retrieve failed");
lsendEmail = false;
}
_reject(site, dependencyTO, approver, lsendEmail, reason);
}
}
Aggregations