Search in sources :

Example 1 with SymbolicLinkValidator

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;
}
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 SymbolicLinkValidator

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;
}
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 3 with SymbolicLinkValidator

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;
}
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)3 SymbolicLinkValidator (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator)3 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)2 Lang (com.agiletec.aps.system.services.lang.Lang)2 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)1 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 CmsAttributeReference (com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference)1 IReferenceableAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute)1