Search in sources :

Example 86 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class ContentInfoTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    int result = super.doStartTag();
    try {
        if (null != this.getMasterObject()) {
            HttpSession session = this.pageContext.getSession();
            UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
            IContentAuthorizationHelper contentAuthHelper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
            boolean isAuthOnEdit = false;
            if (this.isRecord()) {
                // PENSARE ALL'OPPORTUNITA'... meno prestante nel caso di oggetto contenuto!
                String keyValue = (String) super.findValue(this.getKey(), String.class);
                isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, keyValue, false);
            } else {
                isAuthOnEdit = contentAuthHelper.isAuthToEdit(currentUser, (Content) this.getMasterObject());
            }
            if (isAuthOnEdit) {
                if (null != this.getAuthToEditVar()) {
                    ValueStack stack = this.getStack();
                    stack.getContext().put(this.getAuthToEditVar(), isAuthOnEdit);
                    stack.setValue("#attr['" + this.getAuthToEditVar() + "']", isAuthOnEdit, false);
                }
                result = EVAL_BODY_INCLUDE;
            }
        }
    } catch (Throwable t) {
        _logger.error("error in doStartTag", t);
        // ApsSystemUtils.logThrowable(t, this, "doStartTag", "Error on doStartTag");
        throw new JspException("Error on doStartTag", t);
    }
    return result;
}
Also used : JspException(javax.servlet.jsp.JspException) UserDetails(com.agiletec.aps.system.services.user.UserDetails) ValueStack(com.opensymphony.xwork2.util.ValueStack) HttpSession(javax.servlet.http.HttpSession) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) IContentAuthorizationHelper(com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper)

Example 87 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class ContentTypeInfoTag method getPropertyValue.

@Override
protected Object getPropertyValue(Object masterObject, String propertyValue) {
    if (null == propertyValue || !propertyValue.equals("isAuthToEdit")) {
        return super.getPropertyValue(masterObject, propertyValue);
    }
    try {
        HttpSession session = this.pageContext.getSession();
        UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
        Content prototype = (Content) masterObject;
        IContentAuthorizationHelper helper = (IContentAuthorizationHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_AUTHORIZATION_HELPER, this.pageContext);
        return helper.isAuthToEdit(currentUser, prototype);
    } catch (Throwable t) {
        _logger.error("Error extracting property value : Master Object '{}' - property '{}'", masterObject.getClass().getName(), propertyValue, t);
    }
    return null;
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) HttpSession(javax.servlet.http.HttpSession) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) IContentAuthorizationHelper(com.agiletec.plugins.jacms.aps.system.services.content.helper.IContentAuthorizationHelper)

Example 88 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class AbstractContentAction method updateContentOnSession.

protected Content updateContentOnSession(boolean updateMainGroup) {
    Content content = this.getContent();
    this.getContentActionHelper().updateContent(content, updateMainGroup, this.getRequest());
    return content;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 89 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class ContentAction method getShowingPageSelectItems.

/**
 * Return the list of the showing pages of the current content on edit
 *
 * @return The list of the showing pages.
 */
public List<SelectItem> getShowingPageSelectItems() {
    List<SelectItem> pageItems = new ArrayList<SelectItem>();
    try {
        Content content = this.getContent();
        if (null != content) {
            IPage defaultViewerPage = this.getPageManager().getOnlinePage(content.getViewPage());
            if (null != defaultViewerPage && CmsPageUtil.isOnlineFreeViewerPage(defaultViewerPage, null)) {
                pageItems.add(new SelectItem("", this.getText("label.default")));
            }
            if (null == content.getId())
                return pageItems;
            ContentUtilizer pageManagerWrapper = (ContentUtilizer) ApsWebApplicationUtils.getBean(JacmsSystemConstants.PAGE_MANAGER_WRAPPER, this.getRequest());
            List<IPage> pages = pageManagerWrapper.getContentUtilizers(content.getId());
            for (int i = 0; i < pages.size(); i++) {
                IPage page = pages.get(i);
                String pageCode = page.getCode();
                pageItems.add(new SelectItem(pageCode, super.getTitle(pageCode, page.getTitles())));
            }
        }
    } catch (Throwable t) {
        _logger.error("Error on extracting showing pages", t);
        throw new RuntimeException("Error on extracting showing pages", t);
    }
    return pageItems;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) SelectItem(com.agiletec.aps.util.SelectItem) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) ContentUtilizer(com.agiletec.plugins.jacms.aps.system.services.content.ContentUtilizer)

Example 90 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class ContentAction method edit.

/**
 * Esegue l'azione di edit di un contenuto.
 *
 * @return Il codice del risultato dell'azione.
 */
public String edit() {
    try {
        Content content = this.getContentManager().loadContent(this.getContentId(), false);
        if (null == content) {
            throw new ApsSystemException("Contenuto in edit '" + this.getContentId() + "' nullo!");
        }
        if (!this.isUserAllowed(content)) {
            _logger.info("Utente non abilitato all'editazione del contenuto {}", content.getId());
            return USER_NOT_ALLOWED;
        }
        String marker = buildContentOnSessionMarker(content, ApsAdminSystemConstants.EDIT);
        super.setContentOnSessionMarker(marker);
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + marker, content);
    } catch (Throwable t) {
        _logger.error("error in edit", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

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