public class RedmineManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
RedmineManager.INCLUDE |
Constructor and Description |
---|
RedmineManager(java.lang.String uri) |
RedmineManager(java.lang.String uri,
RedmineOptions options) |
RedmineManager(java.lang.String host,
java.lang.String apiAccessKey)
Creates an instance of RedmineManager class.
|
RedmineManager(java.lang.String host,
java.lang.String apiAccessKey,
RedmineOptions options)
Creates an instance of RedmineManager class.
|
RedmineManager(java.lang.String uri,
java.lang.String login,
java.lang.String password) |
RedmineManager(java.lang.String uri,
java.lang.String login,
java.lang.String password,
RedmineOptions options) |
Modifier and Type | Method and Description |
---|---|
void |
addMembership(Membership membership)
Add a membership.
|
void |
addUserToGroup(User user,
Group group)
Adds the given user to the given group.
|
void |
addWatcherToIssue(Watcher watcher,
Issue issue) |
IssueCategory |
createCategory(IssueCategory category)
creates a new
IssueCategory for the Project contained. |
Group |
createGroup(Group base)
Creates a new group.
|
Issue |
createIssue(java.lang.String projectKey,
Issue issue)
Sample usage:
|
Project |
createProject(Project project)
Sample usage:
|
IssueRelation |
createRelation(java.lang.Integer issueId,
java.lang.Integer issueToId,
java.lang.String type) |
TimeEntry |
createTimeEntry(TimeEntry obj) |
User |
createUser(User user) |
Version |
createVersion(Version version)
|
void |
delete(Membership membership) |
void |
deleteCategory(IssueCategory category)
deletes an
IssueCategory . |
void |
deleteGroup(Group base)
Deletes a group.
|
void |
deleteIssue(java.lang.Integer id) |
void |
deleteIssueRelations(Issue redmineIssue)
Delete all issue's relations
|
void |
deleteIssueRelationsByIssueId(java.lang.Integer id)
Delete relations for the given issue ID.
|
void |
deleteMembership(int id) |
void |
deleteProject(java.lang.String projectKey) |
void |
deleteRelation(java.lang.Integer id)
Delete Issue Relation with the given ID.
|
void |
deleteTimeEntry(java.lang.Integer id) |
void |
deleteUser(java.lang.Integer userId) |
void |
deleteVersion(Version version)
|
void |
deleteWatcherFromIssue(Watcher watcher,
Issue issue) |
byte[] |
downloadAttachmentContent(Attachment issueAttachment)
Downloads the content of an
Attachment from the Redmine server. |
void |
downloadAttachmentContent(Attachment issueAttachment,
java.io.OutputStream stream) |
Attachment |
getAttachmentById(int attachmentID)
Delivers an
Attachment by its ID. |
java.util.List<IssueCategory> |
getCategories(int projectID)
delivers a list of
IssueCategory s of a Project |
User |
getCurrentUser() |
Group |
getGroupById(int id)
Returns the group based on its id.
|
Group |
getGroupByName(java.lang.String name)
Returns the group based on its name.
|
java.util.List<Group> |
getGroups()
Load the list of groups on the server.
|
Issue |
getIssueById(java.lang.Integer id,
RedmineManager.INCLUDE... include) |
java.util.List<IssuePriority> |
getIssuePriorities() |
java.util.List<Issue> |
getIssues(java.util.Map<java.lang.String,java.lang.String> pParameters)
Generic method to search for issues.
|
java.util.List<Issue> |
getIssues(java.lang.String projectKey,
java.lang.Integer queryId,
RedmineManager.INCLUDE... include) |
java.util.List<Issue> |
getIssuesBySummary(java.lang.String projectKey,
java.lang.String summaryField)
There could be several issues with the same summary, so the method returns List.
|
Membership |
getMembership(int id) |
java.util.List<Membership> |
getMemberships(Project project) |
java.util.List<Membership> |
getMemberships(java.lang.String project) |
java.util.List<News> |
getNews(java.lang.String projectKey) |
int |
getObjectsPerPage()
This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request.
|
Project |
getProjectByKey(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.
|
Role |
getRoleById(int id) |
java.util.List<Role> |
getRoles() |
java.util.List<SavedQuery> |
getSavedQueries()
Get all "saved queries" available to the current user.
|
java.util.List<SavedQuery> |
getSavedQueries(java.lang.String projectKey)
Get "saved queries" for the given project available to the current user.
|
java.util.List<IssueStatus> |
getStatuses()
Delivers a list of existing
IssueStatus es. |
java.util.List<TimeEntry> |
getTimeEntries() |
java.util.List<TimeEntry> |
getTimeEntriesForIssue(java.lang.Integer issueId) |
TimeEntry |
getTimeEntry(java.lang.Integer id) |
java.util.List<TimeEntryActivity> |
getTimeEntryActivities() |
java.util.List<Tracker> |
getTrackers() |
User |
getUserById(java.lang.Integer userId)
This does NOT require Admin privileges by default Redmine installation (tested with Redmine 2.0.3).
|
java.util.List<User> |
getUsers()
Load the list of users on the server.
|
Version |
getVersionById(int versionId) |
java.util.List<Version> |
getVersions(int projectID)
|
void |
setLogin(java.lang.String login) |
void |
setObjectsPerPage(int pageSize)
This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request.
|
void |
setPassword(java.lang.String password) |
void |
shutdown()
Shutdowns a communicator.
|
void |
update(Identifiable obj) |
Attachment |
uploadAttachment(java.lang.String contentType,
java.io.File content)
Uploads an attachment.
|
Attachment |
uploadAttachment(java.lang.String fileName,
java.lang.String contentType,
byte[] content)
Uploads an attachment.
|
Attachment |
uploadAttachment(java.lang.String fileName,
java.lang.String contentType,
java.io.InputStream content)
Uploads an attachment.
|
public RedmineManager(java.lang.String uri)
public RedmineManager(java.lang.String uri, java.lang.String login, java.lang.String password)
public RedmineManager(java.lang.String host, java.lang.String apiAccessKey)
host
- complete Redmine server web URI, including protocol and port
number. Example: http://demo.redmine.org:8080apiAccessKey
- Redmine API access key. It is shown on "My Account" /
"API access key" webpage (check
http://redmine_server_url/my/account URL). This
parameter is optional (can be set to NULL) for Redmine
projects, which are "public".public RedmineManager(java.lang.String host, java.lang.String apiAccessKey, RedmineOptions options)
host
- complete Redmine server web URI, including protocol and port
number. Example: http://demo.redmine.org:8080apiAccessKey
- Redmine API access key. It is shown on "My Account" /
"API access key" webpage (check
http://redmine_server_url/my/account URL). This
parameter is optional (can be set to NULL) for Redmine
projects, which are "public".public RedmineManager(java.lang.String uri, RedmineOptions options)
public RedmineManager(java.lang.String uri, java.lang.String login, java.lang.String password, RedmineOptions options)
public Issue createIssue(java.lang.String projectKey, Issue issue) throws RedmineException
Issue issueToCreate = new Issue();
issueToCreate.setSubject("This is the summary line 123");
Issue newIssue = mgr.createIssue(PROJECT_KEY, issueToCreate);
projectKey
- The project "identifier". This is a string key like "project-ABC", NOT a database numeric ID.issue
- the Issue object to create on the server.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 projectKey is not foundRedmineException
public java.util.List<Project> getProjects() throws RedmineException
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.RedmineException
public java.util.List<Issue> getIssuesBySummary(java.lang.String projectKey, java.lang.String summaryField) throws RedmineException
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
RedmineException
public java.util.List<Issue> getIssues(java.util.Map<java.lang.String,java.lang.String> pParameters) throws RedmineException
pParameters
- the http parameters key/value pairs to append to the rest api requestRedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
RedmineException
public Issue getIssueById(java.lang.Integer id, RedmineManager.INCLUDE... include) throws RedmineException
id
- the Redmine issue IDinclude
- list of "includes". e.g. "relations", "journals", ...RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
- the issue with the given id is not found on the serverRedmineException
public Project getProjectByKey(java.lang.String projectKey) throws RedmineException
projectKey
- string key like "project-ABC", NOT a database numeric IDRedmineAuthenticationException
- 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
public void deleteProject(java.lang.String projectKey) throws RedmineException
projectKey
- string key like "project-ABC", NOT a database numeric IDRedmineAuthenticationException
- 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
public void deleteIssue(java.lang.Integer id) throws RedmineException
RedmineException
public java.util.List<Issue> getIssues(java.lang.String projectKey, java.lang.Integer queryId, RedmineManager.INCLUDE... include) throws RedmineException
projectKey
- ignored if NULLqueryId
- id of the saved query in Redmine. the query must be accessible to the user
represented by the API access key (if the Redmine project requires authorization).
This parameter is optional, NULL can be provided to get all available issues.RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.RedmineException
Issue
public void update(Identifiable obj) throws RedmineException
RedmineException
public Project createProject(Project project) throws RedmineException
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);
project
- project to create on the serverRedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.RedmineException
public int getObjectsPerPage()
public void setObjectsPerPage(int pageSize)
public java.util.List<User> getUsers() throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
RedmineException
public User getUserById(java.lang.Integer userId) throws RedmineException
RedmineException
public User getCurrentUser() throws RedmineException
RedmineException
public User createUser(User user) throws RedmineException
RedmineException
public void deleteUser(java.lang.Integer userId) throws RedmineException
userId
- user identifier (numeric ID)RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
- if the user with the given id is not foundRedmineException
public java.util.List<Group> getGroups() throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
RedmineException
public Group getGroupById(int id) throws RedmineException
This operation requires "Redmine Administrators" permission.
id
- the id of the groupRedmineException
public Group getGroupByName(java.lang.String name) throws RedmineException
This operation requires "Redmine Administrators" permission.
name
- the name of the groupRedmineException
public Group createGroup(Group base) throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineException
public void deleteGroup(Group base) throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineException
public java.util.List<TimeEntry> getTimeEntries() throws RedmineException
RedmineException
public TimeEntry getTimeEntry(java.lang.Integer id) throws RedmineException
id
- the database Id of the TimeEntry recordRedmineException
public java.util.List<TimeEntry> getTimeEntriesForIssue(java.lang.Integer issueId) throws RedmineException
RedmineException
public TimeEntry createTimeEntry(TimeEntry obj) throws RedmineException
RedmineException
public void deleteTimeEntry(java.lang.Integer id) throws RedmineException
RedmineException
public java.util.List<SavedQuery> getSavedQueries(java.lang.String projectKey) throws RedmineException
This REST API feature was added in Redmine 1.3.0. See http://www.redmine.org/issues/5737
RedmineException
public java.util.List<SavedQuery> getSavedQueries() throws RedmineException
This REST API feature was added in Redmine 1.3.0. See http://www.redmine.org/issues/5737
RedmineException
public IssueRelation createRelation(java.lang.Integer issueId, java.lang.Integer issueToId, java.lang.String type) throws RedmineException
RedmineException
public void deleteRelation(java.lang.Integer id) throws RedmineException
RedmineException
public void deleteIssueRelations(Issue redmineIssue) throws RedmineException
RedmineException
public void deleteIssueRelationsByIssueId(java.lang.Integer id) throws RedmineException
id
- issue IDRedmineException
public java.util.List<IssueStatus> getStatuses() throws RedmineException
IssueStatus
es.IssueStatus
es.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 foundpublic Version createVersion(Version version) throws RedmineException
Version
for the Project
contained. Project
for the Version
must
not be null!version
- the Version
. Must contain a Project
.Version
created by Redminejava.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 foundpublic void deleteVersion(Version version) throws RedmineException
version
- the Version
.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 foundpublic java.util.List<Version> getVersions(int projectID) throws RedmineException
projectID
- the ID of the Project
Version
s of the 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 foundpublic Version getVersionById(int versionId) throws RedmineException
RedmineException
public java.util.List<IssueCategory> getCategories(int projectID) throws RedmineException
IssueCategory
s of a Project
projectID
- the ID of the Project
IssueCategory
s of the 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 foundpublic IssueCategory createCategory(IssueCategory category) throws RedmineException
IssueCategory
for the Project
contained. Project
for the IssueCategory
must
not be null!category
- the IssueCategory
. Must contain a Project
.IssueCategory
created by Redminejava.lang.IllegalArgumentException
- thrown in case the category 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 foundpublic void deleteCategory(IssueCategory category) throws RedmineException
IssueCategory
. category
- the IssueCategory
.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 foundpublic java.util.List<Tracker> getTrackers() throws RedmineException
Tracker
s availableRedmineAuthenticationException
- 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 foundpublic Attachment getAttachmentById(int attachmentID) throws RedmineException
Attachment
by its ID.attachmentID
- the IDAttachment
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 foundpublic void downloadAttachmentContent(Attachment issueAttachment, java.io.OutputStream stream) throws RedmineException
RedmineException
public byte[] downloadAttachmentContent(Attachment issueAttachment) throws RedmineException
Attachment
from the Redmine server.issueAttachment
- the Attachment
RedmineCommunicationException
- thrown in case the download failsRedmineException
public void setLogin(java.lang.String login)
public void setPassword(java.lang.String password)
public java.util.List<News> getNews(java.lang.String projectKey) throws RedmineException
projectKey
- ignored if NULLRedmineException
News
public void shutdown()
public Attachment uploadAttachment(java.lang.String fileName, java.lang.String contentType, java.io.InputStream content) throws RedmineException, java.io.IOException
fileName
- file name of the attachment.contentType
- content type of the attachment.content
- attachment content stream.RedmineException
- if something goes wrong.java.io.IOException
- if input cannot be read. This exception cannot be thrown yet
(I am not sure if http client can distinguish "network"
errors and local errors) but is will be good to distinguish
reading errors and transport errors.public Attachment uploadAttachment(java.lang.String fileName, java.lang.String contentType, byte[] content) throws RedmineException, java.io.IOException
fileName
- file name of the attachment.contentType
- content type of the attachment.content
- attachment content stream.RedmineException
- if something goes wrong.java.io.IOException
- if input cannot be read.public Attachment uploadAttachment(java.lang.String contentType, java.io.File content) throws RedmineException, java.io.IOException
contentType
- content type of the attachment.content
- attachment content stream.RedmineException
- if something goes wrong.java.io.IOException
- if input cannot be read.public java.util.List<Role> getRoles() throws RedmineException
RedmineException
public Role getRoleById(int id) throws RedmineException
RedmineException
public java.util.List<IssuePriority> getIssuePriorities() throws RedmineException
RedmineException
public java.util.List<TimeEntryActivity> getTimeEntryActivities() throws RedmineException
RedmineException
public java.util.List<Membership> getMemberships(java.lang.String project) throws RedmineException
RedmineException
public java.util.List<Membership> getMemberships(Project project) throws RedmineException
RedmineException
public void addMembership(Membership membership) throws RedmineException
membership
- membership.RedmineException
public Membership getMembership(int id) throws RedmineException
RedmineException
public void deleteMembership(int id) throws RedmineException
RedmineException
public void delete(Membership membership) throws RedmineException
RedmineException
public void addUserToGroup(User user, Group group) throws RedmineException
user
- - The user being added.group
- - The new group of the user.RedmineException
public void addWatcherToIssue(Watcher watcher, Issue issue) throws RedmineException
RedmineException
public void deleteWatcherFromIssue(Watcher watcher, Issue issue) throws RedmineException
RedmineException