Search in sources :

Example 11 with ResourceNotFoundException

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;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto)

Example 12 with ResourceNotFoundException

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;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Example 13 with ResourceNotFoundException

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;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException)

Example 14 with ResourceNotFoundException

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);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 15 with ResourceNotFoundException

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);
    }
}
Also used : PageRequest(org.entando.entando.web.page.model.PageRequest) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) Test(org.junit.Test)

Aggregations

ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)53 RestServerError (org.entando.entando.aps.system.exception.RestServerError)27 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)20 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)15 IPage (com.agiletec.aps.system.services.page.IPage)9 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)9 Category (com.agiletec.aps.system.services.category.Category)7 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)7 ResponseEntity (org.springframework.http.ResponseEntity)7 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)5 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 Group (com.agiletec.aps.system.services.group.Group)3 Widget (com.agiletec.aps.system.services.page.Widget)3 Role (com.agiletec.aps.system.services.role.Role)3