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);
}
}
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);
}
}
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;
}
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);
}
}
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.");
}
Aggregations