Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note

Timetracker version 4.7.5 or higher is required to access this API

Note

JIRA Administrators or JIRA System Administrators permission required for the user this service

Timetracker permissions can be managed via this Service:

  • Query users/groups for permissions

  • Add/remove users or groups to each permission settings

API

Permission Service

Code Block
package org.everit.jira.reporting.service.permission;

/**
 * Public Permission Service.
 */
public interface PermissionService {

  /**
   * Get groups and users for the given permission type. Requires System Administrator or Administrator jira permission.
   *
   * @param permissionType
   *          the tpye of permission.
   * @return the {@link GroupUser} object.
   */
  GroupUser getGroupUserByPermissionType(PermissionType permissionType);

  /**
   * Update groups and users for the given permission. Requires System Administrator or Administrator jira permission.
   * This method clears the users and groups previously specified for the permission.
   *
   * @param permissionType
   *          the type of permission.
   * @param groupUser
   *          the {@link GroupUser} object.
   */
  void updatePermission(PermissionType permissionType, GroupUser groupUser);
}

Permission type

Code Block
package org.everit.jira.reporting.service.permission;

/**
 * Type of permissions.
 */
public enum PermissionType {

  /**
   * Permission to create/edit worklogs beyond the period
   */ 
  BEYOND_PERIOD,
  
  /**
   * Permission to browse others worklogs
   */ 
  BROWSE_GROUPS,

  /**
   * Permission to send notification emails about missing days
   */ 
  EMAIL_GROUPS,

  /**
   * Permission to use the Plugin
   */ 
  PLUGIN_PERMISSION,

  /**
   * Project Controllers
   */ 
  PROJECT_CONTROLLER,

  /**
   * Permission to use Reporting
   */ 
  REPORTING_PERMISSION,
 
  /**
   * Permission to use Timetracker
   */ 
  TIMETRACKER_PERMISSION,

  /**
   * Wage managers
   */ 
  WAGE_MANAGER;
}

Group user data

Code Block
/**
 * Group user data container.
 */
public class GroupUser {

  private List<String> groups = Collections.emptyList();

  private List<String> users = Collections.emptyList();

  public List<String> getGroups() {
    return groups;
  }

  public List<String> getUsers() {
    return users;
  }

  public GroupUser setGroups(final List<String> groups) {
    this.groups = groups;
    return this;
  }

  public GroupUser setUsers(final List<String> users) {
    this.users = users;
    return this;
  }

  @Override
  public String toString() {
    return "GroupUser [" + (groups != null ? "groups=" + groups + ", " : "")
        + (users != null ? "users=" + users : "") + "]";
  }

}

Example

Code Block
import com.onresolve.scriptrunner.runner.customisers.PluginModule;
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
import org.everit.jira.reporting.service.permission.PermissionService;
import org.everit.jira.reporting.service.permission.PermissionType;
import org.everit.jira.reporting.service.permission.GroupUser;
import java.util.Arrays;



@WithPlugin("org.everit.jira.timetracker.plugin")

@PluginModule
PermissionService permissionService;

// Gets group user for plugin permission.
GroupUser groupUserForPermission = permissionService.getGroupUserByPermissionType(PermissionType.PLUGIN_PERMISSION);
// log.info(groupUserForPermission)

// Update permission with empty groups and users.
GroupUser groupUser = new GroupUser();
permissionService.updatePermission(PermissionType.PLUGIN_PERMISSION, groupUser);


groupUserForPermission = permissionService.getGroupUserByPermissionType(PermissionType.PLUGIN_PERMISSION);
// log.info(groupUserForPermission)

// update permission with not empty groups and users
groupUser = new GroupUser()
             .setGroups(Arrays.asList("jira-administrators"))
             .setUsers(Arrays.asList("douglas.arnold@everit.biz"));
permissionService.updatePermission(PermissionType.BEYOND_PERIOD, groupUser);

groupUserForPermission = permissionService.getGroupUserByPermissionType(PermissionType.PLUGIN_PERMISSION);
// log.info(groupUserForPermission)