TSK-221: set multiple Authorisations at once.

This commit is contained in:
Marcel Lengl 2018-02-22 11:02:30 +01:00 committed by Holger Hagen
parent 53610a309c
commit bc5e0e9688
15 changed files with 282 additions and 61 deletions

View File

@ -5,6 +5,15 @@ package pro.taskana;
*/ */
public interface WorkbasketAccessItemQuery extends BaseQuery<WorkbasketAccessItem> { public interface WorkbasketAccessItemQuery extends BaseQuery<WorkbasketAccessItem> {
/**
* Add your unique entry id to your query as filter.
*
* @param ids
* the unique entry IDs
* @return the query
*/
WorkbasketAccessItemQuery idIn(String... ids);
/** /**
* Add your workbasket id to your query. * Add your workbasket id to your query.
* *
@ -42,4 +51,14 @@ public interface WorkbasketAccessItemQuery extends BaseQuery<WorkbasketAccessIte
* @return the query * @return the query
*/ */
WorkbasketAccessItemQuery orderByAccessId(SortDirection sortDirection); WorkbasketAccessItemQuery orderByAccessId(SortDirection sortDirection);
/**
* Sort the query result by Id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderById(SortDirection sortDirection);
} }

View File

@ -96,8 +96,11 @@ public interface WorkbasketService {
* @param workbasketAccessItem * @param workbasketAccessItem
* the new workbasketAccessItem * the new workbasketAccessItem
* @return the created WorkbasketAccessItem * @return the created WorkbasketAccessItem
* @throws InvalidArgumentException
* when the preconditions doesn´t match the required ones.
*/ */
WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem); WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException;
/** /**
* This method updates an Workbasket Authorization. * This method updates an Workbasket Authorization.
@ -156,6 +159,20 @@ public interface WorkbasketService {
*/ */
List<WorkbasketAccessItem> getWorkbasketAuthorizations(String workbasketId); List<WorkbasketAccessItem> getWorkbasketAuthorizations(String workbasketId);
/**
* Setting up the new WorkbasketAccessItems for a Workbasket. Already stored values will be completely replaced by
* the current ones.
*
* @param workbasketId
* ID of the access-target workbasket.
* @param wbAccessItems
* List of WorkbasketAccessItems which does replace all current stored ones.
* @throws InvalidArgumentException
* will be thrown when the parameter is NULL or member doesn´t match the preconditions
*/
void setWorkbasketAuthorizations(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException;
/** /**
* This method returns the workbaskets for which the current user has all permissions specified in the permissions * This method returns the workbaskets for which the current user has all permissions specified in the permissions
* list. * list.
@ -321,5 +338,4 @@ public interface WorkbasketService {
*/ */
List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain) List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException; throws NotAuthorizedException, WorkbasketNotFoundException;
} }

View File

@ -27,6 +27,7 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketQueryImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketQueryImpl.class);
private String[] accessIdIn; private String[] accessIdIn;
private String[] workbasketIdIn; private String[] workbasketIdIn;
private String[] idIn;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngineImpl;
private List<String> orderBy; private List<String> orderBy;
@ -36,6 +37,12 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
orderBy = new ArrayList<>(); orderBy = new ArrayList<>();
} }
@Override
public WorkbasketAccessItemQuery idIn(String... ids) {
this.idIn = ids;
return this;
}
@Override @Override
public WorkbasketAccessItemQuery workbasketIdIn(String... id) { public WorkbasketAccessItemQuery workbasketIdIn(String... id) {
this.workbasketIdIn = id; this.workbasketIdIn = id;
@ -49,6 +56,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
return this; return this;
} }
@Override
public WorkbasketAccessItemQuery orderById(SortDirection sortDirection) {
return addOrderCriteria("ID", sortDirection);
}
@Override @Override
public WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection) { public WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection) {
return addOrderCriteria("WORKBASKET_ID", sortDirection); return addOrderCriteria("WORKBASKET_ID", sortDirection);
@ -145,6 +157,10 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
return this; return this;
} }
public String[] getIdIn() {
return this.idIn;
}
public String[] getAccessIdIn() { public String[] getAccessIdIn() {
return accessIdIn; return accessIdIn;
} }
@ -160,7 +176,9 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("WorkbasketAccessItemQueryImpl [accessIdIn="); builder.append("WorkbasketAccessItemQueryImpl [idIn=");
builder.append(Arrays.toString(idIn));
builder.append(", accessIdIn=");
builder.append(Arrays.toString(accessIdIn)); builder.append(Arrays.toString(accessIdIn));
builder.append(", workbasketIdIn="); builder.append(", workbasketIdIn=");
builder.append(Arrays.toString(workbasketIdIn)); builder.append(Arrays.toString(workbasketIdIn));

