TSK-441 Add foreign key constraint for workbasket_id to workbasket-access-list

This commit is contained in:
BerndBreier 2018-04-16 10:54:15 +02:00 committed by Holger Hagen
parent fd0b1436c5
commit 36d66064a7
12 changed files with 106 additions and 57 deletions

View File

@ -101,9 +101,11 @@ public interface WorkbasketService {
* when the preconditions dont match the required ones. * when the preconditions dont match the required ones.
* @throws NotAuthorizedException * @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN * if the current user is not member of role BUSINESS_ADMIN or ADMIN
* @throws WorkbasketNotFoundException
* if the workbasketAccessItem refers to a not existing workbasket
*/ */
WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException;
/** /**
* This method updates a {@link WorkbasketAccessItem}. * This method updates a {@link WorkbasketAccessItem}.

View File

@ -199,7 +199,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
LOGGER.debug("entry to createWorkbasketAccessItemn(workbasketAccessItem = {})", workbasketAccessItem); LOGGER.debug("entry to createWorkbasketAccessItemn(workbasketAccessItem = {})", workbasketAccessItem);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
@ -214,6 +214,11 @@ public class WorkbasketServiceImpl implements WorkbasketService {
"Checking the preconditions of the current WorkbasketAccessItem failed. WorkbasketAccessItem=" "Checking the preconditions of the current WorkbasketAccessItem failed. WorkbasketAccessItem="
+ workbasketAccessItem.toString()); + workbasketAccessItem.toString());
} }
WorkbasketImpl wb = workbasketMapper.findById(workbasketAccessItem.getWorkbasketId());
if (wb == null) {
throw new WorkbasketNotFoundException(workbasketAccessItem.getWorkbasketId(),
"WorkbasketAccessItem " + workbasketAccessItem + " refers to a not existing workbasket");
}
workbasketAccessMapper.insert(accessItem); workbasketAccessMapper.insert(accessItem);
LOGGER.debug("Method createWorkbasketAccessItem() created workbaskteAccessItem {}", LOGGER.debug("Method createWorkbasketAccessItem() created workbaskteAccessItem {}",
accessItem); accessItem);

View File

@ -134,7 +134,8 @@ CREATE TABLE TASKANA.WORKBASKET_ACCESS_LIST(
PERM_CUSTOM_10 SMALLINT NOT NULL, PERM_CUSTOM_10 SMALLINT NOT NULL,
PERM_CUSTOM_11 SMALLINT NOT NULL, PERM_CUSTOM_11 SMALLINT NOT NULL,
PERM_CUSTOM_12 SMALLINT NOT NULL, PERM_CUSTOM_12 SMALLINT NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID),
CONSTRAINT ACCESS_LIST_WB FOREIGN KEY (WORKBASKET_ID) REFERENCES TASKANA.WORKBASKET ON DELETE CASCADE
); );
CREATE TABLE TASKANA.OBJECT_REFERENCE( CREATE TABLE TASKANA.OBJECT_REFERENCE(

View File

@ -1,11 +1,13 @@
package acceptance.workbasket; package acceptance.workbasket;
import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -13,6 +15,7 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import pro.taskana.Workbasket; import pro.taskana.Workbasket;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType; import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.DomainNotFoundException; import pro.taskana.exceptions.DomainNotFoundException;
@ -156,4 +159,35 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
} }
} }
@WithAccessId(userName = "teamlead_2", groupNames = {"businessadmin"})
@Test
public void testCascadingDeleteOfAccessItems()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000008");
String wbId = wb.getId();
// create 2 access Items
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wbId, "teamlead_2");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
accessItem = workbasketService.newWorkbasketAccessItem(wbId, "elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
List<WorkbasketAccessItem> accessItemsBefore = workbasketService.getWorkbasketAccessItems(wbId);
assertEquals(5, accessItemsBefore.size());
workbasketService.deleteWorkbasket(wbId);
try {
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000008");
fail("There should be no result for a deleted Workbasket.");
} catch (WorkbasketNotFoundException e) {
// Workbasket is deleted
}
List<WorkbasketAccessItem> accessItemsAfter = workbasketService.getWorkbasketAccessItems(wbId);
assertEquals(0, accessItemsAfter.size());
}
} }

View File

@ -47,10 +47,11 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "businessadmin"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException, NotAuthorizedException { public void testUpdateWorkbasketAccessItemSucceeds()
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService WorkbasketAccessItem accessItem = workbasketService
.newWorkbasketAccessItem("key1000000000000000000000000000000000000", "user1"); .newWorkbasketAccessItem("WBI:100000000000000000000000000000000002", "user1");
accessItem.setPermAppend(true); accessItem.setPermAppend(true);
accessItem.setPermCustom11(true); accessItem.setPermCustom11(true);
accessItem.setPermRead(true); accessItem.setPermRead(true);
@ -76,7 +77,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
InvalidWorkbasketException { InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService WorkbasketAccessItem accessItem = workbasketService
.newWorkbasketAccessItem("1000000000000000000000000000000000000000", "user1"); .newWorkbasketAccessItem("WBI:100000000000000000000000000000000001", "user1");
accessItem.setPermAppend(true); accessItem.setPermAppend(true);
accessItem.setPermCustom11(true); accessItem.setPermCustom11(true);
accessItem.setPermRead(true); accessItem.setPermRead(true);

View File

@ -405,7 +405,7 @@ public class TaskServiceImplIntAutocommitTest {
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead); accessItem.setPermRead(permRead);

View File

@ -107,16 +107,20 @@ public class TaskServiceImplIntExplicitTest {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
generateSampleAccessItems();
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A"); WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket"); workbasket.setName("workbasket");
// workbasket.setId("1 "); // set id manually for authorization tests
workbasket.setId("1"); // set id manually for authorization tests workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP); workbasket.setType(WorkbasketType.GROUP);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK"); Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket); taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
taskanaEngineImpl.getClassificationService().createClassification(classification); taskanaEngineImpl.getClassificationService().createClassification(classification);
connection.commit(); connection.commit();
Task task = taskServiceImpl.newTask(workbasket.getId()); Task task = taskServiceImpl.newTask(workbasket.getId());
@ -143,12 +147,10 @@ public class TaskServiceImplIntExplicitTest {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
generateSampleAccessItems();
Task task = this.generateDummyTask(); Task task = this.generateDummyTask();
connection.commit(); connection.commit();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("wb", "Elena"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true); accessItem.setPermAppend(true);
accessItem.setPermRead(true); accessItem.setPermRead(true);
accessItem.setPermOpen(true); accessItem.setPermOpen(true);
@ -213,9 +215,6 @@ public class TaskServiceImplIntExplicitTest {
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException { InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
generateSampleAccessItems();
Task test = this.generateDummyTask(); Task test = this.generateDummyTask();
((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2"); ((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2");
taskServiceImpl.createTask(test); taskServiceImpl.createTask(test);
@ -230,8 +229,6 @@ public class TaskServiceImplIntExplicitTest {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
generateSampleAccessItems();
Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A"); Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
wb.setName("dummy-WB"); wb.setName("dummy-WB");
wb.setType(WorkbasketType.PERSONAL); wb.setType(WorkbasketType.PERSONAL);
@ -244,7 +241,7 @@ public class TaskServiceImplIntExplicitTest {
classification.setName("not persisted - so not found."); classification.setName("not persisted - so not found.");
Task task = this.generateDummyTask(); Task task = this.generateDummyTask();
((TaskImpl) task).setWorkbasketKey(wb.getKey()); ((TaskImpl) task).setWorkbasketSummary(wb.asSummary());
task.setClassificationKey(classification.getKey()); task.setClassificationKey(classification.getKey());
taskServiceImpl.createTask(task); taskServiceImpl.createTask(task);
} }
@ -257,9 +254,6 @@ public class TaskServiceImplIntExplicitTest {
WorkbasketAlreadyExistException, DomainNotFoundException { WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
generateSampleAccessItems();
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A"); WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket"); workbasket.setName("workbasket");
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK"); Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
@ -268,6 +262,12 @@ public class TaskServiceImplIntExplicitTest {
workbasket.setType(WorkbasketType.GROUP); workbasket.setType(WorkbasketType.GROUP);
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket); workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
Task task = taskServiceImpl.newTask(workbasket.getId()); Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task"); task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey()); task.setClassificationKey(classification.getKey());
@ -477,22 +477,9 @@ public class TaskServiceImplIntExplicitTest {
return task; return task;
} }
private void generateSampleAccessItems() throws InvalidArgumentException, NotAuthorizedException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
WorkbasketAccessItem accessItem2 = workbasketService.newWorkbasketAccessItem("2", "DummyGroup");
accessItem.setPermRead(true);
accessItem2.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem2);
}
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead); accessItem.setPermRead(permRead);

View File

@ -31,9 +31,11 @@ import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
import pro.taskana.WorkbasketType; import pro.taskana.WorkbasketType;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException; import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.TaskanaEngineProxyForTest; import pro.taskana.impl.TaskanaEngineProxyForTest;
@ -136,7 +138,13 @@ public class WorkbasketServiceImplIntAutocommitTest {
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"}) @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException { public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException,
DomainNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
WorkbasketNotFoundException {
Workbasket wb = createTestWorkbasket("k100000000000000000000000000000000000000", "key1", "DOMAIN_A", "name",
WorkbasketType.PERSONAL);
workBasketService.createWorkbasket(wb);
WorkbasketAccessItem accessItem = workBasketService WorkbasketAccessItem accessItem = workBasketService
.newWorkbasketAccessItem("k100000000000000000000000000000000000000", "Arthur Dent"); .newWorkbasketAccessItem("k100000000000000000000000000000000000000", "Arthur Dent");
accessItem.setPermOpen(true); accessItem.setPermOpen(true);
@ -149,7 +157,16 @@ public class WorkbasketServiceImplIntAutocommitTest {
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"}) @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException { public void testUpdateWorkbasketAccessUser()
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, DomainNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException {
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket("key", "DOMAIN_A");
wb.setId("k200000000000000000000000000000000000000");
wb.setName("name");
wb.setDescription("Description of a Workbasket...");
wb.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(wb);
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
"k200000000000000000000000000000000000000", "k200000000000000000000000000000000000000",
"Zaphod Beeblebrox"); "Zaphod Beeblebrox");
@ -198,7 +215,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getId(), accessId); WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead); accessItem.setPermRead(permRead);

View File

@ -25,8 +25,12 @@ import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
import pro.taskana.WorkbasketType; import pro.taskana.WorkbasketType;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl; import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.configuration.DBCleaner; import pro.taskana.impl.configuration.DBCleaner;
@ -120,27 +124,36 @@ public class WorkbasketServiceImplIntExplicitTest {
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"}) @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException { public void testInsertWorkbasketAccessUser()
throws NotAuthorizedException, SQLException, InvalidArgumentException, WorkbasketNotFoundException,
DomainNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
Workbasket wb = createTestWorkbasket("id1", "key1", "DOMAIN_A", "name", WorkbasketType.CLEARANCE);
workBasketService.createWorkbasket(wb);
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
"Key1", "id1",
"Arthur Dent"); "Arthur Dent");
accessItem.setPermOpen(true); accessItem.setPermOpen(true);
accessItem.setPermRead(true); accessItem.setPermRead(true);
workBasketService.createWorkbasketAccessItem(accessItem); workBasketService.createWorkbasketAccessItem(accessItem);
Assert.assertEquals(1, workBasketService.getWorkbasketAccessItems("Key1").size()); Assert.assertEquals(1, workBasketService.getWorkbasketAccessItems("id1").size());
connection.commit(); connection.commit();
} }
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"}) @WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException { public void testUpdateWorkbasketAccessUser()
throws NotAuthorizedException, SQLException, InvalidArgumentException, WorkbasketNotFoundException,
DomainNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
Workbasket wb = createTestWorkbasket("key2", "kkey2", "DOMAIN_A", "name", WorkbasketType.CLEARANCE);
workBasketService.createWorkbasket(wb);
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
"key2", "key2",
"Zaphod Beeblebrox"); "Zaphod Beeblebrox");
@ -155,7 +168,7 @@ public class WorkbasketServiceImplIntExplicitTest {
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen, private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer) boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
wb.getId(), accessId); wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);

View File

@ -1,8 +1,8 @@
DELETE FROM TASKANA.TASK; DELETE FROM TASKANA.TASK;
DELETE FROM TASKANA.WORKBASKET_ACCESS_LIST;
DELETE FROM TASKANA.WORKBASKET; DELETE FROM TASKANA.WORKBASKET;
DELETE FROM TASKANA.DISTRIBUTION_TARGETS; DELETE FROM TASKANA.DISTRIBUTION_TARGETS;
DELETE FROM TASKANA.CLASSIFICATION; DELETE FROM TASKANA.CLASSIFICATION;
DELETE FROM TASKANA.WORKBASKET_ACCESS_LIST;
DELETE FROM TASKANA.OBJECT_REFERENCE; DELETE FROM TASKANA.OBJECT_REFERENCE;
DELETE FROM TASKANA.ATTACHMENT; DELETE FROM TASKANA.ATTACHMENT;
DELETE FROM TASKANA.JOB; DELETE FROM TASKANA.JOB;

View File

@ -1,9 +1,9 @@
DROP TABLE TASKANA.TASKANA_SCHEMA_VERSION; DROP TABLE TASKANA.TASKANA_SCHEMA_VERSION;
DROP TABLE TASKANA.TASK; DROP TABLE TASKANA.TASK;
DROP TABLE TASKANA.WORKBASKET_ACCESS_LIST;
DROP TABLE TASKANA.WORKBASKET; DROP TABLE TASKANA.WORKBASKET;
DROP TABLE TASKANA.DISTRIBUTION_TARGETS; DROP TABLE TASKANA.DISTRIBUTION_TARGETS;
DROP TABLE TASKANA.CLASSIFICATION; DROP TABLE TASKANA.CLASSIFICATION;
DROP TABLE TASKANA.WORKBASKET_ACCESS_LIST;
DROP TABLE TASKANA.OBJECT_REFERENCE; DROP TABLE TASKANA.OBJECT_REFERENCE;
DROP TABLE TASKANA.ATTACHMENT; DROP TABLE TASKANA.ATTACHMENT;
DROP TABLE TASKANA.JOB; DROP TABLE TASKANA.JOB;

View File

@ -39,14 +39,3 @@ INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000025', 'WBI:100000000000000000000000000000000014', 'group_2', true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false); INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000025', 'WBI:100000000000000000000000000000000014', 'group_2', true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000026', 'WBI:100000000000000000000000000000000015', 'group_2', true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false); INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000026', 'WBI:100000000000000000000000000000000015', 'group_2', true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false);
-- Access to workbaskets for sorting test
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('900', '900', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('901', '901', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('902', '902', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('903', '903', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('904', '904', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('905', '905', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('906', '906', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('907', '907', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('908', '908', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
INSERT INTO TASKANA.WORKBASKET_ACCESS_LIST VALUES ('909', '909', 'max', true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);