use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class AuditServiceImpl method getActivityFeeds.
protected boolean getActivityFeeds(String user, String site, int startPos, int size, String filterType, boolean hideLiveItems, List<ContentItemTO> contentItems, int remainingItem) {
List<AuditLog> activityFeeds = auditServiceInternal.selectUserFeedEntries(user, site, startPos, size, filterType, hideLiveItems);
boolean hasMoreItems = true;
// if number of items returned is less than size it means that table has no more records
if (activityFeeds.size() < size) {
hasMoreItems = false;
}
if (activityFeeds != null && activityFeeds.size() > 0) {
for (int index = 0; index < activityFeeds.size() && remainingItem != 0; index++) {
AuditLog auditLog = activityFeeds.get(index);
String id = auditLog.getPrimaryTargetValue();
ContentItemTO item = createActivityItem(site, auditLog, id);
contentItems.add(item);
remainingItem--;
}
}
logger.debug("Total Item post live filter : " + contentItems.size() + " hasMoreItems : " + hasMoreItems);
return hasMoreItems;
}
use of org.craftercms.studio.api.v1.to.ContentItemTO 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.to.ContentItemTO in project studio by craftercms.
the class ContentServiceImpl method loadContentTypeProperties.
protected void loadContentTypeProperties(String site, ContentItemTO item, String contentType) {
// TODO: SJ: Refactor in 2.7.x
if (item.isFolder()) {
item.setContentType(CONTENT_TYPE_FOLDER);
} else {
if (contentType != null && !contentType.equals(CONTENT_TYPE_FOLDER) && !contentType.equals("asset") && !contentType.equals(CONTENT_TYPE_UNKNOWN)) {
ContentTypeConfigTO config = servicesConfig.getContentTypeConfig(site, contentType);
if (config != null) {
item.setForm(config.getForm());
item.setFormPagePath(config.getFormPath());
item.setPreviewable(config.isPreviewable());
item.isPreviewable = item.previewable;
}
} else {
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
String mimeType = mimeTypesMap.getContentType(item.getName());
if (mimeType != null && !StringUtils.isEmpty(mimeType)) {
item.setPreviewable(ContentUtils.matchesPatterns(mimeType, servicesConfig.getPreviewableMimetypesPaterns(site)));
item.isPreviewable = item.previewable;
}
}
}
// TODO CodeRev:but what if the config is null?
}
use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class ContentServiceImpl method loadContentItem.
protected ContentItemTO loadContentItem(String site, String path) {
// TODO: SJ: Refactor such that the populate of non-XML is also a method in 3.1+
ContentItemTO item = createNewContentItemTO(site, path);
if (item.uri.endsWith(".xml") && !item.uri.startsWith("/config/")) {
try {
item = populateContentDrivenProperties(site, item);
} catch (Exception err) {
logger.debug("error constructing item for object at site '{}' path '{}'", err, site, path);
}
} else {
item.setLevelDescriptor(item.name.equals(servicesConfig.getLevelDescriptorName(site)));
item.page = ContentUtils.matchesPatterns(item.getUri(), servicesConfig.getPagePatterns(site));
item.isPage = item.page;
item.previewable = item.page;
item.isPreviewable = item.previewable;
item.asset = ContentUtils.matchesPatterns(item.getUri(), servicesConfig.getAssetPatterns(site)) || ContentUtils.matchesPatterns(item.getUri(), servicesConfig.getRenderingTemplatePatterns(site)) || ContentUtils.matchesPatterns(item.getUri(), servicesConfig.getScriptsPatterns(site));
item.isAsset = item.asset;
item.component = ContentUtils.matchesPatterns(item.getUri(), servicesConfig.getComponentPatterns(site)) || item.isLevelDescriptor() || item.asset;
item.isComponent = item.component;
item.document = ContentUtils.matchesPatterns(item.getUri(), servicesConfig.getDocumentPatterns(site));
item.isDocument = item.document;
item.browserUri = item.getUri();
item.setContentType(getContentTypeClass(site, path));
}
loadContentTypeProperties(site, item, item.contentType);
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
String mimeType = mimeTypesMap.getContentType(item.getName());
if (StringUtils.isNotEmpty(mimeType)) {
item.setMimeType(mimeType);
}
return item;
}
use of org.craftercms.studio.api.v1.to.ContentItemTO in project studio by craftercms.
the class ContentServiceImpl method populateWorkflowProperties.
protected void populateWorkflowProperties(String site, ContentItemTO item) {
ItemState state = objectStateService.getObjectState(site, item.getUri(), false);
if (state != null) {
if (item.isFolder()) {
boolean liveFolder = objectStateService.isFolderLive(site, item.getUri());
item.setNew(!liveFolder);
item.setLive(liveFolder);
} else {
item.setNew(State.isNew(State.valueOf(state.getState())));
item.setLive(State.isLive(State.valueOf(state.getState())));
}
item.isNew = item.isNew();
item.isLive = item.isLive();
item.setInProgress(!item.isLive());
item.isInProgress = item.isInProgress();
item.setScheduled(State.isScheduled(State.valueOf(state.getState())));
item.isScheduled = item.isScheduled();
item.setSubmitted(State.isSubmitted(State.valueOf(state.getState())));
item.isSubmitted = item.isSubmitted();
item.setInFlight(state.getSystemProcessing() == 1);
item.isInFlight = item.isInFlight();
} else {
if (item.isFolder()) {
boolean liveFolder = objectStateService.isFolderLive(site, item.getUri());
item.setNew(!liveFolder);
item.setLive(liveFolder);
item.isNew = item.isNew();
item.isLive = item.isLive();
item.setInProgress(!item.isLive());
item.isInProgress = item.isInProgress();
}
}
}
Aggregations