Search in sources :

Example 1 with SymbolicLink

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

the class BaseContentGroupBulkCommand method checkContentReferences.

protected boolean checkContentReferences(Content content) {
    List<Lang> systemLangs = this.getSystemLangs();
    IPageManager pageManager = this.getPageManager();
    SymbolicLinkValidator validator = new SymbolicLinkValidator(this.getApplier(), pageManager);
    for (AttributeInterface attribute : content.getAttributeList()) {
        if (attribute instanceof IReferenceableAttribute) {
            List<CmsAttributeReference> references = ((IReferenceableAttribute) attribute).getReferences(systemLangs);
            if (references != null) {
                for (CmsAttributeReference reference : references) {
                    SymbolicLink symbolicLink = this.convertToSymbolicLink(reference);
                    if (symbolicLink != null) {
                        String result = validator.scan(symbolicLink, content);
                        if (ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS.equals(result) || ICmsAttributeErrorCodes.INVALID_RESOURCE_GROUPS.equals(result) || ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS.equals(result)) {
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
Also used : IReferenceableAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute) IPageManager(com.agiletec.aps.system.services.page.IPageManager) SymbolicLinkValidator(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator) Lang(com.agiletec.aps.system.services.lang.Lang) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 2 with SymbolicLink

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

the class BaseContentGroupBulkCommand method convertToSymbolicLink.

protected SymbolicLink convertToSymbolicLink(CmsAttributeReference reference) {
    SymbolicLink symbolicLink = null;
    if (reference != null) {
        String resourceId = reference.getRefResource();
        String contentId = reference.getRefContent();
        String pageCode = reference.getRefPage();
        symbolicLink = new SymbolicLink();
        if (resourceId != null) {
            symbolicLink.setDestinationToResource(resourceId);
        } else if (contentId != null) {
            if (pageCode != null) {
                symbolicLink.setDestinationToContentOnPage(contentId, pageCode);
            } else {
                symbolicLink.setDestinationToContent(contentId);
            }
        } else {
            symbolicLink.setDestinationToPage(pageCode);
        }
    }
    return symbolicLink;
}
Also used : SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 3 with SymbolicLink

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

the class TestLinkResolverManager method testResolveURLLink.

public void testResolveURLLink() {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToUrl("http://www.google.it");
    String text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    String expected = "Qui c'è un link: 'http://www.google.it'; 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 4 with SymbolicLink

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

the class TestLinkResolverManager method testResolveContentOnProtectedPageLink.

public void testResolveContentOnProtectedPageLink() throws Throwable {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToContent("ART187");
    String text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    String expected = "Qui c'è un link: '/Entando/it/contentview.page?contentId=ART187'; fine";
    String resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
    this.setUserOnSession("editorCustomers");
    text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    expected = "Qui c'è un link: '/Entando/it/contentview.page?contentId=ART187'; fine";
    resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
    this.setUserOnSession("editorCoach");
    text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    expected = "Qui c'è un link: '/Entando/it/coach_page.page'; fine";
    resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
    this.setUserOnSession("admin");
    text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    expected = "Qui c'è un link: '/Entando/it/coach_page.page'; fine";
    resolvedText = _resolver.resolveLinks(text, null, _reqCtx);
    assertEquals(expected, resolvedText);
}
Also used : SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 5 with SymbolicLink

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

the class TestLinkResolverManager method testResolvePageLink.

public void testResolvePageLink() {
    SymbolicLink link = new SymbolicLink();
    link.setDestinationToPage("primapagina");
    String text = "Qui c'è un link: '" + link.getSymbolicDestination() + "'; fine";
    String expected = "Qui c'è un link: '/Entando/it/primapagina.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)

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