use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ContentFinderAction method getLastUpdateContentResponse.
@SuppressWarnings("rawtypes")
public List<ContentJO> getLastUpdateContentResponse() {
List<ContentJO> response = null;
try {
EntitySearchFilter modifyOrder = new EntitySearchFilter(IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, false);
modifyOrder.setOrder(EntitySearchFilter.DESC_ORDER);
List<String> ids = this.getContentManager().searchId(new EntitySearchFilter[] { modifyOrder });
if (null != ids && !ids.isEmpty()) {
if (this.getLastUpdateResponseSize() > ids.size() - 1)
this.setLastUpdateResponseSize(ids.size() - 1);
List<String> subList = ids.subList(0, this.getLastUpdateResponseSize());
response = new ArrayList<ContentJO>();
Iterator<String> sublist = subList.iterator();
while (sublist.hasNext()) {
String contentId = sublist.next();
Content content = this.getContentManager().loadContent(contentId, false);
ContentRecordVO vo = this.getContentManager().loadContentVO(contentId);
ContentJO contentJO = new ContentJO(content, vo);
response.add(contentJO);
}
}
} catch (Throwable t) {
_logger.error("Error loading last updated content response", t);
throw new RuntimeException("Error loading last updated content response", t);
}
return response;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ContentFinderAction method insertOnLine.
/**
* Esegue la publicazione di un singolo contenuto direttamente
* dall'interfaccia di visualizzazione dei contenuti in lista.
*
* @return Il codice del risultato dell'azione.
*/
public String insertOnLine() {
try {
if (null == this.getContentIds()) {
this.addActionError(this.getText("error.contents.nothingSelected"));
return INPUT;
}
Iterator<String> iter = this.getContentIds().iterator();
List<Content> publishedContents = new ArrayList<Content>();
while (iter.hasNext()) {
String contentId = (String) iter.next();
Content contentToPublish = this.getContentManager().loadContent(contentId, false);
String[] msgArg = new String[1];
if (null == contentToPublish) {
msgArg[0] = contentId;
this.addActionError(this.getText("error.content.contentToPublishNull", msgArg));
continue;
}
msgArg[0] = contentToPublish.getDescription();
if (!this.isUserAllowed(contentToPublish)) {
this.addActionError(this.getText("error.content.userNotAllowedToPublishContent", msgArg));
continue;
}
this.getContentActionHelper().scanEntity(contentToPublish, this);
if (this.getFieldErrors().size() > 0) {
this.addActionError(this.getText("error.content.publishingContentWithErrors", msgArg));
continue;
}
this.getContentManager().insertOnLineContent(contentToPublish);
_logger.info("Published content {} by user {}", contentToPublish.getId(), this.getCurrentUser().getUsername());
publishedContents.add(contentToPublish);
this.addActivityStreamInfo(contentToPublish, (ApsAdminSystemConstants.ADD + 10), true);
}
// RIVISITARE LABEL e LOGICA DI COSTRUZIONE LABEL
this.addConfirmMessage("message.content.publishedContents", publishedContents);
} catch (Throwable t) {
_logger.error("error in insertOnLine", t);
throw new RuntimeException("Error publishing contents", t);
}
return SUCCESS;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ContentFinderAction method delete.
/**
* Esegue l'operazione di cancellazione contenuto o gruppo contenuti.
*
* @return Il codice del risultato.
*/
public String delete() {
try {
if (null == this.getContentIds()) {
this.addActionError(this.getText("error.contents.nothingSelected"));
return INPUT;
}
Iterator<String> iter = this.getContentIds().iterator();
List<Content> deletedContents = new ArrayList<Content>();
while (iter.hasNext()) {
String contentId = (String) iter.next();
Content contentToDelete = this.getContentManager().loadContent(contentId, false);
String[] msgArg = new String[1];
if (null == contentToDelete) {
msgArg[0] = contentId;
this.addActionError(this.getText("error.content.contentToDeleteNull", msgArg));
continue;
}
msgArg[0] = contentToDelete.getDescription();
if (!this.isUserAllowed(contentToDelete)) {
this.addActionError(this.getText("error.content.userNotAllowedToContentToDelete", msgArg));
continue;
}
if (contentToDelete.isOnLine()) {
this.addActionError(this.getText("error.content.notAllowedToDeleteOnlineContent", msgArg));
continue;
}
this.getContentManager().deleteContent(contentToDelete);
_logger.info("Deleted Content '{}' by user {}", contentToDelete.getId(), this.getCurrentUser().getUsername());
deletedContents.add(contentToDelete);
this.addActivityStreamInfo(contentToDelete, ApsAdminSystemConstants.DELETE, false);
}
// RIVISITARE LABEL e LOGICA DI COSTRUZIONE LABEL
this.addConfirmMessage("message.content.deletedContents", deletedContents);
} catch (Throwable t) {
_logger.error("Error deleting contentd - delete", t);
throw new RuntimeException("Errore in cancellazione contenuti", t);
}
return SUCCESS;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ContentInspectionAction method getReferencedContentsId.
/**
* Return the list of the id of the referenced contents
* @return The list of content id.
*/
public List<String> getReferencedContentsId() {
List<String> referencedContentsId = new ArrayList<String>();
try {
Content content = this.getContent();
if (null == content)
return referencedContentsId;
EntityAttributeIterator attributeIter = new EntityAttributeIterator(content);
while (attributeIter.hasNext()) {
AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
if (currAttribute instanceof IReferenceableAttribute) {
IReferenceableAttribute cmsAttribute = (IReferenceableAttribute) currAttribute;
List<CmsAttributeReference> refs = cmsAttribute.getReferences(this.getLangs());
for (int scanRefs = 0; scanRefs < refs.size(); scanRefs++) {
CmsAttributeReference ref = refs.get(scanRefs);
String contentId = ref.getRefContent();
if (null == contentId)
continue;
if (!referencedContentsId.contains(contentId))
referencedContentsId.add(contentId);
}
}
}
} catch (Throwable t) {
_logger.error("Error getting referenced contents id by content {}", this.getContentId(), t);
String msg = "Error getting referenced contents id by content " + this.getContentId();
throw new RuntimeException(msg, t);
}
return referencedContentsId;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class ContentInspectionAction method getReferencedPages.
public List<IPage> getReferencedPages() {
List<IPage> referencedPages = new ArrayList<IPage>();
try {
Content content = this.getContent();
if (null == content)
return referencedPages;
EntityAttributeIterator attributeIter = new EntityAttributeIterator(content);
while (attributeIter.hasNext()) {
AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
if (currAttribute instanceof IReferenceableAttribute) {
IReferenceableAttribute cmsAttribute = (IReferenceableAttribute) currAttribute;
List<CmsAttributeReference> refs = cmsAttribute.getReferences(this.getLangs());
for (int scanRefs = 0; scanRefs < refs.size(); scanRefs++) {
CmsAttributeReference ref = refs.get(scanRefs);
if (null == ref.getRefPage())
continue;
IPage page = this.getPageManager().getOnlinePage(ref.getRefPage());
if (null == page)
continue;
if (!referencedPages.contains(page)) {
referencedPages.add(page);
}
}
}
}
} catch (Throwable t) {
_logger.error("Error getting referenced pages by content {}", this.getContentId(), t);
String msg = "Error getting referenced pages by content " + this.getContentId();
throw new RuntimeException(msg, t);
}
return referencedPages;
}
Aggregations