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 projectName, java.lang.String versionName, Attachment attachement)
          Add a attachment for a given version of a given project.
 News addNews(java.lang.String projectName, News news)
          Add a news for a given project.
 Version addVersion(java.lang.String projectName, 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 projectName, java.lang.String versionName)
          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 projectName)
          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 projectName, java.lang.String versionName)
          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 projectName)
          Obtain all news defined on a given project.
 Project getProject(java.lang.String projectName)
          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 projectName)
          Obtain all trackers defined on a given project.
 User[] getUsers(java.lang.String projectName)
          Obtain all users defined on a given project.
 Version getVersion(java.lang.String projectName, java.lang.String versionName)
          Obtain a specific version for a given project.
 Version[] getVersions(java.lang.String projectName)
          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 projectName, java.lang.String oldVersionName, Version newVersion)
          Prepare a new version (create it or update it).
 Version updateVersion(java.lang.String projectName, 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 projectName,
                          Version version)
                   throws RedmineServiceException
Description copied from interface: RedmineService
Add a version for a given project.

Specified by:
addVersion in interface RedmineService
Parameters:
projectName - the name of the project
version - the version to add
Returns:
the added version
Throws:
RedmineServiceException - if any pb while sending and retriving datas to redmine server
See Also:
Version

addAttachment

public Attachment addAttachment(java.lang.String projectName,
                                java.lang.String versionName,
                                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:
projectName - the name of the project
versionName - the name of the version
attachement - the attachment to add
Returns:
the added attachment
Throws:
RedmineServiceException - if any pb while sending and retriving datas to redmine server
See Also:
Attachment

addNews

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

Specified by:
addNews in interface RedmineService
Parameters:
projectName - the name of the project
news - the news to add
Returns:
the added news.
Throws:
RedmineServiceException - if any pb while sending and retriving datas to redmine server
See Also:
News

updateVersion

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

Specified by:
updateVersion in interface RedmineService
Parameters:
projectName - the name of the project
version - the version to update
Returns:
the updated version
Throws:
RedmineServiceException - if any pb while sending and retriving datas to redmine server
See Also:
Version

nextVersion

public Version nextVersion(java.lang.String projectName,
                           java.lang.String oldVersionName,
                           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:
projectName - the name of the project
oldVersionName - the name of the old version (optional)
newVersion - the newVersion to create or update
Returns:
the created version
Throws:
RedmineServiceException - if any pb while sending and retriving datas to redmine server
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 - if any pb while retriving datas
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 - if any pb while retriving datas
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 while retriving datas
See Also:
Project

getIssueCategories

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

Specified by:
getIssueCategories in interface RedmineService
Parameters:
projectName - the name of the project
Returns:
the categories of issues for the given project.
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
IssueCategory

getProject

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

Specified by:
getProject in interface RedmineService
Parameters:
projectName - the name of the project
Returns:
the project
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
Project

getTrackers

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

Specified by:
getTrackers in interface RedmineService
Parameters:
projectName - the name of the project
Returns:
the trackers for the given project.
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
Tracker

getNews

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

Specified by:
getNews in interface RedmineService
Parameters:
projectName - the name of the project
Returns:
the news for the given project.
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
News

getUsers

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

Specified by:
getUsers in interface RedmineService
Parameters:
projectName - the name of the project
Returns:
the users for the given project.
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
User

getVersions

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

Specified by:
getVersions in interface RedmineService
Parameters:
projectName - the name of the project
Returns:
the versions of the given project.
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
Version

getVersion

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

Specified by:
getVersion in interface RedmineService
Parameters:
projectName - the name of the project
versionName - the name of the version
Returns:
the version
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
Version

getAttachments

public Attachment[] getAttachments(java.lang.String projectName,
                                   java.lang.String versionName)
                            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:
projectName - the name of the project
versionName - the name of the version
Returns:
the attachments
Throws:
RedmineServiceException - if any pb while retriving datas
See Also:
Attachment

getIssues

public Issue[] getIssues(java.lang.String projectName,
                         java.lang.String versionName)
                  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:
projectName - the name of the project
versionName - the name of the version
Returns:
the issues
Throws:
RedmineServiceException - if any pb while retriving datas
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.