use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator 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.extraAttribute.util.SymbolicLinkValidator 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.extraAttribute.util.SymbolicLinkValidator 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