@Override public List<AttributeFieldError> validate(AttributeTracer tracer) { List<AttributeFieldError> errors = new ArrayList<AttributeFieldError>(); try { if (this.getStatus().equals(Status.INCOMPLETE)) { errors.add(new AttributeFieldError(this, FieldError.INVALID, tracer)); } else { IAttributeValidationRules validationRules = this.getValidationRules(); if (null == validationRules) { return errors; } ILangManager langManager = (ILangManager) this.getBeanFactory().getBean(SystemConstants.LANGUAGE_MANAGER, ILangManager.class); List<AttributeFieldError> validationRulesErrors = validationRules.validate(this, tracer, langManager); if (null != validationRulesErrors) { errors.addAll(validationRulesErrors); } } } catch (Throwable t) { ApsSystemUtils.logThrowable( t, this, "validate", "Error validating Attribute '" + this.getName() + "'"); throw new RuntimeException("Error validating Attribute '" + this.getName() + "'", t); } return errors; }
@Override public void setAttributeConfig(Element attributeElement) throws ApsSystemException { try { String name = this.extractXmlAttribute(attributeElement, "name", true); this.setName(name); String description = this.extractXmlAttribute(attributeElement, "description", false); this.setDescription(description); String searcheable = this.extractXmlAttribute(attributeElement, "searcheable", false); this.setSearcheable(null != searcheable && searcheable.equalsIgnoreCase("true")); IAttributeValidationRules validationCondition = this.getValidationRules(); validationCondition.setConfig(attributeElement); // to guaranted compatibility with previsous version of jAPS 2.0.12 *** Start Block String required = this.extractXmlAttribute(attributeElement, "required", false); if (null != required && required.equalsIgnoreCase("true")) { this.setRequired(true); } // to guaranted compatibility with previsous version of jAPS 2.0.12 *** End Block String indexingType = this.extractXmlAttribute(attributeElement, "indexingtype", false); if (null != indexingType) { this.setIndexingType(indexingType); } else { this.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_NONE); } Element disablingCodesElements = attributeElement.getChild("disablingCodes"); if (null != disablingCodesElements) { String[] disablingCodes = this.extractValues(disablingCodesElements, "code"); this.setDisablingCodes(disablingCodes); } else { // to guaranted compatibility with previsous version of jAPS 2.0.12 *** Start Block String disablingCodesStr = this.extractXmlAttribute(attributeElement, "disablingCodes", false); if (disablingCodesStr != null) { String[] disablingCodes = disablingCodesStr.split(","); this.setDisablingCodes(disablingCodes); } // to guaranted compatibility with previsous version of jAPS 2.0.12 *** End Block } Element rolesElements = attributeElement.getChild("roles"); if (null != rolesElements) { String[] roles = this.extractValues(rolesElements, "role"); this.setRoles(roles); } } catch (Throwable e) { String message = "Error detected while creating the attribute config '" + this.getName() + "' type '" + this.getType() + "'"; ApsSystemUtils.logThrowable(e, this, "getAttributePrototype", message); throw new RuntimeException(message, e); } }