org.nuiton.jredmine
Class DefaultRedmineService

java.lang.Object
  extended by org.nuiton.jredmine.DefaultRedmineService
All Implemented Interfaces:
RedmineService, RedmineServiceImplementor

public class DefaultRedmineService
extends java.lang.Object
implements RedmineService, RedmineServiceImplementor

Default RedmineService implementation base on a RestClient

Since:
1.0.0
Author:
chemit
Plexus component:
role:
"org.nuiton.jredmine.RedmineService"
role-hint:
"default"

Field Summary
protected  boolean init
          internal state to known if service was init
protected static org.apache.commons.logging.Log log
           
protected  org.nuiton.io.rest.RestClient session
          client Rest
protected  RedmineXpp3Helper xpp3Helper
          xpp3 xpp3Helper to transform xml stream to pojo
 
Fields inherited from interface org.nuiton.jredmine.RedmineService
ROLE
 
Constructor Summary
DefaultRedmineService()
           
 
Method Summary
 Attachment addAttachment(java.lang.String projectId, java.lang.String versionId, Attachment attachement)
          Add a attachment for a given version of a given project.
 News addNews(java.lang.String projectId, News news)
          Add a news for a given project.
 Version addVersion(java.lang.String projectId, Version version)
          Add a version for a given project.
protected  void checkInit()
           
 void destroy()
          Close the service and destroy any connexions to the redmine service.
 Attachment[] getAttachments(java.lang.String projectId, java.lang.String versionId)
          Obtain all attachments for a specific version on a given project
<T> T
getData(java.lang.Class<T> type, java.lang.Object... args)
          Generic method to obtain a single data from a redmine server.
protected
<T> T
getDataFromStream(java.lang.Class<T> type, java.io.InputStream stream)
           
<T> T[]
getDatas(java.lang.Class<T> type, java.lang.Object... args)
          Generic method to obtain a array of data from a redmine server.
protected
<T> T[]
getDatasFromStream(java.lang.Class<T> type, java.io.InputStream stream)
           
<T> java.io.InputStream
getDatasStream(java.lang.Class<T> type, java.lang.Object... args)
          Generic method to obtain an input stream of an array of data from a redmine server.
protected
<T> java.io.InputStream
getDataStream(java.lang.Class<T> type, boolean array, java.lang.Object... args)
           
<T> java.io.InputStream
getDataStream(java.lang.Class<T> type, java.lang.Object... args)
          Generic method to obtain an input stream of a data from a redmine server.
 IssueCategory[] getIssueCategories(java.lang.String projectId)
          Obtain all categories defined on issues for a given project.
 IssuePriority[] getIssuePriorities()
          Obtain all the priorities defined on a Issue.
 Issue[] getIssues(java.lang.String projectId, java.lang.String versionId)
          Obtain all issues for a specific version on a given project
 IssueStatus[] getIssueStatuses()
          Obtain all the statuses defined on a Issue.
 News[] getNews(java.lang.String projectId)
          Obtain all news defined on a given project.
 Project getProject(java.lang.String projectId)
          Obtain a project given his name.
 Project[] getProjects()
          Obtain all accessible projets for the loggued user.
protected  org.nuiton.io.rest.RestRequest getRequest(java.lang.String requestName, java.lang.Object... args)
           
 Tracker[] getTrackers(java.lang.String projectId)
          Obtain all trackers defined on a given project.
 User[] getUsers(java.lang.String projectId)
          Obtain all users defined on a given project.
 Version getVersion(java.lang.String projectId, java.lang.String versionId)
          Obtain a specific version for a given project.
 Version[] getVersions(java.lang.String projectId)
          Obtain all versions defined on a given project.
 RedmineServiceImplementor init(org.nuiton.io.rest.RestClient session)
          Initialize the service given a redmine client already initialized.
 RedmineServiceImplementor init(org.nuiton.io.rest.RestClientConfiguration configuration)
          Initialize the service given a client configuration.
 boolean isInit()
          Tests if the service is loogued to the redmine service.
 Version nextVersion(java.lang.String projectId, java.lang.String oldVersionId, Version newVersion)
          Prepare a new version (create it or update it).
 Version updateVersion(java.lang.String projectId, Version version)
          Update a version for a given project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log

session

protected org.nuiton.io.rest.RestClient session
client Rest

Plexus requirement:
role:
"org.nuiton.io.rest.RestClient"
role-hint:
"redmine"

xpp3Helper

protected final RedmineXpp3Helper xpp3Helper
xpp3 xpp3Helper to transform xml stream to pojo


init

protected boolean init
internal state to known if service was init

Constructor Detail

DefaultRedmineService

public DefaultRedmineService()
Method Detail

addVersion

public Version addVersion(java.lang.String projectId,
                          Version version)
                   throws RedmineServiceException
