com.atlassian.jira.bc.issue.worklog
Class DefaultWorklogService

java.lang.Object
  extended by com.atlassian.jira.bc.issue.worklog.DefaultWorklogService
All Implemented Interfaces:
WorklogService

public class DefaultWorklogService
extends Object
implements WorklogService

Default implemenation of the WorklogService.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.issue.worklog.WorklogService
WorklogService.WorklogNewEstimateResult
 
Constructor Summary
DefaultWorklogService(WorklogManager worklogManager, PermissionManager permissionManager, JiraAuthenticationContext jiraAuthenticationContext, VisibilityValidator visibilityValidator, ApplicationProperties applicationProperties, ProjectRoleManager projectRoleManager, IssueManager issueManager)
           
 
Method Summary
protected  Worklog create(JiraServiceContext jiraServiceContext, Worklog worklog, Long newEstimate, boolean dispatchEvent)
           
 Worklog createAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, Worklog worklog, boolean dispatchEvent)
          Persists a new Worklog on the given Issue.
 Worklog createAndRetainRemainingEstimate(JiraServiceContext jiraServiceContext, Worklog worklog, boolean dispatchEvent)
          Persists a new Worklog on the given Issue.
 Worklog createWithNewRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogService.WorklogNewEstimateResult worklogNewEstimate, boolean dispatchEvent)
          Persists a new Worklog on the given Issue.
protected  boolean delete(JiraServiceContext jiraServiceContext, Worklog worklog, Long newEstimate, boolean dispatchEvent)
           
 boolean deleteAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, Worklog worklog, boolean dispatchEvent)
          Deletes the specified Worklog.
 boolean deleteAndRetainRemainingEstimate(JiraServiceContext jiraServiceContext, Worklog worklog, boolean dispatchEvent)
          Deletes the specified Worklog.
 boolean deleteWithNewRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogService.WorklogNewEstimateResult worklogNewEstimate, boolean dispatchEvent)
          Deletes the specified Worklog.
protected  Long getAutoAdjustNewEstimateOnCreate(Issue issue, Long timeSpent)
           
protected  Long getAutoAdjustNewEstimateOnDelete(Issue issue, Long timeSpent)
           
protected  Long getAutoAdjustNewEstimateOnUpdate(Issue issue, Long newTimeSpent, Long originalTimeSpent)
           
 Worklog getById(JiraServiceContext jiraServiceContext, Long id)
          Used to get a worklog by its id.
 List getByIssue(JiraServiceContext jiraServiceContext, Issue issue)
          Returns all child worklogs of a specified issue.
 List getByIssueVisibleToUser(JiraServiceContext jiraServiceContext, Issue issue)
          Returns all child worklogs of a specified issue that the provided user has permission to see.
protected  long getDurationForFormattedString(String timeSpent)
           
protected  boolean hasDeleteAllPermission(User user, Issue issue)
           
protected  boolean hasDeleteOwnPermission(User user, Worklog worklog)
           
protected  boolean hasEditAllPermission(User user, Issue issue)
           
protected  boolean hasEditOwnPermission(User user, Worklog worklog)
           
 boolean hasPermissionToCreate(JiraServiceContext jiraServiceContext, Issue issue)
          Determines if the user has the Permissions.WORK_ISSUE permission, that timetracking is enabled in JIRA and that the associated issue is in an editable workflow state.
 boolean hasPermissionToDelete(JiraServiceContext jiraServiceContext, Worklog worklog)
          Determine whether the current user has the permission to delete the supplied worklog, timetracking is enabled in JIRA and that the associated issue is in an editable workflow state.
 boolean hasPermissionToUpdate(JiraServiceContext jiraServiceContext, Worklog worklog)
          Determine whether the current user has the permission to update the supplied worklog, timetracking is enabled in JIRA and that the associated issue is in an editable workflow state.
 boolean isIssueInEditableWorkflowState(Issue issue)
          Will return true if the issue is in an editable workflow state.
protected  boolean isSameAuthor(User user, Worklog worklog)
           
 boolean isTimeTrackingEnabled()
          Will return true if APKeys.JIRA_OPTION_TIMETRACKING is true, false otherwise.
protected  boolean isUserInGroup(User user, String groupLevel)
           
protected  boolean isUserInRole(Long roleLevel, User user, Issue issue)
           
protected  boolean isValidDuration(String duration)
           
