Search in sources :

Example 6 with SymbolicLink

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

the class TestLinkResolverManager method testResolveContentOnPageLink.

public void testResolveContentOnPageLink() {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToContentOnPage("ART1", "homepage");
    String text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    String expected = "Qui c'è un link: '/Entando/it/homepage.page?contentId=ART1'; fine";
    String resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
}
Also used : SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 7 with SymbolicLink

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

the class TestLinkResolverManager method testResolveContentLink.

public void testResolveContentLink() {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToContent("ART1");
    String text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    String expected = "Qui c'è un link: '/Entando/it/homepage.page'; fine";
    String resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
}
Also used : SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 8 with SymbolicLink

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

the class TestLinkResolverManager method testResolveMix.

public void testResolveMix() {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToContentOnPage("ART1", "homepage");
    String one = link.getSymbolicDestination();
    link.setDestinationToPage("primapagina");
    String two = link.getSymbolicDestination();
    String text = "Trabocchetto: " + SymbolicLink.SYMBOLIC_DEST_PREFIX + " - Qui c'è un link: ''" + one + "'; " + "altro Trabocchetto: " + SymbolicLink.SYMBOLIC_DEST_POSTFIX + " " + two + " fine";
    String expected = "Trabocchetto: " + SymbolicLink.SYMBOLIC_DEST_PREFIX + " - Qui c'è un link: ''/Entando/it/homepage.page?contentId=ART1'; " + "altro Trabocchetto: " + SymbolicLink.SYMBOLIC_DEST_POSTFIX + " /Entando/it/primapagina.page fine";
    String resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
    text = text + text;
    expected = expected + expected;
    resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
}
Also used : SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 9 with SymbolicLink

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

the class CmsHypertextAttribute method validate.

@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
    List<AttributeFieldError> errors = super.validate(tracer);
    try {
        List<Lang> langs = this.getLangManager().getLangs();
        for (Lang lang : langs) {
            AttributeTracer textTracer = (AttributeTracer) tracer.clone();
            textTracer.setLang(lang);
            String text = this.getTextMap().get(lang.getCode());
            if (null == text) {
                continue;
            }
            List<SymbolicLink> links = HypertextAttributeUtil.getSymbolicLinksOnText(text);
            if (null != links && !links.isEmpty()) {
                SymbolicLinkValidator sler = new SymbolicLinkValidator(this.getContentManager(), this.getPageManager());
                for (SymbolicLink symbLink : links) {
                    String linkErrorCode = sler.scan(symbLink, (Content) this.getParentEntity());
                    if (null != linkErrorCode) {
                        AttributeFieldError error = new AttributeFieldError(this, linkErrorCode, textTracer);
                        error.setMessage("Invalid link - page " + symbLink.getPageDest() + " - content " + symbLink.getContentDest() + " - Error code " + linkErrorCode);
                        errors.add(error);
                    }
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Error validating Attribute '{}'", this.getName(), t);
        throw new RuntimeException("Error validating Attribute '" + this.getName() + "'", t);
    }
    return errors;
}
Also used : SymbolicLinkValidator(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeFieldError(com.agiletec.aps.system.common.entity.model.AttributeFieldError) Lang(com.agiletec.aps.system.services.lang.Lang) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 10 with SymbolicLink

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

the class LinkAttribute method validate.

@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
    List<AttributeFieldError> errors = super.validate(tracer);
    try {
        SymbolicLink symbolicLink = this.getSymbolicLink();
        if (null == symbolicLink) {
            return errors;
        }
        SymbolicLinkValidator sler = new SymbolicLinkValidator(this.getContentManager(), this.getPageManager());
        String linkErrorCode = sler.scan(symbolicLink, (Content) this.getParentEntity());
        if (null != linkErrorCode) {
            AttributeFieldError error = new AttributeFieldError(this, linkErrorCode, tracer);
            error.setMessage("Invalid link - page " + symbolicLink.getPageDest() + " - content " + symbolicLink.getContentDest() + " - Error code " + linkErrorCode);
            errors.add(error);
        }
    } catch (Throwable t) {
        logger.error("Error validating link attribute", t);
        throw new RuntimeException("Error validating link attribute", t);
    }
    return errors;
}
Also used : SymbolicLinkValidator(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator) AttributeFieldError(com.agiletec.aps.system.common.entity.model.AttributeFieldError) 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