View File

@ -200,12 +200,19 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) { public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException {
LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem); LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION)); accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
if (workbasketAccessItem.getId() == null || workbasketAccessItem.getAccessId() == null
|| workbasketAccessItem.getWorkbasketId() == null) {
throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed. WorkbasketAccessItem="
+ workbasketAccessItem.toString());
}
workbasketAccessMapper.insert(accessItem); workbasketAccessMapper.insert(accessItem);
LOGGER.debug("Method createWorkbasketAuthorization() created workbaskteAccessItem {}", LOGGER.debug("Method createWorkbasketAuthorization() created workbaskteAccessItem {}",
accessItem); accessItem);
@ -218,12 +225,51 @@ public class WorkbasketServiceImpl implements WorkbasketService {
} }
@Override @Override
public void deleteWorkbasketAuthorization(String id) { public void setWorkbasketAuthorizations(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
LOGGER.debug("entry to deleteWorkbasketAuthorization(id = {})", id); throws InvalidArgumentException {
List<WorkbasketAccessItemImpl> newItems = new ArrayList<>();
try {
LOGGER.debug("entry to setWorkbasketAuthorizations(workbasketAccessItems = {})", wbAccessItems.toString());
taskanaEngine.openConnection();
// Check pre-conditions and set ID
if (!wbAccessItems.isEmpty()) {
for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) {
WorkbasketAccessItemImpl wbAccessItemImpl = (WorkbasketAccessItemImpl) workbasketAccessItem;
if (wbAccessItemImpl.getWorkbasketId() == null) {
throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed - WBID is NULL. WorkbasketAccessItem="
+ workbasketAccessItem.toString());
} else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) {
throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed - the WBID does not match. Target-WBID='"
+ workbasketId + "' WorkbasketAccessItem="
+ workbasketAccessItem.toString());
}
if (wbAccessItemImpl.getId() == null || wbAccessItemImpl.getId().isEmpty()) {
wbAccessItemImpl.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
}
newItems.add(wbAccessItemImpl);
}
// delete all current ones
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
// add all
newItems.stream().forEach(item -> workbasketAccessMapper.insert(item));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from setWorkbasketAuthorizations(workbasketAccessItems = {})", wbAccessItems.toString());
}
}
@Override
public void deleteWorkbasketAuthorization(String accessItemId) {
LOGGER.debug("entry to deleteWorkbasketAuthorization(id = {})", accessItemId);
try { try {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
workbasketAccessMapper.delete(id); workbasketAccessMapper.delete(accessItemId);
LOGGER.debug("Method deleteWorkbasketAuthorization() deleted workbasketAccessItem wit Id {}", id); LOGGER.debug("Method deleteWorkbasketAuthorization() deleted workbasketAccessItem wit Id {}", accessItemId);
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteWorkbasketAuthorization(id)."); LOGGER.debug("exit from deleteWorkbasketAuthorization(id).");
@ -613,7 +659,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
// delete workbasket and sub-tables // delete workbasket and sub-tables
distributionTargetMapper.deleteAllDistributionTargetsBySourceId(wb.getId()); distributionTargetMapper.deleteAllDistributionTargetsBySourceId(wb.getId());
distributionTargetMapper.deleteAllDistributionTargetsByTargetId(wb.getId()); distributionTargetMapper.deleteAllDistributionTargetsByTargetId(wb.getId());
workbasketAccessMapper.deleteAllForWorkbasketId(wb.getId()); workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(wb.getId());
workbasketMapper.delete(workbasketId); workbasketMapper.delete(workbasketId);
} finally { } finally {
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();

View File

@ -273,6 +273,7 @@ public interface QueryMapper {
+ "PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 " + "PERM_CUSTOM_3, PERM_CUSTOM_4, PERM_CUSTOM_5, PERM_CUSTOM_6, PERM_CUSTOM_7, PERM_CUSTOM_8, PERM_CUSTOM_9, PERM_CUSTOM_10, PERM_CUSTOM_11, PERM_CUSTOM_12 "
+ "from WORKBASKET_ACCESS_LIST " + "from WORKBASKET_ACCESS_LIST "
+ "<where>" + "<where>"
+ "<if test='idIn != null'>AND ID IN(<foreach item='item' collection='idIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketIdIn != null'>AND WORKBASKET_ID IN(<foreach item='item' collection='workbasketIdIn' separator=',' >#{item}</foreach>)</if> " + "<if test='workbasketIdIn != null'>AND WORKBASKET_ID IN(<foreach item='item' collection='workbasketIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='accessIdIn != null'>AND ACCESS_ID IN(<foreach item='item' collection='accessIdIn' separator=',' >#{item}</foreach>) </if> " + "<if test='accessIdIn != null'>AND ACCESS_ID IN(<foreach item='item' collection='accessIdIn' separator=',' >#{item}</foreach>) </if> "
+ "</where>" + "</where>"

View File

@ -77,11 +77,11 @@ public interface WorkbasketAccessMapper {
+ "WHERE id = #{workbasketAccessItem.id}") + "WHERE id = #{workbasketAccessItem.id}")
void update(@Param("workbasketAccessItem") WorkbasketAccessItemImpl workbasketAccessItem); void update(@Param("workbasketAccessItem") WorkbasketAccessItemImpl workbasketAccessItem);
@Delete("DELETE FROM WORKBASKET_ACCESS_LIST where id = #{id}") @Delete("DELETE FROM WORKBASKET_ACCESS_LIST WHERE ID = #{id}")
void delete(@Param("id") String id); void delete(@Param("id") String id);
@Delete("DELETE FROM WORKBASKET_ACCESS_LIST where WORKBASKET_ID = #{workbasketId}") @Delete("DELETE FROM WORKBASKET_ACCESS_LIST WHERE WORKBASKET_ID = #{workbasketId}")
void deleteAllForWorkbasketId(@Param("workbasketId") String workbasketId); void deleteAllAccessItemsForWorkbasketId(@Param("workbasketId") String workbasketId);
@Select("<script>SELECT MAX(PERM_READ) AS P_READ, MAX(PERM_OPEN) AS P_OPEN, MAX(PERM_APPEND) AS P_APPEND, MAX(PERM_TRANSFER) AS P_TRANSFER, MAX(PERM_DISTRIBUTE) AS P_DISTRIBUTE, MAX(PERM_CUSTOM_1) AS P_CUSTOM_1, MAX(PERM_CUSTOM_2) AS P_CUSTOM_2, MAX(PERM_CUSTOM_3) AS P_CUSTOM_3, MAX(PERM_CUSTOM_4) AS P_CUSTOM_4, MAX(PERM_CUSTOM_5) AS P_CUSTOM_5, MAX(PERM_CUSTOM_6) AS P_CUSTOM_6, MAX(PERM_CUSTOM_7) AS P_CUSTOM_7, MAX(PERM_CUSTOM_8) AS P_CUSTOM_8, MAX(PERM_CUSTOM_9) AS P_CUSTOM_9, MAX(PERM_CUSTOM_10) AS P_CUSTOM_10, MAX(PERM_CUSTOM_11) AS P_CUSTOM_11, MAX(PERM_CUSTOM_12) AS P_CUSTOM_12 " @Select("<script>SELECT MAX(PERM_READ) AS P_READ, MAX(PERM_OPEN) AS P_OPEN, MAX(PERM_APPEND) AS P_APPEND, MAX(PERM_TRANSFER) AS P_TRANSFER, MAX(PERM_DISTRIBUTE) AS P_DISTRIBUTE, MAX(PERM_CUSTOM_1) AS P_CUSTOM_1, MAX(PERM_CUSTOM_2) AS P_CUSTOM_2, MAX(PERM_CUSTOM_3) AS P_CUSTOM_3, MAX(PERM_CUSTOM_4) AS P_CUSTOM_4, MAX(PERM_CUSTOM_5) AS P_CUSTOM_5, MAX(PERM_CUSTOM_6) AS P_CUSTOM_6, MAX(PERM_CUSTOM_7) AS P_CUSTOM_7, MAX(PERM_CUSTOM_8) AS P_CUSTOM_8, MAX(PERM_CUSTOM_9) AS P_CUSTOM_9, MAX(PERM_CUSTOM_10) AS P_CUSTOM_10, MAX(PERM_CUSTOM_11) AS P_CUSTOM_11, MAX(PERM_CUSTOM_12) AS P_CUSTOM_12 "
+ "FROM WORKBASKET_ACCESS_LIST " + "FROM WORKBASKET_ACCESS_LIST "

View File

@ -108,7 +108,7 @@ CREATE TABLE DISTRIBUTION_TARGETS(
CREATE TABLE WORKBASKET_ACCESS_LIST( CREATE TABLE WORKBASKET_ACCESS_LIST(
ID CHAR(40) NOT NULL, ID CHAR(40) NOT NULL,
WORKBASKET_ID CHAR(40) NOT NULL, WORKBASKET_ID CHAR(40) NOT NULL,
ACCESS_ID VARCHAR(255) NULL, ACCESS_ID VARCHAR(255) NOT NULL,
PERM_READ BOOLEAN NOT NULL, PERM_READ BOOLEAN NOT NULL,
PERM_OPEN BOOLEAN NOT NULL, PERM_OPEN BOOLEAN NOT NULL,
PERM_APPEND BOOLEAN NOT NULL, PERM_APPEND BOOLEAN NOT NULL,

View File

@ -1,5 +1,10 @@
package acceptance.workbasket; package acceptance.workbasket;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
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;
@ -26,6 +31,7 @@ import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.exceptions.TaskAlreadyExistException; import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.WorkbasketAccessItemImpl; import pro.taskana.impl.WorkbasketAccessItemImpl;
import pro.taskana.security.CurrentUserContext;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId; import pro.taskana.security.WithAccessId;
@ -126,6 +132,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
.workbasketKeyDomainIn(new KeyDomain(wbKey, "DOMAIN_A")) .workbasketKeyDomainIn(new KeyDomain(wbKey, "DOMAIN_A"))
.list(); .list();
Assert.assertEquals(1, tasks.size()); Assert.assertEquals(1, tasks.size());
assertThat(createdTask, not(equalTo(null)));
List<WorkbasketAccessItem> accessItems = workbasketService List<WorkbasketAccessItem> accessItems = workbasketService
.getWorkbasketAuthorizations("WBI:100000000000000000000000000000000008"); .getWorkbasketAuthorizations("WBI:100000000000000000000000000000000008");
@ -146,7 +153,86 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
} catch (NotAuthorizedToQueryWorkbasketException ignored) { } catch (NotAuthorizedToQueryWorkbasketException ignored) {
// nothing to do // nothing to do
} }
}
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testUpdatedAccessItemList() throws InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String wbId = "WBI:100000000000000000000000000000000004";
List<WorkbasketAccessItem> accessItems = workbasketService
.getWorkbasketAuthorizations(wbId);
int countBefore = accessItems.size();
// update some values
WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false);
item0.setPermOpen(false);
item0.setPermTransfer(false);
final String updateId0 = item0.getId();
WorkbasketAccessItem item1 = accessItems.get(1);
item1.setPermAppend(false);
item1.setPermOpen(false);
item1.setPermTransfer(false);
final String updateId1 = item1.getId();
workbasketService.setWorkbasketAuthorizations(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = workbasketService
.getWorkbasketAuthorizations(wbId);
int countAfter = updatedAccessItems.size();
assertThat(countAfter, equalTo(countBefore));
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermOpen());
assertFalse(item0.isPermTransfer());
item1 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId1)).findFirst().get();
assertFalse(item1.isPermAppend());
assertFalse(item1.isPermOpen());
assertFalse(item1.isPermTransfer());
}
@WithAccessId(
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testInsertAccessItemList() throws InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String wbId = "WBI:100000000000000000000000000000000004";
List<WorkbasketAccessItem> accessItems = workbasketService
.getWorkbasketAuthorizations(wbId);
int countBefore = accessItems.size();
// update some values
WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false);
item0.setPermOpen(false);
item0.setPermTransfer(false);
final String updateId0 = item0.getId();
// insert new entry
WorkbasketAccessItem newItem = workbasketService.newWorkbasketAccessItem(wbId, CurrentUserContext.getUserid());
newItem.setPermRead(true);
newItem.setPermOpen(true);
newItem.setPermCustom12(true);
accessItems.add(newItem);
workbasketService.setWorkbasketAuthorizations(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = workbasketService
.getWorkbasketAuthorizations(wbId);
int countAfter = updatedAccessItems.size();
assertTrue((countBefore + 1) == countAfter);
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermOpen());
assertFalse(item0.isPermTransfer());
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermTransfer());
} }
@AfterClass @AfterClass

