Search in sources :

Example 11 with SymbolicLink

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

the class HypertextAttributeUtil method getSymbolicLinksOnText.

/**
 * Restituisce la lista di Link Simbolici relativi ai link
 * inseriti nel testo specificato.
 * @param text Il testo da analizzare.
 * @return La lista di link simbolici inserito internalmente al testo.
 */
public static List<SymbolicLink> getSymbolicLinksOnText(String text) {
    List<SymbolicLink> links = new ArrayList<SymbolicLink>();
    if (null != text && text.length() > 0) {
        String temp = text;
        String START_HREF = "href=\"" + SymbolicLink.SYMBOLIC_DEST_PREFIX;
        String END_HREF = SymbolicLink.SYMBOLIC_DEST_POSTFIX + "\"";
        while (temp.indexOf(START_HREF) > 0) {
            int start = temp.indexOf(START_HREF);
            int end = temp.indexOf(END_HREF);
            if (start < end) {
                String symbLinkString = temp.substring(start + 6, end + 2);
                SymbolicLink symbLink = new SymbolicLink();
                boolean isValidLink = symbLink.setSymbolicDestination(symbLinkString);
                if (isValidLink) {
                    links.add(symbLink);
                }
            }
            if (end > 0) {
                temp = temp.substring(end + 2, temp.length() - 1);
            } else {
                temp = temp.substring(start + 6, temp.length() - 1);
            }
        }
    }
    return links;
}
Also used : ArrayList(java.util.ArrayList) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 12 with SymbolicLink

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

the class LinkAttributeHandler method startLink.

private void startLink(Attributes attributes, String qName) throws SAXException {
    this._linkType = extractAttribute(attributes, "type", qName, true);
    ((LinkAttribute) this.getCurrentAttr()).setSymbolicLink(new 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 13 with SymbolicLink

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

the class LinkAttributeHandler method endLink.

private void endLink() {
    SymbolicLink symLink = ((LinkAttribute) this.getCurrentAttr()).getSymbolicLink();
    if (null != symLink && null != _linkType) {
        if (_linkType.equals("content")) {
            symLink.setDestinationToContent(_contentDest);
        } else if (_linkType.equals("external")) {
            symLink.setDestinationToUrl(_urlDest);
        } else if (_linkType.equals("page")) {
            symLink.setDestinationToPage(_pageDest);
        } else if (_linkType.equals("contentonpage")) {
            symLink.setDestinationToContentOnPage(_contentDest, _pageDest);
        }
    }
    _contentDest = null;
    _urlDest = null;
    _pageDest = null;
}
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 14 with SymbolicLink

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

the class ContentWrapper method getContentLink.

/**
 * Restituisce un URL simbolico che punta al contenuto stesso (link di
 * tipo SymbolicLink.CONTENT_TYPE).
 * @return Un URL simbolico da utilizzare come href in un tag &lt;a&gt;
 */
public String getContentLink() {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToContent(this.getId());
    return link.getSymbolicDestination();
}
Also used : SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 15 with SymbolicLink

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

the class TestLinkAttributeAction method testRemoveLink.

public void testRemoveLink() throws Throwable {
    String contentId = "ART102";
    String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
    this.executeEdit(contentId, "admin");
    Content currentContent = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(currentContent);
    LinkAttribute linkAttribute = (LinkAttribute) currentContent.getAttribute("VediAnche");
    assertNotNull(linkAttribute);
    SymbolicLink symbolicLink = linkAttribute.getSymbolicLink();
    assertNotNull(symbolicLink);
    assertEquals("ART111", symbolicLink.getContentDest());
    this.initContentAction("/do/jacms/Content", "removeLink", contentOnSessionMarker);
    this.addParameter("attributeName", "VediAnche");
    this.addParameter("langCode", "it");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    currentContent = this.getContentOnEdit(contentOnSessionMarker);
    assertNotNull(currentContent);
    linkAttribute = (LinkAttribute) currentContent.getAttribute("VediAnche");
    assertNotNull(linkAttribute);
    symbolicLink = linkAttribute.getSymbolicLink();
    assertNull(symbolicLink);
}
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)

Aggregations

SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)27 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)9 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)6 Lang (com.agiletec.aps.system.services.lang.Lang)3 CmsAttributeReference (com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference)3 SymbolicLinkValidator (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator)3 ArrayList (java.util.ArrayList)3 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)2 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)2 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)1 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)1 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 IReferenceableAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute)1 ActionSupport (com.opensymphony.xwork2.ActionSupport)1