Description copied from interface: RedmineService
Add a version for a given project.

Specified by:
addVersion in interface RedmineService
Parameters:
projectId - the name of the project
version - the version to add
Returns:
the added version
Throws:
RedmineServiceException
See Also:
Version

addAttachment

public Attachment addAttachment(java.lang.String projectId,
                                java.lang.String versionId,
                                Attachment attachement)
                         throws RedmineServiceException
Description copied from interface: RedmineService
Add a attachment for a given version of a given project.

Specified by:
addAttachment in interface RedmineService
Parameters:
projectId - the name of the project
versionId - the name of the version
attachement - the attachment to add
Returns:
the added attachment
Throws:
RedmineServiceException
See Also:
Attachment

addNews

public News addNews(java.lang.String projectId,
                    News news)
             throws RedmineServiceException
Description copied from interface: RedmineService
Add a news for a given project.

Specified by:
addNews in interface RedmineService
Parameters:
projectId - the name of the project
news - the news to add
Returns:
the added news.
Throws:
RedmineServiceException
See Also:
News

updateVersion

public Version updateVersion(java.lang.String projectId,
                             Version version)
                      throws RedmineServiceException
Description copied from interface: RedmineService
Update a version for a given project.

Specified by:
updateVersion in interface RedmineService
Parameters:
projectId - the name of the project
version - the version to update
Returns:
the updated version
Throws:
RedmineServiceException
See Also:
Version

nextVersion

public Version nextVersion(java.lang.String projectId,
                           java.lang.String oldVersionId,
                           Version newVersion)
                    throws RedmineServiceException
Description copied from interface: RedmineService
Prepare a new version (create it or update it). If the oldVersionName is given, then all issues unclosed from this old version will be move to the new version.

Specified by:
nextVersion in interface RedmineService
Parameters:
projectId - the name of the project
oldVersionId - the name of the old version (optional)
newVersion - the newVersion to create or update
Returns:
the created version
Throws:
RedmineServiceException
See Also:
Version

getIssueStatuses

public IssueStatus[] getIssueStatuses()
                               throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all the statuses defined on a Issue. Note : The statuses are common for all projects.

Specified by:
getIssueStatuses in interface RedmineService
Returns:
all the issue statuses
Throws:
RedmineServiceException
See Also:
IssueStatus

getIssuePriorities

public IssuePriority[] getIssuePriorities()
                                   throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all the priorities defined on a Issue. Note : The priorities are common for all projects.

Specified by:
getIssuePriorities in interface RedmineService
Returns:
all the issue properties
Throws:
RedmineServiceException
See Also:
IssuePriority

getProjects

public Project[] getProjects()
                      throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all accessible projets for the loggued user.

Specified by:
getProjects in interface RedmineService
Returns:
all the projects
Throws:
RedmineServiceException - if any pb
See Also:
Project

getIssueCategories

public IssueCategory[] getIssueCategories(java.lang.String projectId)
                                   throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all categories defined on issues for a given project.

Specified by:
getIssueCategories in interface RedmineService
Parameters:
projectId - the name of the project
Returns:
the categories of issues for the given project.
Throws:
RedmineServiceException
See Also:
IssueCategory

getProject

public Project getProject(java.lang.String projectId)
                   throws RedmineServiceException
Description copied from interface: RedmineService
Obtain a project given his name.

Specified by:
getProject in interface RedmineService
Parameters:
projectId - the name of the project
Returns:
the project
Throws:
RedmineServiceException
See Also:
Project

getTrackers

public Tracker[] getTrackers(java.lang.String projectId)
                      throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all trackers defined on a given project.

Specified by:
getTrackers in interface RedmineService
Parameters:
projectId - the name of the project
Returns:
the trackers for the given project.
Throws:
RedmineServiceException
See Also:
Tracker

getNews

public News[] getNews(java.lang.String projectId)
               throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all news defined on a given project.

Specified by:
getNews in interface RedmineService
Parameters:
projectId - the name of the project
Returns:
the news for the given project.
Throws:
RedmineServiceException
See Also:
News

getUsers

public User[] getUsers(java.lang.String projectId)
                throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all users defined on a given project.

Specified by:
getUsers in interface RedmineService
Parameters:
projectId - the name of the project
Returns:
the users for the given project.
Throws:
RedmineServiceException
See Also:
User

getVersions

public Version[] getVersions(java.lang.String projectId)
                      throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all versions defined on a given project.

Specified by:
getVersions in interface RedmineService
Parameters:
projectId - the name of the project
Returns:
the versions of the given project.
Throws:
RedmineServiceException
See Also:
Version

getVersion

public Version getVersion(java.lang.String projectId,
                          java.lang.String versionId)
                   throws RedmineServiceException
Description copied from interface: RedmineService
Obtain a specific version for a given project.

