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, 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.WorkbasketcreateWorkbasket(Workbasket newWorkbasket)Create a new Workbasket.WorkbasketAccessItemcreateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)Create and persist a newWorkbasketAccessItemwith a WorkbasketId, an accessId and permissions.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 of it.voiddeleteWorkbasketAccessItem(String accessItemId)Deletes a specificWorkbasketAccessItem.voiddeleteWorkbasketAccessItemsForAccessId(String accessId)Deletes all WorkbasketAccessItems using the given AccessId of a user.BulkOperationResults<String,TaskanaException>deleteWorkbaskets(List<String> workbasketsIds)Deletes a list of workbaskets.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 permissions 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 Workbasket for a given id.WorkbasketgetWorkbasket(String workbasketKey, String domain)Get Workbasket for a given key.List<WorkbasketAccessItem>getWorkbasketAccessItems(String workbasketId)Get allsfor a Workbasket.WorkbasketnewWorkbasket(String key, String domain)Returns a new workbasket which is not persisted.WorkbasketAccessItemnewWorkbasketAccessItem(String workbasketId, String accessId)Returns a new WorkbasketAccessItem which is not persisted.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 a Workbasket.WorkbasketAccessItemupdateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)This method updates aWorkbasketAccessItem.
-
-
-
Constructor Detail
-
WorkbasketServiceImpl
public WorkbasketServiceImpl(InternalTaskanaEngine taskanaEngine, WorkbasketMapper workbasketMapper, DistributionTargetMapper distributionTargetMapper, WorkbasketAccessMapper workbasketAccessMapper)
-
-
Method Detail
-
getWorkbasket
public Workbasket getWorkbasket(String workbasketId) throws WorkbasketNotFoundException, NotAuthorizedException
Description copied from interface:WorkbasketServiceGet Workbasket for a 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 foundNotAuthorizedException- If the current user or group does not have the permissions for interactions.
-
getWorkbasket
public Workbasket getWorkbasket(String workbasketKey, String domain) throws WorkbasketNotFoundException, NotAuthorizedException
Description copied from interface:WorkbasketServiceGet Workbasket for a given key.- 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 foundNotAuthorizedException- If the current user or group does not have the permissions for interactions.
-
createWorkbasket
public Workbasket createWorkbasket(Workbasket newWorkbasket) throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, DomainNotFoundException
Description copied from interface:WorkbasketServiceCreate a new Workbasket.- Specified by:
createWorkbasketin interfaceWorkbasketService- Parameters:
newWorkbasket- The Workbasket to create- Returns:
- the created and persisted Workbasket
- Throws:
InvalidWorkbasketException- If a required property of the Workbasket is not set.NotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMINWorkbasketAlreadyExistException- if the workbasket exists alreadyDomainNotFoundException- if the domain does not exist in the configuration.
-
updateWorkbasket
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate) throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException, InvalidWorkbasketException
Description copied from interface:WorkbasketServiceUpdate a Workbasket.- Specified by:
updateWorkbasketin interfaceWorkbasketService- Parameters:
workbasketToUpdate- The Workbasket to update- Returns:
- the updated Workbasket
- Throws:
NotAuthorizedException- if the current user is not authorized to update the work basketWorkbasketNotFoundException- if the workbasket cannot be found.ConcurrencyException- if an attempt is made to update the workbasket and another user updated it alreadyInvalidWorkbasketException- if workbasket name or type is invalid
-
newWorkbasketAccessItem
public WorkbasketAccessItem newWorkbasketAccessItem(String workbasketId, String accessId)
Description copied from interface:WorkbasketServiceReturns a new WorkbasketAccessItem which is not persisted.- Specified by:
newWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
workbasketId- the workbasket 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, NotAuthorizedException, WorkbasketNotFoundException, WorkbasketAccessItemAlreadyExistException
Description copied from interface:WorkbasketServiceCreate and persist a newWorkbasketAccessItemwith a WorkbasketId, an accessId and permissions.- Specified by:
createWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
workbasketAccessItem- the new workbasketAccessItem- Returns:
- the created WorkbasketAccessItem
- Throws:
InvalidArgumentException- when the preconditions dont match the required ones.NotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMINWorkbasketNotFoundException- if the workbasketAccessItem refers to a not existing workbasket *WorkbasketAccessItemAlreadyExistException- if there exists already a WorkbasketAccessItem for the same access id and workbasket
-
updateWorkbasketAccessItem
public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) throws InvalidArgumentException, NotAuthorizedException
Description copied from interface:WorkbasketServiceThis method updates aWorkbasketAccessItem.- Specified by:
updateWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
workbasketAccessItem- theWorkbasketAccessItem- Returns:
- the updated entity
- Throws:
InvalidArgumentException- if accessid or workbasketId is changed in the workbasketAccessItemNotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMIN
-
deleteWorkbasketAccessItem
public void deleteWorkbasketAccessItem(String accessItemId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceDeletes a specificWorkbasketAccessItem.- Specified by:
deleteWorkbasketAccessItemin interfaceWorkbasketService- Parameters:
accessItemId- the id of the WorbasketAccessItem to be deleted- Throws:
NotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMIN
-
checkAuthorization
public void checkAuthorization(String workbasketId, WorkbasketPermission... requestedPermissions) throws NotAuthorizedException, WorkbasketNotFoundException
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 neededWorkbasketPermissionIf more than one permission is specified, the current user needs all of them.- Throws:
NotAuthorizedException- if the current user has not the requested authorization for the specified workbasketWorkbasketNotFoundException- if the workbasket cannot be found for the given ID.
-
checkAuthorization
public void checkAuthorization(String workbasketKey, String domain, WorkbasketPermission... requestedPermissions) throws NotAuthorizedException, WorkbasketNotFoundException
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 neededWorkbasketPermission. If more than one permission is specified, the current user needs all of them.- Throws:
NotAuthorizedException- if the current user has not the requested permission for the specified workbasketWorkbasketNotFoundException- if no workbasket can be found for the given key+domain values.
-
getWorkbasketAccessItems
public List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceGet allsfor a Workbasket.- Specified by:
getWorkbasketAccessItemsin interfaceWorkbasketService- Parameters:
workbasketId- the id of the Workbasket- Returns:
- List of WorkbasketAccessItems for the Workbasket with workbasketKey
- Throws:
NotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMIN
-
setWorkbasketAccessItems
public void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems) throws NotAuthorizedException, WorkbasketAccessItemAlreadyExistException, InvalidArgumentException
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
WorkbasketAccessIteminwbAccessItems:WorkbasketAccessItem.getWorkbasketId()is not nullWorkbasketAccessItem.getWorkbasketId()is equal toworkbasketIdWorkbasketAccessItem.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:
NotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMINWorkbasketAccessItemAlreadyExistException- ifwbAccessItemscontains multiple accessItems with the same accessId.InvalidArgumentException- will be thrown when the parameterwbAccessItemsis NULL or member doesn't match the preconditions
-
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 BUSINESS_ADMIN or ADMIN
-
newWorkbasket
public Workbasket newWorkbasket(String key, String domain)
Description copied from interface:WorkbasketServiceReturns a new workbasket which is not persisted.- Specified by:
newWorkbasketin interfaceWorkbasketService- Parameters:
key- the workbasket 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 permissions 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 NotAuthorizedException, WorkbasketNotFoundException
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:
NotAuthorizedException- if the current user has no read permission for the specified workbasketWorkbasketNotFoundException- if the workbasket doesn't exist
-
getDistributionTargets
public List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain) throws NotAuthorizedException, WorkbasketNotFoundException
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:
NotAuthorizedException- if the current user has no read permission for the specified workbasketWorkbasketNotFoundException- if the workbasket doesn't exist
-
setDistributionTargets
public void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds) throws WorkbasketNotFoundException, NotAuthorizedException
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 used doesn't have READ permission for the source workbasket
-
addDistributionTarget
public void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) throws NotAuthorizedException, WorkbasketNotFoundException
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:
NotAuthorizedException- if the current user doesn't have READ permission for the source workbasketWorkbasketNotFoundException- if either the source workbasket or the target workbasket doesn't exist
-
removeDistributionTarget
public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceRemove a distribution target from a workbasket. If the 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 doesn't have READ permission for the source workbasket
-
deleteWorkbasket
public boolean deleteWorkbasket(String workbasketId) throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException
Description copied from interface:WorkbasketServiceDeletes the workbasket by the given ID of it.- 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:
NotAuthorizedException- if the current user got no permissions for this interaction.WorkbasketNotFoundException- if the workbasket does not exist.WorkbasketInUseException- if the workbasket does contain task-content.InvalidArgumentException- if the workbasketId is NULL or EMPTY
-
deleteWorkbaskets
public BulkOperationResults<String,TaskanaException> deleteWorkbaskets(List<String> workbasketsIds) throws NotAuthorizedException, InvalidArgumentException
Description copied from interface:WorkbasketServiceDeletes a list of workbaskets.- Specified by:
deleteWorkbasketsin interfaceWorkbasketService- Parameters:
workbasketsIds- the ids of the workbaskets to delete.- Returns:
- the result of the operations with Id and Exception for each failed workbasket deletion.
- Throws:
NotAuthorizedException- if the current user got no permission for this interaction.InvalidArgumentException- if the WorkbasketIds parameter list is NULL or empty
-
getDistributionSources
public List<WorkbasketSummary> getDistributionSources(String workbasketId) throws NotAuthorizedException, WorkbasketNotFoundException
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:
NotAuthorizedException- if the current user has no read permission for the specified workbasketWorkbasketNotFoundException- if the workbasket doesn't exist
-
getDistributionSources
public List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain) throws NotAuthorizedException, WorkbasketNotFoundException
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:
NotAuthorizedException- if the current user has no read permission for the specified workbasketWorkbasketNotFoundException- if the workbasket doesn't exist
-
deleteWorkbasketAccessItemsForAccessId
public void deleteWorkbasketAccessItemsForAccessId(String accessId) throws NotAuthorizedException
Description copied from interface:WorkbasketServiceDeletes all WorkbasketAccessItems using the given AccessId of a user.- Specified by:
deleteWorkbasketAccessItemsForAccessIdin interfaceWorkbasketService- Parameters:
accessId- of a taskana-user.- Throws:
NotAuthorizedException- if the current user is not member of role BUSINESS_ADMIN or ADMIN
-
-