|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.taskadapter.redmineapi.RedmineManager
public class RedmineManager
Entry point for the API: use this class to communicate with Redmine servers.
Nested Class Summary | |
---|---|
static class |
RedmineManager.INCLUDE
|
Constructor Summary | |
---|---|
RedmineManager(String uri)
|
|
RedmineManager(String uri,
RedmineOptions options)
|
|
RedmineManager(String host,
String apiAccessKey)
Creates an instance of RedmineManager class. |
|
RedmineManager(String host,
String apiAccessKey,
RedmineOptions options)
Creates an instance of RedmineManager class. |
|
RedmineManager(String uri,
String login,
String password)
|
|
RedmineManager(String uri,
String login,
String password,
RedmineOptions options)
|
Method Summary | |
---|---|
void |
addMembership(Membership membership)
Add a membership. |
IssueCategory |
createCategory(IssueCategory category)
creates a new IssueCategory for the Project contained. |
Issue |
createIssue(String projectKey,
Issue issue)
Sample usage: |
Project |
createProject(Project project)
Sample usage: |
IssueRelation |
createRelation(Integer issueId,
Integer issueToId,
String type)
|
TimeEntry |
createTimeEntry(TimeEntry obj)
|
User |
createUser(User user)
|
Version |
createVersion(Version version)
creates a new Version for the Project contained. |
void |
delete(Membership membership)
|
void |
deleteCategory(IssueCategory category)
deletes an IssueCategory . |
void |
deleteIssue(Integer id)
|
void |
deleteIssueRelations(Issue redmineIssue)
Delete all issue's relations |
void |
deleteIssueRelationsByIssueId(Integer id)
Delete relations for the given issue ID. |
void |
deleteMembership(int id)
|
void |
deleteProject(String projectKey)
|
void |
deleteRelation(Integer id)
Delete Issue Relation with the given ID. |
void |
deleteTimeEntry(Integer id)
|
void |
deleteUser(Integer userId)
|
void |
deleteVersion(Version version)
deletes a new Version from the Project contained. |
byte[] |
downloadAttachmentContent(Attachment issueAttachment)
Downloads the content of an Attachment from the Redmine server. |
void |
downloadAttachmentContent(Attachment issueAttachment,
OutputStream stream)
|
Attachment |
getAttachmentById(int attachmentID)
Delivers an Attachment by its ID. |
List<IssueCategory> |
getCategories(int projectID)
delivers a list of IssueCategory s of a Project |
User |
getCurrentUser()
|
Issue |
getIssueById(Integer id,
RedmineManager.INCLUDE... include)
|
List<Issue> |
getIssues(Map<String,String> pParameters)
Generic method to search for issues. |
List<Issue> |
getIssues(String projectKey,
Integer queryId,
RedmineManager.INCLUDE... include)
|
List<Issue> |
getIssuesBySummary(String projectKey,
String summaryField)
There could be several issues with the same summary, so the method returns List. |
Membership |
getMembership(int id)
|
List<Membership> |
getMemberships(Project project)
|
List<Membership> |
getMemberships(String project)
|
List<News> |
getNews(String projectKey)
|
int |
getObjectsPerPage()
This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request. |
Project |
getProjectByKey(String projectKey)
|
List<Project> |
getProjects()
Load the list of projects available to the user, which is represented by the API access key. |
List<Role> |
getRoles()
|
List<SavedQuery> |
getSavedQueries()
Get all "saved queries" available to the current user. |
List<SavedQuery> |
getSavedQueries(String projectKey)
Get "saved queries" for the given project available to the current user. |
List<IssueStatus> |
getStatuses()
Delivers a list of existing IssueStatus es. |
List<TimeEntry> |
getTimeEntries()
|
List<TimeEntry> |
getTimeEntriesForIssue(Integer issueId)
|
TimeEntry |
getTimeEntry(Integer id)
|
List<Tracker> |
getTrackers()
|
User |
getUserById(Integer userId)
|
List<User> |
getUsers()
Load the list of users on the server. |
Version |
getVersionById(int versionId)
|
List<Version> |
getVersions(int projectID)
delivers a list of Version s of a Project |
void |
setLogin(String login)
|
void |
setObjectsPerPage(int pageSize)
This number of objects (tasks, projects, users) will be requested from Redmine server in 1 request. |
void |
setPassword(String password)
|
void |
shutdown()
Shutdowns a communicator. |
void |
update(Identifiable obj)
|
Attachment |
uploadAttachment(String contentType,
File content)
Uploads an attachement. |
Attachment |
uploadAttachment(String fileName,
String contentType,
byte[] content)
Uploads an attachement. |
Attachment |
uploadAttachment(String fileName,
String contentType,
InputStream content)
Uploads an attachement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RedmineManager(String uri)
public RedmineManager(String uri, String login, String password)
public RedmineManager(String host, 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(String host, 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(String uri, RedmineOptions options)
public RedmineManager(String uri, String login, String password, RedmineOptions options)
Method Detail |
---|
public Issue createIssue(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 found
RedmineException
public 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 List<Issue> getIssuesBySummary(String projectKey, 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 List<Issue> getIssues(Map<String,String> pParameters) throws RedmineException
pParameters
- the http parameters key/value pairs to append to the rest api request
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.
NotFoundException
RedmineException
public Issue getIssueById(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 server
RedmineException
public Project getProjectByKey(String projectKey) throws RedmineException
projectKey
- string key like "project-ABC", NOT a database numeric ID
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 found
RedmineException
public void deleteProject(String projectKey) throws RedmineException
projectKey
- string key like "project-ABC", NOT a database numeric ID
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 found
RedmineException
public void deleteIssue(Integer id) throws RedmineException
RedmineException
public List<Issue> getIssues(String projectKey, 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 server
RedmineAuthenticationException
- 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 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(Integer userId) throws RedmineException
RedmineException
public User getCurrentUser() throws RedmineException
RedmineException
public User createUser(User user) throws RedmineException
RedmineException
public void deleteUser(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 found
RedmineException
public List<TimeEntry> getTimeEntries() throws RedmineException
RedmineException
public TimeEntry getTimeEntry(Integer id) throws RedmineException
id
- the database Id of the TimeEntry record
RedmineException
public List<TimeEntry> getTimeEntriesForIssue(Integer issueId) throws RedmineException
RedmineException
public TimeEntry createTimeEntry(TimeEntry obj) throws RedmineException
RedmineException
public void deleteTimeEntry(Integer id) throws RedmineException
RedmineException
public List<SavedQuery> getSavedQueries(String projectKey) throws RedmineException
This REST API feature was added in Redmine 1.3.0. See http://www.redmine.org/issues/5737
RedmineException
public 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(Integer issueId, Integer issueToId, String type) throws RedmineException
RedmineException
public void deleteRelation(Integer id) throws RedmineException
RedmineException
public void deleteIssueRelations(Issue redmineIssue) throws RedmineException
RedmineException
public void deleteIssueRelationsByIssueId(Integer id) throws RedmineException
id
- issue ID
RedmineException
public List<IssueStatus> getStatuses() throws RedmineException
IssueStatus
es.
IssueStatus
es.
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- 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 Redmine
IllegalArgumentException
- thrown in case the version does not contain a project.
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- thrown in case an object can not be foundpublic void deleteVersion(Version version) throws RedmineException
Version
from the Project
contained.
version
- the Version
.
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- thrown in case an object can not be foundpublic List<Version> getVersions(int projectID) throws RedmineException
Version
s of a Project
projectID
- the ID of the Project
Version
s of the Project
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- thrown in case an object can not be foundpublic Version getVersionById(int versionId) throws RedmineException
RedmineException
public 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 login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- 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 Redmine
IllegalArgumentException
- thrown in case the category does not contain a project.
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- 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 login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- thrown in case an object can not be foundpublic List<Tracker> getTrackers() throws RedmineException
Tracker
s available
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- thrown in case an object can not be foundpublic Attachment getAttachmentById(int attachmentID) throws RedmineException
Attachment
by its ID.
attachmentID
- the ID
Attachment
RedmineAuthenticationException
- thrown in case something went wrong while trying to login
RedmineException
- thrown in case something went wrong in Redmine
NotFoundException
- thrown in case an object can not be foundpublic void downloadAttachmentContent(Attachment issueAttachment, 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 fails
RedmineException
public void setLogin(String login)
public void setPassword(String password)
public List<News> getNews(String projectKey) throws RedmineException
projectKey
- ignored if NULL
RedmineException
News
public void shutdown()
public Attachment uploadAttachment(String fileName, String contentType, InputStream content) throws RedmineException, IOException
fileName
- file name of the attachement.contentType
- content type of the attachement.content
- attachement content stream.
RedmineException
- if something goes wrong.
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(String fileName, String contentType, byte[] content) throws RedmineException, IOException
fileName
- file name of the attachement.contentType
- content type of the attachement.content
- attachement content stream.
RedmineException
- if something goes wrong.
IOException
- if input cannot be read.public Attachment uploadAttachment(String contentType, File content) throws RedmineException, IOException
contentType
- content type of the attachement.content
- attachement content stream.
RedmineException
- if something goes wrong.
IOException
- if input cannot be read.public List<Role> getRoles() throws RedmineException
RedmineException
public List<Membership> getMemberships(String project) throws RedmineException
RedmineException
public 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |