use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiUserProfileTypeInterface method updateUserProfileType.
public StringApiResponse updateUserProfileType(JAXBUserProfileType jaxbProfileType) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String typeCode = jaxbProfileType.getTypeCode();
IApsEntity masterProfileType = this.getUserProfileManager().getEntityPrototype(typeCode);
if (null == masterProfileType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "User Profile type with code '" + typeCode + "' doesn't exist");
}
Map<String, AttributeInterface> attributes = this.getUserProfileManager().getEntityAttributePrototypes();
IApsEntity profileType = jaxbProfileType.buildEntityType(this.getUserProfileManager().getEntityClass(), attributes);
((IEntityTypesConfigurer) this.getUserProfileManager()).updateEntityPrototype(profileType);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error updating user profile type", t);
// ApsSystemUtils.logThrowable(t, this, "updateProfileType");
throw new ApsSystemException("Error updating user profile type", t);
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ApiUserProfileTypeInterface method addUserProfileType.
public StringApiResponse addUserProfileType(JAXBUserProfileType jaxbProfileType) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String typeCode = jaxbProfileType.getTypeCode();
IApsEntity masterProfileType = this.getUserProfileManager().getEntityPrototype(typeCode);
if (null != masterProfileType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "User Profile type with code '" + typeCode + "' already exists");
}
if (typeCode == null || typeCode.length() != 3) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Invalid type code - '" + typeCode + "'");
}
Map<String, AttributeInterface> attributes = this.getUserProfileManager().getEntityAttributePrototypes();
IApsEntity profileType = jaxbProfileType.buildEntityType(this.getUserProfileManager().getEntityClass(), attributes);
((IEntityTypesConfigurer) this.getUserProfileManager()).addEntityPrototype(profileType);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error adding user profile type", t);
// ApsSystemUtils.logThrowable(t, this, "addProfileType");
throw new ApsSystemException("Error adding user profile type", t);
}
return response;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class WidgetService method removeWidget.
@Override
public void removeWidget(String widgetCode) {
try {
WidgetType type = this.getWidgetManager().getWidgetType(widgetCode);
BeanPropertyBindingResult validationResult = checkWidgetForDelete(type);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
List<String> fragmentCodes = this.getGuiFragmentManager().getGuiFragmentCodesByWidgetType(widgetCode);
for (String fragmentCode : fragmentCodes) {
this.getGuiFragmentManager().deleteGuiFragment(fragmentCode);
}
this.getWidgetManager().deleteWidgetType(widgetCode);
} catch (ApsSystemException e) {
logger.error("Failed to remove widget type for request {} ", widgetCode);
throw new RestServerError("failed to update widget type by code ", e);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class ResponseBuilder method checkParameter.
private void checkParameter(ApiMethod apiMethod, Properties parameters) throws ApiException, Throwable {
try {
List<ApiMethodParameter> apiParameters = apiMethod.getParameters();
if (null == apiParameters || apiParameters.isEmpty()) {
return;
}
List<ApiError> errors = new ArrayList<ApiError>();
for (int i = 0; i < apiParameters.size(); i++) {
ApiMethodParameter apiParam = apiParameters.get(i);
String paramName = apiParam.getKey();
Object value = parameters.get(paramName);
if (apiParam.isRequired() && (null == value || value.toString().trim().length() == 0)) {
errors.add(new ApiError(IApiErrorCodes.API_PARAMETER_REQUIRED, "Parameter '" + paramName + "' is required", Response.Status.BAD_REQUEST));
}
}
if (!errors.isEmpty()) {
throw new ApiException(errors);
}
} catch (ApiException t) {
throw t;
} catch (Throwable t) {
_logger.error("Error checking api parameters", t);
throw new ApsSystemException("Internal Error", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class CacheInfoManager method aroundCacheInfoEvictMethod.
@Around("@annotation(cacheInfoEvict)")
public Object aroundCacheInfoEvictMethod(ProceedingJoinPoint pjp, CacheInfoEvict cacheInfoEvict) throws Throwable {
try {
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Method targetMethod = methodSignature.getMethod();
Class targetClass = pjp.getTarget().getClass();
Method effectiveTargetMethod = targetClass.getMethod(targetMethod.getName(), targetMethod.getParameterTypes());
String[] cacheNames = cacheInfoEvict.value();
Object groupsCsv = this.evaluateExpression(cacheInfoEvict.groups().toString(), targetMethod, pjp.getArgs(), effectiveTargetMethod, targetClass);
if (null != groupsCsv && groupsCsv.toString().trim().length() > 0) {
String[] groups = groupsCsv.toString().split(",");
for (String group : groups) {
for (String cacheName : cacheNames) {
this.flushGroup(cacheName, group);
}
}
}
} catch (Throwable t) {
logger.error("Error while flushing group", t);
throw new ApsSystemException("Error while flushing group", t);
}
return pjp.proceed();
}
Aggregations