Search in sources :

Example 1 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface 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 AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class SearchEngineManager method verifyReloadingNeeded.

protected boolean verifyReloadingNeeded(IApsEntity oldEntityType, IApsEntity newEntityType) {
    List<AttributeInterface> attributes = oldEntityType.getAttributeList();
    for (int i = 0; i < attributes.size(); i++) {
        AttributeInterface oldAttribute = attributes.get(i);
        AttributeInterface newAttribute = (AttributeInterface) newEntityType.getAttribute(oldAttribute.getName());
        boolean isOldAttributeIndexeable = (oldAttribute.getIndexingType() != null && oldAttribute.getIndexingType().equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
        boolean isNewAttributeIndexeable = (newAttribute != null && newAttribute.getIndexingType() != null && newAttribute.getIndexingType().equalsIgnoreCase(IndexableAttributeInterface.INDEXING_TYPE_TEXT));
        if ((isOldAttributeIndexeable && !isNewAttributeIndexeable) || (!isOldAttributeIndexeable && isNewAttributeIndexeable)) {
            return true;
        }
    }
    return false;
}
Also used : IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 3 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class ApiEntityTypeInterface method addEntityType.

public StringApiResponse addEntityType(JAXBEntityType jaxbEntityType) throws Throwable {
    StringApiResponse response = new StringApiResponse();
    try {
        IEntityManager manager = this.getEntityManager();
        String typeCode = jaxbEntityType.getTypeCode();
        IApsEntity masterEntityType = manager.getEntityPrototype(typeCode);
        if (null != masterEntityType) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' already exists");
        }
        if (typeCode == null || typeCode.length() != 3) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Invalid type code - '" + typeCode + "'");
        }
        Map<String, AttributeInterface> attributes = manager.getEntityAttributePrototypes();
        IApsEntity newEntityType = jaxbEntityType.buildEntityType(manager.getEntityClass(), attributes);
        this.checkNewEntityType(jaxbEntityType, newEntityType, response);
        ((IEntityTypesConfigurer) manager).addEntityPrototype(newEntityType);
        response.setResult(IResponseBuilder.SUCCESS, null);
    } catch (ApiException ae) {
        response.addErrors(ae.getErrors());
        response.setResult(IResponseBuilder.FAILURE, null);
    } catch (Throwable t) {
        _logger.error("Error extracting entity type", t);
        // ApsSystemUtils.logThrowable(t, this, "getEntityType");
        throw new ApsSystemException("Error extracting entity type", t);
    }
    return response;
}
Also used : IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 4 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class ApiEntityTypeInterface method updateEntityType.

public StringApiResponse updateEntityType(JAXBEntityType jaxbEntityType) throws Throwable {
    StringApiResponse response = new StringApiResponse();
    try {
        String typeCode = jaxbEntityType.getTypeCode();
        IApsEntity masterUserProfileType = this.getEntityManager().getEntityPrototype(typeCode);
        if (null == masterUserProfileType) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' doesn't exist");
        }
        Map<String, AttributeInterface> attributes = this.getEntityManager().getEntityAttributePrototypes();
        IApsEntity entityTypeToUpdate = jaxbEntityType.buildEntityType(this.getEntityManager().getEntityClass(), attributes);
        this.checkEntityTypeToUpdate(jaxbEntityType, entityTypeToUpdate, response);
        ((IEntityTypesConfigurer) this.getEntityManager()).updateEntityPrototype(entityTypeToUpdate);
        response.setResult(IResponseBuilder.SUCCESS, null);
    } catch (ApiException ae) {
        response.addErrors(ae.getErrors());
        response.setResult(IResponseBuilder.FAILURE, null);
    } catch (Throwable t) {
        _logger.error("Error updating entity type", t);
        // ApsSystemUtils.logThrowable(t, this, "updateEntityType");
        throw new ApsSystemException("Error updating entity type", t);
    }
    return response;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 5 with AttributeInterface

use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.

the class JAXBEntityType method buildEntityType.

public IApsEntity buildEntityType(Class entityClass, Map<String, AttributeInterface> attributes) throws ApiException, Throwable {
    List<ApiError> errors = new ArrayList<ApiError>();
    IApsEntity entityType = null;
    try {
        entityType = (IApsEntity) entityClass.newInstance();
        entityType.setTypeCode(this.getTypeCode());
        entityType.setTypeDescr(this.getTypeDescription());
        List<DefaultJAXBAttributeType> jabxAttributes = this.getAttributes();
        for (int i = 0; i < jabxAttributes.size(); i++) {
            try {
                DefaultJAXBAttributeType jaxbAttributeType = jabxAttributes.get(i);
                AttributeInterface attribute = jaxbAttributeType.createAttribute(attributes);
                if (null != entityType.getAttribute(attribute.getName())) {
                    throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Attribute '" + attribute.getName() + "' already defined");
                }
                entityType.addAttribute(attribute);
            } catch (ApiException e) {
                errors.addAll(e.getErrors());
            }
        }
    } catch (Throwable t) {
        _logger.error("error in buildEntityType", t);
        // ApsSystemUtils.logThrowable(t, this, "buildEntityType");
        throw t;
    }
    if (!errors.isEmpty())
        throw new ApiException(errors);
    return entityType;
}
Also used : ArrayList(java.util.ArrayList) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApiError(org.entando.entando.aps.system.services.api.model.ApiError) DefaultJAXBAttributeType(com.agiletec.aps.system.common.entity.model.attribute.DefaultJAXBAttributeType) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Aggregations

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7