use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class PageService method getPageConfiguration.
@Override
public PageConfigurationDto getPageConfiguration(String pageCode, String status) {
IPage page = this.loadPage(pageCode, status);
if (null == page) {
throw new ResourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
}
PageConfigurationDto pageConfigurationDto = new PageConfigurationDto(page, status);
return pageConfigurationDto;
}
use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class GroupService method getGroup.
@Override
public GroupDto getGroup(String groupCode) {
Group group = this.getGroupManager().getGroup(groupCode);
if (null == group) {
logger.warn("no group found with code {}", groupCode);
throw new ResourceNotFoundException(GroupValidator.ERRCODE_GROUP_NOT_FOUND, "group", groupCode);
}
GroupDto dto = this.getDtoBuilder().convert(group);
dto.setReferences(this.getReferencesInfo(group));
return dto;
}
use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class GroupService method getGroupReferences.
@Override
public PagedMetadata<?> getGroupReferences(String groupCode, String managerName, RestListRequest restRequest) {
Group group = this.getGroupManager().getGroup(groupCode);
if (null == group) {
logger.warn("no group found with code {}", groupCode);
throw new ResourceNotFoundException(GroupValidator.ERRCODE_GROUP_NOT_FOUND, "group", groupCode);
}
GroupServiceUtilizer<?> utilizer = this.getGroupServiceUtilizer(managerName);
if (null == utilizer) {
logger.warn("no references found for {}", managerName);
throw new ResourceNotFoundException(GroupValidator.ERRCODE_GROUP_REFERENCES, "reference", managerName);
}
List<?> dtoList = utilizer.getGroupUtilizer(groupCode);
List<?> subList = restRequest.getSublist(dtoList);
int size = 0;
if (dtoList != null) {
size = dtoList.size();
}
SearcherDaoPaginatedResult<?> pagedResult = new SearcherDaoPaginatedResult(size, subList);
PagedMetadata<Object> pagedMetadata = new PagedMetadata<>(restRequest, pagedResult);
pagedMetadata.setBody((List<Object>) subList);
return pagedMetadata;
}
use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class LabelService method updateLabelGroup.
@Override
public LabelDto updateLabelGroup(LabelDto labelRequest) {
try {
String code = labelRequest.getKey();
ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
if (null == labelGroup) {
logger.warn("no label found with key {}", code);
throw new ResourceNotFoundException(LabelValidator.ERRCODE_LABELGROUP_NOT_FOUND, "label", code);
}
BeanPropertyBindingResult validationResult = this.validateUpdateLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().updateLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in update label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in update label group", t);
}
}
use of org.entando.entando.aps.system.exception.ResourceNotFoundException in project entando-core by entando.
the class PageServiceIntegrationTest method testAddAndRemovePage.
@Test
public void testAddAndRemovePage() throws Throwable {
PageDto pageToClone = pageService.getPage("pagina_11", "draft");
assertNotNull(pageToClone);
PageRequest pageRequest = this.createRequestFromDto(pageToClone);
pageRequest.setCode("pagina_13");
PageDto addedPage = pageService.addPage(pageRequest);
assertNotNull(addedPage);
assertEquals("pagina_13", addedPage.getCode());
assertEquals("pagina_1", addedPage.getParentCode());
addedPage = pageService.getPage("pagina_13", "draft");
assertNotNull(addedPage);
assertEquals("pagina_13", addedPage.getCode());
assertEquals("pagina_1", addedPage.getParentCode());
pageService.removePage("pagina_13");
try {
addedPage = null;
addedPage = pageService.getPage("pagina_13", "draft");
fail("RestRourceNotFoundException not thrown");
} catch (ResourceNotFoundException e) {
assertNull(addedPage);
}
}
Aggregations