use of org.craftercms.studio.api.v1.dal.ItemMetadata in project studio by craftercms.
the class DashboardServiceImpl method preparePublishingResult.
private List<PublishingDashboardItem> preparePublishingResult(List<PublishingHistoryItem> publishingHistory) {
List<PublishingDashboardItem> publishingDashboardItems = new ArrayList<PublishingDashboardItem>();
for (PublishingHistoryItem historyItem : publishingHistory) {
PublishingDashboardItem dashboardItem = new PublishingDashboardItem();
ItemMetadata itemMetadata = objectMetadataManager.getProperties(historyItem.getSiteId(), historyItem.getPath());
dashboardItem.setSiteId(historyItem.getSiteId());
dashboardItem.setPath(historyItem.getPath());
dashboardItem.setLabel(itemMetadata.getName());
dashboardItem.setEnvironment(historyItem.getEnvironment());
dashboardItem.setPublishedDate(historyItem.getPublishedDate());
dashboardItem.setPublisher(historyItem.getPublisher());
publishingDashboardItems.add(dashboardItem);
}
return publishingDashboardItems;
}
use of org.craftercms.studio.api.v1.dal.ItemMetadata in project studio by craftercms.
the class DashboardServiceImpl method prepareContentDashboardResult.
private List<ContentDashboardItem> prepareContentDashboardResult(List<ItemMetadata> itemMetadataList) {
List<ContentDashboardItem> contentDashboardItemList = new ArrayList<ContentDashboardItem>();
if (itemMetadataList != null && itemMetadataList.size() > 0) {
for (ItemMetadata item : itemMetadataList) {
ContentDashboardItem contentDashboardItem = new ContentDashboardItem();
contentDashboardItem.setSiteId(item.getSite());
contentDashboardItem.setPath(item.getPath());
contentDashboardItem.setLabel(item.getName());
contentDashboardItem.setModifier(item.getModifier());
contentDashboardItem.setModifiedDate(item.getModified());
contentDashboardItemList.add(contentDashboardItem);
}
}
return contentDashboardItemList;
}
use of org.craftercms.studio.api.v1.dal.ItemMetadata in project studio by craftercms.
the class PublishServiceImpl method preparePublishingResult.
private List<PublishingDashboardItem> preparePublishingResult(List<PublishingHistoryItem> publishingHistory) {
List<PublishingDashboardItem> publishingDashboardItems = new ArrayList<PublishingDashboardItem>();
for (PublishingHistoryItem historyItem : publishingHistory) {
PublishingDashboardItem dashboardItem = new PublishingDashboardItem();
ItemMetadata itemMetadata = objectMetadataManager.getProperties(historyItem.getSiteId(), historyItem.getPath());
dashboardItem.setSiteId(historyItem.getSiteId());
dashboardItem.setPath(historyItem.getPath());
dashboardItem.setLabel(itemMetadata.getName());
dashboardItem.setEnvironment(historyItem.getEnvironment());
dashboardItem.setPublishedDate(historyItem.getPublishedDate());
dashboardItem.setPublisher(historyItem.getPublisher());
publishingDashboardItems.add(dashboardItem);
}
return publishingDashboardItems;
}
use of org.craftercms.studio.api.v1.dal.ItemMetadata in project studio by craftercms.
the class ContentServiceImpl method populateMetadata.
protected void populateMetadata(String site, ContentItemTO item) {
// TODO: SJ: Refactor to return a ContentItemTO instead of changing the parameter
// TODO: SJ: Change method name to be getContentItemMetadata or similar
// TODO: SJ: 3.1+
// TODO: SJ: Create a method String getValueIfNotNull(String) to use to return not null/empty string if null
// TODO: SJ: Use that method to reduce redundant code here. 3.1+
ItemMetadata metadata = objectMetadataManager.getProperties(site, item.getUri());
if (metadata != null) {
// database if it's not null
if (StringUtils.isEmpty(metadata.getLockOwner())) {
item.setLockOwner("");
} else {
item.setLockOwner(metadata.getLockOwner());
}
// Set the scheduled date
if (metadata.getLaunchDate() != null) {
item.scheduledDate = metadata.getLaunchDate();
item.setScheduledDate(metadata.getLaunchDate());
}
if (metadata.getPublishedDate() != null) {
item.published = true;
item.setPublished(true);
item.publishedDate = metadata.getPublishedDate();
item.setPublishedDate(metadata.getPublishedDate());
}
// Set the modifier (user) if known
if (StringUtils.isEmpty(metadata.getModifier())) {
item.setUser("");
item.setUserLastName("");
item.setUserFirstName("");
} else {
item.user = metadata.getModifier();
item.setUser(metadata.getModifier());
if (StringUtils.isEmpty(metadata.getFirstName())) {
item.userFirstName = metadata.getModifier();
item.setUserFirstName(metadata.getModifier());
} else {
item.userFirstName = metadata.getFirstName();
item.setUserFirstName(metadata.getFirstName());
}
if (StringUtils.isEmpty(metadata.getLastName())) {
item.userLastName = "";
item.setUserLastName("");
} else {
item.userLastName = metadata.getLastName();
item.setUserLastName(metadata.getLastName());
}
}
if (metadata.getModified() != null) {
item.lastEditDate = metadata.getModified();
item.eventDate = metadata.getModified();
item.setLastEditDate(metadata.getModified());
item.setEventDate(metadata.getModified());
}
if (StringUtils.isNotEmpty(metadata.getSubmissionComment())) {
item.setSubmissionComment(metadata.getSubmissionComment());
}
if (StringUtils.isNotEmpty(metadata.getSubmittedToEnvironment())) {
item.setSubmittedToEnvironment(metadata.getSubmittedToEnvironment());
}
} else {
item.setLockOwner("");
}
}
use of org.craftercms.studio.api.v1.dal.ItemMetadata in project studio by craftercms.
the class ContentServiceImpl method updateDatabaseOnMove.
protected void updateDatabaseOnMove(String site, String fromPath, String movePath) throws SiteNotFoundException {
logger.debug("updateDatabaseOnMove FROM {0} TO {1} ", fromPath, movePath);
String user = securityService.getCurrentUser();
Map<String, String> params = new HashMap<>();
params.put(DmConstants.KEY_SOURCE_PATH, fromPath);
params.put(DmConstants.KEY_TARGET_PATH, movePath);
// These do not exist in 3.0, note some extensions may be using it
// params.put(DmConstants.KEY_SOURCE_FULL_PATH, expandRelativeSitePath(site, fromPath));
// params.put(DmConstants.KEY_TARGET_FULL_PATH, expandRelativeSitePath(site, movePath));
ContentItemTO renamedItem = getContentItem(site, movePath, 0);
String contentType = renamedItem.getContentType();
if (!renamedItem.isFolder()) {
dmContentLifeCycleService.process(site, user, movePath, contentType, DmContentLifeCycleService.ContentLifeCycleOperation.RENAME, params);
// change the path of this object in the object state database
objectStateService.updateObjectPath(site, fromPath, movePath);
objectStateService.transition(site, renamedItem, SAVE);
renamedItem = getContentItem(site, movePath, 0);
}
// update metadata
if (!objectMetadataManager.isRenamed(site, fromPath)) {
// if an item was previously moved, we do not track intermediate moves because it will
// ultimately orphan deployed content. Old Path is always the OLDEST DEPLOYED PATH
ItemMetadata metadata = objectMetadataManager.getProperties(site, fromPath);
if (metadata == null && !renamedItem.isFolder()) {
if (!objectMetadataManager.metadataExist(site, fromPath)) {
objectMetadataManager.insertNewObjectMetadata(site, fromPath);
}
metadata = objectMetadataManager.getProperties(site, fromPath);
}
if (!renamedItem.isNew() && !renamedItem.isFolder()) {
// if the item is not new, we need to track the old URL for deployment
logger.debug("item is not new, and has not previously been moved. Track the old URL {0}", fromPath);
Map<String, Object> objMetadataProps = new HashMap<String, Object>();
objMetadataProps.put(ItemMetadata.PROP_RENAMED, 1);
objMetadataProps.put(ItemMetadata.PROP_OLD_URL, fromPath);
objectMetadataManager.setObjectMetadata(site, fromPath, objMetadataProps);
}
}
if (!renamedItem.isFolder()) {
if (objectMetadataManager.metadataExist(site, movePath)) {
if (!StringUtils.equalsIgnoreCase(fromPath, movePath)) {
objectMetadataManager.deleteObjectMetadata(site, movePath);
}
}
objectMetadataManager.updateObjectPath(site, fromPath, movePath);
}
// write activity stream
SiteFeed siteFeed = siteService.getSite(site);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_MOVE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(user);
auditLog.setPrimaryTargetId(site + ":" + movePath);
if (renamedItem.isFolder()) {
auditLog.setPrimaryTargetType(TARGET_TYPE_FOLDER);
} else {
auditLog.setPrimaryTargetType(TARGET_TYPE_CONTENT_ITEM);
}
auditLog.setPrimaryTargetValue(movePath);
auditLog.setPrimaryTargetSubtype(getContentTypeClass(site, movePath));
auditServiceInternal.insertAuditLog(auditLog);
updateDependenciesOnMove(site, fromPath, movePath);
}
Aggregations