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