Class 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"));
     
    • Constructor Detail

      • 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
      • ProjectService

        @Deprecated
        public ProjectService​(org.springframework.web.client.RestTemplate restTemplate,
                              AccountService accountService)
        Deprecated.
        use ProjectService(RestTemplate, AccountService) constructor instead
        Constructs service for GoodData project management (list projects, create a project, ...).
        Parameters:
        restTemplate - RESTful HTTP Spring template
        accountService - GoodData account service
    • Method Detail

      • getProjects

        public Collection<Project> getProjects()
        Get all projects current user has access to.
        Returns:
        collection of all projects current user has access to
        Throws:
        com.gooddata.GoodDataException - when projects can't be accessed
      • 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.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.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.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.GoodDataException - when project can't be deleted
      • validateProject

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

        public com.gooddata.collections.PageableList<User> listUsers​(Project project)
        Get first page of paged list of users by given project.
        Parameters:
        project - project of users
        Returns:
        MultiPageList list of found users or empty list
      • listUsers

        public com.gooddata.collections.PageableList<User> listUsers​(Project project,
                                                                     com.gooddata.collections.Page startPage)
        Get defined page of paged list of users by given project.
        Parameters:
        project - project of users
        startPage - page to be retrieved first
        Returns:
        MultiPageList 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