Specified by:
getVersion in interface RedmineService
Parameters:
projectId - the name of the project
versionId - the name of the version
Returns:
the version
Throws:
RedmineServiceException
See Also:
Version

getAttachments

public Attachment[] getAttachments(java.lang.String projectId,
                                   java.lang.String versionId)
                            throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all attachments for a specific version on a given project

Specified by:
getAttachments in interface RedmineService
Parameters:
projectId - the name of the project
versionId - the name of the version
Returns:
the attachments
Throws:
RedmineServiceException
See Also:
Attachment

getIssues

public Issue[] getIssues(java.lang.String projectId,
                         java.lang.String versionId)
                  throws RedmineServiceException
Description copied from interface: RedmineService
Obtain all issues for a specific version on a given project

Specified by:
getIssues in interface RedmineService
Parameters:
projectId - the name of the project
versionId - the name of the version
Returns:
the issues
Throws:
RedmineServiceException
See Also:
Issue

isInit

public boolean isInit()
Description copied from interface: RedmineServiceImplementor
Tests if the service is loogued to the redmine service.

Specified by:
isInit in interface RedmineServiceImplementor
Returns:
true is service is init and loggued to Redmine service, false otherwise.

init

public RedmineServiceImplementor init(org.nuiton.io.rest.RestClientConfiguration configuration)
                               throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Initialize the service given a client configuration.

Specified by:
init in interface RedmineServiceImplementor
Parameters:
configuration - the configuration to be used to init the internal redmine client
Returns:
the initialized service
Throws:
RedmineServiceException

init

public RedmineServiceImplementor init(org.nuiton.io.rest.RestClient session)
                               throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Initialize the service given a redmine client already initialized.

Specified by:
init in interface RedmineServiceImplementor
Parameters:
session - the redmine client to be used by the service
Returns:
the initialized service
Throws:
RedmineServiceException
See Also:
RedmineRestClient

destroy

public void destroy()
             throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Close the service and destroy any connexions to the redmine service.

Specified by:
destroy in interface RedmineServiceImplementor
Throws:
RedmineServiceException

getData

public <T> T getData(java.lang.Class<T> type,
                     java.lang.Object... args)
          throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Generic method to obtain a single data from a redmine server.

Specified by:
getData in interface RedmineServiceImplementor
Type Parameters:
T - the type of data to obtain
Parameters:
type - the type of data to obtain
args - the parameters to obtain the data
Returns:
the obtained data
Throws:
RedmineServiceException

getDatas

public <T> T[] getDatas(java.lang.Class<T> type,
                        java.lang.Object... args)
             throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Generic method to obtain a array of data from a redmine server.

Specified by:
getDatas in interface RedmineServiceImplementor
Type Parameters:
T - the type of data to obtain
Parameters:
type - the type of data to obtain
args - the parameters to obtain the datas
Returns:
the obtained datas
Throws:
RedmineServiceException

getDataStream

public <T> java.io.InputStream getDataStream(java.lang.Class<T> type,
                                             java.lang.Object... args)
                                  throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Generic method to obtain an input stream of a data from a redmine server.

Specified by:
getDataStream in interface RedmineServiceImplementor
Type Parameters:
T - the type of data to obtain
Parameters:
type - the type of data to obtain
args - the parameters to obtain the data
Returns:
the input stream containing the data
Throws:
RedmineServiceException

getDatasStream

public <T> java.io.InputStream getDatasStream(java.lang.Class<T> type,
                                              java.lang.Object... args)
                                   throws RedmineServiceException
Description copied from interface: RedmineServiceImplementor
Generic method to obtain an input stream of an array of data from a redmine server.

Specified by:
getDatasStream in interface RedmineServiceImplementor
Type Parameters:
T - the type of data to obtain
Parameters:
type - the type of data to obtain
args - the parameters to obtain the datas
Returns:
the input stream containing the datas
Throws:
RedmineServiceException

getDataStream

protected <T> java.io.InputStream getDataStream(java.lang.Class<T> type,
                                                boolean array,
                                                java.lang.Object... args)
                                     throws RedmineServiceException
Throws:
RedmineServiceException

getRequest

protected org.nuiton.io.rest.RestRequest getRequest(java.lang.String requestName,
                                                    java.lang.Object... args)
                                             throws RedmineServiceException
Throws:
RedmineServiceException

getDataFromStream

protected <T> T getDataFromStream(java.lang.Class<T> type,
                                  java.io.InputStream stream)
                       throws RedmineServiceException
Throws:
RedmineServiceException

getDatasFromStream

protected <T> T[] getDatasFromStream(java.lang.Class<T> type,
                                     java.io.InputStream stream)
                          throws RedmineServiceException
Throws:
RedmineServiceException

checkInit

protected void checkInit()
                  throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException


Copyright © 2009 CodeLutin. All Rights Reserved.