use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class AbstractEntityService method updateEntityType.
protected synchronized O updateEntityType(String entityManagerCode, EntityTypeDtoRequest request, BindingResult bindingResult) {
IEntityManager entityManager = this.extractEntityManager(entityManagerCode);
try {
if (null == entityManager.getEntityPrototype(request.getCode())) {
this.addError(EntityTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, bindingResult, new String[] { request.getCode() }, "entityType.notExists");
return null;
}
IDtoBuilder<I, O> builder = this.getEntityTypeFullDtoBuilder(entityManager);
I entityPrototype = this.createEntityType(entityManager, request, bindingResult);
if (bindingResult.hasErrors()) {
return null;
} else {
((IEntityTypesConfigurer) entityManager).updateEntityPrototype(entityPrototype);
I newPrototype = (I) entityManager.getEntityPrototype(request.getCode());
O newType = builder.convert(newPrototype);
newType.setStatus(String.valueOf(entityManager.getStatus(request.getCode())));
return newType;
}
} catch (Throwable e) {
logger.error("Error updating entity type", e);
throw new RestServerError("error updating entity type", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class GroupService method addGroup.
@Override
public GroupDto addGroup(GroupRequest groupRequest) {
try {
Group group = this.createGroup(groupRequest);
this.getGroupManager().addGroup(group);
return this.getDtoBuilder().convert(group);
} catch (ApsSystemException e) {
logger.error("Error adding group", e);
throw new RestServerError("error add group", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class GroupService method removeGroup.
@Override
public void removeGroup(String groupName) {
try {
Group group = this.getGroupManager().getGroup(groupName);
BeanPropertyBindingResult validationResult = this.checkGroupForDelete(group);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
if (null != group) {
this.getGroupManager().removeGroup(group);
}
} catch (ApsSystemException e) {
logger.error("Error in delete group {}", groupName, e);
throw new RestServerError("error in delete group", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class GroupService method getGroups.
@SuppressWarnings("rawtypes")
@Override
public PagedMetadata<GroupDto> getGroups(RestListRequest restListReq) {
try {
// transforms the filters by overriding the key specified in the request with the correct one known by the dto
List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(restListReq.buildFieldSearchFilters());
filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(GroupDto.getEntityFieldName(i.getKey())));
SearcherDaoPaginatedResult<Group> groups = this.getGroupManager().getGroups(filters);
List<GroupDto> dtoList = dtoBuilder.convert(groups.getList());
PagedMetadata<GroupDto> pagedMetadata = new PagedMetadata<>(restListReq, groups);
pagedMetadata.setBody(dtoList);
return pagedMetadata;
} catch (Throwable t) {
logger.error("error in search groups", t);
throw new RestServerError("error in search groups", t);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class GroupService method getReferencesInfo.
public Map<String, Boolean> getReferencesInfo(Group group) {
Map<String, Boolean> references = new HashMap<String, Boolean>();
try {
String[] defNames = applicationContext.getBeanNamesForType(GroupUtilizer.class);
for (int i = 0; i < defNames.length; i++) {
Object service = null;
try {
service = applicationContext.getBean(defNames[i]);
} catch (Throwable t) {
logger.error("error in hasReferencingObjects", t);
service = null;
}
if (service != null) {
GroupUtilizer<?> groupUtilizer = (GroupUtilizer<?>) service;
List<?> utilizers = groupUtilizer.getGroupUtilizers(group.getName());
if (utilizers != null && !utilizers.isEmpty()) {
references.put(groupUtilizer.getName(), true);
} else {
references.put(groupUtilizer.getName(), false);
}
}
}
} catch (ApsSystemException ex) {
logger.error("error loading references for group {}", group.getName(), ex);
throw new RestServerError("error in getReferencingObjects ", ex);
}
return references;
}
Aggregations