protected  boolean isValidNewEstimate(JiraServiceContext jiraServiceContext, String newEstimate)
           
protected  boolean isValidWorklogInputFields(JiraServiceContext jiraServiceContext, Issue issue, String timeSpent, Date startDate)
           
protected  Worklog update(JiraServiceContext jiraServiceContext, Worklog worklog, Long newEstimate, boolean dispatchEvent)
           
 Worklog updateAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, Worklog worklog, boolean dispatchEvent)
          Updates the provided Worklog.
 Worklog updateAndRetainRemainingEstimate(JiraServiceContext jiraServiceContext, Worklog worklog, boolean dispatchEvent)
          Updates the provided Worklog.
 Worklog updateWithNewRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogService.WorklogNewEstimateResult worklogNewEstimate, boolean dispatchEvent)
          Updates the provided Worklog.
 Worklog validateCreate(JiraServiceContext jiraServiceContext, Issue issue, String timeSpent, Date startDate, String comment, String groupLevel, String roleLevelId)
          Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue) to create a worklog for this issue.
 WorklogService.WorklogNewEstimateResult validateCreateWithNewEstimate(JiraServiceContext jiraServiceContext, Issue issue, String timeSpent, Date startDate, String comment, String groupLevel, String roleLevelId, String newEstimate)
          Determines whether worklogs are enabled in JIRA and if the user has the required permission as determined by calling WorklogService.hasPermissionToCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue) to create a worklog for this issue.
 Worklog validateDelete(JiraServiceContext jiraServiceContext, Long worklogId)
          Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to delete a worklog for this issue.
 WorklogService.WorklogNewEstimateResult validateDeleteWithNewEstimate(JiraServiceContext jiraServiceContext, Long worklogId, String newEstimate)
          Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to delete a worklog for this issue.
protected  Worklog validateParamsAndCreateWorklog(JiraServiceContext jiraServiceContext, Issue issue, String author, String groupLevel, String roleLevelId, String timeSpent, Date startDate, Long worklogId, String comment, Date created, Date updated, String updateAuthor)
           
 Worklog validateUpdate(JiraServiceContext jiraServiceContext, Long worklogId, String timeSpent, Date startDate, String comment, String groupLevel, String roleLevelId)
          Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToUpdate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to update a worklog for this issue.
 WorklogService.WorklogNewEstimateResult validateUpdateWithNewEstimate(JiraServiceContext jiraServiceContext, Long worklogId, String timeSpent, Date startDate, String comment, String groupLevel, String roleLevelId, String newEstimate)
          Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToUpdate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to update a worklog for this issue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWorklogService

public DefaultWorklogService(WorklogManager worklogManager,
                             PermissionManager permissionManager,
                             JiraAuthenticationContext jiraAuthenticationContext,
                             VisibilityValidator visibilityValidator,
                             ApplicationProperties applicationProperties,
                             ProjectRoleManager projectRoleManager,
                             IssueManager issueManager)
Method Detail

validateDelete

public Worklog validateDelete(JiraServiceContext jiraServiceContext,
                              Long worklogId)
Description copied from interface: WorklogService
Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to delete a worklog for this issue.

Specified by:
validateDelete in interface WorklogService
Parameters:
jiraServiceContext - containing the user who wishes to create a worklog and the errorCollection that will contain any errors in calling the method
worklogId - identifies the worklog that the update validation will occur against
Returns:
Worklog which can be passed to the delete methods if has permission and the data passed in is valid, null otherwise

validateDeleteWithNewEstimate

public WorklogService.WorklogNewEstimateResult validateDeleteWithNewEstimate(JiraServiceContext jiraServiceContext,
                                                                             Long worklogId,
                                                                             String newEstimate)
Description copied from interface: WorklogService
Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToDelete(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to delete a worklog for this issue.

Specified by:
validateDeleteWithNewEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the user who wishes to create a worklog and the errorCollection that will contain any errors in calling the method
worklogId - identifies the worklog that the delete validation will occur against
newEstimate - The value to change the issues remaining estimate to.
Returns:
Worklog which can be passed to the delete methods if has permission and the data passed in is valid, null otherwise

deleteWithNewRemainingEstimate

public boolean deleteWithNewRemainingEstimate(JiraServiceContext jiraServiceContext,
                                              WorklogService.WorklogNewEstimateResult worklogNewEstimate,
                                              boolean dispatchEvent)
Description copied from interface: WorklogService
Deletes the specified Worklog. This method will adjust the issues remaining estimate to be the new value which has been passed to this method, the old remaining estimate value will be lost.

Specified by:
deleteWithNewRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to update the supplied worklog and the ErrorCollection that will contain any errors encountered in calling the method
worklogNewEstimate - the Worklog and new estimate for the issue.
dispatchEvent - whether or not you want to have an event dispatched on Worklog delete @return the deleted Worklog object, or null if no object has been deleted.

deleteAndRetainRemainingEstimate

public boolean deleteAndRetainRemainingEstimate(JiraServiceContext jiraServiceContext,
                                                Worklog worklog,
                                                boolean dispatchEvent)
Description copied from interface: WorklogService
Deletes the specified Worklog. This method will make no adjustment to the issues remaining estimate.

Specified by:
deleteAndRetainRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to update the supplied worklog and the ErrorCollection that will contain any errors encountered in calling the method
worklog - Deletes a worklog from the datastore (identified by its id). This should have been generated by a call to WorklogService.validateDelete(com.atlassian.jira.bc.JiraServiceContext,Long)
dispatchEvent - whether or not you want to have an event dispatched on Worklog delete
Returns:
true if the Worklog was successfully deleted, false otherwise

deleteAndAutoAdjustRemainingEstimate

public boolean deleteAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext,
                                                    Worklog worklog,
                                                    boolean dispatchEvent)
Description copied from interface: WorklogService
Deletes the specified Worklog. This method will auto-adjust the issues remaining estimate by adding the time spent on the deleted worklog.

Specified by:
deleteAndAutoAdjustRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to update the supplied worklog and the ErrorCollection that will contain any errors encountered in calling the method
worklog - Deletes a worklog from the datastore (identified by its id). This should have been generated by a call to WorklogService.validateDelete(com.atlassian.jira.bc.JiraServiceContext,Long)
dispatchEvent - whether or not you want to have an event dispatched on Worklog delete
Returns:
true if the Worklog was successfully deleted, false otherwise

validateUpdate

public Worklog validateUpdate(JiraServiceContext jiraServiceContext,
                              Long worklogId,
                              String timeSpent,
                              Date startDate,
                              String comment,
                              String groupLevel,
                              String roleLevelId)
Description copied from interface: WorklogService
Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToUpdate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to update a worklog for this issue.

Specified by:
validateUpdate in interface WorklogService
Parameters:
jiraServiceContext - containing the user who wishes to create a worklog and the errorCollection that will contain any errors in calling the method
worklogId - identifies the worklog that the update validation will occur against
timeSpent - the time spent on the work
startDate - the date on which the work was performed
comment - The body of the comment associated with the worklog
groupLevel - The group level visibility of the worklog (null if roleLevelId specified)
roleLevelId - The role level id visibility of the worklog (null if groupLevel specified)
Returns:
Worklog which can be passed to the update methods if has permission and the data passed in is valid, null otherwise

validateUpdateWithNewEstimate

public WorklogService.WorklogNewEstimateResult validateUpdateWithNewEstimate(JiraServiceContext jiraServiceContext,
                                                                             Long worklogId,
                                                                             String timeSpent,
                                                                             Date startDate,
                                                                             String comment,
                                                                             String groupLevel,
                                                                             String roleLevelId,
                                                                             String newEstimate)
Description copied from interface: WorklogService
Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToUpdate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.worklog.Worklog) to update a worklog for this issue.

Specified by:
validateUpdateWithNewEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the user who wishes to create a worklog and the errorCollection that will contain any errors in calling the method
worklogId - identifies the worklog that the update validation will occur against
timeSpent - the time spent on the work
startDate - the date on which the work was performed
comment - The body of the comment associated with the worklog
groupLevel - The group level visibility of the worklog (null if roleLevelId specified)
roleLevelId - The role level id visibility of the worklog (null if groupLevel specified)
newEstimate - The value to change the issues remaining estimate to.
Returns:
Worklog which can be passed to the update methods if has permission and the data passed in is valid, null otherwise

updateWithNewRemainingEstimate

public Worklog updateWithNewRemainingEstimate(JiraServiceContext jiraServiceContext,
                                              WorklogService.WorklogNewEstimateResult worklogNewEstimate,
                                              boolean dispatchEvent)
Description copied from interface: WorklogService
Updates the provided Worklog. This method will adjust the issues remaining estimate to be the new value which has been passed to this method, the old remaining estimate value will be lost.

Specified by:
updateWithNewRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
worklogNewEstimate - the Worklog and new estimate for the issue.
dispatchEvent - whether or not you want to have an event dispatched on Worklog update @return the updated Worklog object, or null if no object has been updated.

updateAndRetainRemainingEstimate

public Worklog updateAndRetainRemainingEstimate(JiraServiceContext jiraServiceContext,
                                                Worklog worklog,
                                                boolean dispatchEvent)
Description copied from interface: WorklogService
Updates the provided Worklog. This method will make no adjustment to the issues remaining estimate.

Specified by:
updateAndRetainRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to update the supplied worklog and the ErrorCollection that will contain any errors encountered in calling the method
worklog - Updates fields of an existing worklog in the datastore (identified by its id) with the supplied worklog.This should have been generated by a call to WorklogService.validateUpdate(com.atlassian.jira.bc.JiraServiceContext,Long,String,java.util.Date,String,String,String)
dispatchEvent - whether or not you want to have an event dispatched on Worklog update
Returns:
the updated Worklog object, or null if no object has been updated.

updateAndAutoAdjustRemainingEstimate

public Worklog updateAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext,
                                                    Worklog worklog,
                                                    boolean dispatchEvent)
Description copied from interface: WorklogService
Updates the provided Worklog. This method will auto-adjust the issues remaining estimate based on the updated value of the time spent on the work.

Specified by:
updateAndAutoAdjustRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to update the worklog and the ErrorCollection that will contain any errors in calling the method
worklog - Updates fields of an existing worklog in the datastore (identified by its id) with the supplied worklog. This should have been generated by a call to WorklogService.validateCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue,String,java.util.Date,String,String,String)
dispatchEvent - whether or not you want to have an event dispatched on Worklog update
Returns:
the update Worklog object, or null if no object has been updated.

delete

protected boolean delete(JiraServiceContext jiraServiceContext,
                         Worklog worklog,
                         Long newEstimate,
                         boolean dispatchEvent)

update

protected Worklog update(JiraServiceContext jiraServiceContext,
                         Worklog worklog,
                         Long newEstimate,
                         boolean dispatchEvent)

validateCreate

public Worklog validateCreate(JiraServiceContext jiraServiceContext,
                              Issue issue,
                              String timeSpent,
                              Date startDate,
                              String comment,
                              String groupLevel,
                              String roleLevelId)
Description copied from interface: WorklogService
Determines whether worklogs are enabled in JIRA and if the user has the required permissions as determined by calling WorklogService.hasPermissionToCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue) to create a worklog for this issue.

Specified by:
validateCreate in interface WorklogService
Parameters:
jiraServiceContext - containing the user who wishes to create a worklog and the errorCollection that will contain any errors in calling the method
issue - that will have a worklog associated with it
timeSpent - the time spent on the work
startDate - the date on which the work was performed
comment - The body of the comment associated with the worklog
groupLevel - The group level visibility of the worklog (null if roleLevelId specified)
roleLevelId - The role level id visibility of the worklog (null if groupLevel specified)
Returns:
Worklog which can be passed to the create methods if has permission and the data passed in is valid, null otherwise

validateCreateWithNewEstimate

public WorklogService.WorklogNewEstimateResult validateCreateWithNewEstimate(JiraServiceContext jiraServiceContext,
                                                                             Issue issue,
                                                                             String timeSpent,
                                                                             Date startDate,
                                                                             String comment,
                                                                             String groupLevel,
                                                                             String roleLevelId,
                                                                             String newEstimate)
Description copied from interface: WorklogService
Determines whether worklogs are enabled in JIRA and if the user has the required permission as determined by calling WorklogService.hasPermissionToCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue) to create a worklog for this issue.

Specified by:
validateCreateWithNewEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the user who wishes to create a worklog and the errorCollection that will contain any errors in calling the method
issue - that will have a worklog associated with it
timeSpent - the time spent on the work
startDate - the date on which the work was performed
comment - The body of the comment associated with the worklog
groupLevel - The group level visibility of the worklog (null if roleLevelId specified)
roleLevelId - The role level id visibility of the worklog (null if groupLevel specified)
newEstimate - The value to change the issues remaining estimate to.
Returns:
WorklogNewEstimateResult the Worklog of which can be passed to the create methods if has permission and the data passed in is valid, null otherwise

createWithNewRemainingEstimate

public Worklog createWithNewRemainingEstimate(JiraServiceContext jiraServiceContext,
                                              WorklogService.WorklogNewEstimateResult worklogNewEstimate,
                                              boolean dispatchEvent)
Description copied from interface: WorklogService
Persists a new Worklog on the given Issue. This method will adjust the issues remaining estimate to be the new value which has been passed to this method, the old remaining estimate value will be lost.

Specified by:
createWithNewRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
worklogNewEstimate - the Worklog and new estimate for the issue.
dispatchEvent - whether or not you want to have an event dispatched on Worklog creation @return the created Worklog object, or null if no object created.
Returns:
the created Worklog object or null if no object was created.

createAndRetainRemainingEstimate

public Worklog createAndRetainRemainingEstimate(JiraServiceContext jiraServiceContext,
                                                Worklog worklog,
                                                boolean dispatchEvent)
Description copied from interface: WorklogService
Persists a new Worklog on the given Issue. This method will make no adjustment to the issues remaining estimate.

Specified by:
createAndRetainRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
worklog - Is the worklog to persist to the datastore. This should have been generated by a call to WorklogService.validateCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue,String,java.util.Date,String,String,String)
dispatchEvent - whether or not you want to have an event dispatched on Worklog creation
Returns:
the created Worklog object, or null if no object created.

createAndAutoAdjustRemainingEstimate

public Worklog createAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext,
                                                    Worklog worklog,
                                                    boolean dispatchEvent)
Description copied from interface: WorklogService
Persists a new Worklog on the given Issue. This method will auto-adjust the issues remaining estimate based on the value of the time spent on the work.

Specified by:
createAndAutoAdjustRemainingEstimate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
worklog - Is the worklog to persist to the datastore. This should have been generated by a call to WorklogService.validateCreate(com.atlassian.jira.bc.JiraServiceContext,com.atlassian.jira.issue.Issue,String,java.util.Date,String,String,String)
dispatchEvent - whether or not you want to have an event dispatched on Worklog creation
Returns:
the created Worklog object, or null if no object created.

hasPermissionToCreate

public boolean hasPermissionToCreate(JiraServiceContext jiraServiceContext,
                                     Issue issue)
Description copied from interface: WorklogService
Determines if the user has the Permissions.WORK_ISSUE permission, that timetracking is enabled in JIRA and that the associated issue is in an editable workflow state.

Specified by:
hasPermissionToCreate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
issue - the issue to add the worklog to
Returns:
true if the user has permission to create a worklog on the specified issue, false otherwise

hasPermissionToUpdate

public boolean hasPermissionToUpdate(JiraServiceContext jiraServiceContext,
                                     Worklog worklog)
Description copied from interface: WorklogService
Determine whether the current user has the permission to update the supplied worklog, timetracking is enabled in JIRA and that the associated issue is in an editable workflow state.

In case of errors, add error messages to the error collection within the servicecontext.

Passing in null worklog or a worklog with null ID will return false and an error message will be added to the error collection.

Passing in null error collection will throw NPE.

This method will return true if the user is a member of the worklog's group/role level (if specified) AND

and false otherwise.

Specified by:
hasPermissionToUpdate in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to update the worklog and the ErrorCollection that will contain any errors in calling the method
worklog - the Worklog the user wishes to update
Returns:
true if the user has permission to update the supplied worklog, false otherwise

hasPermissionToDelete

public boolean hasPermissionToDelete(JiraServiceContext jiraServiceContext,
                                     Worklog worklog)
Description copied from interface: WorklogService
Determine whether the current user has the permission to delete the supplied worklog, timetracking is enabled in JIRA and that the associated issue is in an editable workflow state.

In case of errors, add error messages to the error collection within the servicecontext.

Passing in null worklog or a worklog with null ID will return false and an error message will be added to the error collection.

Passing in null error collection will throw NPE.

This method will return true if the user is a member of the worklog's group/role level (if specified) AND

and false otherwise.

Specified by:
hasPermissionToDelete in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to delete the worklog and the ErrorCollection that will contain any errors in calling the method
worklog - the Worklog the user wishes to delete
Returns:
true if the user has permission to delete the supplied worklog, false otherwise

getById

public Worklog getById(JiraServiceContext jiraServiceContext,
                       Long id)
Description copied from interface: WorklogService
Used to get a worklog by its id.

Specified by:
getById in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
id - uniquely identifies the worklog
Returns:
returns the worklog for the passed in id, null if not found.

getByIssue

public List getByIssue(JiraServiceContext jiraServiceContext,
                       Issue issue)
Description copied from interface: WorklogService
Returns all child worklogs of a specified issue.

Specified by:
getByIssue in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
issue - the specified parent issue (not null)
Returns:
a List of Worklogs, ordered by creation date. An empty List will be returned if none are found

getByIssueVisibleToUser

public List getByIssueVisibleToUser(JiraServiceContext jiraServiceContext,
                                    Issue issue)
Description copied from interface: WorklogService
Returns all child worklogs of a specified issue that the provided user has permission to see.

Specified by:
getByIssueVisibleToUser in interface WorklogService
Parameters:
jiraServiceContext - containing the User who wishes to create a worklog and the ErrorCollection that will contain any errors in calling the method
issue - the specified parent issue (not null)
Returns:
a List of Worklogs, ordered by creation date. An empty List will be returned if none are found

isTimeTrackingEnabled

public boolean isTimeTrackingEnabled()
Description copied from interface: WorklogService
Will return true if APKeys.JIRA_OPTION_TIMETRACKING is true, false otherwise.

Specified by:
isTimeTrackingEnabled in interface WorklogService
Returns:
true if enabled, false otherwise.

isIssueInEditableWorkflowState

public boolean isIssueInEditableWorkflowState(Issue issue)
Description copied from interface: WorklogService
Will return true if the issue is in an editable workflow state.

Specified by:
isIssueInEditableWorkflowState in interface WorklogService
Parameters:
issue - the issue to see if it is in an editable store
Returns:
true if editable, false otherwise

validateParamsAndCreateWorklog

protected Worklog validateParamsAndCreateWorklog(JiraServiceContext jiraServiceContext,
                                                 Issue issue,
                                                 String author,
                                                 String groupLevel,
                                                 String roleLevelId,
                                                 String timeSpent,
                                                 Date startDate,
                                                 Long worklogId,
                                                 String comment,
                                                 Date created,
                                                 Date updated,
                                                 String updateAuthor)

create

protected Worklog create(JiraServiceContext jiraServiceContext,
                         Worklog worklog,
                         Long newEstimate,
                         boolean dispatchEvent)

hasEditOwnPermission

protected boolean hasEditOwnPermission(User user,
                                       Worklog worklog)

hasEditAllPermission

protected boolean hasEditAllPermission(User user,
                                       Issue issue)

hasDeleteOwnPermission

protected boolean hasDeleteOwnPermission(User user,
                                         Worklog worklog)

hasDeleteAllPermission

protected boolean hasDeleteAllPermission(User user,
                                         Issue issue)

isSameAuthor

protected boolean isSameAuthor(User user,
                               Worklog worklog)

getAutoAdjustNewEstimateOnUpdate

protected Long getAutoAdjustNewEstimateOnUpdate(Issue issue,
                                                Long newTimeSpent,
                                                Long originalTimeSpent)

getAutoAdjustNewEstimateOnCreate

protected Long getAutoAdjustNewEstimateOnCreate(Issue issue,
                                                Long timeSpent)

getAutoAdjustNewEstimateOnDelete

protected Long getAutoAdjustNewEstimateOnDelete(Issue issue,
                                                Long timeSpent)

isValidNewEstimate

protected boolean isValidNewEstimate(JiraServiceContext jiraServiceContext,
                                     String newEstimate)

isValidWorklogInputFields

protected boolean isValidWorklogInputFields(JiraServiceContext jiraServiceContext,
                                            Issue issue,
                                            String timeSpent,
                                            Date startDate)

isValidDuration

protected boolean isValidDuration(String duration)

getDurationForFormattedString

protected long getDurationForFormattedString(String timeSpent)

isUserInGroup

protected boolean isUserInGroup(User user,
                                String groupLevel)

isUserInRole

protected boolean isUserInRole(Long roleLevel,
                               User user,
                               Issue issue)


Copyright © 2002-2007 Atlassian. All Rights Reserved.