use of io.gravitee.rest.api.model.UpdatePageEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiPageResource method updateApiPage.
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update a page", notes = "User must have the MANAGE_PAGES permission to use this service")
@ApiResponses({ @ApiResponse(code = 201, message = "Page successfully updated", response = PageEntity.class), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.API_DOCUMENTATION, acls = RolePermissionAction.UPDATE) })
public PageEntity updateApiPage(@ApiParam(name = "page", required = true) @Valid @NotNull UpdatePageEntity updatePageEntity) {
PageEntity existingPage = pageService.findById(page);
if (existingPage.getType().equals(PageType.SYSTEM_FOLDER.name())) {
throw new PageSystemFolderActionException("Update");
} else if (existingPage.getType().equals(PageType.MARKDOWN_TEMPLATE.name())) {
throw new PageMarkdownTemplateActionException("Update");
}
updatePageEntity.setLastContributor(getAuthenticatedUser());
return pageService.update(page, updatePageEntity);
}
use of io.gravitee.rest.api.model.UpdatePageEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiPageResource method partialUpdateApiPage.
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update a page", notes = "User must have the MANAGE_PAGES permission to use this service")
@ApiResponses({ @ApiResponse(code = 201, message = "Page successfully updated", response = PageEntity.class), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.API_DOCUMENTATION, acls = RolePermissionAction.UPDATE) })
public PageEntity partialUpdateApiPage(@ApiParam(name = "page") UpdatePageEntity updatePageEntity) {
PageEntity existingPage = pageService.findById(page);
if (existingPage.getType().equals(PageType.SYSTEM_FOLDER.name())) {
throw new PageSystemFolderActionException("Update");
} else if (existingPage.getType().equals(PageType.MARKDOWN_TEMPLATE.name())) {
throw new PageMarkdownTemplateActionException("Update");
}
updatePageEntity.setLastContributor(getAuthenticatedUser());
return pageService.update(page, updatePageEntity, true);
}
use of io.gravitee.rest.api.model.UpdatePageEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiPageResource method updatePageContent.
@PUT
@Path("/content")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Put the page's content", notes = "User must have the MANAGE_PAGES permission to use this service")
@ApiResponses({ @ApiResponse(code = 201, message = "Page content successfully updated"), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.API_DOCUMENTATION, acls = RolePermissionAction.UPDATE) })
public String updatePageContent(@ApiParam(name = "content", required = true) @Valid @NotNull String content) {
pageService.findById(page);
UpdatePageEntity updatePageEntity = new UpdatePageEntity();
updatePageEntity.setContent(content);
PageEntity update = pageService.update(page, updatePageEntity, true);
return update.getContent();
}
use of io.gravitee.rest.api.model.UpdatePageEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalPagesResourceAdminTest method shouldNotUpdateSystemFolder.
@Test
public void shouldNotUpdateSystemFolder() {
reset(apiService, pageService, membershipService);
final PageEntity pageMock = new PageEntity();
pageMock.setType("SYSTEM_FOLDER");
doReturn(pageMock).when(pageService).findById(PAGE_NAME);
final Response response = envTarget(PAGE_NAME).request().put(Entity.json(new UpdatePageEntity()));
assertEquals(BAD_REQUEST_400, response.getStatus());
}
use of io.gravitee.rest.api.model.UpdatePageEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalPagesResourceAdminTest method shouldNotUpdatePatchSystemFolder.
@Test
public void shouldNotUpdatePatchSystemFolder() {
reset(apiService, pageService, membershipService);
final PageEntity pageMock = new PageEntity();
pageMock.setType("SYSTEM_FOLDER");
doReturn(pageMock).when(pageService).findById(PAGE_NAME);
final Response response = envTarget(PAGE_NAME).request().method(javax.ws.rs.HttpMethod.PATCH, Entity.json(new UpdatePageEntity()));
assertEquals(BAD_REQUEST_400, response.getStatus());
}
Aggregations