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