Search in sources :

Example 96 with ApsSystemException

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

the class DataObjectModelService method removeDataObjectModel.

@Override
public void removeDataObjectModel(Long dataModelId) {
    try {
        DataObjectModel dataObjectModel = this.getDataObjectModelManager().getDataObjectModel(dataModelId);
        if (null == dataObjectModel) {
            return;
        }
        DataModelDto dto = this.getDtoBuilder().convert(dataObjectModel);
        BeanPropertyBindingResult validationResult = this.checkDataObjectModelForDelete(dataObjectModel, dto);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        this.getDataObjectModelManager().removeDataObjectModel(dataObjectModel);
    } catch (ApsSystemException e) {
        logger.error("Error in delete DataObjectModel {}", dataModelId, e);
        throw new RestServerError("error in delete DataObjectModel", e);
    }
}
Also used : DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 97 with ApsSystemException

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

the class DataObjectModelService method updateDataObjectModel.

@Override
public DataModelDto updateDataObjectModel(DataObjectModelRequest dataObjectModelRequest) {
    String code = dataObjectModelRequest.getModelId();
    try {
        Long modelId = Long.parseLong(code);
        DataObjectModel dataObjectModel = this.getDataObjectModelManager().getDataObjectModel(modelId);
        if (null == dataObjectModel) {
            throw new RestRourceNotFoundException("dataObjectModel", code);
        }
        dataObjectModel.setDataType(dataObjectModelRequest.getType());
        dataObjectModel.setDescription(dataObjectModelRequest.getDescr());
        dataObjectModel.setShape(dataObjectModelRequest.getModel());
        dataObjectModel.setStylesheet(dataObjectModelRequest.getStylesheet());
        this.getDataObjectModelManager().updateDataObjectModel(dataObjectModel);
        return this.getDtoBuilder().convert(dataObjectModel);
    } catch (RestRourceNotFoundException e) {
        throw e;
    } catch (ApsSystemException e) {
        logger.error("Error updating DataObjectModel {}", code, e);
        throw new RestServerError("error in update DataObjectModel", e);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 98 with ApsSystemException

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

the class ApiDataObjectModelInterface method getModels.

public StringListApiResponse getModels(Properties properties) throws ApiException, Throwable {
    StringListApiResponse response = new StringListApiResponse();
    try {
        List<DataObjectModel> models = null;
        String dataTypeParam = properties.getProperty("dataType");
        String dataType = (null != dataTypeParam && dataTypeParam.trim().length() > 0) ? dataTypeParam.trim() : null;
        if (null != dataType && null == this.getDataObjectManager().getSmallDataTypesMap().get(dataType)) {
            ApiError error = new ApiError(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type " + dataType + " does not exist", Response.Status.CONFLICT);
            response.addError(error);
            dataType = null;
        }
        if (null != dataType) {
            models = this.getDataObjectModelManager().getModelsForDataObjectType(dataType);
        } else {
            models = this.getDataObjectModelManager().getDataObjectModels();
        }
        List<String> list = new ArrayList<String>();
        if (null != models) {
            for (int i = 0; i < models.size(); i++) {
                DataObjectModel model = models.get(i);
                list.add(String.valueOf(model.getId()));
            }
        }
        response.setResult(list, null);
    } catch (Throwable t) {
        _logger.error("Error loading models", t);
        throw new ApsSystemException("Error loading models", t);
    }
    return response;
}
Also used : StringListApiResponse(org.entando.entando.aps.system.services.api.model.StringListApiResponse) ArrayList(java.util.ArrayList) DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiError(org.entando.entando.aps.system.services.api.model.ApiError)

Example 99 with ApsSystemException

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

the class ApiDataObjectModelInterface method deleteModel.

public void deleteModel(Properties properties) throws ApiException, Throwable {
    String idString = properties.getProperty("id");
    int id = 0;
    try {
        id = Integer.parseInt(idString);
    } catch (NumberFormatException e) {
        throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Invalid number format for 'id' parameter - '" + idString + "'", Response.Status.CONFLICT);
    }
    DataObjectModel model = this.getDataObjectModelManager().getDataObjectModel(id);
    if (null == model) {
        throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Model with id '" + idString + "' does not exist", Response.Status.CONFLICT);
    }
    try {
        this.getDataObjectModelManager().removeDataObjectModel(model);
    } catch (Throwable t) {
        _logger.error("Error deleting model", t);
        throw new ApsSystemException("Error deleting model", t);
    }
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 100 with ApsSystemException

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

the class IndexerDAO method init.

/**
 * Inizializzazione dell'indicizzatore.
 *
 * @param dir La cartella locale contenitore dei dati persistenti.
 * @throws ApsSystemException In caso di errore
 */
@Override
public void init(File dir) throws ApsSystemException {
    try {
        this._dir = FSDirectory.open(dir);
        this._dir.setLockFactory(new SimpleFSLockFactory(dir));
    } catch (Throwable t) {
        _logger.error("Error creating directory", t);
        throw new ApsSystemException("Error creating directory", t);
    }
    _logger.debug("Indexer: search engine index ok.");
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) SimpleFSLockFactory(org.apache.lucene.store.SimpleFSLockFactory)

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