use of org.entando.entando.aps.system.services.api.model.ApiException in project entando-core by entando.
the class ResponseBuilder method createResponse.
@Override
@Deprecated
public Object createResponse(String resourceName, Properties parameters) throws ApsSystemException {
Object apiResponse = null;
try {
ApiMethod method = this.extractApiMethod(ApiMethod.HttpMethod.GET, null, resourceName);
apiResponse = this.createResponse(method, parameters);
} catch (ApiException e) {
_logger.error("Error creating response for method GET, resource '{}'", resourceName, e);
if (apiResponse == null) {
apiResponse = new StringApiResponse();
}
((AbstractApiResponse) apiResponse).addErrors(e.getErrors());
}
return apiResponse;
}
use of org.entando.entando.aps.system.services.api.model.ApiException in project entando-core by entando.
the class ResponseBuilder method invokePutPostDeleteMethod.
protected Object invokePutPostDeleteMethod(ApiMethod apiMethod, Object bean, Properties parameters, Object bodyObject) throws ApiException, Throwable {
Object result = null;
try {
if (apiMethod.getHttpMethod().equals(ApiMethod.HttpMethod.DELETE)) {
result = this.invokeDeleteMethod(apiMethod, bean, parameters);
} else {
result = this.invokePutPostMethod(apiMethod, bean, parameters, bodyObject);
}
if (null != result)
return result;
StringApiResponse response = new StringApiResponse();
response.setResult(SUCCESS, null);
result = response;
} catch (NoSuchMethodException e) {
_logger.error("No such method '{}' of class '{}'", apiMethod.getSpringBeanMethod(), bean.getClass(), e);
throw new ApiException(IApiErrorCodes.API_METHOD_ERROR, "Method not supported - " + this.buildApiSignature(apiMethod), Response.Status.INTERNAL_SERVER_ERROR);
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof ApiException) {
throw (ApiException) e.getTargetException();
} else {
_logger.error("Error invoking method '{}' of class '{}'", apiMethod.getSpringBeanMethod(), bean.getClass());
throw new ApiException(IApiErrorCodes.API_METHOD_ERROR, "Error invoking Method - " + this.buildApiSignature(apiMethod), Response.Status.INTERNAL_SERVER_ERROR);
}
} catch (Throwable t) {
_logger.error("Error invoking method '{}' of class '{}'", apiMethod.getSpringBeanMethod(), bean.getClass(), t);
throw t;
}
return result;
}
use of org.entando.entando.aps.system.services.api.model.ApiException in project entando-core by entando.
the class ResponseBuilder method invoke.
@Override
@Deprecated
public Object invoke(String resourceName, Properties parameters) throws ApiException, ApsSystemException {
Object result = null;
try {
ApiMethod api = this.extractApiMethod(ApiMethod.HttpMethod.GET, null, resourceName);
this.checkParameter(api, parameters);
Object bean = this.extractBean(api);
result = this.invokeGetMethod(api, bean, "", parameters, true);
} catch (ApiException ae) {
_logger.error("Error invoking method GET for resource '{}'", resourceName, ae);
throw ae;
} catch (Throwable t) {
_logger.error("Error invoking method GET for resource '{}'", resourceName, t);
throw new ApsSystemException("Error invoking method GET for resource '" + resourceName + "'", t);
}
return result;
}
use of org.entando.entando.aps.system.services.api.model.ApiException in project entando-core by entando.
the class ApiDataObjectInterface method updateDataObjectText.
public void updateDataObjectText(JAXBDataObjectAttribute jaxbDataObjectAttribute, Properties properties) throws ApiException, Throwable {
try {
String dataId = jaxbDataObjectAttribute.getDataId();
DataObject masterDataObject = this.getDataObjectManager().loadDataObject(jaxbDataObjectAttribute.getDataId(), true);
if (null == masterDataObject) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject with code '" + dataId + "' does not exist", Response.Status.CONFLICT);
}
String attributeName = jaxbDataObjectAttribute.getAttributeName();
AttributeInterface attribute = (AttributeInterface) masterDataObject.getAttribute(attributeName);
if (null == attribute) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject Attribute with code '" + attributeName + "' does not exist into DataObject " + dataId, Response.Status.CONFLICT);
} else if (!(attribute instanceof ITextAttribute)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "DataObject Attribute with code '" + attributeName + "' isn't a Text Atttribute", Response.Status.CONFLICT);
}
String langCode = jaxbDataObjectAttribute.getLangCode();
String value = jaxbDataObjectAttribute.getValue();
if (StringUtils.isEmpty(langCode) || StringUtils.isEmpty(value)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "LangCode or value is Empty", Response.Status.CONFLICT);
}
((ITextAttribute) attribute).setText(value, langCode);
this.getDataObjectManager().insertDataObject(masterDataObject);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error updating DataObject attribute", t);
throw new ApsSystemException("Error updating DataObject attribute", t);
}
}
use of org.entando.entando.aps.system.services.api.model.ApiException in project entando-core by entando.
the class ApiDataObjectInterface method extractDataObjects.
protected List<String> extractDataObjects(Properties properties) throws Throwable {
List<String> contentsId = null;
try {
ApiDataObjectListBean bean = this.buildSearchBean(properties);
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
contentsId = this.getDataObjectListHelper().getDataTypesId(bean, user);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("error in extractDataObjects", t);
throw new ApsSystemException("Error into API method", t);
}
return contentsId;
}
Aggregations