View File

@ -516,7 +516,7 @@ public class WorkbasketServiceImplTest {
verify(taskQueryMock, times(1)).list(); verify(taskQueryMock, times(1)).list();
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(wb.getId()); verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(wb.getId());
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsByTargetId(wb.getId()); verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsByTargetId(wb.getId());
verify(workbasketAccessMapperMock, times(1)).deleteAllForWorkbasketId(wb.getId()); verify(workbasketAccessMapperMock, times(1)).deleteAllAccessItemsForWorkbasketId(wb.getId());
verify(workbasketMapperMock, times(1)).delete(wb.getId()); verify(workbasketMapperMock, times(1)).delete(wb.getId());
verify(taskanaEngineImplMock, times(1)).returnConnection(); verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock, verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,

View File

@ -401,7 +401,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 {
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

@ -540,7 +540,7 @@ public class TaskServiceImplIntExplicitTest {
return task; return task;
} }
private void generateSampleAccessItems() { private void generateSampleAccessItems() throws InvalidArgumentException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena"); WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true); accessItem.setPermAppend(true);
accessItem.setPermRead(true); accessItem.setPermRead(true);
@ -554,7 +554,7 @@ public class TaskServiceImplIntExplicitTest {
} }
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 {
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

@ -132,7 +132,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena")
@Test @Test
public void testSelectWorkbasket() public void testSelectWorkbasket()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException { throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
InvalidArgumentException {
String id = IdGenerator.generateWithPrefix("TWB"); String id = IdGenerator.generateWithPrefix("TWB");
Workbasket workbasket = createTestWorkbasket(id, "key0", "novatec", "Superbasket", WorkbasketType.GROUP); Workbasket workbasket = createTestWorkbasket(id, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
workbasket = workBasketService.createWorkbasket(workbasket); workbasket = workBasketService.createWorkbasket(workbasket);
@ -150,7 +151,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena")
@Test @Test
public void testSelectWorkbasketWithDistribution() public void testSelectWorkbasketWithDistribution()
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException { throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
InvalidArgumentException {
String id = IdGenerator.generateWithPrefix("TWB"); String id = IdGenerator.generateWithPrefix("TWB");
Workbasket wbDist1 = createTestWorkbasket(id, "key0", "novatec", "Superbasket", WorkbasketType.GROUP); Workbasket wbDist1 = createTestWorkbasket(id, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
wbDist1 = workBasketService.createWorkbasket(wbDist1); wbDist1 = workBasketService.createWorkbasket(wbDist1);
@ -191,7 +193,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
workbasket2 = workBasketService.createWorkbasket(workbasket2); workbasket2 = workBasketService.createWorkbasket(workbasket2);
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false); createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId())); List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
Thread.sleep(20L); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets); workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
String id3 = IdGenerator.generateWithPrefix("TWB"); String id3 = IdGenerator.generateWithPrefix("TWB");
@ -201,7 +203,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false); createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId())); List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId()));
Thread.sleep(20L); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets); workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId()); Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
@ -219,7 +221,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
} }
@Test @Test
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException { public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
WorkbasketAccessItem accessItem = workBasketService WorkbasketAccessItem accessItem = workBasketService
.newWorkbasketAccessItem("k100000000000000000000000000000000000000", "Arthur Dent"); .newWorkbasketAccessItem("k100000000000000000000000000000000000000", "Arthur Dent");
accessItem.setPermOpen(true); accessItem.setPermOpen(true);
@ -298,7 +300,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
assertTrue("Basket1".equals(name) || "Basket2".equals(name) || "Basket3".equals(name)); assertTrue("Basket1".equals(name) || "Basket2".equals(name) || "Basket3".equals(name));
} }
Thread.sleep(20L); Thread.sleep(SLEEP_TIME);
WorkbasketQuery query5 = workBasketService.createWorkbasketQuery() WorkbasketQuery query5 = workBasketService.createWorkbasketQuery()
.modifiedWithin( .modifiedWithin(
new TimeInterval(Instant.now().minus(Duration.ofDays(31)), Instant.now().minus(Duration.ofDays(14)))); new TimeInterval(Instant.now().minus(Duration.ofDays(31)), Instant.now().minus(Duration.ofDays(14))));
@ -329,7 +331,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
} }
private void generateSampleDataForQuery() private void generateSampleDataForQuery()
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException { throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidArgumentException {
WorkbasketImpl basket1 = (WorkbasketImpl) workBasketService.newWorkbasket("k1", "novatec"); WorkbasketImpl basket1 = (WorkbasketImpl) workBasketService.newWorkbasket("k1", "novatec");
basket1.setId("1000000000000000000000000000000000000000"); basket1.setId("1000000000000000000000000000000000000000");
basket1.setName("Basket1"); basket1.setName("Basket1");
@ -412,7 +415,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 {
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

@ -26,6 +26,7 @@ import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
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.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -123,7 +124,8 @@ public class WorkbasketServiceImplIntExplicitTest {
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena")
@Test @Test
public void testSelectWorkbasket() public void testSelectWorkbasket()
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException { throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
@ -143,7 +145,8 @@ public class WorkbasketServiceImplIntExplicitTest {
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena")
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testGetWorkbasketFail() public void testGetWorkbasketFail()
throws WorkbasketNotFoundException, SQLException, InvalidWorkbasketException, NotAuthorizedException { throws WorkbasketNotFoundException, SQLException, InvalidWorkbasketException, NotAuthorizedException,
InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
@ -159,7 +162,8 @@ public class WorkbasketServiceImplIntExplicitTest {
@WithAccessId(userName = "Elena") @WithAccessId(userName = "Elena")
@Test @Test
public void testSelectWorkbasketWithDistribution() public void testSelectWorkbasketWithDistribution()
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException { throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
@ -210,7 +214,7 @@ public class WorkbasketServiceImplIntExplicitTest {
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false); createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId())); List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
Thread.sleep(20L); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets); workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
String id3 = IdGenerator.generateWithPrefix("TWB"); String id3 = IdGenerator.generateWithPrefix("TWB");
@ -220,7 +224,7 @@ public class WorkbasketServiceImplIntExplicitTest {
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false); createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId())); List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId()));
Thread.sleep(20L); Thread.sleep(SLEEP_TIME);
workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets); workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId()); Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
@ -238,7 +242,7 @@ public class WorkbasketServiceImplIntExplicitTest {
} }
@Test @Test
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, SQLException { public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
@ -254,7 +258,7 @@ public class WorkbasketServiceImplIntExplicitTest {
} }
@Test @Test
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException { public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
workBasketService = taskanaEngine.getWorkbasketService(); workBasketService = taskanaEngine.getWorkbasketService();
@ -271,7 +275,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 {
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem( WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
wb.getId(), accessId); wb.getId(), accessId);
accessItem.setPermOpen(permOpen); accessItem.setPermOpen(permOpen);

View File

@ -1,5 +1,6 @@
package pro.taskana.rest; package pro.taskana.rest;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -188,19 +190,46 @@ public class WorkbasketController {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketAccessItemResource> createWorkbasketAuthorization( public ResponseEntity<WorkbasketAccessItemResource> createWorkbasketAuthorization(
@RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) { @RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) {
WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper.toModel(workbasketAccessItemResource); try {
workbasketAccessItem = workbasketService.createWorkbasketAuthorization(workbasketAccessItem); WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper
return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK); .toModel(workbasketAccessItemResource);
workbasketAccessItem = workbasketService.createWorkbasketAuthorization(workbasketAccessItem);
return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK);
} catch (InvalidArgumentException e) {
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
}
} }
@PutMapping(path = "/authorizations/{authId}") @PutMapping(path = "/authorizations/{authId}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketAccessItemResource> updateWorkbasketAuthorization( public ResponseEntity<WorkbasketAccessItemResource> updateWorkbasketAuthorization(
@PathVariable(value = "authId") String authId, @PathVariable(value = "authId") String authId,
@RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) throws InvalidArgumentException { @RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) {
WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper.toModel(workbasketAccessItemResource); try {
workbasketAccessItem = workbasketService.updateWorkbasketAuthorization(workbasketAccessItem); WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper
return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK); .toModel(workbasketAccessItemResource);
workbasketAccessItem = workbasketService.updateWorkbasketAuthorization(workbasketAccessItem);
return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK);
} catch (InvalidArgumentException e) {
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
}
}
@RequestMapping(value = "/{workbasketId}/authorizations/", method = RequestMethod.PUT)
public ResponseEntity<?> setWorkbasketAuthorizations(@PathVariable(value = "workbasketId") String workbasketId,
@RequestBody List<WorkbasketAccessItemResource> workbasketAccessResourceItems) {
try {
if (workbasketAccessResourceItems == null) {
throw new InvalidArgumentException("Can´t create something with NULL body-value.");
}
List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>();
workbasketAccessResourceItems.stream()
.forEach(item -> wbAccessItems.add(workbasketAccessItemMapper.toModel(item)));
workbasketService.setWorkbasketAuthorizations(workbasketId, wbAccessItems);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (InvalidArgumentException | NullPointerException e) {
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
}
} }
@DeleteMapping(path = "/authorizations/{authId}") @DeleteMapping(path = "/authorizations/{authId}")

