Search in sources :

Example 91 with Content

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;
}
Also used : ContentJO(org.entando.entando.plugins.jacms.apsadmin.content.rs.model.ContentJO) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ContentRecordVO(com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 92 with Content

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;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList)

Example 93 with Content

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;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList)

Example 94 with Content

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;
}
Also used : IReferenceableAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) EntityAttributeIterator(com.agiletec.aps.system.common.util.EntityAttributeIterator)

Example 95 with Content

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;
}
Also used : IReferenceableAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) EntityAttributeIterator(com.agiletec.aps.system.common.util.EntityAttributeIterator)

Aggregations

Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)227 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)29 ArrayList (java.util.ArrayList)26 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 ActionSupport (com.opensymphony.xwork2.ActionSupport)14 List (java.util.List)14 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 HttpSession (javax.servlet.http.HttpSession)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)12 IPage (com.agiletec.aps.system.services.page.IPage)10 Date (java.util.Date)8 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)7 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)7 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)7 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)7 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6