Package pro.taskana.workbasket.internal
Class WorkbasketServiceImpl
- java.lang.Object
-
- pro.taskana.workbasket.internal.WorkbasketServiceImpl
-
- All Implemented Interfaces:
WorkbasketService
public class WorkbasketServiceImpl extends Object implements WorkbasketService
This is the implementation of WorkbasketService.
-
-
Constructor Summary
Constructors Constructor Description WorkbasketServiceImpl(InternalTaskanaEngine taskanaEngine, HistoryEventManager historyEventManager, WorkbasketMapper workbasketMapper, DistributionTargetMapper distributionTargetMapper, WorkbasketAccessMapper workbasketAccessMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)Add a distribution target to a Workbasket.voidcheckAuthorization(String workbasketKey, String domain, WorkbasketPermission... requestedPermissions)This method checks the authorization for the actual User.voidcheckAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions)This method checks the authorization for the actual User.voidcheckModifiedHasNotChanged(Workbasket oldWorkbasket, WorkbasketImpl workbasketImplToUpdate)Check if current workbasket is based on the newest (by modified).WorkbasketcreateWorkbasket(Workbasket newWorkbasket)Creates a new Workbasket.WorkbasketAccessItemcreateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)WorkbasketAccessItemQuerycreateWorkbasketAccessItemQuery()This method provides a query builder for querying the database.WorkbasketQuerycreateWorkbasketQuery()This method provides a query builder for querying the database.booleandeleteWorkbasket(String workbasketId)Deletes the Workbasket by the given id.voiddeleteWorkbasketAccessItem(String accessItemId)Deletes a specific WorkbasketAccessItem.voiddeleteWorkbasketAccessItemsForAccessId(String accessId)Deletes all WorkbasketAccessItems using the given WorkbasketAccessItem.getAccessId().BulkOperationResults<String,TaskanaException>deleteWorkbaskets(List<String> workbasketsIds)Deletes the list of Workbaskets specified via ids.List<WorkbasketSummary>getDistributionSources(String workbasketId)Returns the distribution sources for a given Workbasket.List<WorkbasketSummary>getDistributionSources(String workbasketKey, String domain)Returns the distribution sources for a given Workbasket.List<WorkbasketSummary>getDistributionTargets(String workbasketId)Returns the distribution targets for a given Workbasket.List<WorkbasketSummary>getDistributionTargets(String workbasketKey, String domain)Returns the distribution targets for a given Workbasket.List<WorkbasketPermission>getPermissionsForWorkbasket(String workbasketId)Returns a set with all permissions of the current user at this Workbasket.
If the workbasketId is invalid, an empty List of WorkbasketPermissions is returned since there is no distinction made between the situation that the Workbasket is not found and the caller has no permissions on the Workbasket.WorkbasketgetWorkbasket(String workbasketId)Get the Workbasket specified by the given id.WorkbasketgetWorkbasket(String workbasketKey, String domain)List<WorkbasketAccessItem>getWorkbasketAccessItems(String workbasketId)Get all WorkbasketAccessItems for a Workbasket.WorkbasketnewWorkbasket(String key, String domain)Returns a new Workbasket which is not inserted.WorkbasketAccessItemnewWorkbasketAccessItem(String workbasketId, String accessId)Returns a new WorkbasketAccessItem which is not inserted.voidremoveDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)Remove a distribution target from a Workbasket.voidsetDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)Set the distribution targets for a Workbasket.voidsetWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)Setting up the new WorkbasketAccessItems for a Workbasket.WorkbasketupdateWorkbasket(Workbasket workbasketToUpdate)Update the given Workbasket.WorkbasketAccessItemupdateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)This method updates a WorkbasketAccessItem.
-
-
-
Constructor Detail
-
WorkbasketServiceImpl
public WorkbasketServiceImpl(InternalTaskanaEngine taskanaEngine, HistoryEventManager historyEventManager, WorkbasketMapper workbasketMapper, DistributionTargetMapper distributionTargetMapper, WorkbasketAccessMapper workbasketAccessMapper)
-
-
Method Detail
-
getWorkbasket
public Workbasket getWorkbasket(String workbasketId) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceGet the Workbasket specified by the given id.- Specified by:
getWorkbasketin interfaceWorkbasketService- Parameters:
workbasketId- the id of the Workbasket requested- Returns:
- the requested Workbasket
- Throws:
WorkbasketNotFoundException- If the Workbasket with workbasketId is not foundNotAuthorizedOnWorkbasketException- if the current user has no WorkbasketPermission.READ for the requested Workbasket
-
getWorkbasket
public Workbasket getWorkbasket(String workbasketKey, String domain) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketService- Specified by:
getWorkbasketin interfaceWorkbasketService- Parameters:
workbasketKey- the key of the Workbasket requesteddomain- the domain of the Workbasket- Returns:
- the requested Workbasket
- Throws:
WorkbasketNotFoundException- If the Workbasket with workbasketId is not foundNotAuthorizedOnWorkbasketException- if the current user has no WorkbasketPermission.READ for the requested Workbasket
-
createWorkbasket
public Workbasket createWorkbasket(Workbasket newWorkbasket) throws InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException, NotAuthorizedException
Description copied from interface:WorkbasketService- Specified by:
createWorkbasketin interfaceWorkbasketService- Parameters:
newWorkbasket- The Workbasket to create- Returns:
- the created and inserted Workbasket
- Throws:
InvalidArgumentException- If a required property of the Workbasket is not set.WorkbasketAlreadyExistException- if the Workbasket exists alreadyDomainNotFoundException- if the domain does not exist in the configuration.NotAuthorizedException- if the current user is not member of role admin or business-admin
-
updateWorkbasket
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate) throws InvalidArgumentException, WorkbasketNotFoundException, ConcurrencyException, NotAuthorizedException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceUpdate the given Workbasket.- Specified by:
updateWorkbasketin interfaceWorkbasketService- Parameters:
workbasketToUpdate- The Workbasket to update- Returns:
- the updated Workbasket
- Throws:
InvalidArgumentException- if name or type of the Workbasket is invalidWorkbasketNotFoundException- if the Workbasket cannot be found.ConcurrencyException- if an attempt is made to update the Workbasket and another user updated it already; that's the case if the given modified timestamp differs from the one in the databaseNotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMINNotAuthorizedOnWorkbasketException- This is never thrown
-
newWorkbasketAccessItem
public WorkbasketAccessItem newWorkbasketAccessItem(String workbasketId, String accessId)
Description copied from interface:WorkbasketServiceReturns a new WorkbasketAccessItem which is not inserted.- Specified by:
newWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
workbasketId- the id used to identify the referenced WorkbasketaccessId- the group id or user id for which access is controlled- Returns:
- new WorkbasketAccessItem
-
createWorkbasketAccessItem
public WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) throws InvalidArgumentException, WorkbasketNotFoundException, WorkbasketAccessItemAlreadyExistException, NotAuthorizedException
Description copied from interface:WorkbasketService- Specified by:
createWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
workbasketAccessItem- the new WorkbasketAccessItem- Returns:
- the created WorkbasketAccessItem
- Throws:
InvalidArgumentException- if the preconditions don't match the required ones.WorkbasketNotFoundException- if the WorkbasketAccessItem refers to a not existing workbasketWorkbasketAccessItemAlreadyExistException- if there exists already a WorkbasketAccessItem for the same accessId and WorkbasketNotAuthorizedException- if the current user is not member of role admin or business-admin
-
updateWorkbasketAccessItem
public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) throws InvalidArgumentException, NotAuthorizedException
Description copied from interface:WorkbasketServiceThis method updates a WorkbasketAccessItem.- Specified by:
updateWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
workbasketAccessItem- the WorkbasketAccessItem- Returns:
- the updated entity
- Throws:
InvalidArgumentException- if accessId or workbasketId is changed in the WorkbasketAccessItemNotAuthorizedException- if the current user is not member of role admin or business-admin
-
deleteWorkbasketAccessItem
public void deleteWorkbasketAccessItem(String accessItemId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceDeletes a specific WorkbasketAccessItem.- Specified by:
deleteWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
accessItemId- the id of the WorkbasketAccessItem to be deleted- Throws:
NotAuthorizedException- if the current user is not member of role admin or business-admin
-
checkAuthorization
public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceThis method checks the authorization for the actual User.- Specified by:
checkAuthorizationin interfaceWorkbasketService- Parameters:
workbasketId- the id of the Workbasket we want to accessrequestedPermissions- the needed WorkbasketPermission; if more than one permission is specified, the current user needs all of them- Throws:
WorkbasketNotFoundException- if the Workbasket cannot be found for the given id.NotAuthorizedOnWorkbasketException- if the current user has not the requested authorization for the specified Workbasket
-
checkAuthorization
public void checkAuthorization(String workbasketKey, String domain, WorkbasketPermission... requestedPermissions) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceThis method checks the authorization for the actual User.- Specified by:
checkAuthorizationin interfaceWorkbasketService- Parameters:
workbasketKey- the key of the Workbasket we want to accessdomain- the domain of the Workbasket we want to accessrequestedPermissions- the needed WorkbasketPermission; if more than one permission is specified, the current user needs all of them.- Throws:
WorkbasketNotFoundException- if no Workbasket can be found for the given key and domain values.NotAuthorizedOnWorkbasketException- if the current user has not the requested permission for the specified Workbasket
-
getWorkbasketAccessItems
public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceGet all WorkbasketAccessItems for a Workbasket.- Specified by:
getWorkbasketAccessItemsin interfaceWorkbasketService- Parameters:
workbasketId- the id of the Workbasket- Returns:
- List of WorkbasketAccessItems for the Workbasket
- Throws:
NotAuthorizedException- if the current user is not member of role TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMIN
-
setWorkbasketAccessItems
public void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems) throws WorkbasketAccessItemAlreadyExistException, InvalidArgumentException, WorkbasketNotFoundException, NotAuthorizedException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceSetting up the new WorkbasketAccessItems for a Workbasket. Already stored values will be completely replaced by the current ones.Preconditions for each WorkbasketAccessItem then
wbAccessItems:- WorkbasketAccessItem.getWorkbasketId() is not null
- WorkbasketAccessItem.getWorkbasketId() is equal to
workbasketId - WorkbasketAccessItem.getAccessId() is unique
- Specified by:
setWorkbasketAccessItemsin interfaceWorkbasketService- Parameters:
workbasketId- id of the access-target Workbasket.wbAccessItems- List of WorkbasketAccessItems which does replace all current stored ones.- Throws:
WorkbasketAccessItemAlreadyExistException- ifwbAccessItemscontains multiple WorkbasketAccessItem with the same accessId.InvalidArgumentException- will be thrown when the parameterwbAccessItemsis NULL or member doesn't match the preconditionsWorkbasketNotFoundException- if the Workbasket cannot be found for the given id.NotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMINNotAuthorizedOnWorkbasketException- This is never thrown
-
createWorkbasketQuery
public WorkbasketQuery createWorkbasketQuery()
Description copied from interface:WorkbasketServiceThis method provides a query builder for querying the database.- Specified by:
createWorkbasketQueryin interfaceWorkbasketService- Returns:
- a WorkbasketQuery
-
createWorkbasketAccessItemQuery
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException
Description copied from interface:WorkbasketServiceThis method provides a query builder for querying the database.- Specified by:
createWorkbasketAccessItemQueryin interfaceWorkbasketService- Returns:
- a WorkbasketAccessItemQuery
- Throws:
NotAuthorizedException- if the current user is not member of role admin or business-admin
-
newWorkbasket
public Workbasket newWorkbasket(String key, String domain)
Description copied from interface:WorkbasketServiceReturns a new Workbasket which is not inserted.- Specified by:
newWorkbasketin interfaceWorkbasketService- Parameters:
key- the key used to identify the Workbasketdomain- the domain of the new Workbasket- Returns:
- new Workbasket
-
getPermissionsForWorkbasket
public List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId)
Description copied from interface:WorkbasketServiceReturns a set with all permissions of the current user at this Workbasket.
If the workbasketId is invalid, an empty List of WorkbasketPermissions is returned since there is no distinction made between the situation that the Workbasket is not found and the caller has no permissions on the Workbasket.- Specified by:
getPermissionsForWorkbasketin interfaceWorkbasketService- Parameters:
workbasketId- the id of the referenced Workbasket- Returns:
- a
Listwith allWorkbasketPermissions of the caller on the requested Workbasket.
-
getDistributionTargets
public List<WorkbasketSummary> getDistributionTargets(String workbasketId) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceReturns the distribution targets for a given Workbasket.- Specified by:
getDistributionTargetsin interfaceWorkbasketService- Parameters:
workbasketId- the id of the referenced Workbasket- Returns:
- the distribution targets of the specified Workbasket
- Throws:
WorkbasketNotFoundException- if the Workbasket doesn't existNotAuthorizedOnWorkbasketException- if the current user has no READ permission for the specified Workbasket
-
getDistributionTargets
public List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceReturns the distribution targets for a given Workbasket.- Specified by:
getDistributionTargetsin interfaceWorkbasketService- Parameters:
workbasketKey- the key of the referenced Workbasketdomain- the domain of the referenced Workbasket- Returns:
- the distribution targets of the specified Workbasket
- Throws:
WorkbasketNotFoundException- if the Workbasket doesn't existNotAuthorizedOnWorkbasketException- if the current user has no READ permission for the specified Workbasket
-
setDistributionTargets
public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceSet the distribution targets for a Workbasket.- Specified by:
setDistributionTargetsin interfaceWorkbasketService- Parameters:
sourceWorkbasketId- the id of the source Workbasket for which the distribution targets are to be settargetWorkbasketIds- a list of the ids of the target Workbaskets- Throws:
WorkbasketNotFoundException- if either the source Workbasket or any of the target Workbaskets don't existNotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMINNotAuthorizedOnWorkbasketException- This is never thrown
-
addDistributionTarget
public void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) throws WorkbasketNotFoundException, NotAuthorizedException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceAdd a distribution target to a Workbasket. If the specified distribution target exists already, the method silently returns without doing anything.- Specified by:
addDistributionTargetin interfaceWorkbasketService- Parameters:
sourceWorkbasketId- the id of the source WorkbaskettargetWorkbasketId- the id of the target Workbasket- Throws:
WorkbasketNotFoundException- if either the source Workbasket or the target Workbasket doesn't existNotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMINNotAuthorizedOnWorkbasketException- if the current user doesn't have READ permission for the source Workbaskets
-
removeDistributionTarget
public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) throws NotAuthorizedException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceRemove a distribution target from a Workbasket. If the specified distribution target doesn't exist, the method silently returns without doing anything.- Specified by:
removeDistributionTargetin interfaceWorkbasketService- Parameters:
sourceWorkbasketId- The id of the source WorkbaskettargetWorkbasketId- The id of the target Workbasket- Throws:
NotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMINNotAuthorizedOnWorkbasketException- If the current user doesn't have READ permission for the source Workbasket
-
deleteWorkbasket
public boolean deleteWorkbasket(String workbasketId) throws WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException, NotAuthorizedException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceDeletes the Workbasket by the given id.- Specified by:
deleteWorkbasketin interfaceWorkbasketService- Parameters:
workbasketId- id of the Workbasket which should be deleted.- Returns:
- true if the Workbasket was deleted successfully; false if the Workbasket is marked for deletion
- Throws:
WorkbasketNotFoundException- if the Workbasket does not existWorkbasketInUseException- if the Workbasket does contain task-contentInvalidArgumentException- if the workbasketId is NULL or EMPTYNotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMINNotAuthorizedOnWorkbasketException- This is never thrown
-
deleteWorkbaskets
public BulkOperationResults<String,TaskanaException> deleteWorkbaskets(List<String> workbasketsIds) throws InvalidArgumentException, NotAuthorizedException
Description copied from interface:WorkbasketServiceDeletes the list of Workbaskets specified via ids.- Specified by:
deleteWorkbasketsin interfaceWorkbasketService- Parameters:
workbasketsIds- the ids of the Workbaskets to delete.- Returns:
- the result of the operations and an Exception for each failed workbasket deletion
- Throws:
InvalidArgumentException- if the WorkbasketIds parameter List is NULL or emptyNotAuthorizedException- if the current user is not member of TaskanaRole.BUSINESS_ADMIN or TaskanaRole.ADMIN
-
getDistributionSources
public List<WorkbasketSummary> getDistributionSources(String workbasketId) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceReturns the distribution sources for a given Workbasket.- Specified by:
getDistributionSourcesin interfaceWorkbasketService- Parameters:
workbasketId- the id of the referenced Workbasket- Returns:
- the workbaskets that are distribution sources of the specified Workbasket.
- Throws:
WorkbasketNotFoundException- if the Workbasket doesn't existNotAuthorizedOnWorkbasketException- if the current user has no READ permission for the specified Workbasket
-
getDistributionSources
public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain) throws WorkbasketNotFoundException, NotAuthorizedOnWorkbasketException
Description copied from interface:WorkbasketServiceReturns the distribution sources for a given Workbasket.- Specified by:
getDistributionSourcesin interfaceWorkbasketService- Parameters:
workbasketKey- the key of the referenced Workbasketdomain- the domain of the referenced Workbasket- Returns:
- the workbaskets that are distribution sources of the specified Workbasket.
- Throws:
WorkbasketNotFoundException- if the Workbasket doesn't existNotAuthorizedOnWorkbasketException- if the current user has no READ permission for the specified Workbasket
-
deleteWorkbasketAccessItemsForAccessId
public void deleteWorkbasketAccessItemsForAccessId(String accessId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceDeletes all WorkbasketAccessItems using the given WorkbasketAccessItem.getAccessId().- Specified by:
deleteWorkbasketAccessItemsForAccessIdin interfaceWorkbasketService- Parameters:
accessId- id of a taskana-User.- Throws:
NotAuthorizedException- if the current user is not member of role admin or business-admin
-
checkModifiedHasNotChanged
public void checkModifiedHasNotChanged(Workbasket oldWorkbasket, WorkbasketImpl workbasketImplToUpdate) throws ConcurrencyException
Check if current workbasket is based on the newest (by modified).- Parameters:
oldWorkbasket- the old workbasket in the systemworkbasketImplToUpdate- the workbasket to update- Throws:
ConcurrencyException- if the workbasket has been modified by some other process; that's the case if the given modified timestamp differs from the one in the database
-
-