TSK-213 introduce Interface and Implementation for WorkbasketAccessItem
This commit is contained in:
parent
4d24ff7c67
commit
2c9d595123
|
@ -0,0 +1,309 @@
|
|||
package pro.taskana;
|
||||
|
||||
/**
|
||||
* Interface for WorkbasketAccessItem. This interface is used to control access of users to workbaskets.
|
||||
*
|
||||
* @author bbr
|
||||
*/
|
||||
public interface WorkbasketAccessItem {
|
||||
|
||||
/**
|
||||
* Returns the current id of the WorkbasketAccessItem.
|
||||
*
|
||||
* @return Id
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the key of the referenced workbasket.
|
||||
*
|
||||
* @return the workbasket key
|
||||
*/
|
||||
String getWorkbasketKey();
|
||||
|
||||
/**
|
||||
* Returns the group id or user id for which this WorkbasketAccessItem controls access permissions.
|
||||
*
|
||||
* @return access id, this is the group id or user id
|
||||
*/
|
||||
String getAccessId();
|
||||
|
||||
/**
|
||||
* Returns whether read of the referenced workbasket is permitted.
|
||||
*
|
||||
* @return read permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermRead();
|
||||
|
||||
/**
|
||||
* Sets read permission for the referenced workbasket.
|
||||
*
|
||||
* @param permRead
|
||||
* specifies whether read is permitted for the referenced workbasket.
|
||||
*/
|
||||
void setPermRead(boolean permRead);
|
||||
|
||||
/**
|
||||
* Returns whether open of the referenced workbasket is permitted.
|
||||
*
|
||||
* @return open permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermOpen();
|
||||
|
||||
/**
|
||||
* Sets open permission for the referenced workbasket.
|
||||
*
|
||||
* @param permOpen
|
||||
* specifies whether open is permitted for the referenced workbasket.
|
||||
*/
|
||||
void setPermOpen(boolean permOpen);
|
||||
|
||||
/**
|
||||
* Returns whether append to the referenced workbasket is permitted.
|
||||
*
|
||||
* @return append permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermAppend();
|
||||
|
||||
/**
|
||||
* Sets append permission for the referenced workbasket.
|
||||
*
|
||||
* @param permAppend
|
||||
* specifies whether append to the referenced workbasket is permitted.
|
||||
*/
|
||||
void setPermAppend(boolean permAppend);
|
||||
|
||||
/**
|
||||
* Returns whether transfer from the referenced workbasket is permitted.
|
||||
*
|
||||
* @return transfer permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermTransfer();
|
||||
|
||||
/**
|
||||
* Sets transfer permission for the referenced workbasket.
|
||||
*
|
||||
* @param permTransfer
|
||||
* specifies whether transfer from the referenced workbasket is permitted.
|
||||
*/
|
||||
void setPermTransfer(boolean permTransfer);
|
||||
|
||||
/**
|
||||
* Returns whether distribute from the referenced workbasket is permitted.
|
||||
*
|
||||
* @return distribute permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermDistribute();
|
||||
|
||||
/**
|
||||
* Sets distribute permission for the referenced workbasket.
|
||||
*
|
||||
* @param permDistribute
|
||||
* specifies whether distribute from the referenced workbasket is permitted.
|
||||
*/
|
||||
void setPermDistribute(boolean permDistribute);
|
||||
|
||||
/**
|
||||
* Returns whether custom1 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom1 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom1();
|
||||
|
||||
/**
|
||||
* Sets the custom1 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom1
|
||||
* specifies whether custom1 permission is granted
|
||||
*/
|
||||
void setPermCustom1(boolean permCustom1);
|
||||
|
||||
/**
|
||||
* Returns whether custom2 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom2 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom2();
|
||||
|
||||
/**
|
||||
* Sets the custom2 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom2
|
||||
* specifies whether custom2 permission is granted
|
||||
*/
|
||||
void setPermCustom2(boolean permCustom2);
|
||||
|
||||
/**
|
||||
* Returns whether custom3 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom3 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom3();
|
||||
|
||||
/**
|
||||
* Sets the custom3 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom3
|
||||
* specifies whether custom3 permission is granted
|
||||
*/
|
||||
void setPermCustom3(boolean permCustom3);
|
||||
|
||||
/**
|
||||
* Returns whether custom4 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom4 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom4();
|
||||
|
||||
/**
|
||||
* Sets the custom4 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom4
|
||||
* specifies whether custom4 permission is granted
|
||||
*/
|
||||
void setPermCustom4(boolean permCustom4);
|
||||
|
||||
/**
|
||||
* Returns whether custom5 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom5 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom5();
|
||||
|
||||
/**
|
||||
* Sets the custom5 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom5
|
||||
* specifies whether custom5 permission is granted
|
||||
*/
|
||||
void setPermCustom5(boolean permCustom5);
|
||||
|
||||
/**
|
||||
* Returns whether custom6 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom6 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom6();
|
||||
|
||||
/**
|
||||
* Sets the custom6 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom6
|
||||
* specifies whether custom6 permission is granted
|
||||
*/
|
||||
void setPermCustom6(boolean permCustom6);
|
||||
|
||||
/**
|
||||
* Returns whether custom7 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom7 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom7();
|
||||
|
||||
/**
|
||||
* Sets the custom7 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom7
|
||||
* specifies whether custom7 permission is granted
|
||||
*/
|
||||
void setPermCustom7(boolean permCustom7);
|
||||
|
||||
/**
|
||||
* Returns whether custom8 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom8 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom8();
|
||||
|
||||
/**
|
||||
* Sets the custom8 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom8
|
||||
* specifies whether custom8 permission is granted
|
||||
*/
|
||||
void setPermCustom8(boolean permCustom8);
|
||||
|
||||
/**
|
||||
* Returns whether custom9 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom9 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom9();
|
||||
|
||||
/**
|
||||
* Sets the custom9 permission for the referenced workbasket. The semantics of this custom permission is transparent
|
||||
* to taskana.
|
||||
*
|
||||
* @param permCustom9
|
||||
* specifies whether custom9 permission is granted
|
||||
*/
|
||||
void setPermCustom9(boolean permCustom9);
|
||||
|
||||
/**
|
||||
* Returns whether custom10 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom10 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom10();
|
||||
|
||||
/**
|
||||
* Sets the custom10 permission for the referenced workbasket. The semantics of this custom permission is
|
||||
* transparent to taskana.
|
||||
*
|
||||
* @param permCustom10
|
||||
* specifies whether custom10 permission is granted
|
||||
*/
|
||||
void setPermCustom10(boolean permCustom10);
|
||||
|
||||
/**
|
||||
* Returns whether custom11 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom11 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom11();
|
||||
|
||||
/**
|
||||
* Sets the custom11 permission for the referenced workbasket. The semantics of this custom permission is
|
||||
* transparent to taskana.
|
||||
*
|
||||
* @param permCustom11
|
||||
* specifies whether custom11 permission is granted
|
||||
*/
|
||||
void setPermCustom11(boolean permCustom11);
|
||||
|
||||
/**
|
||||
* Returns whether custom12 permission is granted for the referenced workbasket. The semantics of this custom
|
||||
* permission is transparent to taskana.
|
||||
*
|
||||
* @return custom12 permission for the referenced workbasket
|
||||
*/
|
||||
boolean isPermCustom12();
|
||||
|
||||
/**
|
||||
* Sets the custom12 permission for the referenced workbasket. The semantics of this custom permission is
|
||||
* transparent to taskana.
|
||||
*
|
||||
* @param permCustom12
|
||||
* specifies whether custom12 permission is granted
|
||||
*/
|
||||
void setPermCustom12(boolean permCustom12);
|
||||
}
|
|
@ -2,10 +2,10 @@ package pro.taskana;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
|
||||
/**
|
||||
|
@ -76,6 +76,17 @@ public interface WorkbasketService {
|
|||
Workbasket updateWorkbasket(Workbasket workbasket)
|
||||
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Returns a new WorkbasketAccessItem which is not persisted.
|
||||
*
|
||||
* @param workbasketKey
|
||||
* the workbasket key used to identify the referenced workbasket
|
||||
* @param accessId
|
||||
* the group id or user id for which access is controlled
|
||||
* @return new WorkbasketAccessItem
|
||||
*/
|
||||
WorkbasketAccessItem newWorkbasketAccessItem(String workbasketKey, String accessId);
|
||||
|
||||
/**
|
||||
* Create and persist a new Workbasket Authorization with a Workbasket and a AccessId.
|
||||
*
|
||||
|
@ -91,15 +102,11 @@ public interface WorkbasketService {
|
|||
* @param workbasketAccessItem
|
||||
* the Authorization
|
||||
* @return the updated entity
|
||||
* @throws InvalidArgumentException
|
||||
* if accessid or workbasketkey is changed in the workbasketAccessItem
|
||||
*/
|
||||
WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem);
|
||||
|
||||
/**
|
||||
* Get all authorizations of the workbasket.
|
||||
*
|
||||
* @return a WorkbasketAccessItem list
|
||||
*/
|
||||
List<WorkbasketAccessItem> getAllAuthorizations();
|
||||
WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
|
||||
throws InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Deletes a specific authorization.
|
||||
|
@ -121,15 +128,6 @@ public interface WorkbasketService {
|
|||
*/
|
||||
void checkAuthorization(String workbasketKey, WorkbasketAuthorization authorization) throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* This method get one WorkbasketAccessItem with an id.
|
||||
*
|
||||
* @param id
|
||||
* the id of the requested WorkbasketAccessItem
|
||||
* @return the full {@link WorkbasketAccessItem}
|
||||
*/
|
||||
WorkbasketAccessItem getWorkbasketAuthorization(String id);
|
||||
|
||||
/**
|
||||
* Get all authorizations for a Workbasket.
|
||||
*
|
||||
|
@ -161,7 +159,7 @@ public interface WorkbasketService {
|
|||
*
|
||||
* @param key
|
||||
* the workbasket key used to identify the workbasket
|
||||
* @return newWorkbasket
|
||||
* @return new Workbasket
|
||||
*/
|
||||
Workbasket newWorkbasket(String key);
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
try {
|
||||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
taskanaEngineImpl.openConnection();
|
||||
checkAuthorization();
|
||||
checkOpenPermissionForWorkbasketKey();
|
||||
List<TaskSummaryImpl> tasks = new ArrayList<>();
|
||||
tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
|
||||
|
@ -221,7 +221,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
List<TaskSummary> result = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
checkAuthorization();
|
||||
checkOpenPermissionForWorkbasketKey();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
List<TaskSummaryImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
|
||||
|
@ -252,7 +252,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
TaskSummary result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
checkAuthorization();
|
||||
checkOpenPermissionForWorkbasketKey();
|
||||
TaskSummaryImpl taskSummaryImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
if (taskSummaryImpl == null) {
|
||||
return null;
|
||||
|
@ -275,7 +275,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
Long rowCount = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
checkAuthorization();
|
||||
checkOpenPermissionForWorkbasketKey();
|
||||
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
return (rowCount == null) ? 0L : rowCount;
|
||||
} finally {
|
||||
|
@ -284,7 +284,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkAuthorization() throws NotAuthorizedException {
|
||||
private void checkOpenPermissionForWorkbasketKey() throws NotAuthorizedException {
|
||||
if (this.workbasketKey != null && this.workbasketKey.length > 0) {
|
||||
for (String wbKey : this.workbasketKey) {
|
||||
taskanaEngineImpl.getWorkbasketService().checkAuthorization(wbKey, WorkbasketAuthorization.OPEN);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package pro.taskana.model;
|
||||
package pro.taskana.impl;
|
||||
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
||||
/**
|
||||
* WorkbasketAccessItem entity.
|
||||
* WorkbasketAccessItem Entity.
|
||||
*/
|
||||
public class WorkbasketAccessItem {
|
||||
public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
|
||||
|
||||
private String id;
|
||||
private String workbasketKey;
|
||||
|
@ -28,6 +29,15 @@ public class WorkbasketAccessItem {
|
|||
private boolean permCustom11;
|
||||
private boolean permCustom12;
|
||||
|
||||
WorkbasketAccessItemImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -36,6 +46,11 @@ public class WorkbasketAccessItem {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#getWorkbasketKey()
|
||||
*/
|
||||
@Override
|
||||
public String getWorkbasketKey() {
|
||||
return workbasketKey;
|
||||
}
|
||||
|
@ -44,6 +59,11 @@ public class WorkbasketAccessItem {
|
|||
this.workbasketKey = workbasketKey;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#getAccessId()
|
||||
*/
|
||||
@Override
|
||||
public String getAccessId() {
|
||||
return accessId;
|
||||
}
|
||||
|
@ -56,138 +76,308 @@ public class WorkbasketAccessItem {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermRead()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermRead() {
|
||||
return permRead;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermRead(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermRead(boolean permRead) {
|
||||
this.permRead = permRead;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermOpen()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermOpen() {
|
||||
return permOpen;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermOpen(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermOpen(boolean permOpen) {
|
||||
this.permOpen = permOpen;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermAppend()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermAppend() {
|
||||
return permAppend;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermAppend(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermAppend(boolean permAppend) {
|
||||
this.permAppend = permAppend;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermTransfer()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermTransfer() {
|
||||
return permTransfer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermTransfer(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermTransfer(boolean permTransfer) {
|
||||
this.permTransfer = permTransfer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermDistribute()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermDistribute() {
|
||||
return permDistribute;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermDistribute(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermDistribute(boolean permDistribute) {
|
||||
this.permDistribute = permDistribute;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom1()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom1() {
|
||||
return permCustom1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom1(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom1(boolean permCustom1) {
|
||||
this.permCustom1 = permCustom1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom2()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom2() {
|
||||
return permCustom2;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom2(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom2(boolean permCustom2) {
|
||||
this.permCustom2 = permCustom2;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom3()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom3() {
|
||||
return permCustom3;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom3(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom3(boolean permCustom3) {
|
||||
this.permCustom3 = permCustom3;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom4()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom4() {
|
||||
return permCustom4;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom4(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom4(boolean permCustom4) {
|
||||
this.permCustom4 = permCustom4;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom5()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom5() {
|
||||
return permCustom5;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom5(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom5(boolean permCustom5) {
|
||||
this.permCustom5 = permCustom5;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom6()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom6() {
|
||||
return permCustom6;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom6(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom6(boolean permCustom6) {
|
||||
this.permCustom6 = permCustom6;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom7()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom7() {
|
||||
return permCustom7;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom7(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom7(boolean permCustom7) {
|
||||
this.permCustom7 = permCustom7;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom8()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom8() {
|
||||
return permCustom8;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom8(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom8(boolean permCustom8) {
|
||||
this.permCustom8 = permCustom8;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom9()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom9() {
|
||||
return permCustom9;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom9(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom9(boolean permCustom9) {
|
||||
this.permCustom9 = permCustom9;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom10()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom10() {
|
||||
return permCustom10;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom10(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom10(boolean permCustom10) {
|
||||
this.permCustom10 = permCustom10;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom11()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom11() {
|
||||
return permCustom11;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom11(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom11(boolean permCustom11) {
|
||||
this.permCustom11 = permCustom11;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#isPermCustom12()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermCustom12() {
|
||||
return permCustom12;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see pro.taskana.impl.WorkbasketAccessItem#setPermCustom12(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setPermCustom12(boolean permCustom12) {
|
||||
this.permCustom12 = permCustom12;
|
||||
}
|
|
@ -11,16 +11,17 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketQuery;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.SystemException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.mappings.DistributionTargetMapper;
|
||||
import pro.taskana.model.mappings.WorkbasketAccessMapper;
|
||||
|
@ -189,33 +190,28 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) {
|
||||
LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
workbasketAccessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
|
||||
workbasketAccessMapper.insert(workbasketAccessItem);
|
||||
LOGGER.debug("Method createWorkbasketAuthorization() created workbaskteAccessItem {}",
|
||||
workbasketAccessItem);
|
||||
return workbasketAccessItem;
|
||||
} finally {
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from createWorkbasketAuthorization(workbasketAccessItem). Returning result {}",
|
||||
workbasketAccessItem);
|
||||
}
|
||||
public WorkbasketAccessItem newWorkbasketAccessItem(String workbasketKey, String accessId) {
|
||||
WorkbasketAccessItemImpl accessItem = new WorkbasketAccessItemImpl();
|
||||
accessItem.setWorkbasketKey(workbasketKey);
|
||||
accessItem.setAccessId(accessId);
|
||||
return accessItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketAccessItem getWorkbasketAuthorization(String id) {
|
||||
LOGGER.debug("entry to getWorkbasketAuthorization(id = {})", id);
|
||||
WorkbasketAccessItem result = null;
|
||||
public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) {
|
||||
LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem);
|
||||
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
result = workbasketAccessMapper.findById(id);
|
||||
return result;
|
||||
accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
|
||||
workbasketAccessMapper.insert(accessItem);
|
||||
LOGGER.debug("Method createWorkbasketAuthorization() created workbaskteAccessItem {}",
|
||||
accessItem);
|
||||
return accessItem;
|
||||
} finally {
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from getWorkbasketAuthorization(id). Returning result {}", result);
|
||||
LOGGER.debug("exit from createWorkbasketAuthorization(workbasketAccessItem). Returning result {}",
|
||||
accessItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,24 +228,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkbasketAccessItem> getAllAuthorizations() {
|
||||
LOGGER.debug("entry to getAllAuthorizations()");
|
||||
List<WorkbasketAccessItem> result = null;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
result = workbasketAccessMapper.findAll();
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from getAllAuthorizations(). Returning {} resulting Objects: {} ",
|
||||
numberOfResultObjects, LoggerUtils.listToString(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkAuthorization(String workbasketKey, WorkbasketAuthorization workbasketAuthorization)
|
||||
throws NotAuthorizedException {
|
||||
|
@ -258,28 +236,40 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem) {
|
||||
public WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
|
||||
throws InvalidArgumentException {
|
||||
LOGGER.debug("entry to updateWorkbasketAuthorization(workbasketAccessItem = {}", workbasketAccessItem);
|
||||
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
workbasketAccessMapper.update(workbasketAccessItem);
|
||||
WorkbasketAccessItem originalItem = workbasketAccessMapper.findById(accessItem.getId());
|
||||
|
||||
if ((originalItem.getAccessId() != null && !originalItem.getAccessId().equals(accessItem.getAccessId()))
|
||||
|| (originalItem.getWorkbasketKey() != null
|
||||
&& !originalItem.getWorkbasketKey().equals(accessItem.getWorkbasketKey()))) {
|
||||
throw new InvalidArgumentException(
|
||||
"AccessId and Workbasketkey must not be changed in updateWorkbasketAuthorization calls");
|
||||
}
|
||||
|
||||
workbasketAccessMapper.update(accessItem);
|
||||
LOGGER.debug("Method updateWorkbasketAuthorization() updated workbasketAccessItem {}",
|
||||
workbasketAccessItem);
|
||||
return workbasketAccessItem;
|
||||
accessItem);
|
||||
return accessItem;
|
||||
} finally {
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from updateWorkbasketAuthorization(workbasketAccessItem). Returning {}",
|
||||
workbasketAccessItem);
|
||||
accessItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkbasketAccessItem> getWorkbasketAuthorizations(String workbasketKey) {
|
||||
LOGGER.debug("entry to getWorkbasketAuthorizations(workbasketId = {})", workbasketKey);
|
||||
List<WorkbasketAccessItem> result = null;
|
||||
List<WorkbasketAccessItem> result = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
result = workbasketAccessMapper.findByWorkbasketKey(workbasketKey);
|
||||
List<WorkbasketAccessItemImpl> queryResult = workbasketAccessMapper.findByWorkbasketKey(workbasketKey);
|
||||
result.addAll(queryResult);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngine.returnConnection();
|
||||
|
@ -546,7 +536,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
CurrentUserContext.getUserid(),
|
||||
workbasketAuthorization == null ? "null" : workbasketAuthorization.name(), workbasketKey);
|
||||
|
||||
List<WorkbasketAccessItem> accessItems;
|
||||
List<WorkbasketAccessItemImpl> accessItems;
|
||||
|
||||
if (workbasketKey != null) {
|
||||
accessItems = workbasketAccessMapper
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.apache.ibatis.annotations.Results;
|
|||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.impl.WorkbasketAccessItemImpl;
|
||||
|
||||
/**
|
||||
* This class is the mybatis mapping of workbasket access items.
|
||||
|
@ -19,7 +19,7 @@ import pro.taskana.model.WorkbasketAccessItem;
|
|||
public interface WorkbasketAccessMapper {
|
||||
|
||||
@Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, 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 WHERE ID = #{id}")
|
||||
+ "FROM WORKBASKET_ACCESS_LIST WHERE ID = #{id}")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
|
||||
|
@ -40,11 +40,11 @@ public interface WorkbasketAccessMapper {
|
|||
@Result(property = "permCustom9", column = "PERM_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "PERM_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "PERM_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12") })
|
||||
WorkbasketAccessItem findById(@Param("id") String id);
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12")})
|
||||
WorkbasketAccessItemImpl findById(@Param("id") String id);
|
||||
|
||||
@Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, 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 WHERE ACCESS_ID = #{accessId}")
|
||||
+ "FROM WORKBASKET_ACCESS_LIST WHERE ACCESS_ID = #{accessId}")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
|
||||
|
@ -65,11 +65,11 @@ public interface WorkbasketAccessMapper {
|
|||
@Result(property = "permCustom9", column = "PERM_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "PERM_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "PERM_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12") })
|
||||
List<WorkbasketAccessItem> findByAccessId(@Param("accessId") String accessId);
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12")})
|
||||
List<WorkbasketAccessItemImpl> findByAccessId(@Param("accessId") String accessId);
|
||||
|
||||
@Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, 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 WHERE WORKBASKET_KEY = #{key}")
|
||||
+ "FROM WORKBASKET_ACCESS_LIST WHERE WORKBASKET_KEY = #{key}")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
|
||||
|
@ -90,71 +90,46 @@ public interface WorkbasketAccessMapper {
|
|||
@Result(property = "permCustom9", column = "PERM_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "PERM_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "PERM_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12") })
|
||||
List<WorkbasketAccessItem> findByWorkbasketKey(@Param("key") String key);
|
||||
|
||||
@Select("SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, 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 ORDER BY ID")
|
||||
@Results(value = {
|
||||
@Result(property = "id", column = "ID"),
|
||||
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
|
||||
@Result(property = "accessId", column = "ACCESS_ID"),
|
||||
@Result(property = "permRead", column = "PERM_READ"),
|
||||
@Result(property = "permOpen", column = "PERM_OPEN"),
|
||||
@Result(property = "permAppend", column = "PERM_APPEND"),
|
||||
@Result(property = "permTransfer", column = "PERM_TRANSFER"),
|
||||
@Result(property = "permDistribute", column = "PERM_DISTRIBUTE"),
|
||||
@Result(property = "permCustom1", column = "PERM_CUSTOM_1"),
|
||||
@Result(property = "permCustom2", column = "PERM_CUSTOM_2"),
|
||||
@Result(property = "permCustom3", column = "PERM_CUSTOM_3"),
|
||||
@Result(property = "permCustom4", column = "PERM_CUSTOM_4"),
|
||||
@Result(property = "permCustom5", column = "PERM_CUSTOM_5"),
|
||||
@Result(property = "permCustom6", column = "PERM_CUSTOM_6"),
|
||||
@Result(property = "permCustom7", column = "PERM_CUSTOM_7"),
|
||||
@Result(property = "permCustom8", column = "PERM_CUSTOM_8"),
|
||||
@Result(property = "permCustom9", column = "PERM_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "PERM_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "PERM_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12") })
|
||||
List<WorkbasketAccessItem> findAll();
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12")})
|
||||
List<WorkbasketAccessItemImpl> findByWorkbasketKey(@Param("key") String key);
|
||||
|
||||
@Insert("INSERT INTO WORKBASKET_ACCESS_LIST (ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, 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) "
|
||||
+ "VALUES (#{workbasketAccessItem.id}, #{workbasketAccessItem.workbasketKey}, #{workbasketAccessItem.accessId}, #{workbasketAccessItem.permRead}, #{workbasketAccessItem.permOpen}, #{workbasketAccessItem.permAppend}, #{workbasketAccessItem.permTransfer}, #{workbasketAccessItem.permDistribute}, #{workbasketAccessItem.permCustom1}, #{workbasketAccessItem.permCustom2}, #{workbasketAccessItem.permCustom3}, #{workbasketAccessItem.permCustom4}, #{workbasketAccessItem.permCustom5}, #{workbasketAccessItem.permCustom6}, #{workbasketAccessItem.permCustom7}, #{workbasketAccessItem.permCustom8}, #{workbasketAccessItem.permCustom9}, #{workbasketAccessItem.permCustom10}, #{workbasketAccessItem.permCustom11}, #{workbasketAccessItem.permCustom12})")
|
||||
@Options(keyProperty = "id", keyColumn = "ID")
|
||||
void insert(@Param("workbasketAccessItem") WorkbasketAccessItem workbasketAccessItem);
|
||||
void insert(@Param("workbasketAccessItem") WorkbasketAccessItemImpl workbasketAccessItem);
|
||||
|
||||
@Update("UPDATE WORKBASKET_ACCESS_LIST SET WORKBASKET_KEY = #{workbasketAccessItem.workbasketKey}, ACCESS_ID = #{workbasketAccessItem.accessId}, PERM_READ = #{workbasketAccessItem.permRead}, PERM_OPEN = #{workbasketAccessItem.permOpen}, PERM_APPEND = #{workbasketAccessItem.permAppend}, PERM_TRANSFER = #{workbasketAccessItem.permTransfer}, PERM_DISTRIBUTE = #{workbasketAccessItem.permDistribute}, PERM_CUSTOM_1 = #{workbasketAccessItem.permCustom1}, PERM_CUSTOM_2 = #{workbasketAccessItem.permCustom2}, PERM_CUSTOM_3 = #{workbasketAccessItem.permCustom3}, PERM_CUSTOM_4 = #{workbasketAccessItem.permCustom4}, PERM_CUSTOM_5 = #{workbasketAccessItem.permCustom5}, PERM_CUSTOM_6 = #{workbasketAccessItem.permCustom6}, PERM_CUSTOM_7 = #{workbasketAccessItem.permCustom7}, PERM_CUSTOM_8 = #{workbasketAccessItem.permCustom8}, PERM_CUSTOM_9 = #{workbasketAccessItem.permCustom9}, PERM_CUSTOM_10 = #{workbasketAccessItem.permCustom10}, PERM_CUSTOM_11 = #{workbasketAccessItem.permCustom11}, PERM_CUSTOM_12 = #{workbasketAccessItem.permCustom12} "
|
||||
+ "WHERE id = #{workbasketAccessItem.id}")
|
||||
void update(@Param("workbasketAccessItem") WorkbasketAccessItem workbasketAccessItem);
|
||||
void update(@Param("workbasketAccessItem") WorkbasketAccessItemImpl workbasketAccessItem);
|
||||
|
||||
@Delete("DELETE FROM WORKBASKET_ACCESS_LIST where id = #{id}")
|
||||
void delete(@Param("id") String id);
|
||||
|
||||
@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 "
|
||||
+ "WHERE WORKBASKET_KEY = #{workbasketKey} "
|
||||
+ "AND ACCESS_ID IN(<foreach item='item' collection='accessIds' separator=',' >#{item}</foreach>)"
|
||||
+ "</script>")
|
||||
+ "FROM WORKBASKET_ACCESS_LIST "
|
||||
+ "WHERE WORKBASKET_KEY = #{workbasketKey} "
|
||||
+ "AND ACCESS_ID IN(<foreach item='item' collection='accessIds' separator=',' >#{item}</foreach>)"
|
||||
+ "</script>")
|
||||
@Results(value = {
|
||||
@Result(property = "permRead", column = "P_READ"),
|
||||
@Result(property = "permOpen", column = "P_OPEN"),
|
||||
@Result(property = "permAppend", column = "P_APPEND"),
|
||||
@Result(property = "permTransfer", column = "P_TRANSFER"),
|
||||
@Result(property = "permDistribute", column = "P_DISTRIBUTE"),
|
||||
@Result(property = "permCustom1", column = "P_CUSTOM_1"),
|
||||
@Result(property = "permCustom2", column = "P_CUSTOM_2"),
|
||||
@Result(property = "permCustom3", column = "P_CUSTOM_3"),
|
||||
@Result(property = "permCustom4", column = "P_CUSTOM_4"),
|
||||
@Result(property = "permCustom5", column = "P_CUSTOM_5"),
|
||||
@Result(property = "permCustom6", column = "P_CUSTOM_6"),
|
||||
@Result(property = "permCustom7", column = "P_CUSTOM_7"),
|
||||
@Result(property = "permCustom8", column = "P_CUSTOM_8"),
|
||||
@Result(property = "permCustom9", column = "P_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "P_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "P_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "P_CUSTOM_12") })
|
||||
WorkbasketAccessItem findByWorkbasketAndAccessId(
|
||||
@Param("workbasketKey") String workbasketKey, @Param("accessIds") List<String> accessIds);
|
||||
@Result(property = "permRead", column = "P_READ"),
|
||||
@Result(property = "permOpen", column = "P_OPEN"),
|
||||
@Result(property = "permAppend", column = "P_APPEND"),
|
||||
@Result(property = "permTransfer", column = "P_TRANSFER"),
|
||||
@Result(property = "permDistribute", column = "P_DISTRIBUTE"),
|
||||
@Result(property = "permCustom1", column = "P_CUSTOM_1"),
|
||||
@Result(property = "permCustom2", column = "P_CUSTOM_2"),
|
||||
@Result(property = "permCustom3", column = "P_CUSTOM_3"),
|
||||
@Result(property = "permCustom4", column = "P_CUSTOM_4"),
|
||||
@Result(property = "permCustom5", column = "P_CUSTOM_5"),
|
||||
@Result(property = "permCustom6", column = "P_CUSTOM_6"),
|
||||
@Result(property = "permCustom7", column = "P_CUSTOM_7"),
|
||||
@Result(property = "permCustom8", column = "P_CUSTOM_8"),
|
||||
@Result(property = "permCustom9", column = "P_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "P_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "P_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "P_CUSTOM_12")})
|
||||
WorkbasketAccessItemImpl findByWorkbasketAndAccessId(
|
||||
@Param("workbasketKey") String workbasketKey, @Param("accessIds") List<String> accessIds);
|
||||
|
||||
@Select("<script>SELECT ID, WORKBASKET_KEY, ACCESS_ID, PERM_READ, PERM_OPEN, PERM_APPEND, PERM_TRANSFER, PERM_DISTRIBUTE, PERM_CUSTOM_1, PERM_CUSTOM_2, 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 "
|
||||
|
@ -197,10 +172,11 @@ public interface WorkbasketAccessMapper {
|
|||
@Result(property = "permCustom9", column = "PERM_CUSTOM_9"),
|
||||
@Result(property = "permCustom10", column = "PERM_CUSTOM_10"),
|
||||
@Result(property = "permCustom11", column = "PERM_CUSTOM_11"),
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12") })
|
||||
List<WorkbasketAccessItem> findByWorkbasketAndAccessIdAndAuthorization(
|
||||
@Result(property = "permCustom12", column = "PERM_CUSTOM_12")})
|
||||
List<WorkbasketAccessItemImpl> findByWorkbasketAndAccessIdAndAuthorization(
|
||||
@Param("workbasketKey") String workbasketKey, @Param("accessIds") List<String> accessIds,
|
||||
@Param("authorization") String authorization);
|
||||
|
||||
@Select("<script>SELECT A.ID, A.WORKBASKET_KEY, A.ACCESS_ID, A.PERM_READ, A.PERM_OPEN, A.PERM_APPEND, A.PERM_TRANSFER, A.PERM_DISTRIBUTE, A.PERM_CUSTOM_1, A.PERM_CUSTOM_2, A.PERM_CUSTOM_3, A.PERM_CUSTOM_4, A.PERM_CUSTOM_5, A.PERM_CUSTOM_6, A.PERM_CUSTOM_7, A.PERM_CUSTOM_8 "
|
||||
+ "FROM WORKBASKET_ACCESS_LIST AS A "
|
||||
+ "LEFT JOIN WORKBASKET AS W ON A.WORKBASKET_KEY = W.KEY "
|
||||
|
@ -236,7 +212,7 @@ public interface WorkbasketAccessMapper {
|
|||
@Result(property = "permCustom6", column = "PERM_CUSTOM_6"),
|
||||
@Result(property = "permCustom7", column = "PERM_CUSTOM_7"),
|
||||
@Result(property = "permCustom8", column = "PERM_CUSTOM_8")})
|
||||
List<WorkbasketAccessItem> findByWorkbasketAndAccessIdAndAuthorizationsById(
|
||||
List<WorkbasketAccessItemImpl> findByWorkbasketAndAccessIdAndAuthorizationsById(
|
||||
@Param("workbasketId") String workbasketId, @Param("accessIds") List<String> accessIds,
|
||||
@Param("authorization") String authorization);
|
||||
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
package acceptance.workbasket;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.TaskSummary;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskAlreadyExistException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.WorkbasketAccessItemImpl;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "update workbasket" scenarios.
|
||||
*/
|
||||
@RunWith(JAASRunner.class)
|
||||
public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
|
||||
|
||||
public UpdateWorkbasketAuthorizationsAccTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("key1", "user1");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermCustom11(true);
|
||||
accessItem.setPermRead(true);
|
||||
accessItem = workbasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
accessItem.setPermCustom1(true);
|
||||
accessItem.setPermAppend(false);
|
||||
WorkbasketAccessItem updatedItem = workbasketService.updateWorkbasketAuthorization(accessItem);
|
||||
|
||||
Assert.assertEquals(false, updatedItem.isPermAppend());
|
||||
Assert.assertEquals(true, updatedItem.isPermRead());
|
||||
Assert.assertEquals(true, updatedItem.isPermCustom11());
|
||||
Assert.assertEquals(true, updatedItem.isPermCustom1());
|
||||
Assert.assertEquals(false, updatedItem.isPermCustom2());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessItemRejected()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("key1", "user1");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermCustom11(true);
|
||||
accessItem.setPermRead(true);
|
||||
accessItem = workbasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
accessItem.setPermCustom1(true);
|
||||
accessItem.setPermAppend(false);
|
||||
((WorkbasketAccessItemImpl) accessItem).setAccessId("willi");
|
||||
try {
|
||||
workbasketService.updateWorkbasketAuthorization(accessItem);
|
||||
fail("InvalidArgumentException was expected because access id was changed");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
((WorkbasketAccessItemImpl) accessItem).setAccessId("user1");
|
||||
accessItem = workbasketService.updateWorkbasketAuthorization(accessItem);
|
||||
Assert.assertEquals(false, accessItem.isPermAppend());
|
||||
Assert.assertEquals(true, accessItem.isPermRead());
|
||||
Assert.assertEquals(true, accessItem.isPermCustom11());
|
||||
Assert.assertEquals(true, accessItem.isPermCustom1());
|
||||
Assert.assertEquals(false, accessItem.isPermCustom2());
|
||||
|
||||
((WorkbasketAccessItemImpl) accessItem).setWorkbasketKey("key2");
|
||||
try {
|
||||
workbasketService.updateWorkbasketAuthorization(accessItem);
|
||||
fail("InvalidArgumentException was expected because key was changed");
|
||||
} catch (InvalidArgumentException ex) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_2"})
|
||||
@Test
|
||||
public void testUpdatedAccessItemLeadsToNotAuthorizedException()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
String wbKey = "USER_2_1";
|
||||
String groupName = "group_2";
|
||||
|
||||
Task newTask = taskService.newTask(wbKey);
|
||||
newTask.setClassificationKey("T2100");
|
||||
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
Task createdTask = taskService.createTask(newTask);
|
||||
List<TaskSummary> tasks = taskService.createTaskQuery()
|
||||
.workbasketKeyIn(wbKey)
|
||||
.list();
|
||||
Assert.assertEquals(1, tasks.size());
|
||||
|
||||
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAuthorizations(wbKey);
|
||||
WorkbasketAccessItem theAccessItem = accessItems.stream()
|
||||
.filter(x -> groupName.equals(x.getAccessId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
Assert.assertTrue(theAccessItem != null);
|
||||
theAccessItem.setPermOpen(false);
|
||||
workbasketService.updateWorkbasketAuthorization(theAccessItem);
|
||||
|
||||
try {
|
||||
taskService.createTaskQuery()
|
||||
.workbasketKeyIn(wbKey)
|
||||
.list();
|
||||
fail("NotAuthorizedException was expected ");
|
||||
} catch (NotAuthorizedException ignored) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanUpClass() {
|
||||
FileUtils.deleteRecursive("~/data", true);
|
||||
}
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ import pro.taskana.TaskSummary;
|
|||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
|
@ -49,10 +50,8 @@ import pro.taskana.impl.TaskanaEngineImpl;
|
|||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
|
@ -464,10 +463,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey(wb.getKey());
|
||||
accessItem.setAccessId(accessId);
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getKey(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
accessItem.setPermAppend(permAppend);
|
||||
|
|
|
@ -32,6 +32,7 @@ import pro.taskana.TaskSummary;
|
|||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
|
@ -53,10 +54,8 @@ import pro.taskana.impl.WorkbasketImpl;
|
|||
import pro.taskana.impl.WorkbasketServiceImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.ObjectReference;
|
||||
import pro.taskana.model.TaskState;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
|
@ -149,10 +148,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
Task task = this.generateDummyTask();
|
||||
connection.commit();
|
||||
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey("wb");
|
||||
accessItem.setAccessId("Elena");
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("wb", "Elena");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermRead(true);
|
||||
accessItem.setPermOpen(true);
|
||||
|
@ -231,10 +227,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
objectReference.setValue("4444");
|
||||
objectReference.setType("type");
|
||||
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey("wb");
|
||||
accessItem.setAccessId("Elena");
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("wb", "Elena");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermRead(true);
|
||||
accessItem.setPermOpen(true);
|
||||
|
@ -556,19 +549,13 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
private void generateSampleAccessItems() {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey("k1");
|
||||
accessItem.setAccessId("Elena");
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("k1", "Elena");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermRead(true);
|
||||
accessItem.setPermOpen(true);
|
||||
workbasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
WorkbasketAccessItem accessItem2 = new WorkbasketAccessItem();
|
||||
accessItem2.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem2.setWorkbasketKey("k2");
|
||||
accessItem2.setAccessId("DummyGroup");
|
||||
WorkbasketAccessItem accessItem2 = workbasketService.newWorkbasketAccessItem("k2", "DummyGroup");
|
||||
accessItem.setPermRead(true);
|
||||
accessItem2.setPermOpen(true);
|
||||
workbasketService.createWorkbasketAuthorization(accessItem2);
|
||||
|
@ -576,10 +563,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey(wb.getKey());
|
||||
accessItem.setAccessId(accessId);
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getKey(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
accessItem.setPermAppend(permAppend);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.junit.runner.RunWith;
|
|||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketQuery;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
|
@ -39,7 +40,6 @@ import pro.taskana.impl.WorkbasketImpl;
|
|||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.model.mappings.WorkbasketMapper;
|
||||
|
@ -218,36 +218,31 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
|
||||
@Test
|
||||
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setWorkbasketKey("k1");
|
||||
accessItem.setAccessId("Arthur Dent");
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem("k1", "Arthur Dent");
|
||||
accessItem.setPermOpen(true);
|
||||
accessItem.setPermRead(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
Assert.assertEquals(1, workBasketService.getAllAuthorizations().size());
|
||||
Assert.assertEquals(1, workBasketService.getWorkbasketAuthorizations("k1").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setWorkbasketKey("k2");
|
||||
accessItem.setAccessId("Arthur Dent");
|
||||
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem("k2",
|
||||
"Zaphod Beeblebrox");
|
||||
accessItem.setPermOpen(true);
|
||||
accessItem.setPermRead(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
Assert.assertEquals(1, workBasketService.getAllAuthorizations().size());
|
||||
Assert.assertEquals(1, workBasketService.getWorkbasketAuthorizations("k2").size());
|
||||
|
||||
accessItem.setAccessId("Zaphod Beeblebrox");
|
||||
accessItem.setPermAppend(true);
|
||||
workBasketService.updateWorkbasketAuthorization(accessItem);
|
||||
|
||||
if (TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds()) {
|
||||
Assert.assertEquals("zaphod beeblebrox",
|
||||
workBasketService.getWorkbasketAuthorization(accessItem.getId()).getAccessId());
|
||||
Assert.assertEquals("zaphod beeblebrox", accessItem.getAccessId());
|
||||
} else {
|
||||
Assert.assertEquals("zaphod beeblebrox",
|
||||
workBasketService.getWorkbasketAuthorization(accessItem.getId()).getAccessId());
|
||||
Assert.assertEquals("Zaphod Beeblebrox", accessItem.getAccessId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,10 +337,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
basket1.setType(WorkbasketType.GROUP);
|
||||
basket1.setDomain("novatec");
|
||||
basket1 = (WorkbasketImpl) workBasketService.createWorkbasket(basket1);
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey(basket1.getKey());
|
||||
accessItem.setAccessId("Bernd");
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(basket1.getKey(), "Bernd");
|
||||
accessItem.setPermTransfer(true);
|
||||
accessItem.setPermCustom1(true);
|
||||
accessItem.setPermOpen(true);
|
||||
|
@ -359,10 +351,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
basket2.setType(WorkbasketType.CLEARANCE);
|
||||
basket2.setDomain("consulting");
|
||||
basket2 = (WorkbasketImpl) workBasketService.createWorkbasket(basket2);
|
||||
WorkbasketAccessItem accessItem2 = new WorkbasketAccessItem();
|
||||
accessItem2.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem2.setWorkbasketKey(basket2.getKey());
|
||||
accessItem2.setAccessId("group2");
|
||||
WorkbasketAccessItem accessItem2 = workBasketService.newWorkbasketAccessItem(basket2.getKey(), "group2");
|
||||
accessItem2.setPermTransfer(true);
|
||||
accessItem2.setPermRead(true);
|
||||
accessItem2.setPermCustom4(true);
|
||||
|
@ -377,10 +366,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
basket3.setType(WorkbasketType.TOPIC);
|
||||
basket3.setDomain("develop");
|
||||
basket3 = (WorkbasketImpl) workBasketService.createWorkbasket(basket3);
|
||||
WorkbasketAccessItem accessItem3 = new WorkbasketAccessItem();
|
||||
accessItem3.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem3.setWorkbasketKey(basket3.getKey());
|
||||
accessItem3.setAccessId("group3");
|
||||
WorkbasketAccessItem accessItem3 = workBasketService.newWorkbasketAccessItem(basket3.getKey(), "group3");
|
||||
accessItem3.setPermOpen(true);
|
||||
accessItem3.setPermRead(true);
|
||||
accessItem3.setPermAppend(true);
|
||||
|
@ -394,10 +380,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
basket4.setDomain("");
|
||||
List<String> distTargets = new ArrayList<>(Arrays.asList(basket1.getId(), basket2.getId(), basket3.getId()));
|
||||
basket4 = (WorkbasketImpl) workBasketService.createWorkbasket(basket4);
|
||||
WorkbasketAccessItem accessItem4 = new WorkbasketAccessItem();
|
||||
accessItem4.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem4.setWorkbasketKey(basket4.getKey());
|
||||
accessItem4.setAccessId("Bernd");
|
||||
WorkbasketAccessItem accessItem4 = workBasketService.newWorkbasketAccessItem(basket4.getKey(), "Bernd");
|
||||
accessItem4.setPermOpen(true);
|
||||
accessItem4.setPermRead(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem4);
|
||||
|
@ -434,10 +417,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey(wb.getKey());
|
||||
accessItem.setAccessId(accessId);
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getKey(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
accessItem.setPermAppend(permAppend);
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
|
|||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
|
@ -33,7 +34,6 @@ import pro.taskana.impl.WorkbasketImpl;
|
|||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
@ -247,14 +247,14 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setWorkbasketKey("Key1");
|
||||
accessItem.setAccessId("Arthur Dent");
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
|
||||
"Key1",
|
||||
"Arthur Dent");
|
||||
accessItem.setPermOpen(true);
|
||||
accessItem.setPermRead(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
Assert.assertEquals(1, workBasketService.getAllAuthorizations().size());
|
||||
Assert.assertEquals(1, workBasketService.getWorkbasketAuthorizations("Key1").size());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
|
@ -263,29 +263,22 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setWorkbasketKey("key2");
|
||||
accessItem.setAccessId("Arthur Dent");
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
|
||||
"key2",
|
||||
"Zaphod Beeblebrox");
|
||||
accessItem.setPermOpen(true);
|
||||
accessItem.setPermRead(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
Assert.assertEquals(1, workBasketService.getAllAuthorizations().size());
|
||||
|
||||
accessItem.setAccessId("Zaphod Beeblebrox");
|
||||
workBasketService.updateWorkbasketAuthorization(accessItem);
|
||||
|
||||
Assert.assertEquals("zaphod beeblebrox",
|
||||
workBasketService.getWorkbasketAuthorization(accessItem.getId()).getAccessId());
|
||||
Assert.assertEquals(1, workBasketService.getWorkbasketAuthorizations("key2").size());
|
||||
Assert.assertEquals("zaphod beeblebrox", accessItem.getAccessId());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) {
|
||||
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
|
||||
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
|
||||
accessItem.setWorkbasketKey(wb.getKey());
|
||||
accessItem.setAccessId(accessId);
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
|
||||
wb.getKey(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
accessItem.setPermAppend(permAppend);
|
||||
|
|
|
@ -18,12 +18,13 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.WorkbasketAccessItem;
|
||||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
|
||||
@RestController
|
||||
|
@ -141,7 +142,7 @@ public class WorkbasketController {
|
|||
|
||||
@RequestMapping(value = "/authorizations/{authid}", method = RequestMethod.PUT)
|
||||
public WorkbasketAccessItem updateWorkbasketAuthorization(@PathVariable(value = "authid") String authId,
|
||||
@RequestBody WorkbasketAccessItem workbasketAccessItem) {
|
||||
@RequestBody WorkbasketAccessItem workbasketAccessItem) throws InvalidArgumentException {
|
||||
return workbasketService.updateWorkbasketAuthorization(workbasketAccessItem);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue