Class ProjectService

java.lang.Object
com.gooddata.sdk.service.AbstractService
com.gooddata.sdk.service.project.ProjectService

public class ProjectService extends AbstractService
List projects, create a project, ...

Usage example:


     ProjectService projectService = gd.getProjectService();
     Collection<Project> projects = projectService.getProjects();
     Project project = projectService.createProject(new Project("my project", "MyToken"));
 
  • Field Details

    • PROJECT_TEMPLATE

      public static final org.springframework.web.util.UriTemplate PROJECT_TEMPLATE
    • PROJECT_USERS_TEMPLATE

      public static final org.springframework.web.util.UriTemplate PROJECT_USERS_TEMPLATE
    • PROJECT_USER_TEMPLATE

      public static final org.springframework.web.util.UriTemplate PROJECT_USER_TEMPLATE
    • LIST_PROJECTS_TEMPLATE

      public static final org.springframework.web.util.UriTemplate LIST_PROJECTS_TEMPLATE
  • Constructor Details

    • ProjectService

      public ProjectService(org.springframework.web.client.RestTemplate restTemplate, AccountService accountService, GoodDataSettings settings)
      Constructs service for GoodData project management (list projects, create a project, ...).
      Parameters:
      restTemplate - RESTful HTTP Spring template
      accountService - GoodData account service
      settings - settings
  • Method Details

    • getProjects

      @Deprecated public Collection<Project> getProjects()
      Deprecated.
      use listProjects() or listProjects(PageRequest) instead. Deprecated since version 3.0.0. Will be removed in one of future versions.
      Get all projects current user has access to.
      Returns:
      collection of all projects current user has access to
      Throws:
      com.gooddata.sdk.common.GoodDataException - when projects can't be accessed
    • listProjects

      public com.gooddata.sdk.common.collections.PageBrowser<Project> listProjects()
      Get browser of projects that current user has access to.
      Returns:
      PageBrowser list of found projects or empty list
    • listProjects

      public com.gooddata.sdk.common.collections.PageBrowser<Project> listProjects(com.gooddata.sdk.common.collections.PageRequest startPage)
      Get defined page of paged list of projects that current user has access to.
      Parameters:
      startPage - page to be retrieved first
      Returns:
      PageBrowser list of found projects or empty list
    • listProjects

      public com.gooddata.sdk.common.collections.PageBrowser<Project> listProjects(Account account, com.gooddata.sdk.common.collections.PageRequest startPage)
      Get defined page of paged list of projects that given user/account has access to.
      Parameters:
      account - user whose projects will be returned
      startPage - page to be retrieved
      Returns:
      PageBrowser list of found projects for given user or empty list
    • listProjects

      public com.gooddata.sdk.common.collections.PageBrowser<Project> listProjects(Account account)
      Get browser of projects that given user/account has access to.
      Parameters:
      account - user whose projects will be returned
      Returns:
      PageBrowser list of found projects for given user or empty list
    • createProject

      public FutureResult<Project> createProject(Project project)
      Create new project.
      Parameters:
      project - project to be created
      Returns:
      created project (including very useful id)
      Throws:
      com.gooddata.sdk.common.GoodDataException - when projects creation fails
    • getProjectByUri

      public Project getProjectByUri(String uri)
      Get project by URI.
      Parameters:
      uri - URI of project resource (/gdc/projects/{id})
      Returns:
      project
      Throws:
      com.gooddata.sdk.common.GoodDataException - when project can't be accessed
    • getProjectById

      public Project getProjectById(String id)
      Get project by id.
      Parameters:
      id - id of project
      Returns:
      project
      Throws:
      com.gooddata.sdk.common.GoodDataException - when project can't be accessed
    • removeProject

      public void removeProject(Project project)
      Removes given project
      Parameters:
      project - project to be removed
      Throws:
      com.gooddata.sdk.common.GoodDataException - when project can't be deleted
    • getProjectTemplates

      public Collection<ProjectTemplate> getProjectTemplates(Project project)
    • getAvailableProjectValidationTypes

      public Set<ProjectValidationType> getAvailableProjectValidationTypes(Project project)
      Get available validation types for project. Which can be passed to validateProject(Project, ProjectValidationType...).
      Parameters:
      project - project to fetch validation types for
      Returns:
      available validations
    • validateProject

      public FutureResult<ProjectValidationResults> validateProject(Project project)
      Validate project using all available validations.
      Parameters:
      project - project to validate
      Returns:
      results of validation
    • validateProject

      public FutureResult<ProjectValidationResults> validateProject(Project project, ProjectValidationType... validations)
      Validate project with given validations
      Parameters:
      project - project to validate
      validations - validations to use
      Returns:
      results of validation
    • validateProject

      public FutureResult<ProjectValidationResults> validateProject(Project project, Set<ProjectValidationType> validations)
      Validate project with given validations
      Parameters:
      project - project to validate
      validations - validations to use
      Returns:
      results of validation
    • listUsers

      public com.gooddata.sdk.common.collections.PageBrowser<User> listUsers(Project project)
      Get browser of users by given project.
      Parameters:
      project - project of users
      Returns:
      PageBrowser list of found users or empty list
    • listUsers

      public com.gooddata.sdk.common.collections.PageBrowser<User> listUsers(Project project, com.gooddata.sdk.common.collections.PageRequest startPage)
      Get defined page of paged list of users by given project.
      Parameters:
      project - project of users
      startPage - page to be retrieved first
      Returns:
      PageBrowser list of found users or empty list
    • getRoles

      public Set<Role> getRoles(Project project)
      Get set of user role by given project.

      Note: This makes n+1 API calls to retrieve all role details.

      Parameters:
      project - project of roles
      Returns:
      set of found roles or empty set
    • getRoleByUri

      public Role getRoleByUri(String uri)
      Get role by given URI.
      Parameters:
      uri - role uri
      Returns:
      found role
      Throws:
      RoleNotFoundException - when the role doesn't exist
    • sendInvitations

      public CreatedInvitations sendInvitations(Project project, Invitation... invitations)
      Send project invitations to users
      Parameters:
      project - target project
      invitations - invitations
      Returns:
      created invitation
    • getUser

      public User getUser(Project project, Account account)
      get user in project
      Parameters:
      project - where to find
      account - which user to find
      Returns:
      User representation in project
      Throws:
      UserInProjectNotFoundException - when user is not in project
    • addUserToProject

      public User addUserToProject(Project project, Account account, Role... userRoles)
      Add user in to the project
      Parameters:
      project - where to add user
      account - to be added
      userRoles - list of user roles
      Returns:
      user added to the project
      Throws:
      ProjectUsersUpdateException - in case of failure
    • updateUserInProject

      public void updateUserInProject(Project project, User... users)
      Update user in the project
      Parameters:
      project - in which to update user
      users - to update
      Throws:
      ProjectUsersUpdateException - in case of failure
    • removeUserFromProject

      public void removeUserFromProject(Project project, Account account)
      Removes given account from a project without checking if really account is in project.

      You can:

      • Remove yourself from a project (leave the project). You cannot leave the project if you are the only admin in the project.
      • Remove another user from a project. You need to have the canSuspendUser permission in this project.

      Parameters:
      account - account to be removed
      project - project from user will be removed
      Throws:
      com.gooddata.sdk.common.GoodDataException - when account can't be removed