Package com.taskadapter.redmineapi
Class ProjectManager
- java.lang.Object
-
- com.taskadapter.redmineapi.ProjectManager
-
public class ProjectManager extends java.lang.Object
Works with Projects and their Versions.Obtain it via RedmineManager:
RedmineManager redmineManager = RedmineManagerFactory.createWithUserAuth(redmineURI, login, password); ProjectManager projectManager = redmineManager.getProjectManager();
Sample usage:
projectManager.getProjectById(123); projects = projectManager.getProjects(); // create project Project project = ProjectFactory.create(); project.setName("MyProject"); project.setDescription("description"); project.setHomepage("www.mypage.com"); createdProject = projectManager.createProject(project);
- See Also:
RedmineManager.getIssueManager()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Membership
addGroupToProject(int projectId, int groupId, java.util.Collection<Role> roles)
Membership
addUserToProject(int projectId, int userId, java.util.Collection<Role> roles)
Project
createProject(Project project)
Sample usage:Version
createVersion(Version version)
void
deleteProject(java.lang.String projectKey)
void
deleteProjectMembership(int membershipId)
Remove the project member from the project.void
deleteProjectMembership(Membership membership)
void
deleteVersion(Version version)
java.util.List<News>
getNews(java.lang.String projectKey)
Project
getProjectById(int id)
Project
getProjectByKey(java.lang.String projectKey)
Membership
getProjectMember(int membershipId)
java.util.List<Membership>
getProjectMembers(int projectId)
java.util.List<Membership>
getProjectMembers(java.lang.String projectKey)
java.util.List<Project>
getProjects()
Load the list of projects available to the user, which is represented by the API access key.Version
getVersionById(int versionId)
java.util.List<Version>
getVersions(int projectID)
void
update(Project object)
void
update(Version object)
void
updateProjectMembership(Membership membership)
-
-
-
Method Detail
-
createProject
public Project createProject(Project project) throws RedmineException
Sample usage:Project project = new Project(); Long timeStamp = Calendar.getInstance().getTimeInMillis(); String key = "projkey" + timeStamp; String name = "project number " + timeStamp; String description = "some description for the project"; project.setIdentifier(key); project.setName(name); project.setDescription(description); Project createdProject = mgr.createProject(project);
- Parameters:
project
- project to create on the server- Returns:
- the newly created Project object.
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.RedmineException
-
getProjects
public java.util.List<Project> getProjects() throws RedmineException
Load the list of projects available to the user, which is represented by the API access key.Redmine ignores "get trackers info" parameter for "get projects" request. see bug http://www.redmine.org/issues/8545 The field is already accessible for a specific project for a long time (GET /projects/:id) but in the projects list (GET /projects) it's only on the svn trunk for now (Sep 8, 2014). It will be included in Redmine 2.6.0 which isn't out yet.
- Returns:
- list of Project objects
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.RedmineException
-
getProjectByKey
public Project getProjectByKey(java.lang.String projectKey) throws RedmineException
- Parameters:
projectKey
- string key like "project-ABC", NOT a database numeric ID- Returns:
- Redmine's project
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException
- the project with the given key is not foundRedmineException
-
getProjectById
public Project getProjectById(int id) throws RedmineException
- Parameters:
id
- project database Id, like 123. this is not a string "key" like "myproject".- Returns:
- Redmine's project
- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization.NotFoundException
- the project with the given id is not foundRedmineException
-
deleteProject
public void deleteProject(java.lang.String projectKey) throws RedmineException
- Parameters:
projectKey
- string key like "project-ABC", NOT a database numeric ID- Throws:
RedmineAuthenticationException
- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException
- if the project with the given key is not foundRedmineException
-
createVersion
public Version createVersion(Version version) throws RedmineException
creates a newVersion
for theProject
contained.
Pre-condition: the attributeProject
for theVersion
must not be null!- Parameters:
version
- theVersion
. Must contain aProject
.- Returns:
- the new
Version
created by Redmine - Throws:
java.lang.IllegalArgumentException
- thrown in case the version does not contain a project.RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
deleteVersion
public void deleteVersion(Version version) throws RedmineException
- Parameters:
version
- theVersion
.- Throws:
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
getVersions
public java.util.List<Version> getVersions(int projectID) throws RedmineException
- Parameters:
projectID
- the ID of theProject
- Returns:
- the list of
Version
s of theProject
- Throws:
RedmineAuthenticationException
- thrown in case something went wrong while trying to loginRedmineException
- thrown in case something went wrong in RedmineNotFoundException
- thrown in case an object can not be found
-
getVersionById
public Version getVersionById(int versionId) throws RedmineException
- Throws:
RedmineException
-
update
public void update(Project object) throws RedmineException
- Throws:
RedmineException
-
update
public void update(Version object) throws RedmineException
- Throws:
RedmineException
-
getNews
public java.util.List<News> getNews(java.lang.String projectKey) throws RedmineException
- Parameters:
projectKey
- ignored if NULL- Returns:
- list of news objects
- Throws:
RedmineException
- See Also:
News
-
addUserToProject
public Membership addUserToProject(int projectId, int userId, java.util.Collection<Role> roles) throws RedmineException
- Throws:
RedmineException
-
addGroupToProject
public Membership addGroupToProject(int projectId, int groupId, java.util.Collection<Role> roles) throws RedmineException
- Throws:
RedmineException
-
getProjectMembers
public java.util.List<Membership> getProjectMembers(java.lang.String projectKey) throws RedmineException
- Parameters:
projectKey
- string-based project key (like "TEST")- Returns:
- list of project members (users or groups)
- Throws:
RedmineException
-
getProjectMembers
public java.util.List<Membership> getProjectMembers(int projectId) throws RedmineException
- Parameters:
projectId
- database ID of the project (like 123)- Returns:
- list of project members (users or groups)
- Throws:
RedmineException
-
getProjectMember
public Membership getProjectMember(int membershipId) throws RedmineException
- Throws:
RedmineException
-
deleteProjectMembership
public void deleteProjectMembership(int membershipId) throws RedmineException
Remove the project member from the project. This does not delete the user/group itself.- Parameters:
membershipId
- id of the "membership" relation- Throws:
RedmineException
-
deleteProjectMembership
public void deleteProjectMembership(Membership membership) throws RedmineException
- Throws:
RedmineException
-
updateProjectMembership
public void updateProjectMembership(Membership membership) throws RedmineException
- Throws:
RedmineException
-
-