View File

@ -23,6 +23,7 @@ import pro.taskana.Workbasket;
import pro.taskana.WorkbasketQuery; import pro.taskana.WorkbasketQuery;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
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.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -73,24 +74,27 @@ public class WorkbasketDefinitionController {
} }
/** /**
* This method imports a <b>list of {@link WorkbasketDefinition}</b>. * This method imports a <b>list of {@link WorkbasketDefinition}</b>. This does not exactly match the REST norm, but
* This does not exactly match the REST norm, but we want to have an option to import all settings at once. * we want to have an option to import all settings at once. When a logical equal (key and domain are equal)
* When a logical equal (key and domain are equal) workbasket already exists an update will be executed. * workbasket already exists an update will be executed. Otherwise a new workbasket will be created.
* Otherwise a new workbasket will be created.
* *
* @param definitions the list of workbasket definitions which will be imported to the current system. * @param definitions
* @return Return answer is determined by the status code: * the list of workbasket definitions which will be imported to the current system.
* 200 - all good * @return Return answer is determined by the status code: 200 - all good 400 - list state error (referring to non
* 400 - list state error (referring to non existing id's) * existing id's) 401 - not authorized
* 401 - not authorized * @throws InvalidArgumentException
* When the pre-conditions of a workbasket doesn´t match.
*/ */
@PostMapping(path = "/import") @PostMapping(path = "/import")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity<String> importWorkbaskets(@RequestBody List<WorkbasketDefinition> definitions) { public ResponseEntity<String> importWorkbaskets(@RequestBody List<WorkbasketDefinition> definitions)
throws InvalidArgumentException {
try { try {
// key: logical ID // key: logical ID
// value: system ID (in database) // value: system ID (in database)
Map<String, String> systemIds = workbasketService.createWorkbasketQuery().list().stream() Map<String, String> systemIds = workbasketService.createWorkbasketQuery()
.list()
.stream()
.collect(Collectors.toMap(this::logicalId, WorkbasketSummary::getId)); .collect(Collectors.toMap(this::logicalId, WorkbasketSummary::getId));
// key: old system ID // key: old system ID
@ -105,18 +109,15 @@ public class WorkbasketDefinitionController {
String oldId = res.workbasketId; String oldId = res.workbasketId;
res.workbasketId = systemIds.get(logicalId(res)); res.workbasketId = systemIds.get(logicalId(res));
workbasket = workbasketService.updateWorkbasket( workbasket = workbasketService.updateWorkbasket(
workbasketMapper.toModel(res) workbasketMapper.toModel(res));
);
res.workbasketId = oldId; res.workbasketId = oldId;
} else { } else {
workbasket = workbasketService.createWorkbasket( workbasket = workbasketService.createWorkbasket(
workbasketMapper.toModel(res) workbasketMapper.toModel(res));
);
} }
for (WorkbasketAccessItemResource authorization : definition.authorizations) { for (WorkbasketAccessItemResource authorization : definition.authorizations) {
workbasketService.createWorkbasketAuthorization( workbasketService.createWorkbasketAuthorization(
workbasketAccessItemMapper.toModel(authorization) workbasketAccessItemMapper.toModel(authorization));
);
} }
idConversion.put(definition.workbasketResource.workbasketId, workbasket.getId()); idConversion.put(definition.workbasketResource.workbasketId, workbasket.getId());
} }
@ -132,15 +133,13 @@ public class WorkbasketDefinitionController {
throw new WorkbasketNotFoundException( throw new WorkbasketNotFoundException(
String.format( String.format(
"invalid import state: Workbasket '%s' does not exist in the given import list", "invalid import state: Workbasket '%s' does not exist in the given import list",
oldId) oldId));
);
} }
} }
workbasketService.setDistributionTargets( workbasketService.setDistributionTargets(
// no verification necessary since the workbasket was already imported in step 1. // no verification necessary since the workbasket was already imported in step 1.
idConversion.get(definition.workbasketResource.workbasketId), distributionTargets idConversion.get(definition.workbasketResource.workbasketId), distributionTargets);
);
} }
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);