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) { ApsSystemUtils.logThrowable(t, this, "buildEntityType"); throw t; } if (!errors.isEmpty()) throw new ApiException(errors); return entityType; }