TSK-679 - Delete all workbasket access items for a user
This commit is contained in:
parent
bf38e98f1c
commit
afe618eba4
|
@ -635,6 +635,45 @@ include::../../../{snippets}/GetTaskClassificationReportDocTest/http-response.ad
|
||||||
|
|
||||||
Same as task status report
|
Same as task status report
|
||||||
|
|
||||||
|
== WorkbasketAccessItems-Resource
|
||||||
|
|
||||||
|
=== GET a list of all workbasketAccessItems
|
||||||
|
|
||||||
|
A `GET` return all workbasketAccessItems that correspond the given data.
|
||||||
|
|
||||||
|
==== Example Request
|
||||||
|
|
||||||
|
include::../../../{snippets}/GetWorkbasketAccessItemsDocTest/http-request.adoc[]
|
||||||
|
|
||||||
|
==== Example Response
|
||||||
|
|
||||||
|
include::../../../{snippets}/GetWorkbasketAccessItemsDocTest/http-response.adoc[]
|
||||||
|
|
||||||
|
==== Response Structure
|
||||||
|
|
||||||
|
include::../../../{snippets}/GetWorkbasketAccessItemsDocTest/response-fields.adoc[]
|
||||||
|
|
||||||
|
=== Filter and sort options
|
||||||
|
|
||||||
|
The list generated in the response can be filtered using following parameters in the uri: +
|
||||||
|
workbasket-key | workbasket-key-like | access-id | access-id-like +
|
||||||
|
name | name-like | key | key-like | owner | owner-like | description-like | domain | +
|
||||||
|
|
||||||
|
It can also be sorted by using this set of parameters: +
|
||||||
|
sortBy = { workbasket-key | access-id } | order={ desc | asc }
|
||||||
|
|
||||||
|
=== Delete a workbasketAccessItems
|
||||||
|
|
||||||
|
A `DELETE` request is used to delete a workbasketAccessItems.
|
||||||
|
|
||||||
|
==== Example request
|
||||||
|
|
||||||
|
include::../../../{snippets}/RemoveWorkbasketAccessItemsDocTest/http-request.adoc[]
|
||||||
|
|
||||||
|
==== Example response
|
||||||
|
|
||||||
|
include::../../../{snippets}/RemoveWorkbasketAccessItemsDocTest/http-response.adoc[]
|
||||||
|
|
||||||
== Other Resources (using the TaskanaEngineController)
|
== Other Resources (using the TaskanaEngineController)
|
||||||
|
|
||||||
These resources are directly connected to the Taskana Engine endpoint.
|
These resources are directly connected to the Taskana Engine endpoint.
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
package pro.taskana.doc.api;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||||
|
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||||
|
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
|
||||||
|
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||||
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
import pro.taskana.rest.RestConfiguration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||||
|
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
|
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
|
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
|
||||||
|
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||||
|
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||||
|
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
public class WorkbasketAccessItemControllerRestDocumentation {
|
||||||
|
@LocalServerPort
|
||||||
|
int port;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WebApplicationContext context;
|
||||||
|
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>();
|
||||||
|
private FieldDescriptor[] accessItemFieldDescriptors;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
document("{methodName}",
|
||||||
|
preprocessRequest(prettyPrint()),
|
||||||
|
preprocessResponse(prettyPrint()));
|
||||||
|
|
||||||
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||||
|
.apply(springSecurity())
|
||||||
|
.apply(documentationConfiguration(this.restDocumentation)
|
||||||
|
.operationPreprocessors()
|
||||||
|
.withResponseDefaults(prettyPrint())
|
||||||
|
.withRequestDefaults(prettyPrint()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket id");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", "The access id. This could be either a userid or a full qualified group id");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessName", "The name");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketKey", "The workbasket key");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", "The permission to read the information about the workbasket");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen", "The permission to view the content (the tasks) of a workbasket");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend", "The permission to add tasks to the workbasket (required for creation and tranferring of tasks)");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer", "The permission to transfer tasks (out of the current workbasket)");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute", "The permission to distribute tasks from the workbasket");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom1", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom4", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom5", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom6", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom7", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom8", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom9", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom10", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom11", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom12", "");
|
||||||
|
accessItemFieldDescriptionsMap.put("_links.self.href", "Link to self");
|
||||||
|
accessItemFieldDescriptionsMap.put("page", "Number of page");
|
||||||
|
|
||||||
|
accessItemFieldDescriptors = new FieldDescriptor[] {
|
||||||
|
fieldWithPath("_embedded.accessItems[].accessItemId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].workbasketId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].accessId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].accessName").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].workbasketKey").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permRead").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permOpen").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permAppend").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permTransfer").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permDistribute").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom1").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom2").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom3").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom4").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom5").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom6").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom7").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom8").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom9").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom10").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom11").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")),
|
||||||
|
fieldWithPath("_embedded.accessItems[].permCustom12").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")),
|
||||||
|
fieldWithPath("_links.self.href").description(accessItemFieldDescriptionsMap.get("_links.self.href")),
|
||||||
|
fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page"))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWorkbasketAccessItemsDocTest() throws Exception {
|
||||||
|
this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_1_1")
|
||||||
|
.accept("application/hal+json")
|
||||||
|
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
.andDo(MockMvcRestDocumentation.document("GetWorkbasketAccessItemsDocTest",
|
||||||
|
responseFields(accessItemFieldDescriptors)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeWorkbasketAccessItemsDocTest() throws Exception {
|
||||||
|
this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port + "/v1/workbasket-access-items/?access-id=user_1_1")
|
||||||
|
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isNoContent())
|
||||||
|
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,8 +3,10 @@ package pro.taskana.rest;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.web.server.LocalServerPort;
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.core.ParameterizedTypeReference;
|
import org.springframework.core.ParameterizedTypeReference;
|
||||||
|
@ -23,6 +25,7 @@ import java.util.Collections;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||||
properties = {"devMode=true"})
|
properties = {"devMode=true"})
|
||||||
|
@ -45,7 +48,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllWorkbasketAccessItems() {
|
public void testGetAllWorkbasketAccessItems() {
|
||||||
ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> response = template.exchange(
|
ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> response = template.exchange(
|
||||||
url + port + "/v1/workbasket-access", HttpMethod.GET, request,
|
url + port + "/v1/workbasket-access-items", HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
||||||
});
|
});
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||||
|
@ -53,7 +56,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWorkbasketAccessItemsKeepingFilters() {
|
public void testGetWorkbasketAccessItemsKeepingFilters() {
|
||||||
String parameters = "/v1/workbasket-access/?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
String parameters = "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
||||||
ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> response = template.exchange(
|
ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> response = template.exchange(
|
||||||
url + port + parameters, HttpMethod.GET, request,
|
url + port + parameters, HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
||||||
|
@ -69,7 +72,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
public void testThrowsExceptionIfInvalidFilterIsUsed() {
|
public void testThrowsExceptionIfInvalidFilterIsUsed() {
|
||||||
try {
|
try {
|
||||||
template.exchange(
|
template.exchange(
|
||||||
url + port + "/v1/workbasket-access/?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1", HttpMethod.GET, request,
|
url + port + "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=1&page-size=9&invalid=user_1_1", HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
||||||
});
|
});
|
||||||
fail();
|
fail();
|
||||||
|
@ -81,7 +84,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSecondPageSortedByWorkbasketKey() {
|
public void testGetSecondPageSortedByWorkbasketKey() {
|
||||||
String parameters = "/v1/workbasket-access/?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
String parameters = "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
||||||
ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> response = template.exchange(
|
ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> response = template.exchange(
|
||||||
url + port + parameters, HttpMethod.GET, request,
|
url + port + parameters, HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketAccesItemExtendedResource>>() {
|
||||||
|
@ -101,6 +104,30 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
assertEquals(1, response.getBody().getMetadata().getNumber());
|
assertEquals(1, response.getBody().getMetadata().getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveWorkbasketAccessItemsOfUser() {
|
||||||
|
String parameters = "/v1/workbasket-access-items/?access-id=user_1_1";
|
||||||
|
ResponseEntity<Void> response = template.exchange(
|
||||||
|
url + port + parameters, HttpMethod.DELETE, request,
|
||||||
|
new ParameterizedTypeReference<Void>() {
|
||||||
|
});
|
||||||
|
assertNull(response.getBody());
|
||||||
|
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
||||||
|
String parameters = "/v1/workbasket-access-items/?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
||||||
|
try {
|
||||||
|
ResponseEntity<Void> response = template.exchange(
|
||||||
|
url + port + parameters, HttpMethod.DELETE, request,
|
||||||
|
new ParameterizedTypeReference<Void>() {
|
||||||
|
});
|
||||||
|
} catch (HttpClientErrorException e) {
|
||||||
|
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a REST template which is capable of dealing with responses in HAL format
|
* Return a REST template which is capable of dealing with responses in HAL format
|
||||||
*
|
*
|
||||||
|
|
|
@ -307,6 +307,10 @@ public class LdapClient {
|
||||||
return env.getProperty("taskana.ldap.groupsOfUser");
|
return env.getProperty("taskana.ldap.groupsOfUser");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGroup(String accessId) {
|
||||||
|
return accessId.contains(getGroupSearchBase());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context Mapper for user entries.
|
* Context Mapper for user entries.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
@ -21,6 +22,7 @@ import pro.taskana.WorkbasketAccessItemQuery;
|
||||||
import pro.taskana.WorkbasketService;
|
import pro.taskana.WorkbasketService;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
|
import pro.taskana.ldap.LdapClient;
|
||||||
import pro.taskana.rest.resource.WorkbasketAccesItemExtendedResource;
|
import pro.taskana.rest.resource.WorkbasketAccesItemExtendedResource;
|
||||||
import pro.taskana.rest.resource.assembler.WorkbasketAccessItemExtendedAssembler;
|
import pro.taskana.rest.resource.assembler.WorkbasketAccessItemExtendedAssembler;
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ import pro.taskana.rest.resource.assembler.WorkbasketAccessItemExtendedAssembler
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
|
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
|
||||||
@RequestMapping(path = "/v1/workbasket-access", produces = "application/hal+json")
|
@RequestMapping(path = "/v1/workbasket-access-items", produces = "application/hal+json")
|
||||||
public class WorkbasketAccessItemController extends AbstractPagingController {
|
public class WorkbasketAccessItemController extends AbstractPagingController {
|
||||||
|
|
||||||
private static final String LIKE = "%";
|
private static final String LIKE = "%";
|
||||||
|
@ -45,9 +47,20 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
||||||
private static final String PAGING_PAGE = "page";
|
private static final String PAGING_PAGE = "page";
|
||||||
private static final String PAGING_PAGE_SIZE = "page-size";
|
private static final String PAGING_PAGE_SIZE = "page-size";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
LdapClient ldapClient;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkbasketService workbasketService;
|
private WorkbasketService workbasketService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This GET method return all workbasketAccessItems that correspond the given data.
|
||||||
|
*
|
||||||
|
* @param params filter, order and access ids.
|
||||||
|
* @return all WorkbasketAccesItemExtendedResource.
|
||||||
|
* @throws NotAuthorizedException if the user is not authorized.
|
||||||
|
* @throws InvalidArgumentException if some argument is invalid.
|
||||||
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> getWorkbasketAccessItems(
|
public ResponseEntity<PagedResources<WorkbasketAccesItemExtendedResource>> getWorkbasketAccessItems(
|
||||||
@RequestParam MultiValueMap<String, String> params)
|
@RequestParam MultiValueMap<String, String> params)
|
||||||
|
@ -86,6 +99,34 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
||||||
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This DELETE method delete all workbasketAccessItems that correspond the given accessId.
|
||||||
|
*
|
||||||
|
* @param accessId which need remove his workbasketAccessItems.
|
||||||
|
* @return ResponseEntity if the user is not authorized.
|
||||||
|
* @throws NotAuthorizedException if the user is not authorized.
|
||||||
|
* @throws InvalidArgumentException if some argument is invalid.
|
||||||
|
*/
|
||||||
|
@DeleteMapping
|
||||||
|
public ResponseEntity<Void> removeWorkbasketAccessItems(
|
||||||
|
@RequestParam("access-id") String accessId)
|
||||||
|
throws NotAuthorizedException, InvalidArgumentException {
|
||||||
|
if (!ldapClient.isGroup(accessId)) {
|
||||||
|
List<WorkbasketAccessItemExtended> workbasketAccessItemList = workbasketService.createWorkbasketAccessItemExtendedQuery()
|
||||||
|
.accessIdIn(accessId)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
if (workbasketAccessItemList != null && !workbasketAccessItemList.isEmpty()) {
|
||||||
|
workbasketService.deleteWorkbasketAccessItemsForAccessId(accessId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
accessId + " corresponding to a group, not a user. You just can remove access items for a user");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
|
||||||
|
}
|
||||||
|
|
||||||
private WorkbasketAccessItemQuery.Extended getAccessIds(WorkbasketAccessItemQuery.Extended query,
|
private WorkbasketAccessItemQuery.Extended getAccessIds(WorkbasketAccessItemQuery.Extended query,
|
||||||
MultiValueMap<String, String> params) throws InvalidArgumentException {
|
MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||||
if (params.containsKey(ACCESS_IDS)) {
|
if (params.containsKey(ACCESS_IDS)) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<div class="pull-right btn-group">
|
<div class="pull-right btn-group">
|
||||||
<button *ngIf="AccessItemsForm" type="button" class="btn btn-default" data-toggle="tooltip" title="Revoke access">
|
<button *ngIf="AccessItemsForm" type="button" (click)="revokeAccess()" class="btn btn-default" data-toggle="tooltip" title="Revoke access">
|
||||||
<span class="glyphicon glyphicon-remove red" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-remove red" aria-hidden="true"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,6 +13,9 @@ import { SortingModel } from 'app/models/sorting';
|
||||||
import { RequestInProgressService } from '../../services/requestInProgress/request-in-progress.service';
|
import { RequestInProgressService } from '../../services/requestInProgress/request-in-progress.service';
|
||||||
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
||||||
import { ErrorModel } from 'app/models/modal-error';
|
import { ErrorModel } from 'app/models/modal-error';
|
||||||
|
import { RemoveConfirmationService } from 'app/services/remove-confirmation/remove-confirmation.service';
|
||||||
|
import { AlertModel, AlertType } from 'app/models/alert';
|
||||||
|
import { AlertService } from 'app/services/alert/alert.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'taskana-access-items-management',
|
selector: 'taskana-access-items-management',
|
||||||
|
@ -71,6 +74,8 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy {
|
||||||
private accessIdsService: AccessIdsService,
|
private accessIdsService: AccessIdsService,
|
||||||
private formsValidatorService: FormsValidatorService,
|
private formsValidatorService: FormsValidatorService,
|
||||||
private requestInProgressService: RequestInProgressService,
|
private requestInProgressService: RequestInProgressService,
|
||||||
|
private removeConfirmationService: RemoveConfirmationService,
|
||||||
|
private alertService: AlertService,
|
||||||
private errorModalService: ErrorModalService) { }
|
private errorModalService: ErrorModalService) { }
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,6 +143,41 @@ export class AccessItemsManagementComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
revokeAccess() {
|
||||||
|
this.removeConfirmationService.setRemoveConfirmation(
|
||||||
|
this.onRemoveConfirmed.bind(this),
|
||||||
|
`You are going to delete all access related: ${
|
||||||
|
this.accessIdSelected
|
||||||
|
}. Can you confirm this action?`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onRemoveConfirmed() {
|
||||||
|
this.requestInProgressService.setRequestInProgress(true);
|
||||||
|
this.accessIdsService.removeAccessItemsPermissions(this.accessIdSelected)
|
||||||
|
.subscribe(
|
||||||
|
response => {
|
||||||
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
|
this.alertService.triggerAlert(
|
||||||
|
new AlertModel(
|
||||||
|
AlertType.SUCCESS,
|
||||||
|
`${this.accessIdSelected
|
||||||
|
} was removed successfully`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
this.searchForAccessItemsWorkbaskets();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.requestInProgressService.setRequestInProgress(false);
|
||||||
|
this.errorModalService.triggerError(
|
||||||
|
new ErrorModel(
|
||||||
|
`You can't delete a group`,
|
||||||
|
error
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private unSubscribe(subscription: Subscription): void {
|
private unSubscribe(subscription: Subscription): void {
|
||||||
if (subscription) { subscription.unsubscribe(); }
|
if (subscription) { subscription.unsubscribe(); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ export class AccessIdsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.accessItemsRef = this.httpClient.get<AccessItemsWorkbasketResource>(encodeURI(
|
return this.accessItemsRef = this.httpClient.get<AccessItemsWorkbasketResource>(encodeURI(
|
||||||
`${environment.taskanaRestUrl}/v1/workbasket-access/${TaskanaQueryParameters.getQueryParameters(sortModel.sortBy,
|
`${environment.taskanaRestUrl}/v1/workbasket-access-items/${TaskanaQueryParameters.getQueryParameters(sortModel.sortBy,
|
||||||
sortModel.sortDirection,
|
sortModel.sortDirection,
|
||||||
undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
|
undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
|
||||||
accessIds.map((values: AccessIdDefinition) => {
|
accessIds.map((values: AccessIdDefinition) => {
|
||||||
|
@ -44,4 +44,9 @@ export class AccessIdsService {
|
||||||
}).join('|'),
|
}).join('|'),
|
||||||
accessIdLike, workbasketKeyLike)}`))
|
accessIdLike, workbasketKeyLike)}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeAccessItemsPermissions(accessId: string) {
|
||||||
|
return this.httpClient
|
||||||
|
.delete<AccessItemsWorkbasketResource>(`${environment.taskanaRestUrl}/v1/workbasket-access-items/?access-id=` + accessId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue