Tabnine Logo
WorklogService.hasPermissionToUpdate
Code IndexAdd Tabnine to your IDE (free)

How to use
hasPermissionToUpdate
method
in
com.atlassian.jira.bc.issue.worklog.WorklogService

Best Java code snippets using com.atlassian.jira.bc.issue.worklog.WorklogService.hasPermissionToUpdate (Showing top 3 results out of 315)

origin: com.atlassian.jira/jira-core

@Override
public List<IssueAction> getActions(Issue issue, ApplicationUser remoteUser)
{
  JiraServiceContextImpl context = new JiraServiceContextImpl(remoteUser, new SimpleErrorCollection());
  List<Worklog> userWorklogs = worklogService.getByIssueVisibleToUser(context, issue);
  List<IssueAction> worklogs = Lists.newArrayListWithCapacity(userWorklogs.size());
  final Locale userLocale = context.getI18nBean().getLocale();
  for (Worklog userWorklog : userWorklogs)
  {
    boolean canEditWorklog = worklogService.hasPermissionToUpdate(context, userWorklog);
    boolean canDeleteWorklog = worklogService.hasPermissionToDelete(context, userWorklog);
    worklogs.add(new WorklogAction(descriptor, userWorklog, jiraDurationUtils, canEditWorklog, canDeleteWorklog, fieldLayoutManager, rendererManager, userLocale, userFormats));
  }
  // This is a bit of a hack to indicate that there are no comments to display
  if (worklogs.isEmpty())
  {
    IssueAction action = new GenericMessageAction(descriptor.getI18nBean().getText("viewissue.nowork"));
    return Lists.newArrayList(action);
  }
  Collections.sort(worklogs, IssueActionComparator.COMPARATOR);
  return worklogs;
}
origin: com.atlassian.jira.plugins/atlassian-jira-rpc-plugin

public boolean hasPermissionToUpdateWorklog(User user, String worklogId)
    throws RemoteException, RemoteValidationException
{
  JiraServiceContext serviceContext = new JiraServiceContextImpl(user, new SimpleErrorCollection());
  Long id = SoapUtils.toLongRequired(worklogId);
  Worklog worklog = worklogService.getById(serviceContext, id);
  // getById does not currenty return errors but it might so we do this code
  checkAndThrowValidationException(serviceContext.getErrorCollection());
  return worklog != null && worklogService.hasPermissionToUpdate(serviceContext, worklog);
}
origin: com.atlassian.jira/jira-core

public String doDefault() throws Exception
{
  // Retrieve the worklog
  worklog = worklogService.getById(getJiraServiceContext(), getWorklogId());
  if (worklog == null)
  {
    addErrorMessage(getText("logwork.error.update.invalid.id", (getWorklogId() == null) ? null : getWorklogId().toString()));
    return ERROR;
  }
  if (!worklogService.hasPermissionToUpdate(getJiraServiceContext(), worklog))
  {
    //user doesn't have permission to run this action
    return "securitybreach";
  }
  //pre-populate the fields
  final BigDecimal hoursPerDay = getHoursPerDay();
  final BigDecimal daysPerWeek = getDaysPerWeek();
  final BigDecimal secondsPerHour = BigDecimal.valueOf(DateUtils.Duration.HOUR.getSeconds());
  final long secondsPerDay = hoursPerDay.multiply(secondsPerHour).longValueExact();
  final long secondsPerWeek = daysPerWeek.multiply(hoursPerDay).multiply(secondsPerHour).longValueExact();
  setTimeLogged(DateUtils.getDurationStringSeconds(worklog.getTimeSpent(), secondsPerDay, secondsPerWeek));
  setStartDate(getFormattedStartDate(worklog.getStartDate()));
  setComment(worklog.getComment());
  setCommentLevel(CommentVisibility.getCommentLevelFromLevels(worklog.getGroupLevel(), worklog.getRoleLevelId()));
  return super.doDefault();
}
com.atlassian.jira.bc.issue.worklogWorklogServicehasPermissionToUpdate

Javadoc

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

  • The user has the com.atlassian.jira.security.Permissions#WORKLOG_EDIT_ALL permission; OR
  • The user is the Worklog author and has the com.atlassian.jira.security.Permissions#WORKLOG_EDIT_OWN permission
and false otherwise.

Popular methods of WorklogService

  • createAndAutoAdjustRemainingEstimate
  • validateCreate
  • getById
    Used to get a worklog by its id.
  • createAndRetainRemainingEstimate
    Persists a new com.atlassian.jira.issue.worklog.Worklog on the given Issue. This method will make no
  • createWithNewRemainingEstimate
    Persists a new com.atlassian.jira.issue.worklog.Worklog on the given Issue. This method will adjust
  • deleteAndAutoAdjustRemainingEstimate
    Deletes the specified com.atlassian.jira.issue.worklog.Worklog. This method will auto-adjust the iss
  • deleteAndRetainRemainingEstimate
    Deletes the specified com.atlassian.jira.issue.worklog.Worklog. This method will make no adjustment
  • deleteWithNewRemainingEstimate
    Deletes the specified com.atlassian.jira.issue.worklog.Worklog. This method will adjust the issues r
  • getByIssueVisibleToUser
    Returns a PagedList over all all child worklogs of a specified issue that the provided user has perm
  • updateAndAutoAdjustRemainingEstimate
    Updates the provided com.atlassian.jira.issue.worklog.Worklog. This method will auto-adjust the issu
  • updateAndRetainRemainingEstimate
    Updates the provided com.atlassian.jira.issue.worklog.Worklog. This method will make no adjustment t
  • updateWithNewRemainingEstimate
    Updates the provided com.atlassian.jira.issue.worklog.Worklog. This method will adjust the issues re
  • updateAndRetainRemainingEstimate,
  • updateWithNewRemainingEstimate,
  • validateCreateWithNewEstimate,
  • validateDelete,
  • validateDeleteWithNewEstimate,
  • validateUpdate,
  • validateUpdateWithNewEstimate,
  • createWithManuallyAdjustedEstimate,
  • deleteWithManuallyAdjustedEstimate,
  • hasPermissionToDelete

Popular in Java

  • Running tasks concurrently on multiple threads
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • Menu (java.awt)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Join (org.hibernate.mapping)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now