r211 - in trunk/jredmine-client/src: main/java/org/nuiton/jredmine main/java/org/nuiton/jredmine/model main/java/org/nuiton/jredmine/model/io/xpp3 main/java/org/nuiton/jredmine/rest test/java/org/nuiton/jredmine test/java/org/nuiton/jredmine/model/io/xpp3 test/java/org/nuiton/jredmine/rest
Author: tchemit Date: 2011-06-04 19:01:31 +0200 (Sat, 04 Jun 2011) New Revision: 211 Url: http://nuiton.org/repositories/revision/jredmine/211 Log: improve code (reformat + javadoc + other code improvments) Anomalie #1568: Plexus is not well used Evolution #1557: Close the version on redmine project (using the status of a project's version) Anomalie #1558: Error 500 on next-version mojo Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineAnonymousService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineServiceImplementor.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Attachment.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/I18nAble.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAble.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueCategory.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssuePriority.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueStatus.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/News.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Project.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Tracker.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/DefaultRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/ProjectScopeRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/RedmineRestClient.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/VersionScopeRequestBuilder.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/AbstractRedmineServiceTest.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineAnonymousServiceTest.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceAsAnonymousTest.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/rest/RedmineRestClientTest.java Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineAnonymousService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineAnonymousService.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineAnonymousService.java 2011-06-04 17:01:31 UTC (rev 211) @@ -28,7 +28,17 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.io.rest.RestClient; import org.nuiton.io.rest.RestClientConfiguration; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; import org.nuiton.jredmine.rest.RedmineRestClient; /** @@ -38,29 +48,21 @@ * <p/> * Created: 2 janv. 2010 * - * @author chemit - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @plexus.component role="org.nuiton.jredmine.RedmineAnonymousService" role-hint="default" - * @see org.nuiton.io.rest.RestClientConfiguration#isAnonymous() + * @see RestClientConfiguration#isAnonymous() * @since 1.0.3 */ public class DefaultRedmineAnonymousService implements RedmineServiceImplementor, RedmineAnonymousService { - /** - * Logger - */ - private static final Log log = LogFactory.getLog(DefaultRedmineAnonymousService.class); - //FIXME Make this works again (there is a bad internal state somewhere...) -// /** -// * @plexus.requirement role="org.nuiton.jredmine.RedmineServiceImplementor" role-hint="default" -// */ + + /** Logger. */ + private static final Log log = + LogFactory.getLog(DefaultRedmineAnonymousService.class); + + /** @plexus.requirement role="org.nuiton.jredmine.RedmineServiceImplementor" role-hint="default" */ protected RedmineServiceImplementor delegateImplementor; public DefaultRedmineAnonymousService() { - delegateImplementor = new DefaultRedmineServiceImplementor(); } /////////////////////////////////////////////////////////////////////////// @@ -69,12 +71,16 @@ @Override public IssueStatus[] getIssueStatuses() throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_ISSUE_STATUS_LIST, IssueStatus.class); + return getDatas(RedmineRestClient.GET_ISSUE_STATUS_LIST, + IssueStatus.class + ); } @Override public IssuePriority[] getIssuePriorities() throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_ISSUE_PRIORITY_LIST, IssuePriority.class); + return getDatas(RedmineRestClient.GET_ISSUE_PRIORITY_LIST, + IssuePriority.class + ); } @Override @@ -84,74 +90,116 @@ @Override public IssueCategory[] getIssueCategories(String projectName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_ISSUE_CATEGORY_LIST, IssueCategory.class, projectName); + return getDatas(RedmineRestClient.GET_ISSUE_CATEGORY_LIST, + IssueCategory.class, + projectName + ); } @Override public Project getProject(String projectName) throws RedmineServiceException { - return getData(RedmineRestClient.GET_PROJECT, Project.class, projectName); + return getData(RedmineRestClient.GET_PROJECT, + Project.class, + projectName + ); } @Override public Tracker[] getTrackers(String projectName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_TRACKER_LIST, Tracker.class, projectName); + return getDatas(RedmineRestClient.GET_TRACKER_LIST, + Tracker.class, + projectName + ); } @Override public News[] getNews(String projectName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_NEWS_LIST, News.class, projectName); + return getDatas(RedmineRestClient.GET_NEWS_LIST, + News.class, + projectName + ); } @Override - public User[] getUsers(String projectName) throws RedmineServiceException { - return getProjectMembers(projectName); - } - - @Override public User[] getProjectMembers(String projectName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_USER_LIST, User.class, projectName); + return getDatas(RedmineRestClient.GET_USER_LIST, + User.class, + projectName + ); } @Override public Version[] getVersions(String projectName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_VERSION_LIST, Version.class, projectName); + return getDatas(RedmineRestClient.GET_VERSION_LIST, + Version.class, + projectName + ); } @Override - public Version getVersion(String projectName, String versionName) throws RedmineServiceException { - return getData(RedmineRestClient.GET_VERSION, Version.class, projectName, versionName); + public Version getVersion(String projectName, + String versionName) throws RedmineServiceException { + return getData(RedmineRestClient.GET_VERSION, + Version.class, + projectName, + versionName + ); } @Override - public Attachment[] getAttachments(String projectName, String versionName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_ATTACHMENTS_LIST, Attachment.class, projectName, versionName); + public Attachment[] getAttachments(String projectName, + String versionName) throws RedmineServiceException { + return getDatas(RedmineRestClient.GET_ATTACHMENTS_LIST, + Attachment.class, + projectName, + versionName + ); } @Override - public Issue[] getIssues(String projectName, String versionName) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_ISSUE_LIST, Issue.class, projectName, versionName); + public Issue[] getIssues(String projectName, + String versionName) throws RedmineServiceException { + return getDatas(RedmineRestClient.GET_ISSUE_LIST, + Issue.class, + projectName, + versionName + ); } @Override - public TimeEntry[] getIssueTimeEntries(String projectName, String issueId) throws RedmineServiceException { - return getDatas(RedmineRestClient.GET_ISSUE_TIME_ENTRY_LIST, TimeEntry.class, projectName, issueId); + public TimeEntry[] getIssueTimeEntries(String projectName, + String issueId) throws RedmineServiceException { + return getDatas(RedmineRestClient.GET_ISSUE_TIME_ENTRY_LIST, + TimeEntry.class, + projectName, + issueId + ); } @Override public Issue[] getIssues(String projectName) throws RedmineServiceException { - Issue[] result = getDatas(RedmineRestClient.GET_PROJECT_ISSUES, Issue.class, projectName); + Issue[] result = getDatas(RedmineRestClient.GET_PROJECT_ISSUES, + Issue.class, + projectName + ); return result; } @Override public Issue[] getOpenedIssues(String projectName) throws RedmineServiceException { - Issue[] result = getDatas(RedmineRestClient.GET_PROJECT_OPENED_ISSUES, Issue.class, projectName); + Issue[] result = getDatas(RedmineRestClient.GET_PROJECT_OPENED_ISSUES, + Issue.class, + projectName + ); return result; } @Override public Issue[] getClosedIssues(String projectName) throws RedmineServiceException { - Issue[] result = getDatas(RedmineRestClient.GET_PROJECT_CLOSED_ISSUES, Issue.class, projectName); + Issue[] result = getDatas(RedmineRestClient.GET_PROJECT_CLOSED_ISSUES, + Issue.class, + projectName + ); return result; } @@ -179,22 +227,30 @@ } @Override - public <T> T getData(String requestName, Class<T> type, Object... args) throws RedmineServiceException { + public <T> T getData(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { return delegateImplementor.getData(requestName, type, args); } @Override - public <T> T[] getDatas(String requestName, Class<T> type, Object... args) throws RedmineServiceException { + public <T> T[] getDatas(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { return delegateImplementor.getDatas(requestName, type, args); } @Override - public <T> T sendData(String requestName, Class<T> klazz, Object... args) throws RedmineServiceException { + public <T> T sendData(String requestName, + Class<T> klazz, + Object... args) throws RedmineServiceException { return delegateImplementor.sendData(requestName, klazz, args); } @Override - public <T> T[] sendDatas(String requestName, Class<T> klazz, Object... args) throws RedmineServiceException { + public <T> T[] sendDatas(String requestName, + Class<T> klazz, + Object... args) throws RedmineServiceException { return delegateImplementor.sendDatas(requestName, klazz, args); } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java 2011-06-04 17:01:31 UTC (rev 211) @@ -28,13 +28,17 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.io.rest.RestClient; import org.nuiton.io.rest.RestClientConfiguration; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Version; import org.nuiton.jredmine.rest.RedmineRestClient; /** * Default {@link RedmineService} implementation based on a {@link RestClient} * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @plexus.component role="org.nuiton.jredmine.RedmineService" role-hint="default" * @since 1.0.0 */ @@ -68,44 +72,84 @@ } @Override - public Version addVersion(String projectName, Version version) throws RedmineServiceException { + public Version addVersion(String projectName, + Version version) throws RedmineServiceException { + // send data and obtain created version - Version result = sendData(RedmineRestClient.ADD_VERSION, Version.class, projectName, version); + Version result = sendData(RedmineRestClient.ADD_VERSION, + Version.class, + projectName, + version + ); return result; } @Override - public Version updateVersion(String projectName, Version version) throws RedmineServiceException { + public Version updateVersion(String projectName, + Version version) throws RedmineServiceException { + // send data and obtain updated version - Version result = sendData(RedmineRestClient.UPDATE_VERSION, Version.class, projectName, version); + Version result = sendData(RedmineRestClient.UPDATE_VERSION, + Version.class, + projectName, + version + ); return result; } @Override - public Version nextVersion(String projectName, String oldVersionName, Version newVersion) throws RedmineServiceException { - // send data and obtain updated version - Version result = sendData(RedmineRestClient.NEXT_VERSION, Version.class, projectName, oldVersionName, newVersion); + public Version nextVersion(String projectName, + String oldVersionName, + Version newVersion) throws RedmineServiceException { + + // send data and obtain updated or created new version + Version result = sendData(RedmineRestClient.NEXT_VERSION, + Version.class, + projectName, + newVersion, + oldVersionName + ); return result; } @Override - public Attachment addAttachment(String projectName, String versionName, Attachment attachement) throws RedmineServiceException { + public Attachment addAttachment(String projectName, + String versionName, + Attachment attachement) throws RedmineServiceException { + // send data and obtain created attachment - Attachment result = sendData(RedmineRestClient.ADD_ATTACHMENT, Attachment.class, projectName, versionName, attachement); + Attachment result = sendData(RedmineRestClient.ADD_ATTACHMENT, + Attachment.class, + projectName, + versionName, + attachement + ); return result; } @Override - public News addNews(String projectName, News news) throws RedmineServiceException { + public News addNews(String projectName, + News news) throws RedmineServiceException { // send data and obtain created news - News result = sendData(RedmineRestClient.ADD_NEWS, News.class, projectName, news); + News result = sendData(RedmineRestClient.ADD_NEWS, + News.class, + projectName, + news + ); return result; } @Override - public TimeEntry addIssueTimeEntry(String projectName, String issueId, TimeEntry entry) throws RedmineServiceException { + public TimeEntry addIssueTimeEntry(String projectName, + String issueId, + TimeEntry entry) throws RedmineServiceException { // send data and obtain updated version - TimeEntry result = sendData(RedmineRestClient.ADD_ISSUE_TIME_ENTRY, TimeEntry.class, projectName, issueId, entry); + TimeEntry result = sendData(RedmineRestClient.ADD_ISSUE_TIME_ENTRY, + TimeEntry.class, + projectName, + issueId, + entry + ); return result; } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineServiceImplementor.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineServiceImplementor.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineServiceImplementor.java 2011-06-04 17:01:31 UTC (rev 211) @@ -26,7 +26,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.nuiton.io.rest.RestClient; import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.io.rest.RestException; @@ -34,39 +33,35 @@ import org.nuiton.jredmine.model.io.xpp3.RedmineXpp3Helper; import org.nuiton.jredmine.rest.RedmineRestClient; -import java.io.IOException; import java.io.InputStream; /** + * Default Redmine technical service implementation. + * <p/> * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @plexus.component role="org.nuiton.jredmine.RedmineServiceImplementor" role-hint="default" + * @see RedmineServiceImplementor * @since 1.0.3 */ public class DefaultRedmineServiceImplementor implements RedmineServiceImplementor { + + /** Logger */ + private static final Log log = + LogFactory.getLog(DefaultRedmineServiceImplementor.class); + /** - * Logger + * Client Rest. + * + * @plexus.requirement role="org.nuiton.io.rest.RestClient" role-hint="redmine" */ - private static final Log log = LogFactory.getLog(DefaultRedmineServiceImplementor.class); - //FIXME Make this works again (there is a bad internal state somewhere...) -// /** -// * client Rest -// * -// * @plexus.requirement role="org.nuiton.io.rest.RestClient" role-hint="redmine" -// */ protected RestClient session; - /** - * xpp3 xpp3Helper to transform xml stream to pojo - */ + + /** xpp3 xpp3Helper to transform xml stream to pojo */ protected final RedmineXpp3Helper xpp3Helper; - /** - * internal state to known if service was init - */ + + /** internal state to known if service was init */ protected boolean init; public DefaultRedmineServiceImplementor() { @@ -96,7 +91,8 @@ @Override public RedmineServiceImplementor init(RestClient session) throws RedmineServiceException { if (init) { - throw new IllegalStateException("the client " + this + " was already init!"); + throw new IllegalStateException( + "the client " + this + " was already init!"); } try { this.session = session; @@ -107,7 +103,8 @@ init = true; } catch (Exception e) { - throw new RedmineServiceException("could not init service for reason " + e.getMessage(), e); + throw new RedmineServiceException( + "could not init service for reason " + e.getMessage(), e); } return this; } @@ -120,7 +117,9 @@ try { session.close(); } catch (RestException ex) { - throw new RedmineServiceException("has problem while closing Rest client " + ex.getMessage(), ex); + throw new RedmineServiceException( + "has problem while closing Rest client " + + ex.getMessage(), ex); } } } finally { @@ -133,7 +132,9 @@ } @Override - public <T> T getData(String requestName, Class<T> type, Object... args) throws RedmineServiceException { + public <T> T getData(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { checkInit(); InputStream stream = askDataStream(requestName, args); T result = getDataFromStream(type, stream); @@ -141,7 +142,9 @@ } @Override - public <T> T[] getDatas(String requestName, Class<T> type, Object... args) throws RedmineServiceException { + public <T> T[] getDatas(String requestName, + Class<T> type, + Object... args) throws RedmineServiceException { checkInit(); InputStream stream = askDataStream(requestName, args); T[] result = getDatasFromStream(type, stream); @@ -149,7 +152,9 @@ } @Override - public <T> T sendData(String requestName, Class<T> klazz, Object... args) throws RedmineServiceException { + public <T> T sendData(String requestName, + Class<T> klazz, + Object... args) throws RedmineServiceException { checkLoggued(); InputStream stream = sendDataStream(requestName, args); T result = getDataFromStream(klazz, stream); @@ -157,7 +162,9 @@ } @Override - public <T> T[] sendDatas(String requestName, Class<T> klazz, Object... args) throws RedmineServiceException { + public <T> T[] sendDatas(String requestName, + Class<T> klazz, + Object... args) throws RedmineServiceException { checkLoggued(); InputStream stream = sendDataStream(requestName, args); T[] result = getDatasFromStream(klazz, stream); @@ -170,7 +177,8 @@ checkSessionNotNull(session); checkSessionConfigurationNotNull(session); if (session.getConfiguration().isAnonymous()) { - throw new RedmineServiceLoginException("can not access this service in anonymous mode"); + throw new RedmineServiceLoginException( + "can not access this service in anonymous mode"); } } @@ -180,11 +188,13 @@ checkSessionNotNull(session); checkSessionConfigurationNotNull(session); if (!session.getConfiguration().isAnonymous()) { - throw new RedmineServiceLoginException("session must be anonymous in this service"); + throw new RedmineServiceLoginException( + "session must be anonymous in this service"); } } - protected InputStream askDataStream(String requestName, Object... args) throws RedmineServiceException { + protected InputStream askDataStream(String requestName, + Object... args) throws RedmineServiceException { RestRequest r = getRequest(requestName, args); @@ -194,11 +204,14 @@ InputStream stream = session.askData(r); return stream; } catch (Exception e) { - throw new RedmineServiceException("could not obtain data stream for request " + requestName + " for reason " + e.getMessage(), e); + throw new RedmineServiceException( + "could not obtain data stream for request " + requestName + + " for reason " + e.getMessage(), e); } } - protected InputStream sendDataStream(String requestName, Object... args) throws RedmineServiceException { + protected InputStream sendDataStream(String requestName, + Object... args) throws RedmineServiceException { RestRequest r = getRequest(requestName, args); @@ -208,24 +221,31 @@ InputStream stream = session.sendData(r); return stream; } catch (Exception e) { - throw new RedmineServiceException("could not send data stream for request " + requestName + " for reason " + e.getMessage(), e); + throw new RedmineServiceException( + "could not send data stream for request " + requestName + + " for reason " + e.getMessage(), e); } } - protected RestRequest getRequest(String requestName, Object... args) throws RedmineServiceException { + protected RestRequest getRequest(String requestName, + Object... args) throws RedmineServiceException { RestRequest r; try { r = session.getRequest(requestName, args); } catch (Exception e) { - throw new RedmineServiceException("could not find the request named " + requestName + " for reason " + e.getMessage(), e); + throw new RedmineServiceException( + "could not find the request named " + requestName + + " for reason " + e.getMessage(), e); } if (r == null) { - throw new RedmineServiceException("could not find the request named " + requestName); + throw new RedmineServiceException( + "could not find the request named " + requestName); } return r; } - protected <T> T getDataFromStream(Class<T> type, InputStream stream) throws RedmineServiceException { + protected <T> T getDataFromStream(Class<T> type, + InputStream stream) throws RedmineServiceException { if (stream == null) { return null; } @@ -233,30 +253,32 @@ try { T result = xpp3Helper.readObject(type, stream, true); return result; - } catch (IOException ex) { - throw new RedmineServiceException("could not obtain datas of type " + type + " for reason " + ex.getMessage(), ex); - } catch (XmlPullParserException ex) { - throw new RedmineServiceException("could not obtain datas of type " + type + " for reason " + ex.getMessage(), ex); + } catch (Exception ex) { + throw new RedmineServiceException( + "could not obtain datas of type " + type + " for reason " + + ex.getMessage(), ex); } } - protected <T> T[] getDatasFromStream(Class<T> type, InputStream stream) throws RedmineServiceException { + protected <T> T[] getDatasFromStream(Class<T> type, + InputStream stream) throws RedmineServiceException { if (stream == null) { return null; } try { T[] result = xpp3Helper.readObjects(type, stream, true); return result; - } catch (IOException ex) { - throw new RedmineServiceException("could not obtain datas of type " + type + " for reason " + ex.getMessage(), ex); - } catch (XmlPullParserException ex) { - throw new RedmineServiceException("could not obtain datas of type " + type + " for reason " + ex.getMessage(), ex); + } catch (Exception ex) { + throw new RedmineServiceException( + "could not obtain datas of type " + type + " for reason " + + ex.getMessage(), ex); } } protected void checkInit() throws IllegalStateException { if (!init) { - throw new IllegalStateException("the client " + this + " is not init!"); + throw new IllegalStateException( + "the client " + this + " is not init!"); } } @@ -268,7 +290,8 @@ protected void checkSessionConfigurationNotNull(RestClient session) { if (session.getConfiguration() == null) { - throw new NullPointerException("session configuration can not be null"); + throw new NullPointerException( + "session configuration can not be null"); } } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,28 +24,33 @@ */ package org.nuiton.jredmine; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; /** * Contract of all redmine operations which do not requires any login to server. * <p/> - * A default implementation is offered in - * {@link DefaultRedmineAnonymousService}. + * A default implementation is {@link DefaultRedmineAnonymousService}. * <p/> * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @see DefaultRedmineAnonymousService * @since 1.0.3 */ public interface RedmineAnonymousService { /** - * Obtain all accessible projets. + * Obtain all accessible projects. * * @return all the projects * @throws RedmineServiceException if any pb while retriving datas @@ -122,19 +127,7 @@ * @return the users for the given project. * @throws RedmineServiceException if any pb while retriving datas * @see User - * @deprecated since 1.0.3, use now {@link #getProjectMembers(String)}. */ - @Deprecated - User[] getUsers(String projectName) throws RedmineServiceException; - - /** - * Obtain all users defined on a given project. - * - * @param projectName the name of the project - * @return the users for the given project. - * @throws RedmineServiceException if any pb while retriving datas - * @see User - */ User[] getProjectMembers(String projectName) throws RedmineServiceException; /** @@ -156,10 +149,11 @@ * @throws RedmineServiceException if any pb while retriving datas * @see Version */ - Version getVersion(String projectName, String versionName) throws RedmineServiceException; + Version getVersion(String projectName, + String versionName) throws RedmineServiceException; /** - * Obtain all issues for a given project + * Obtain all issues for a given project. * * @param projectName the name of the project * @return the issues @@ -170,7 +164,7 @@ Issue[] getIssues(String projectName) throws RedmineServiceException; /** - * Obtain all opened issues for a given project + * Obtain all opened issues for a given project. * * @param projectName the name of the project * @return the issues @@ -181,7 +175,7 @@ Issue[] getOpenedIssues(String projectName) throws RedmineServiceException; /** - * Obtain all closed issues for a given project + * Obtain all closed issues for a given project. * * @param projectName the name of the project * @return the issues @@ -192,7 +186,7 @@ Issue[] getClosedIssues(String projectName) throws RedmineServiceException; /** - * Obtain all issues for a specific version on a given project + * Obtain all issues for a specific version on a given project. * * @param projectName the name of the project * @param versionName the name of the version @@ -200,7 +194,8 @@ * @throws RedmineServiceException if any pb while retriving datas * @see Issue */ - Issue[] getIssues(String projectName, String versionName) throws RedmineServiceException; + Issue[] getIssues(String projectName, + String versionName) throws RedmineServiceException; /** * Obtain for a given issue of a given project all the time entries. @@ -211,10 +206,11 @@ * @throws RedmineServiceException if any pb while retrieving time entries of the issue * @since 1.0.3 */ - TimeEntry[] getIssueTimeEntries(String projectName, String issueId) throws RedmineServiceException; + TimeEntry[] getIssueTimeEntries(String projectName, + String issueId) throws RedmineServiceException; /** - * Obtain all attachments for a specific version on a given project + * Obtain all attachments for a specific version on a given project. * * @param projectName the name of the project * @param versionName the name of the version @@ -222,5 +218,6 @@ * @throws RedmineServiceException if any pb while retriving datas * @see Attachment */ - Attachment[] getAttachments(String projectName, String versionName) throws RedmineServiceException; + Attachment[] getAttachments(String projectName, + String versionName) throws RedmineServiceException; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,22 +24,22 @@ */ package org.nuiton.jredmine; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Version; /** * Contract of all redmine operations that needs a login to be performed. * <p/> - * A default implementation is offered in - * {@link org.nuiton.jredmine.DefaultRedmineService}. + * A default implementation is offered in {@link DefaultRedmineService}. * <p/> * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @see RedmineAnonymousService * @see RedmineService * @since 1.0.3 @@ -53,7 +53,7 @@ * * @return all the projects belonged by the loggued user * @throws RedmineServiceException if any pb while retriving datas - * @see org.nuiton.jredmine.model.Project + * @see Project * @since 1.0.3 */ Project[] getUserProjects() throws RedmineServiceException; @@ -66,10 +66,12 @@ * @param projectName the name of the project * @param version the version to add * @return the added version - * @throws RedmineServiceException if any pb while sending and retriving datas to redmine server + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server * @see Version */ - Version addVersion(String projectName, Version version) throws RedmineServiceException; + Version addVersion(String projectName, + Version version) throws RedmineServiceException; /** * Update a version for a given project. @@ -79,10 +81,12 @@ * @param projectName the name of the project * @param version the version to update * @return the updated version - * @throws RedmineServiceException if any pb while sending and retriving datas to redmine server + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server * @see Version */ - Version updateVersion(String projectName, Version version) throws RedmineServiceException; + Version updateVersion(String projectName, + Version version) throws RedmineServiceException; /** * Prepare a new version (create it or update it). @@ -96,10 +100,13 @@ * @param oldVersionName the name of the old version (optional) * @param newVersion the newVersion to create or update * @return the created version - * @throws RedmineServiceException if any pb while sending and retriving datas to redmine server + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server * @see Version */ - Version nextVersion(String projectName, String oldVersionName, Version newVersion) throws RedmineServiceException; + Version nextVersion(String projectName, + String oldVersionName, + Version newVersion) throws RedmineServiceException; /** * Add a news for a given project. @@ -109,7 +116,8 @@ * @param projectName the name of the project * @param news the news to add * @return the added news. - * @throws RedmineServiceException if any pb while sending and retriving datas to redmine server + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server * @see News */ News addNews(String projectName, News news) throws RedmineServiceException; @@ -123,10 +131,13 @@ * @param versionName the name of the version * @param attachement the attachment to add * @return the added attachment - * @throws RedmineServiceException if any pb while sending and retriving datas to redmine server + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server * @see Attachment */ - Attachment addAttachment(String projectName, String versionName, Attachment attachement) throws RedmineServiceException; + Attachment addAttachment(String projectName, + String versionName, + Attachment attachement) throws RedmineServiceException; /** * Add a new time entry to the given issue for the given project and @@ -138,10 +149,13 @@ * @param issueId the id of the issue to update * @param entry time entry to add * @return the created time entry - * @throws RedmineServiceException if any pb while sending or retrieving datas to redmine server + * @throws RedmineServiceException if any pb while sending or retrieving + * datas to redmine server * @see Issue * @see TimeEntry * @since 1.0.3 */ - TimeEntry addIssueTimeEntry(String projectName, String issueId, TimeEntry entry) throws RedmineServiceException; + TimeEntry addIssueTimeEntry(String projectName, + String issueId, + TimeEntry entry) throws RedmineServiceException; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java 2011-06-04 17:01:31 UTC (rev 211) @@ -30,15 +30,13 @@ * <b>Note:</b> A default implementation is offered : * {@link DefaultRedmineService} * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @see DefaultRedmineService * @since 1.0.0 */ public interface RedmineService extends RedmineAnonymousService, RedmineLogguedService { - /** - * Plexus lookup name - */ + /** Plexus lookup name. */ String ROLE = RedmineService.class.getName(); } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java 2011-06-04 17:01:31 UTC (rev 211) @@ -26,8 +26,8 @@ /** * An exception to throw when something is wrong in a {@link RedmineService}. - * - * @author chemit + * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class RedmineServiceException extends Exception { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2011-06-04 17:01:31 UTC (rev 211) @@ -30,14 +30,14 @@ /** * Technical contract to implements a redmine service which wrap the - * {@link org.nuiton.jredmine.rest.RedmineRestClient}. + * {@link RedmineRestClient}. * <p/> - * A default implementation is offered in {@link org.nuiton.jredmine.DefaultRedmineServiceImplementor}. + * A default implementation is offered in {@link DefaultRedmineServiceImplementor}. * <p/> * Any concrete implentation of a redmine service should implements this.. * - * @author chemit - * @see org.nuiton.jredmine.DefaultRedmineServiceImplementor + * @author tchemit <chemit@codelutin.com> + * @see DefaultRedmineServiceImplementor * @since 1.0.0 */ public interface RedmineServiceImplementor { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java 2011-06-04 17:01:31 UTC (rev 211) @@ -26,15 +26,11 @@ /** * An exception to be thrown when a problem with authentication state in a - * {@link org.nuiton.jredmine.RedmineService}. + * {@link RedmineService}. * <p/> * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @since 1.0.3 */ public class RedmineServiceLoginException extends RedmineServiceException { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Attachment.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Attachment.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Attachment.java 2011-06-04 17:01:31 UTC (rev 211) @@ -30,26 +30,36 @@ /** * A file attachment from redmine server. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class Attachment implements IdAble { protected int id; + protected int authorId; + protected int containerId; + protected int filesize; + protected int downloads; + protected Date createdOn; + protected String containerType; + protected String contentType; + protected String description; + protected String digest; + protected String diskFilename; + protected String filename; - /** - * not from redmine but to redmine (file to attach) - */ + + /** not from redmine but to redmine (file to attach) */ protected File toUpload; public int getAuthorId() { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/I18nAble.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/I18nAble.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/I18nAble.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,7 +27,7 @@ /** * Alls object offers an name. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public interface I18nAble { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAble.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAble.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAble.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,7 +27,7 @@ /** * Alls object offers an id. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public interface IdAble { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java 2011-06-04 17:01:31 UTC (rev 211) @@ -29,32 +29,53 @@ /** * An issue on redmine's server. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class Issue implements IdAble, I18nAble { +public class Issue implements IdAble, I18nAble { protected int assignedToId; + protected int authorId; + protected int categoryId; + protected int doneRatio; + protected int lockVersion; + protected int priorityId; + protected int projectId; + protected int statusId; + protected int trackerId; + protected int fixedVersionId; + protected int id; + protected int parentId; + protected int rootId; + protected int lft; + protected int rgt; + protected float estimatedHours; + protected Date createdOn; + protected Date updatedOn; + protected Date dueDate; + protected Date startDate; + protected String description; + protected String subject; @Override @@ -66,7 +87,7 @@ public String getName() { return getSubject(); } - + public int getAssignedToId() { return assignedToId; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueCategory.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueCategory.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueCategory.java 2011-06-04 17:01:31 UTC (rev 211) @@ -25,15 +25,17 @@ package org.nuiton.jredmine.model; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class IssueCategory implements IdAble, I18nAble { protected int projectId; + protected int assignedToId; + protected int id; + protected String name; public int getAssignedToId() { @@ -54,8 +56,8 @@ return projectId; } - public void setAssignedToId(int assigneToId) { - this.assignedToId = assigneToId; + public void setAssignedToId(int assignedToId) { + this.assignedToId = assignedToId; } public void setId(int id) { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssuePriority.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssuePriority.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssuePriority.java 2011-06-04 17:01:31 UTC (rev 211) @@ -25,19 +25,25 @@ package org.nuiton.jredmine.model; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class IssuePriority implements IdAble,I18nAble{ +public class IssuePriority implements IdAble, I18nAble { protected int id; + protected int parentId; + protected int projectId; + protected boolean isDefault; + protected boolean active; + protected String name; + protected String opt; + protected int position; @Override Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueStatus.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueStatus.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IssueStatus.java 2011-06-04 17:01:31 UTC (rev 211) @@ -25,17 +25,21 @@ package org.nuiton.jredmine.model; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class IssueStatus implements IdAble, I18nAble { protected int id; + protected int position; + protected int defaultDoneRatio; + protected boolean isClosed; + protected boolean isDefault; + protected String name; @Override Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2011-06-04 17:01:31 UTC (rev 211) @@ -32,8 +32,8 @@ /** * Some usefull methods on redmine's entities, mainly to filter datas. - * - * @author chemit + * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class ModelHelper { @@ -97,11 +97,11 @@ return filter.toArray((T[]) Array.newInstance(type, filter.size())); } - public static final Comparator<IdAble> ID_ABLE_COMPARATOR = new Comparator<IdAble>(){ + public static final Comparator<IdAble> ID_ABLE_COMPARATOR = new Comparator<IdAble>() { @Override public int compare(IdAble o1, IdAble o2) { - return o1.getId()-o2.getId(); + return o1.getId() - o2.getId(); } - } ; + }; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/News.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/News.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/News.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,19 +27,25 @@ import java.util.Date; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class News implements IdAble, I18nAble { protected int id; + protected int projectId; + protected int authorId; + protected int commentsCount; + protected String description; + protected String title; + protected String summary; + protected Date createdOn; @Override Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Project.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Project.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Project.java 2011-06-04 17:01:31 UTC (rev 211) @@ -28,24 +28,36 @@ /** * redmine project - * - * @author chemit + * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class Project implements IdAble, I18nAble { protected Date createdOn; + protected Date updatedOn; + protected String description; + protected String homepage; + protected String identifier; + protected String name; + protected int id; + protected int lft; + protected int rgt; + protected int parentId; + protected int projectsCount; + protected int status; + protected boolean isPublic; public Date getCreatedOn() { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java 2011-06-04 17:01:31 UTC (rev 211) @@ -29,7 +29,7 @@ /** * Un énumération pour connaitre l'ensemble des classes du modèle. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public enum RedmineModelEnum { @@ -47,10 +47,12 @@ attachment(Attachment.class, RedmineModelScope.version, RedmineRestClient.GET_ATTACHMENTS_LIST); private final Class<?> modelType; + private final RedmineModelScope scope; + private final String requestAll; - private RedmineModelEnum(Class<?> modelType, RedmineModelScope scope, String requestAll) { + RedmineModelEnum(Class<?> modelType, RedmineModelScope scope, String requestAll) { this.modelType = modelType; this.scope = scope; this.requestAll = requestAll; @@ -71,7 +73,7 @@ public static RedmineModelEnum valueOf(Class<?> type) { for (RedmineModelEnum e : values()) { - if (type == e.getModelType()) { + if (e.getModelType().equals(type)) { return e; } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java 2011-06-04 17:01:31 UTC (rev 211) @@ -40,25 +40,17 @@ * elle est aussi de scope {@link #project} car la version (resp. l'issue) * dépend en dépend. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public enum RedmineModelScope { - /** - * none scope, requires nothing - */ + /** none scope, requires nothing. */ none, - /** - * project scope, requires a project - */ + /** project scope, requires a project. */ project, - /** - * version scope, requires a project and a version - */ + /** version scope, requires a project and a version. */ version, - /** - * issue scope, requires a project and an issue - */ - issue; + /** issue scope, requires a project and an issue. */ + issue } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java 2011-06-04 17:01:31 UTC (rev 211) @@ -29,28 +29,33 @@ /** * Created: 31 déc. 2009 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @since 1.0.3 */ public class TimeEntry implements IdAble { protected int id; + protected int activityId; + protected int issueId; + protected int projectId; + protected int userId; protected int tyear; + protected int tmonth; + protected int tweek; + protected float hours; protected Date spentOn; + protected Date createdOn; + protected Date updatedOn; protected String comments; Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Tracker.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Tracker.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Tracker.java 2011-06-04 17:01:31 UTC (rev 211) @@ -25,18 +25,23 @@ package org.nuiton.jredmine.model; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class Tracker implements IdAble, I18nAble { protected int id; + protected int projectId; + protected int trackerId; + protected int position; + protected boolean isInChlog; + protected boolean isInRoadmap; + protected String name; @Override Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,29 +27,43 @@ import java.util.Date; /** - * - * @author chemit - * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class User implements IdAble, I18nAble { protected boolean admin; + protected boolean mailNotification; + protected int id; + protected int authSourceId; + protected int memberId; + protected int roleId; + protected int status; + protected Date createdOn; + protected Date updatedOn; + protected Date lastLoginOn; + protected String firstname; + protected String lastname; + protected String login; + protected String language; + protected String mail; + protected String hashedPassword; + protected String identityUrl; public boolean isAdmin() { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,21 +27,29 @@ import java.util.Date; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class Version implements IdAble, I18nAble { protected Date createdOn; + protected Date updatedOn; + protected Date effectiveDate; + protected String name; + protected String description; + protected String wikiPageTitle; + protected String sharing; + protected String status; + protected int id; + protected int projectId; public Date getCreatedOn() { Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java (rev 0) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java 2011-06-04 17:01:31 UTC (rev 211) @@ -0,0 +1,13 @@ +package org.nuiton.jredmine.model; + +/** + * Possible values of a version status. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.1 + */ +public enum VersionStatusEnum { + open, + locked, + closed +} Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,15 +24,17 @@ */ package org.nuiton.jredmine.model.io.xpp3; -import java.beans.IntrospectionException; import org.nuiton.io.xpp3.AbstractXpp3Reader; import org.nuiton.jredmine.model.Attachment; + +import java.beans.IntrospectionException; + import static org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers; /** * {@link Attachment} reader. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class AttachmentXpp3Reader extends AbstractXpp3Reader<Attachment> { @@ -45,21 +47,21 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(Attachment.class, RedmineDataConverter.Integer, true, allMappers, - "author-id", - "container-id", - "filesize", - "downloads", - "id"); + "author-id", + "container-id", + "filesize", + "downloads", + "id"); addTagTextContentMappers(Attachment.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on"); + "created-on"); addTagTextContentMappers(Attachment.class, RedmineDataConverter.Text, true, allMappers, - "container-type", - "content-type", - "description", - "digest", - "disk-filename", - "filename"); + "container-type", + "content-type", + "description", + "digest", + "disk-filename", + "filename"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,16 +24,18 @@ */ package org.nuiton.jredmine.model.io.xpp3; -import java.beans.IntrospectionException; import org.nuiton.io.xpp3.AbstractXpp3Reader; import org.nuiton.jredmine.model.Issue; import org.nuiton.jredmine.model.IssueCategory; + +import java.beans.IntrospectionException; + import static org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers; /** * {@link Issue} reader. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class IssueCategoryXpp3Reader extends AbstractXpp3Reader<IssueCategory> { @@ -46,11 +48,11 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(IssueCategory.class, RedmineDataConverter.Integer, true, allMappers, - "project-id", - "assigned-to-id", - "id"); + "project-id", + "assigned-to-id", + "id"); addTagTextContentMappers(IssueCategory.class, RedmineDataConverter.Text, true, allMappers, - "name"); + "name"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -35,7 +35,7 @@ /** * {@link Issue} reader. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class IssuePriorityXpp3Reader extends AbstractXpp3Reader<IssuePriority> { @@ -49,17 +49,17 @@ addTagTextContentMappers(IssuePriority.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "parent-id", - "project-id", - "position"); + "id", + "parent-id", + "project-id", + "position"); addTagTextContentMappers(IssuePriority.class, RedmineDataConverter.Boolean, true, allMappers, - "is-default", - "active"); + "is-default", + "active"); addTagTextContentMappers(IssuePriority.class, RedmineDataConverter.Text, true, allMappers, - "name", - "opt"); + "name", + "opt"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -35,7 +35,7 @@ /** * {@link Issue} reader. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class IssueStatusXpp3Reader extends AbstractXpp3Reader<IssueStatus> { @@ -48,15 +48,15 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(IssueStatus.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "position", - "default-done-ratio"); + "id", + "position", + "default-done-ratio"); addTagTextContentMappers(IssueStatus.class, RedmineDataConverter.Boolean, true, allMappers, - "is-closed", - "is-default"); + "is-closed", + "is-default"); addTagTextContentMappers(IssueStatus.class, RedmineDataConverter.Text, true, allMappers, - "name"); + "name"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -34,7 +34,7 @@ /** * {@link Issue} reader. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class IssueXpp3Reader extends AbstractXpp3Reader<Issue> { @@ -47,35 +47,35 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(Issue.class, RedmineDataConverter.Integer, true, allMappers, - "assigned-to-id", - "author-id", - "category-id", - "done-ratio", - "lock-version", - "priority-id", - "project-id", - "status-id", - "tracker-id", - "fixed-version-id", - "id", - "parent-id", - "root-id", - "lft", - "rgt"); + "assigned-to-id", + "author-id", + "category-id", + "done-ratio", + "lock-version", + "priority-id", + "project-id", + "status-id", + "tracker-id", + "fixed-version-id", + "id", + "parent-id", + "root-id", + "lft", + "rgt"); addTagTextContentMappers(Issue.class, RedmineDataConverter.Float, true, allMappers, - "estimated-hours"); + "estimated-hours"); addTagTextContentMappers(Issue.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on", - "updated-on"); + "created-on", + "updated-on"); addTagTextContentMappers(Issue.class, RedmineDataConverter.Date, true, allMappers, - "due-date", - "start-date"); + "due-date", + "start-date"); addTagTextContentMappers(Issue.class, RedmineDataConverter.Text, true, allMappers, - "description", - "subject"); + "description", + "subject"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,15 +24,15 @@ */ package org.nuiton.jredmine.model.io.xpp3; -import java.beans.IntrospectionException; import org.nuiton.io.xpp3.AbstractXpp3Reader; import org.nuiton.jredmine.model.News; +import java.beans.IntrospectionException; + import static org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers; /** - * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class NewsXpp3Reader extends AbstractXpp3Reader<News> { @@ -45,17 +45,17 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(News.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "author-id", - "project-id", - "comments-count"); + "id", + "author-id", + "project-id", + "comments-count"); addTagTextContentMappers(News.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on"); + "created-on"); addTagTextContentMappers(News.class, RedmineDataConverter.Text, true, allMappers, - "description", - "summary", - "title"); + "description", + "summary", + "title"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -34,7 +34,7 @@ /** * {@link Project} reader. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class ProjectXpp3Reader extends AbstractXpp3Reader<Project> { @@ -47,24 +47,24 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(Project.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "lft", - "rgt", - "parent-id", - "projects-count", - "status"); + "id", + "lft", + "rgt", + "parent-id", + "projects-count", + "status"); addTagTextContentMappers(Project.class, RedmineDataConverter.Boolean, true, allMappers, - "is-public"); + "is-public"); addTagTextContentMappers(Project.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on", - "updated-on"); + "created-on", + "updated-on"); addTagTextContentMappers(Project.class, RedmineDataConverter.Text, true, allMappers, - "description", - "homepage", - "identifier", - "name"); + "description", + "homepage", + "identifier", + "name"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,88 +24,82 @@ */ package org.nuiton.jredmine.model.io.xpp3; +import org.nuiton.io.xpp3.DataConverter; + import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; -import org.nuiton.io.xpp3.DataConverter; /** * A enumaration to convert some data from a string representation. - * + * <p/> * Can not use directly a converter from commons-beans library, since we have * several different converter to use for same type (see {@link #Date} and * {@link #Datetime}). * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public enum RedmineDataConverter implements DataConverter { Boolean { - @Override public Object convert(String t) throws Exception { Object r = java.lang.Boolean.valueOf(t); return r; } }, Short { - @Override public Object convert(String t) throws Exception { Object r = java.lang.Short.valueOf(t); return r; } }, Integer { - @Override public Object convert(String t) throws Exception { Object r = java.lang.Integer.valueOf(t); return r; } }, Long { - @Override public Object convert(String t) throws Exception { Object r = java.lang.Long.valueOf(t); return r; } }, Float { - @Override public Object convert(String t) throws Exception { Object r = java.lang.Float.valueOf(t); return r; } }, Double { - @Override public Object convert(String t) throws Exception { Object r = java.lang.Double.valueOf(t); return r; } }, Date { - @Override public Object convert(String t) throws Exception { Object r = dateParser.parse(t); return r; } }, Datetime { - @Override public Object convert(String t) throws Exception { Object r = datetimeParser.parse(t); return r; } }, Text { - @Override public Object convert(String t) throws Exception { return t; } }; + //FIXME TC20090907 this a a big hack (the + party) redmine returns us a timezone // in a format we can not deal with (+hh:mm), so actually, ignore it... static final DateFormat datetimeParser = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss\'+\'SS\':\'SS", Locale.US); + static final DateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd", Locale.US); } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2011-06-04 17:01:31 UTC (rev 211) @@ -45,7 +45,7 @@ /** * Pour construire le modèle à partir de fichiers xml contenant les données. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class RedmineXpp3Helper { @@ -53,40 +53,74 @@ /** Logger. */ private static final Log log = LogFactory.getLog(RedmineXpp3Helper.class); - public <O> O readObject(Class<O> klass, String txt, boolean strict) throws IOException, XmlPullParserException { - O result = readObject(klass, new ByteArrayInputStream(txt.getBytes()), strict); + public <O> O readObject(Class<O> klass, + String txt, + boolean strict) throws IOException, XmlPullParserException { + O result = readObject(klass, + new ByteArrayInputStream(txt.getBytes()), + strict + ); return result; } - public <O> O[] readObjects(Class<O> klass, String txt, boolean strict) throws IOException, XmlPullParserException { - O[] results = readObjects(klass, new ByteArrayInputStream(txt.getBytes()), strict); + public <O> O[] readObjects(Class<O> klass, + String txt, + boolean strict) throws IOException, XmlPullParserException { + O[] results = readObjects(klass, + new ByteArrayInputStream(txt.getBytes()), + strict + ); return results; } - public <O> O readObject(Class<O> klass, File file, boolean strict) throws IOException, XmlPullParserException { - O result = readObject(klass, new FileInputStream(file), strict); - return result; + public <O> O readObject(Class<O> klass, + File file, + boolean strict) throws IOException, XmlPullParserException { + FileInputStream stream = new FileInputStream(file); + try { + O result = readObject(klass, stream, strict); + return result; + } finally { + stream.close(); + } } - public <O> O[] readObjects(Class<O> klass, File file, boolean strict) throws IOException, XmlPullParserException { - O[] results = readObjects(klass, new FileInputStream(file), strict); - return results; + public <O> O[] readObjects(Class<O> klass, + File file, + boolean strict) throws IOException, XmlPullParserException { + FileInputStream stream = new FileInputStream(file); + try { + O[] results = readObjects(klass, stream, strict); + return results; + } finally { + stream.close(); + } } - public <O> O readObject(Class<O> klass, InputStream stream, boolean strict) throws IOException, XmlPullParserException { + public <O> O readObject(Class<O> klass, + InputStream stream, + boolean strict) throws IOException, XmlPullParserException { RedmineModelEnum.safeValueOf(klass); - O result = readObject(klass, ReaderFactory.newXmlReader(stream), strict); + O result = readObject(klass, + ReaderFactory.newXmlReader(stream), + strict + ); return result; } - public <O> O[] readObjects(Class<O> klass, InputStream stream, boolean strict) throws IOException, XmlPullParserException { + public <O> O[] readObjects(Class<O> klass, + InputStream stream, + boolean strict) throws IOException, XmlPullParserException { RedmineModelEnum.safeValueOf(klass); - O[] results = readObjects(klass, ReaderFactory.newXmlReader(stream), strict); + O[] results = readObjects(klass, + ReaderFactory.newXmlReader(stream), + strict + ); return results; } @@ -96,7 +130,7 @@ * @param <O> the type of objects to return * @param klass the type of object to read * @param reader the reader where to parse the xml - * @param strict + * @param strict a flag to have a strict reading of input source * @return the loaded objects * @throws IOException if any io pb * @throws XmlPullParserException if any parsing pb @@ -142,14 +176,14 @@ return result; } - /** + /** * Read a single object from a xml stream. * * @param <O> the type of object to read * @param klass the type of object to read * @param reader the reader where to parse the xml - * @param strict - * @return the loaded object + * @param strict a flag to have a strict reading of input source + * @return the loaded object * @throws IOException if any io pb * @throws XmlPullParserException if any parsing pb */ Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -25,19 +25,16 @@ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; -import static org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers; import org.nuiton.jredmine.model.TimeEntry; import java.beans.IntrospectionException; +import static org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers; + /** * Created: 31 déc. 2009 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> */ public class TimeEntryXpp3Reader extends AbstractXpp3Reader<TimeEntry> { @@ -49,28 +46,28 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "activity-id", - "issue-id", - "project-id", - "user-id", - "tyear", - "tmonth", - "tweek" + "id", + "activity-id", + "issue-id", + "project-id", + "user-id", + "tyear", + "tmonth", + "tweek" ); addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Float, true, allMappers, - "hours" + "hours" ); addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on", - "updated-on"); + "created-on", + "updated-on"); addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Date, true, allMappers, - "spent-on"); + "spent-on"); addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Text, true, allMappers, - "comments"); + "comments"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,15 +24,17 @@ */ package org.nuiton.jredmine.model.io.xpp3; -import java.beans.IntrospectionException; import org.nuiton.io.xpp3.AbstractXpp3Reader; import org.nuiton.jredmine.model.Tracker; + +import java.beans.IntrospectionException; + import static org.nuiton.io.xpp3.Xpp3Helper.addTagTextContentMappers; /** * {@link Tracker} reader. - * - * @author chemit + * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class TrackerXpp3Reader extends AbstractXpp3Reader<Tracker> { @@ -45,16 +47,16 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(Tracker.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "project-id", - "tracker-id", - "position"); + "id", + "project-id", + "tracker-id", + "position"); addTagTextContentMappers(Tracker.class, RedmineDataConverter.Boolean, true, allMappers, - "is-in-chlog", - "is-in-roadmap"); + "is-in-chlog", + "is-in-roadmap"); addTagTextContentMappers(Tracker.class, RedmineDataConverter.Text, true, allMappers, - "name"); + "name"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -33,8 +33,8 @@ /** * {@link User} reader. - * - * @author chemit + * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class UserXpp3Reader extends AbstractXpp3Reader<User> { @@ -47,28 +47,28 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(User.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "auth-source-id", - "member-id", - "role-id", - "status"); + "id", + "auth-source-id", + "member-id", + "role-id", + "status"); addTagTextContentMappers(User.class, RedmineDataConverter.Boolean, true, allMappers, - "admin", - "mail-notification"); + "admin", + "mail-notification"); addTagTextContentMappers(User.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on", - "updated-on", - "last-login-on"); + "created-on", + "updated-on", + "last-login-on"); addTagTextContentMappers(User.class, RedmineDataConverter.Text, true, allMappers, - "firstname", - "hashed-password", - "language", - "lastname", - "login", - "identity-url", - "mail"); + "firstname", + "hashed-password", + "language", + "lastname", + "login", + "identity-url", + "mail"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java 2011-06-04 17:01:31 UTC (rev 211) @@ -33,7 +33,8 @@ /** * {@link Version} reader. - * @author chemit + * + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class VersionXpp3Reader extends AbstractXpp3Reader<Version> { @@ -46,20 +47,20 @@ protected void initMappers() throws IntrospectionException { addTagTextContentMappers(Version.class, RedmineDataConverter.Integer, true, allMappers, - "id", - "project-id"); + "id", + "project-id"); addTagTextContentMappers(Version.class, RedmineDataConverter.Datetime, true, allMappers, - "created-on", - "updated-on"); + "created-on", + "updated-on"); addTagTextContentMappers(Version.class, RedmineDataConverter.Date, true, allMappers, - "effective-date"); + "effective-date"); addTagTextContentMappers(Version.class, RedmineDataConverter.Text, true, allMappers, - "name", - "description", - "wiki-page-title", - "sharing", - "status"); + "name", + "description", + "wiki-page-title", + "sharing", + "status"); } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/DefaultRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/DefaultRequestBuilder.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/DefaultRequestBuilder.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,22 +24,26 @@ */ package org.nuiton.jredmine.rest; +import org.nuiton.io.rest.RestRequest; +import org.nuiton.io.rest.RestRequestBuilder; + import java.io.File; import java.util.Map; -import org.nuiton.io.rest.RestRequest; -import org.nuiton.io.rest.RestRequestBuilder; - /** * Default {@link RestRequestBuilder} to be used in {@link RedmineRestClient}. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class DefaultRequestBuilder implements RestRequestBuilder { public static final String CONTEXT_PATH = "jredmine"; + + public static final String[] EMPTY_STRING_ARRAY = new String[0]; + protected String name; + protected String action; public DefaultRequestBuilder(String name, String action) { @@ -53,13 +57,12 @@ } /** - * * @param args the args of the request * @return TODO */ public String[] getParameters(Object... args) { // by default, no parameter - return new String[0]; + return EMPTY_STRING_ARRAY; } public String[] getPath(Object... args) { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java 2011-06-04 17:01:31 UTC (rev 211) @@ -29,11 +29,7 @@ * <p/> * Created: 1 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @since 1.0.3 */ public class IssueScopeRequestBuilder extends ProjectScopeRequestBuilder { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/ProjectScopeRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/ProjectScopeRequestBuilder.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/ProjectScopeRequestBuilder.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,7 +27,7 @@ /** * Builder of requests which are in a project context. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class ProjectScopeRequestBuilder extends DefaultRequestBuilder { Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/RedmineRestClient.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/RedmineRestClient.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/RedmineRestClient.java 2011-06-04 17:01:31 UTC (rev 211) @@ -29,11 +29,23 @@ import org.apache.commons.httpclient.StatusLine; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.util.StringUtils; import org.nuiton.io.rest.RestClient; import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.io.rest.RestRequest; import org.nuiton.io.rest.RestSession; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.VersionStatusEnum; import java.io.File; import java.io.IOException; @@ -47,41 +59,68 @@ * Implementation of a {@link RestClient} to access a Redmine server via the * {@code redmine_rest} rails plugin. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @plexus.component role="org.nuiton.io.rest.RestClient" role-hint="redmine" * @since 1.0.0 */ public class RedmineRestClient extends RestClient { private static final Log log = LogFactory.getLog(RedmineRestClient.class); - public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + public static final String GET_ISSUE_LIST = Issue.class.getName() + "list"; + public static final String GET_ISSUE_STATUS_LIST = IssueStatus.class.getName() + "list"; + public static final String GET_ISSUE_PRIORITY_LIST = IssuePriority.class.getName() + "list"; + public static final String GET_ISSUE_CATEGORY_LIST = IssueCategory.class.getName() + "list"; + public static final String GET_ISSUE_TIME_ENTRY_LIST = TimeEntry.class.getName() + "list"; + public static final String GET_PROJECT_LIST = Project.class.getName() + "list"; + public static final String GET_PROJECT_ISSUES = Project.class.getName() + "issues"; + public static final String GET_PROJECT_OPENED_ISSUES = Project.class.getName() + "opened-issues"; + public static final String GET_PROJECT_CLOSED_ISSUES = Project.class.getName() + "closed-issues"; + public static final String GET_USER_PROJECTS = Project.class.getName() + "forUser"; + public static final String GET_PROJECT = Project.class.getName() + "detail"; + public static final String GET_VERSION_LIST = Version.class.getName() + "list"; + public static final String GET_TRACKER_LIST = Tracker.class.getName() + "list"; + public static final String GET_ATTACHMENTS_LIST = Attachment.class.getName() + "list"; + public static final String GET_USER_LIST = User.class.getName() + "list"; + public static final String GET_NEWS_LIST = News.class.getName() + "list"; + public static final String GET_VERSION = Version.class.getName() + "detail"; + public static final String ADD_VERSION = Version.class.getName() + "add"; + public static final String UPDATE_VERSION = Version.class.getName() + "update"; + public static final String NEXT_VERSION = Version.class.getName() + "next"; + public static final String ADD_NEWS = News.class.getName() + "add"; + public static final String ADD_ATTACHMENT = Attachment.class.getName() + "add"; + public static final String ADD_ISSUE_TIME_ENTRY = TimeEntry.class.getName() + "add"; + public static final String LOGIN = "login"; + public static final String LOGOUT = "logout"; + public static final String PING = "ping"; + public final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + public RedmineRestClient() { } @@ -128,11 +167,13 @@ @Override public String[] getParameters(Object... args) { Version version = (Version) args[1]; - String date = version.getEffectiveDate() == null ? "" : DATE_FORMAT.format(version.getEffectiveDate()); + String date = getVersionEffectiveDate(version); + String status = getVersionStatus(version); return new String[]{ "version[name]", version.getName(), "version[description]", version.getDescription(), - "version[effective_date]", date + "version[effective_date]", date, + "version[status]", status }; } }); @@ -142,11 +183,13 @@ @Override public String[] getParameters(Object... args) { Version version = (Version) args[1]; - String date = version.getEffectiveDate() == null ? "" : DATE_FORMAT.format(version.getEffectiveDate()); + String date = getVersionEffectiveDate(version); + String status = getVersionStatus(version); return new String[]{ "version[name]", version.getName(), "version[description]", version.getDescription(), - "version[effective_date]", date + "version[effective_date]", date, + "version[status]", status }; } }); @@ -156,14 +199,17 @@ @Override public String[] getParameters(Object... args) { - String oldVersionId = (String) args[1]; - Version version = (Version) args[2]; - String date = version.getEffectiveDate() == null ? "" : DATE_FORMAT.format(version.getEffectiveDate()); + + Version version = (Version) args[1]; + String date = getVersionEffectiveDate(version); + String status = getVersionStatus(version); + String oldVersionName = (String) args[2]; return new String[]{ - "oldVersionName", oldVersionId, + "oldVersionName", oldVersionName, "version[name]", version.getName(), "version[description]", version.getDescription(), - "version[effective_date]", date + "version[effective_date]", date, + "version[status]", status }; } }); @@ -234,7 +280,6 @@ }; } }); - } @Override @@ -277,25 +322,32 @@ if (statusCode != HttpStatus.SC_OK) { gm.releaseConnection(); - throw new IOException("Got error code <" + statusCode + ":" + sl.getReasonPhrase() + "> on " + gm.getPath()); + throw new IOException( + "Got error code <" + statusCode + ":" + + sl.getReasonPhrase() + "> on " + gm.getPath()); } String content = gm.getResponseBodyAsString(); boolean ok = "ping".equals(content); if (!ok) { - throw new IOException("can not connect to " + configuration.getRestUrl()); + throw new IOException( + "can not connect to " + configuration.getRestUrl()); } } catch (IOException ex) { throw ex; } catch (Exception ex) { - throw new IOException("could not ping " + configuration.getRestUrl() + " for reason " + ex.getMessage(), ex); + throw new IOException( + "could not ping " + configuration.getRestUrl() + + " for reason " + ex.getMessage(), ex); } } protected void login(RestSession session) throws IOException { - RestRequest request = getRequest(LOGIN, configuration.getRestUsername(), configuration.getRestPassword()); + RestRequest request = getRequest(LOGIN, + configuration.getRestUsername(), + configuration.getRestPassword()); HttpMethod gm = session.doRequest(request); @@ -307,10 +359,27 @@ if (statusCode != HttpStatus.SC_OK) { gm.releaseConnection(); - throw new IOException("Got error code <" + statusCode + ":" + sl.getReasonPhrase() + "> on " + gm.getPath()); + throw new IOException( + "Got error code <" + statusCode + ":" + + sl.getReasonPhrase() + "> on " + gm.getPath()); } // ok session is logged in } + + protected String getVersionStatus(Version version) { + String status = version.getStatus(); + if (StringUtils.isEmpty(status)) { + + // use default open status + status = VersionStatusEnum.open.name(); + } + return status; + } + + protected String getVersionEffectiveDate(Version version) { + return version.getEffectiveDate() == null ? "" : + DATE_FORMAT.format(version.getEffectiveDate()); + } } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/VersionScopeRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/VersionScopeRequestBuilder.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/VersionScopeRequestBuilder.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,7 +27,7 @@ /** * Builder of requests which are in a project and version context. * - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class VersionScopeRequestBuilder extends ProjectScopeRequestBuilder { Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/AbstractRedmineServiceTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/AbstractRedmineServiceTest.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/AbstractRedmineServiceTest.java 2011-06-04 17:01:31 UTC (rev 211) @@ -26,51 +26,75 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.nuiton.io.rest.RestClientConfiguration; -import static org.nuiton.jredmine.TestHelper.getTestConfiguration; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; import org.nuiton.jredmine.rest.RedmineRestClient; +import static org.nuiton.jredmine.TestHelper.getTestConfiguration; + /** * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> */ public abstract class AbstractRedmineServiceTest<S extends RedmineAnonymousService> implements RedmineTestContract { - /** - * Logger - */ + + /** Logger. */ private static final Log log = LogFactory.getLog(AbstractRedmineServiceTest.class); - /** - * shared rest client (open only one session for all the test) - */ + /** shared rest client (open only one session for all the test). */ static RedmineRestClient client; - /** - * service to test - */ + + /** service to test. */ private S service; protected Project[] projects; + protected Project project; + protected Version[] versions; + protected Version version; + protected User[] users; + protected Issue[] issues; + protected IssuePriority[] issuePriorities; + protected IssueStatus[] issueStatuses; + protected IssueCategory[] issueCategories; + protected Tracker[] trackers; + protected News newz; + protected News[] news; + protected Attachment attachment; + protected Attachment[] attachments; + protected TimeEntry timeEntry; + protected TimeEntry[] timeEntries; private final Class<S> serviceType; Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineAnonymousServiceTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineAnonymousServiceTest.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineAnonymousServiceTest.java 2011-06-04 17:01:31 UTC (rev 211) @@ -31,11 +31,7 @@ /** * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> */ public class DefaultRedmineAnonymousServiceTest extends AbstractRedmineServiceTest<DefaultRedmineAnonymousService> { Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceAsAnonymousTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceAsAnonymousTest.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceAsAnonymousTest.java 2011-06-04 17:01:31 UTC (rev 211) @@ -35,11 +35,7 @@ /** * Created: 2 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * */ public class DefaultRedmineServiceAsAnonymousTest extends AbstractRedmineServiceTest<DefaultRedmineService> { Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java 2011-06-04 17:01:31 UTC (rev 211) @@ -26,9 +26,7 @@ import org.junit.Test; -/** - * @author chemit - */ +/** @author tchemit <chemit@codelutin.com> */ public class DefaultRedmineServiceTest extends AbstractRedmineServiceTest<DefaultRedmineService> { public DefaultRedmineServiceTest() { Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java 2011-06-04 17:01:31 UTC (rev 211) @@ -25,21 +25,19 @@ package org.nuiton.jredmine; /** - * contract of methods to tests for both redmine rest client and redmine service. + * Contract of methods to tests for both redmine rest client and redmine service. * <p/> * Created: 1 janv. 2010 * - * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin - * @version $Revision$ - * <p/> - * Mise a jour: $Date$ par : - * $Author$ + * @author tchemit <chemit@codelutin.com> * @since 1.0.3 */ public interface RedmineTestContract { String PROJECT_NAME = "one"; + String VERSION_NAME = "1.0.0"; + String ISSUE_ID = "6"; void getProjects() throws Exception; Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java 2011-06-04 17:01:31 UTC (rev 211) @@ -30,25 +30,45 @@ import org.nuiton.io.xpp3.AbstractXpp3Reader; import org.nuiton.io.xpp3.PropertyMapper; import org.nuiton.io.xpp3.Xpp3Helper; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.RedmineModelEnum; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; import org.nuiton.jredmine.model.io.xpp3.RedmineDataConverter; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; /** - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public abstract class TestHelper { protected static File basedir; + protected static RestClientConfiguration DEFAULT_CONFIGURATION; + protected static Properties defaultConfig; + protected static Properties userConfig; + protected static EnumMap<RedmineModelEnum, List<?>> memoryModel; public static void initDefaultConfiguration() throws IOException { @@ -66,7 +86,7 @@ userConfig = new Properties(defaultConfig); for (String key : System.getenv().keySet()) { String env = System.getenv(key); - if (key.startsWith("test.") && (env != null && !env.trim().isEmpty())) { + if (key.startsWith("test.") && env != null && !env.trim().isEmpty()) { userConfig.setProperty(key, env); } } @@ -131,9 +151,7 @@ dst.setVerbose(src.isVerbose()); } - /** - * @return the basedir for all tests - */ + /** @return the basedir for all tests */ public static File getBasedir() { if (basedir == null) { String path = System.getenv("basedir"); Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java 2011-06-04 17:01:31 UTC (rev 211) @@ -27,9 +27,25 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.plexus.util.IOUtil; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.nuiton.jredmine.TestHelper; -import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.IssueCategory; +import org.nuiton.jredmine.model.IssuePriority; +import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.RedmineModelEnum; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; import java.beans.Introspector; import java.io.File; @@ -40,12 +56,14 @@ import java.util.Set; /** - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class RedmineXpp3HelperTest { - protected static final Log log = LogFactory.getLog(RedmineXpp3HelperTest.class); + protected static final Log log = + LogFactory.getLog(RedmineXpp3HelperTest.class); + //TODO use the RedmineModelEnum and finish the model mock (miss some types) private static final RedmineModelEnum[] TYPE_ORDER = new RedmineModelEnum[]{ RedmineModelEnum.attachment, @@ -60,10 +78,15 @@ RedmineModelEnum.news, RedmineModelEnum.timeEntry }; + protected static File testDir; + protected static RedmineXpp3Helper builder; + File file; + protected boolean verbose; + protected static int universeSize; @BeforeClass @@ -111,7 +134,7 @@ /** * Test the method {@code read} of class ModelBuilder. * - * @throws Exception + * @throws Exception for any exceptions */ @Test public void testRead() throws Exception { @@ -149,24 +172,24 @@ }; action.run("single", - Arrays.asList(TestHelper.getModel(Attachment.class).get(0)), - Arrays.asList(TestHelper.getModel(Issue.class).get(0)), - Arrays.asList(TestHelper.getModel(Project.class).get(0)), - Arrays.asList(TestHelper.getModel(Tracker.class).get(0)), - Arrays.asList(TestHelper.getModel(User.class).get(0)), - Arrays.asList(TestHelper.getModel(Version.class).get(0)), - Arrays.asList(TestHelper.getModel(IssueStatus.class).get(0)), - Arrays.asList(TestHelper.getModel(IssuePriority.class).get(0)), - Arrays.asList(TestHelper.getModel(IssueCategory.class).get(0)), - Arrays.asList(TestHelper.getModel(News.class).get(0)), - Arrays.asList(TestHelper.getModel(TimeEntry.class).get(0)) + Arrays.asList(TestHelper.getModel(Attachment.class).get(0)), + Arrays.asList(TestHelper.getModel(Issue.class).get(0)), + Arrays.asList(TestHelper.getModel(Project.class).get(0)), + Arrays.asList(TestHelper.getModel(Tracker.class).get(0)), + Arrays.asList(TestHelper.getModel(User.class).get(0)), + Arrays.asList(TestHelper.getModel(Version.class).get(0)), + Arrays.asList(TestHelper.getModel(IssueStatus.class).get(0)), + Arrays.asList(TestHelper.getModel(IssuePriority.class).get(0)), + Arrays.asList(TestHelper.getModel(IssueCategory.class).get(0)), + Arrays.asList(TestHelper.getModel(News.class).get(0)), + Arrays.asList(TestHelper.getModel(TimeEntry.class).get(0)) ); } /** * Test the method {@code readArray} of class ModelBuilder. * - * @throws Exception + * @throws Exception for any exceptions */ @Test @SuppressWarnings("unchecked") @@ -204,52 +227,50 @@ }; action.run("array-empty", - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList(), - Collections.emptyList()); + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList()); action.run("array-singleton", - Arrays.asList(TestHelper.getModel(Attachment.class).get(0)), - Arrays.asList(TestHelper.getModel(Issue.class).get(0)), - Arrays.asList(TestHelper.getModel(Project.class).get(0)), - Arrays.asList(TestHelper.getModel(Tracker.class).get(0)), - Arrays.asList(TestHelper.getModel(User.class).get(0)), - Arrays.asList(TestHelper.getModel(Version.class).get(0)), - Arrays.asList(TestHelper.getModel(IssueStatus.class).get(0)), - Arrays.asList(TestHelper.getModel(IssuePriority.class).get(0)), - Arrays.asList(TestHelper.getModel(IssueCategory.class).get(0)), - Arrays.asList(TestHelper.getModel(News.class).get(0)), - Arrays.asList(TestHelper.getModel(TimeEntry.class).get(0)) + Arrays.asList(TestHelper.getModel(Attachment.class).get(0)), + Arrays.asList(TestHelper.getModel(Issue.class).get(0)), + Arrays.asList(TestHelper.getModel(Project.class).get(0)), + Arrays.asList(TestHelper.getModel(Tracker.class).get(0)), + Arrays.asList(TestHelper.getModel(User.class).get(0)), + Arrays.asList(TestHelper.getModel(Version.class).get(0)), + Arrays.asList(TestHelper.getModel(IssueStatus.class).get(0)), + Arrays.asList(TestHelper.getModel(IssuePriority.class).get(0)), + Arrays.asList(TestHelper.getModel(IssueCategory.class).get(0)), + Arrays.asList(TestHelper.getModel(News.class).get(0)), + Arrays.asList(TestHelper.getModel(TimeEntry.class).get(0)) ); action.run("array-multi", - TestHelper.getModel(Attachment.class), - TestHelper.getModel(Issue.class), - TestHelper.getModel(Project.class), - TestHelper.getModel(Tracker.class), - TestHelper.getModel(User.class), - TestHelper.getModel(Version.class), - TestHelper.getModel(IssueStatus.class), - TestHelper.getModel(IssuePriority.class), - TestHelper.getModel(IssueCategory.class), - TestHelper.getModel(News.class), - TestHelper.getModel(TimeEntry.class) + TestHelper.getModel(Attachment.class), + TestHelper.getModel(Issue.class), + TestHelper.getModel(Project.class), + TestHelper.getModel(Tracker.class), + TestHelper.getModel(User.class), + TestHelper.getModel(Version.class), + TestHelper.getModel(IssueStatus.class), + TestHelper.getModel(IssuePriority.class), + TestHelper.getModel(IssueCategory.class), + TestHelper.getModel(News.class), + TestHelper.getModel(TimeEntry.class) ); } - /** - * A little action wrapper to simplify this test class :) - */ + /** A little action wrapper to simplify this test class :) */ public static abstract class TestAction { /** Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/rest/RedmineRestClientTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/rest/RedmineRestClientTest.java 2011-06-04 16:57:56 UTC (rev 210) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/rest/RedmineRestClientTest.java 2011-06-04 17:01:31 UTC (rev 211) @@ -24,8 +24,16 @@ */ package org.nuiton.jredmine.rest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.codehaus.plexus.util.IOUtil; -import org.junit.*; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.io.rest.RestException; import org.nuiton.io.rest.RestRequest; @@ -36,12 +44,17 @@ import java.io.InputStream; /** - * @author chemit + * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ public class RedmineRestClientTest implements RedmineTestContract { + /** Logger. */ + private static final Log log = + LogFactory.getLog(RedmineRestClientTest.class); + static RestClientConfiguration configuration; + RedmineRestClient client; public RedmineRestClientTest() { @@ -59,7 +72,9 @@ } catch (Exception e) { // could not log - System.out.println("could not connect to server " + configuration.getRestUrl() + ", will skip test " + RedmineRestClientTest.class.getName()); + if (log.isWarnEnabled()) { + log.warn("could not connect to server " + configuration.getRestUrl() + ", will skip test " + RedmineRestClientTest.class.getName()); + } } finally { Assume.assumeTrue(client.isOpen()); } @@ -147,7 +162,7 @@ @Override public void getUserProjects() throws Exception { - + doRequest(RedmineRestClient.GET_USER_PROJECTS, PROJECT_NAME); } @@ -260,7 +275,9 @@ askData = client.askData(request); toString = IOUtil.toString(askData); if (configuration.isVerbose()) { - System.out.println(toString); + if (log.isInfoEnabled()) { + log.info(toString); + } } } }
participants (1)
-
tchemit@users.nuiton.org