Search in sources :

Example 36 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class ApiEntityTypeInterface method getEntityType.

public JAXBEntityType getEntityType(Properties properties) throws Throwable {
    JAXBEntityType jaxbEntityType = null;
    try {
        IEntityManager manager = this.getEntityManager();
        String typeCode = properties.getProperty(this.getTypeCodeParamName());
        IApsEntity masterEntityType = manager.getEntityPrototype(typeCode);
        if (null == masterEntityType) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, this.getTypeLabel() + " with code '" + typeCode + "' does not exist");
        }
        jaxbEntityType = this.createJAXBEntityType(masterEntityType);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("Error extracting entity type", t);
        // ApsSystemUtils.logThrowable(t, this, "getEntityType");
        throw new ApsSystemException("Error extracting entity type", t);
    }
    return jaxbEntityType;
}
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) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 37 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException 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 38 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class ApiEntityTypeInterface method getEntityTypes.

public StringListApiResponse getEntityTypes(Properties properties) throws Throwable {
    StringListApiResponse response = new StringListApiResponse();
    try {
        IEntityManager manager = this.getEntityManager();
        Map<String, IApsEntity> prototypes = manager.getEntityPrototypes();
        List<String> codes = new ArrayList<String>();
        codes.addAll(prototypes.keySet());
        Collections.sort(codes);
        response.setResult(codes, null);
    } catch (Throwable t) {
        _logger.error("Error extracting entity type codes", t);
        // ApsSystemUtils.logThrowable(t, this, "getEntityTypes");
        throw new ApsSystemException("Error extracting entity type codes", t);
    }
    return response;
}
Also used : StringListApiResponse(org.entando.entando.aps.system.services.api.model.StringListApiResponse) IEntityManager(com.agiletec.aps.system.common.entity.IEntityManager) ArrayList(java.util.ArrayList) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 39 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class AbstractDatabaseUtils method getType.

protected IDatabaseManager.DatabaseType getType(DataSource dataSource) throws ApsSystemException {
    String typeString = null;
    try {
        String driverClassName = this.invokeGetMethod("getDriverClassName", dataSource);
        Iterator<Object> typesIter = this.getDatabaseTypeDrivers().keySet().iterator();
        while (typesIter.hasNext()) {
            String typeCode = (String) typesIter.next();
            List<String> driverClassNames = (List<String>) this.getDatabaseTypeDrivers().get(typeCode);
            if (null != driverClassNames && driverClassNames.contains(driverClassName)) {
                typeString = typeCode;
                break;
            }
        }
        if (null == typeString) {
            _logger.error("Type not recognized for Driver '{}' - Recognized types '{}'", driverClassName, IDatabaseManager.DatabaseType.values());
            return IDatabaseManager.DatabaseType.UNKNOWN;
        }
        return Enum.valueOf(IDatabaseManager.DatabaseType.class, typeString.toUpperCase());
    } catch (Throwable t) {
        _logger.error("Invalid type for db - '{}' - ", typeString, t);
        throw new ApsSystemException("Invalid type for db - '" + typeString + "'", t);
    }
}
Also used : List(java.util.List) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 40 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class ComponentManager method loadComponents.

protected void loadComponents() throws ApsSystemException {
    try {
        ComponentLoader loader = new ComponentLoader(this.getLocationPatterns(), this.getPostProcessClasses());
        Map<String, Component> componentMap = loader.getComponents();
        List<Component> components = new ArrayList<Component>();
        components.addAll(componentMap.values());
        List<Component> orderedComponents = this.getOrderedComponents(components);
        this.setComponents(orderedComponents);
    } catch (Throwable t) {
        _logger.error("Error loading components definitions", t);
        throw new ApsSystemException("Error loading components definitions", t);
    }
}
Also used : ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Component(org.entando.entando.aps.system.init.model.Component) ComponentLoader(org.entando.entando.aps.system.init.util.ComponentLoader)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)452 ArrayList (java.util.ArrayList)53 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)48 RestServerError (org.entando.entando.aps.system.exception.RestServerError)39 ApsProperties (com.agiletec.aps.util.ApsProperties)26 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)23 HashMap (java.util.HashMap)23 UserDetails (com.agiletec.aps.system.services.user.UserDetails)21 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)21 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)20 Date (java.util.Date)20 StringReader (java.io.StringReader)18 IPage (com.agiletec.aps.system.services.page.IPage)17 List (java.util.List)17 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)16 File (java.io.File)16 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 Widget (com.agiletec.aps.system.services.page.Widget)15 IOException (java.io.IOException)15 Cache (org.springframework.cache.Cache)15