Search in sources :

Example 11 with LinkAttribute

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

the class TestContentLinkAction method testJoinContentLink_1.

public void testJoinContentLink_1() throws Throwable {
    String contentOnSessionMarker = this.extractSessionMarker("ART1", ApsAdminSystemConstants.EDIT);
    this.initJoinLinkTest("admin", "ART1", "VediAnche", "it");
    this.initContentAction("/do/jacms/Content/Link", "joinContentLink", contentOnSessionMarker);
    this.addParameter("contentId", "ART1");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    Content content = this.getContentOnEdit(contentOnSessionMarker);
    LinkAttribute attribute = (LinkAttribute) content.getAttribute("VediAnche");
    SymbolicLink symbolicLink = attribute.getSymbolicLink();
    assertNotNull(symbolicLink);
    assertNull(symbolicLink.getPageDest());
    assertEquals("ART1", symbolicLink.getContentDest());
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 12 with LinkAttribute

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

the class TestUrlLinkAction method testJoinContentLink_1.

public void testJoinContentLink_1() throws Throwable {
    String contentOnSessionMarker = this.initJoinLinkTest("ART1", "VediAnche", "it");
    this.initContentAction("/do/jacms/Content/Link", "joinUrlLink", contentOnSessionMarker);
    this.addParameter("url", "http://www.japsportal.org");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    Content content = this.getContentOnEdit(contentOnSessionMarker);
    LinkAttribute attribute = (LinkAttribute) content.getAttribute("VediAnche");
    SymbolicLink symbolicLink = attribute.getSymbolicLink();
    assertNotNull(symbolicLink);
    assertNull(symbolicLink.getPageDest());
    assertNull(symbolicLink.getContentDest());
    assertEquals("http://www.japsportal.org", symbolicLink.getUrlDest());
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 13 with LinkAttribute

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

the class LinkAttributeActionHelper method initSessionParams.

@Override
public void initSessionParams(ILinkAttributeAction action, HttpServletRequest request) {
    AttributeInterface attribute = null;
    HttpSession session = request.getSession();
    if (null != action.getParentAttributeName()) {
        attribute = (AttributeInterface) getContent(request).getAttribute(action.getParentAttributeName());
        session.setAttribute(ATTRIBUTE_NAME_SESSION_PARAM, action.getParentAttributeName());
        session.setAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM, action.getAttributeName());
    } else {
        attribute = (AttributeInterface) getContent(request).getAttribute(action.getAttributeName());
        session.setAttribute(ATTRIBUTE_NAME_SESSION_PARAM, action.getAttributeName());
    }
    if (action.getElementIndex() >= 0) {
        session.setAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM, new Integer(action.getElementIndex()));
    }
    session.setAttribute(LINK_LANG_CODE_SESSION_PARAM, action.getLangCode());
    LinkAttribute linkAttribute = (LinkAttribute) getLinkAttribute(attribute, request);
    session.setAttribute(SYMBOLIC_LINK_SESSION_PARAM, linkAttribute.getSymbolicLink());
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) HttpSession(javax.servlet.http.HttpSession) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 14 with LinkAttribute

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

the class LinkAttributeActionHelper method updateLink.

protected void updateLink(AttributeInterface currentAttribute, String[] destinations, int destType) {
    if (destinations.length != 3) {
        throw new RuntimeException("Destinazioni non riconosciute");
    }
    SymbolicLink symbolicLink = new SymbolicLink();
    switch(destType) {
        case (SymbolicLink.CONTENT_TYPE):
            symbolicLink.setDestinationToContent(destinations[1]);
            break;
        case (SymbolicLink.CONTENT_ON_PAGE_TYPE):
            symbolicLink.setDestinationToContentOnPage(destinations[1], destinations[2]);
            break;
        case SymbolicLink.PAGE_TYPE:
            symbolicLink.setDestinationToPage(destinations[2]);
            break;
        case SymbolicLink.URL_TYPE:
            symbolicLink.setDestinationToUrl(destinations[0]);
            break;
        default:
            symbolicLink.setDestinationToContent("");
            break;
    }
    ((LinkAttribute) currentAttribute).setSymbolicLink(symbolicLink);
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 15 with LinkAttribute

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

the class LinkAttributeActionHelper method getLinkAttribute.

protected AttributeInterface getLinkAttribute(AttributeInterface attribute, HttpServletRequest request) {
    HttpSession session = request.getSession();
    if (attribute instanceof CompositeAttribute) {
        String includedAttributeName = (String) session.getAttribute(INCLUDED_ELEMENT_NAME_SESSION_PARAM);
        AttributeInterface includedAttribute = ((CompositeAttribute) attribute).getAttribute(includedAttributeName);
        return getLinkAttribute(includedAttribute, request);
    } else if (attribute instanceof MonoListAttribute) {
        Integer elementIndex = (Integer) session.getAttribute(LIST_ELEMENT_INDEX_SESSION_PARAM);
        AttributeInterface attributeElement = ((MonoListAttribute) attribute).getAttribute(elementIndex.intValue());
        return getLinkAttribute(attributeElement, request);
    } else if (attribute instanceof LinkAttribute) {
        return attribute;
    } else {
        throw new RuntimeException("Caso non gestito : Atttributo tipo " + attribute.getClass());
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) CompositeAttribute(com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute) HttpSession(javax.servlet.http.HttpSession) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)15 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)9 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)6 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)6 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)4 HttpSession (javax.servlet.http.HttpSession)4 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)1 AbstractComplexAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractComplexAttribute)1 AbstractListAttribute (com.agiletec.aps.system.common.entity.model.attribute.AbstractListAttribute)1 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)1 HypertextAttribute (com.agiletec.aps.system.common.entity.model.attribute.HypertextAttribute)1 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)1 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)1 AbstractResourceAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.AbstractResourceAttribute)1 ResourceAttributeInterface (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface)1 ActionSupport (com.opensymphony.xwork2.ActionSupport)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1