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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations