r288 - in trunk: jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x jredmine-client-1.3.x/src/test/java/org/nuiton/jredmine/v1_3_x jredmine-client-api/src/main/java/org/nuiton/jredmine/model jredmine-client-api/src/main/java/org/nuiton/jredmine/request jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin
Author: tchemit Date: 2012-07-13 18:48:19 +0200 (Fri, 13 Jul 2012) New Revision: 288 Url: http://nuiton.org/repositories/revision/jredmine/288 Log: improve some misc stuff (constants, and al.) Modified: trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineAnonymousServiceImpl.java trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRequestFactoryImpl.java trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRestClient.java trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceImpl.java trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceProviderImpl.java trunk/jredmine-client-1.3.x/src/test/java/org/nuiton/jredmine/v1_3_x/RedmineServiceAsAnonymousTest.java trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/model/ModelHelper.java trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java trunk/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java Modified: trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineAnonymousServiceImpl.java =================================================================== --- trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineAnonymousServiceImpl.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineAnonymousServiceImpl.java 2012-07-13 16:48:19 UTC (rev 288) @@ -37,6 +37,7 @@ import org.nuiton.jredmine.model.IssueCategory; import org.nuiton.jredmine.model.IssuePriority; import org.nuiton.jredmine.model.IssueStatus; +import org.nuiton.jredmine.model.ModelHelper; import org.nuiton.jredmine.model.News; import org.nuiton.jredmine.model.Project; import org.nuiton.jredmine.model.TimeEntry; @@ -73,26 +74,26 @@ @Override public IssueStatus[] getIssueStatuses() throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_ISSUE_STATUS_LIST, + return getDatas(ModelHelper.GET_ALL_ISSUE_STATUS_REQUEST_NAME, IssueStatus.class ); } @Override public IssuePriority[] getIssuePriorities() throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_ISSUE_PRIORITY_LIST, + return getDatas(ModelHelper.GET_ALL_ISSUE_PRIORITY_REQUEST_NAME, IssuePriority.class ); } @Override public Project[] getProjects() throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_PROJECT_LIST, Project.class); + return getDatas(ModelHelper.GET_ALL_PROJECT_REQUEST_NAME, Project.class); } @Override public IssueCategory[] getIssueCategories(String projectName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_ISSUE_CATEGORY_LIST, + return getDatas(ModelHelper.GET_ALL_ISSUE_CATEGORY_REQUEST_NAME, IssueCategory.class, projectName ); @@ -100,7 +101,7 @@ @Override public Project getProject(String projectName) throws RedmineServiceException { - return getData(RedmineRequestFactoryImpl.GET_PROJECT, + return getData(ModelHelper.GET_PROJECT_REQUEST_NAME, Project.class, projectName ); @@ -108,7 +109,7 @@ @Override public Tracker[] getTrackers(String projectName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_TRACKER_LIST, + return getDatas(ModelHelper.GET_ALL_TRACKER_REQUEST_NAME, Tracker.class, projectName ); @@ -116,7 +117,7 @@ @Override public News[] getNews(String projectName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_NEWS_LIST, + return getDatas(ModelHelper.GET_ALL_NEWS_REQUEST_NAME, News.class, projectName ); @@ -124,7 +125,7 @@ @Override public User[] getProjectMembers(String projectName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_USER_LIST, + return getDatas(ModelHelper.GET_ALL_USER_REQUEST_NAME, User.class, projectName ); @@ -132,7 +133,7 @@ @Override public Version[] getVersions(String projectName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_VERSION_LIST, + return getDatas(ModelHelper.GET_ALL_VERSION_REQUEST_NAME, Version.class, projectName ); @@ -141,7 +142,7 @@ @Override public Version getVersion(String projectName, String versionName) throws RedmineServiceException { - return getData(RedmineRequestFactoryImpl.GET_VERSION, + return getData(ModelHelper.GET_VERSION_REQUEST_NAME, Version.class, projectName, versionName @@ -151,7 +152,7 @@ @Override public Attachment[] getAttachments(String projectName, String versionName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_ATTACHMENTS_LIST, + return getDatas(ModelHelper.GET_ALL_ATTACHMENTS_REQUEST_NAME, Attachment.class, projectName, versionName @@ -161,7 +162,7 @@ @Override public Issue[] getIssues(String projectName, String versionName) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_ISSUE_LIST, + return getDatas(ModelHelper.GET_ALL_ISSUES_REQUEST_NAME, Issue.class, projectName, versionName @@ -171,7 +172,7 @@ @Override public TimeEntry[] getIssueTimeEntries(String projectName, String issueId) throws RedmineServiceException { - return getDatas(RedmineRequestFactoryImpl.GET_ISSUE_TIME_ENTRY_LIST, + return getDatas(ModelHelper.GET_ALL_ISSUE_TIME_ENTRY_REQUEST_NAME, TimeEntry.class, projectName, issueId @@ -180,7 +181,7 @@ @Override public Issue[] getIssues(String projectName) throws RedmineServiceException { - Issue[] result = getDatas(RedmineRequestFactoryImpl.GET_PROJECT_ISSUES, + Issue[] result = getDatas(ModelHelper.GET_ALL_PROJECT_ISSUES_REQUEST_NAME, Issue.class, projectName ); @@ -189,7 +190,7 @@ @Override public Issue[] getOpenedIssues(String projectName) throws RedmineServiceException { - Issue[] result = getDatas(RedmineRequestFactoryImpl.GET_PROJECT_OPENED_ISSUES, + Issue[] result = getDatas(ModelHelper.GET_ALL_PROJECT_OPENED_ISSUES_REQUEST_NAME, Issue.class, projectName ); @@ -198,7 +199,7 @@ @Override public Issue[] getClosedIssues(String projectName) throws RedmineServiceException { - Issue[] result = getDatas(RedmineRequestFactoryImpl.GET_PROJECT_CLOSED_ISSUES, + Issue[] result = getDatas(ModelHelper.GET_ALL_PROJECT_CLOSED_ISSUES_REQUEST_NAME, Issue.class, projectName ); Modified: trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRequestFactoryImpl.java =================================================================== --- trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRequestFactoryImpl.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRequestFactoryImpl.java 2012-07-13 16:48:19 UTC (rev 288) @@ -5,15 +5,9 @@ import org.nuiton.io.rest.RestMethod; import org.nuiton.io.rest.RestRequest; 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.ModelHelper; 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 org.nuiton.jredmine.request.DefaultRedmineRequestBuilder; @@ -34,68 +28,16 @@ */ public class RedmineRequestFactoryImpl extends AbstractRequestFactory { - 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"; - @Override public void addDefaultRequests() { // misc requests - addRequestBuilder(new DefaultRedmineRequestBuilder(PING, RestMethod.GET, "jredmine", "ping")); -// addRequestBuilder(new DefaultRedmineRequestBuilder(PING, RestMethod.GET, "projects")); - addRequestBuilder(new DefaultRedmineRequestBuilder(LOGOUT, RestMethod.GET, "jredmine", "logout")); -// addRequestBuilder(new DefaultRedmineRequestBuilder(LOGIN, RestMethod.POST, "login") { - addRequestBuilder(new DefaultRedmineRequestBuilder(LOGIN, RestMethod.POST, "jredmine", "login") { + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.PING_REQUEST_NAME, RestMethod.GET, "jredmine", "ping")); +// addRequestBuilder(new DefaultRedmineRequestBuilder(PING_REQUEST_NAME, RestMethod.GET, "projects")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.LOGOUT_REQUEST_NAME, RestMethod.GET, "jredmine", "logout")); +// addRequestBuilder(new DefaultRedmineRequestBuilder(LOGIN_REQUEST_NAME, RestMethod.POST, "login") { + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.LOGIN_REQUEST_NAME, RestMethod.POST, "jredmine", "login") { private static final long serialVersionUID = 1L; @@ -109,25 +51,25 @@ // data with no scope requests - addRequestBuilder(new DefaultRedmineRequestBuilder(GET_PROJECT_LIST, RestMethod.GET, "jredmine", "get_projects.xml")); -// addRequestBuilder(new DefaultRedmineRequestBuilder(GET_PROJECT_LIST, RestMethod.GET, "projects.xml")); - addRequestBuilder(new DefaultRedmineRequestBuilder(GET_USER_PROJECTS, RestMethod.GET, "jredmine", "get_user_projects.xml")); - addRequestBuilder(new DefaultRedmineRequestBuilder(GET_ISSUE_STATUS_LIST, RestMethod.GET, "jredmine", "get_issue_statuses.xml")); - addRequestBuilder(new DefaultRedmineRequestBuilder(GET_ISSUE_PRIORITY_LIST, RestMethod.GET, "jredmine", "get_issue_priorities.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_REQUEST_NAME, RestMethod.GET, "jredmine", "get_projects.xml")); +// addRequestBuilder(new DefaultRedmineRequestBuilder(GET_ALL_PROJECT_REQUEST_NAME, RestMethod.GET, "projects.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_USER_PROJECTS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_user_projects.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_STATUS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_statuses.xml")); + addRequestBuilder(new DefaultRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_PRIORITY_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_priorities.xml")); // data with project scope requests - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_PROJECT, RestMethod.GET, "jredmine", "get_project.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_PROJECT_ISSUES, RestMethod.GET, "jredmine", "get_project_issues.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_PROJECT_OPENED_ISSUES, RestMethod.GET, "jredmine", "get_project_opened_issues.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_PROJECT_CLOSED_ISSUES, RestMethod.GET, "jredmine", "get_project_closed_issues.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_VERSION_LIST, RestMethod.GET, "jredmine", "get_project_versions.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_ISSUE_CATEGORY_LIST, RestMethod.GET, "jredmine", "get_issue_categories.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_TRACKER_LIST, RestMethod.GET, "jredmine", "get_project_trackers.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_USER_LIST, RestMethod.GET, "jredmine", "get_project_users.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(GET_NEWS_LIST, RestMethod.GET, "jredmine", "get_project_news.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_PROJECT_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_issues.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_OPENED_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_opened_issues.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_PROJECT_CLOSED_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_closed_issues.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_VERSION_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_versions.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_CATEGORY_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_categories.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_TRACKER_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_trackers.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_USER_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_users.xml")); + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.GET_ALL_NEWS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_project_news.xml")); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ADD_VERSION, RestMethod.POST, "jredmine", "add_version.xml") { + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.ADD_VERSION_REQUEST_NAME, RestMethod.POST, "jredmine", "add_version.xml") { private static final long serialVersionUID = 1L; @Override @@ -144,7 +86,7 @@ } }); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(UPDATE_VERSION, RestMethod.POST, "jredmine", "update_version.xml") { + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.UPDATE_VERSION_REQUEST_NAME, RestMethod.POST, "jredmine", "update_version.xml") { private static final long serialVersionUID = 1L; @Override @@ -161,7 +103,7 @@ } }); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(NEXT_VERSION, RestMethod.POST, "jredmine", "next_version.xml") { + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.NEXT_VERSION_REQUEST_NAME, RestMethod.POST, "jredmine", "next_version.xml") { private static final long serialVersionUID = 1L; @Override @@ -182,7 +124,7 @@ } }); - addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ADD_NEWS, RestMethod.POST, "jredmine", "add_news.xml") { + addRequestBuilder(new ProjectScopeRedmineRequestBuilder(ModelHelper.ADD_NEWS_REQUEST_NAME, RestMethod.POST, "jredmine", "add_news.xml") { private static final long serialVersionUID = 1L; @Override @@ -198,10 +140,10 @@ // version scope requests - addRequestBuilder(new VersionScopeRedmineRequestBuilder(GET_VERSION, RestMethod.GET, "jredmine", "get_version.xml")); - addRequestBuilder(new VersionScopeRedmineRequestBuilder(GET_ISSUE_LIST, RestMethod.GET, "jredmine", "get_version_issues.xml")); - addRequestBuilder(new VersionScopeRedmineRequestBuilder(GET_ATTACHMENTS_LIST, RestMethod.GET, "jredmine", "get_version_attachments.xml")); - addRequestBuilder(new VersionScopeRedmineRequestBuilder(ADD_ATTACHMENT, RestMethod.POST, "jredmine", "add_version_attachment.xml") { + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.GET_VERSION_REQUEST_NAME, RestMethod.GET, "jredmine", "get_version.xml")); + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUES_REQUEST_NAME, RestMethod.GET, "jredmine", "get_version_issues.xml")); + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ATTACHMENTS_REQUEST_NAME, RestMethod.GET, "jredmine", "get_version_attachments.xml")); + addRequestBuilder(new VersionScopeRedmineRequestBuilder(ModelHelper.ADD_ATTACHMENT_REQUEST_NAME, RestMethod.POST, "jredmine", "add_version_attachment.xml") { private static final long serialVersionUID = 1L; @Override @@ -225,9 +167,9 @@ // issue scope requests - addRequestBuilder(new IssueScopeRedmineRequestBuilder(GET_ISSUE_TIME_ENTRY_LIST, RestMethod.GET, "jredmine", "get_issue_times.xml")); + addRequestBuilder(new IssueScopeRedmineRequestBuilder(ModelHelper.GET_ALL_ISSUE_TIME_ENTRY_REQUEST_NAME, RestMethod.GET, "jredmine", "get_issue_times.xml")); - addRequestBuilder(new IssueScopeRedmineRequestBuilder(ADD_ISSUE_TIME_ENTRY, RestMethod.POST, "jredmine", "add_issue_time.xml") { + addRequestBuilder(new IssueScopeRedmineRequestBuilder(ModelHelper.ADD_ISSUE_TIME_ENTRY_REQUEST_NAME, RestMethod.POST, "jredmine", "add_issue_time.xml") { private static final long serialVersionUID = 1L; @Override Modified: trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRestClient.java =================================================================== --- trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRestClient.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineRestClient.java 2012-07-13 16:48:19 UTC (rev 288) @@ -34,6 +34,7 @@ import org.nuiton.io.rest.RestClient; import org.nuiton.io.rest.RestRequest; import org.nuiton.io.rest.RestSession; +import org.nuiton.jredmine.model.ModelHelper; import org.nuiton.jredmine.model.Version; import org.nuiton.jredmine.model.VersionStatusEnum; @@ -86,7 +87,7 @@ if (session != null) { try { - RestRequest request = getRequest(RedmineRequestFactoryImpl.LOGOUT); + RestRequest request = getRequest(ModelHelper.LOGOUT_REQUEST_NAME); session.setOpen(false); session.doRequest(request); } finally { @@ -99,7 +100,7 @@ try { - RestRequest request = getRequest(RedmineRequestFactoryImpl.PING); + RestRequest request = getRequest(ModelHelper.PING_REQUEST_NAME); HttpMethod gm = session.doRequest(request); StatusLine sl = gm.getStatusLine(); @@ -134,7 +135,7 @@ public void login(RestSession session) throws IOException { - RestRequest request = getRequest(RedmineRequestFactoryImpl.LOGIN, + RestRequest request = getRequest(ModelHelper.LOGIN_REQUEST_NAME, configuration.getRestUsername(), configuration.getRestPassword()); @@ -147,7 +148,7 @@ } if (statusCode != HttpStatus.SC_OK && - statusCode!= HttpStatus.SC_MOVED_TEMPORARILY) { + statusCode != HttpStatus.SC_MOVED_TEMPORARILY) { gm.releaseConnection(); throw new IOException( "Got error code <" + statusCode + ":" + Modified: trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceImpl.java =================================================================== --- trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceImpl.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceImpl.java 2012-07-13 16:48:19 UTC (rev 288) @@ -32,6 +32,7 @@ import org.nuiton.jredmine.RedmineServiceException; import org.nuiton.jredmine.RedmineServiceImplementor; import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.ModelHelper; import org.nuiton.jredmine.model.News; import org.nuiton.jredmine.model.Project; import org.nuiton.jredmine.model.TimeEntry; @@ -63,7 +64,7 @@ @Override public Project[] getUserProjects() throws RedmineServiceException { checkLoggued(); - Project[] result = getDatas(RedmineRequestFactoryImpl.GET_USER_PROJECTS, Project.class); + Project[] result = getDatas(ModelHelper.GET_USER_PROJECTS_REQUEST_NAME, Project.class); return result; } @@ -72,7 +73,7 @@ Version version) throws RedmineServiceException { // send data and obtain created version - Version result = sendData(RedmineRequestFactoryImpl.ADD_VERSION, + Version result = sendData(ModelHelper.ADD_VERSION_REQUEST_NAME, Version.class, projectName, version @@ -85,7 +86,7 @@ Version version) throws RedmineServiceException { // send data and obtain updated version - Version result = sendData(RedmineRequestFactoryImpl.UPDATE_VERSION, + Version result = sendData(ModelHelper.UPDATE_VERSION_REQUEST_NAME, Version.class, projectName, version @@ -99,7 +100,7 @@ Version newVersion) throws RedmineServiceException { // send data and obtain updated or created new version - Version result = sendData(RedmineRequestFactoryImpl.NEXT_VERSION, + Version result = sendData(ModelHelper.NEXT_VERSION_REQUEST_NAME, Version.class, projectName, newVersion, @@ -114,7 +115,7 @@ Attachment attachement) throws RedmineServiceException { // send data and obtain created attachment - Attachment result = sendData(RedmineRequestFactoryImpl.ADD_ATTACHMENT, + Attachment result = sendData(ModelHelper.ADD_ATTACHMENT_REQUEST_NAME, Attachment.class, projectName, versionName, @@ -127,7 +128,7 @@ public News addNews(String projectName, News news) throws RedmineServiceException { // send data and obtain created news - News result = sendData(RedmineRequestFactoryImpl.ADD_NEWS, + News result = sendData(ModelHelper.ADD_NEWS_REQUEST_NAME, News.class, projectName, news @@ -140,7 +141,7 @@ String issueId, TimeEntry entry) throws RedmineServiceException { // send data and obtain updated version - TimeEntry result = sendData(RedmineRequestFactoryImpl.ADD_ISSUE_TIME_ENTRY, + TimeEntry result = sendData(ModelHelper.ADD_ISSUE_TIME_ENTRY_REQUEST_NAME, TimeEntry.class, projectName, issueId, Modified: trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceProviderImpl.java =================================================================== --- trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceProviderImpl.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-1.3.x/src/main/java/org/nuiton/jredmine/v1_3_x/RedmineServiceProviderImpl.java 2012-07-13 16:48:19 UTC (rev 288) @@ -9,8 +9,8 @@ * Implmentation of {@link RedmineServiceProvider} for this module. * * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.jredmine.RedmineServiceProvider" role-hint="1.3.x" * @since 1.4 - @plexus.component role="org.nuiton.jredmine.RedmineServiceProvider" role-hint="1.3.x" */ public class RedmineServiceProviderImpl implements RedmineServiceProvider { Modified: trunk/jredmine-client-1.3.x/src/test/java/org/nuiton/jredmine/v1_3_x/RedmineServiceAsAnonymousTest.java =================================================================== --- trunk/jredmine-client-1.3.x/src/test/java/org/nuiton/jredmine/v1_3_x/RedmineServiceAsAnonymousTest.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-1.3.x/src/test/java/org/nuiton/jredmine/v1_3_x/RedmineServiceAsAnonymousTest.java 2012-07-13 16:48:19 UTC (rev 288) @@ -28,7 +28,7 @@ * @author tchemit <chemit@codelutin.com> * @since 1.5 */ -public class RedmineServiceAsAnonymousTest { +public class RedmineServiceAsAnonymousTest { protected static final RedmineFixtures fixtures = new RedmineFixtures(); Modified: trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/model/ModelHelper.java =================================================================== --- trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2012-07-13 16:48:19 UTC (rev 288) @@ -23,6 +23,9 @@ * #L% */ +import org.nuiton.io.rest.RestRequestBuilder; +import org.nuiton.jredmine.request.DefaultRedmineRequestBuilder; + import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; @@ -37,6 +40,75 @@ */ public class ModelHelper { + public static final String GET_ALL_ISSUES_REQUEST_NAME = Issue.class.getName() + "/all"; + + public static final String GET_ALL_ISSUE_STATUS_REQUEST_NAME = IssueStatus.class.getName() + "/all"; + + public static final String GET_ALL_ISSUE_PRIORITY_REQUEST_NAME = IssuePriority.class.getName() + "/all"; + + public static final String GET_ALL_ISSUE_CATEGORY_REQUEST_NAME = IssueCategory.class.getName() + "/all"; + + public static final String GET_ALL_ISSUE_TIME_ENTRY_REQUEST_NAME = TimeEntry.class.getName() + "/all"; + + public static final String GET_ALL_PROJECT_REQUEST_NAME = Project.class.getName() + "/all"; + + public static final String GET_ALL_PROJECT_ISSUES_REQUEST_NAME = Project.class.getName() + "/all"; + + public static final String GET_ALL_PROJECT_OPENED_ISSUES_REQUEST_NAME = Project.class.getName() + "/opened-issues"; + + public static final String GET_ALL_PROJECT_CLOSED_ISSUES_REQUEST_NAME = Project.class.getName() + "/closed-issues"; + + public static final String GET_USER_PROJECTS_REQUEST_NAME = Project.class.getName() + "/forUser"; + + public static final String GET_PROJECT_REQUEST_NAME = Project.class.getName() + "/detail"; + + public static final String GET_ALL_VERSION_REQUEST_NAME = Version.class.getName() + "/all"; + + public static final String GET_ALL_TRACKER_REQUEST_NAME = Tracker.class.getName() + "/all"; + + public static final String GET_ALL_ATTACHMENTS_REQUEST_NAME = Attachment.class.getName() + "/all"; + + public static final String GET_ALL_USER_REQUEST_NAME = User.class.getName() + "/all"; + + public static final String GET_ALL_NEWS_REQUEST_NAME = News.class.getName() + "/all"; + + public static final String GET_VERSION_REQUEST_NAME = Version.class.getName() + "/detail"; + + public static final String ADD_VERSION_REQUEST_NAME = Version.class.getName() + "/add"; + + public static final String UPDATE_VERSION_REQUEST_NAME = Version.class.getName() + "/update"; + + public static final String NEXT_VERSION_REQUEST_NAME = Version.class.getName() + "/next"; + + public static final String ADD_NEWS_REQUEST_NAME = News.class.getName() + "/add"; + + public static final String ADD_ATTACHMENT_REQUEST_NAME = Attachment.class.getName() + "/add"; + + public static final String ADD_ISSUE_TIME_ENTRY_REQUEST_NAME = TimeEntry.class.getName() + "/add"; + + public static final String LOGIN_REQUEST_NAME = "login"; + + public static final String LOGOUT_REQUEST_NAME = "logout"; + + public static final String PING_REQUEST_NAME = "ping"; + + public static final String VERSION_SCOPE = "version"; + + public static final String PROJECT_SCOPE = "project"; + + public static final String ISSUE_SCOPE = "issue"; + + public static String getRequestScope(RestRequestBuilder requestBuilder) { + String scope; + if (requestBuilder instanceof DefaultRedmineRequestBuilder) { + + scope = ((DefaultRedmineRequestBuilder) requestBuilder).getScope(); + } else { + scope = null; + } + return scope; + } + public static <T extends IdAble> T byId(int id, T... datas) { for (T data : datas) { if (data.getId() == id) { Modified: trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-13 16:48:19 UTC (rev 288) @@ -50,7 +50,9 @@ protected final RestMethod method; - public DefaultRedmineRequestBuilder(String name, RestMethod method, String... action) { + public DefaultRedmineRequestBuilder(String name, + RestMethod method, + String... action) { this.name = name; this.action = action; this.method = method; @@ -61,6 +63,10 @@ return name; } + public String getScope() { + return null; + } + /** * Compute a array of pair (key-value) from the given arguments. * <p/> Modified: trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-13 16:48:19 UTC (rev 288) @@ -24,6 +24,7 @@ */ import org.nuiton.io.rest.RestMethod; +import org.nuiton.jredmine.model.ModelHelper; /** * To build request with a project and issue scope. @@ -35,10 +36,16 @@ private static final long serialVersionUID = 1L; - public IssueScopeRedmineRequestBuilder(String name, RestMethod method, String... action) { + public IssueScopeRedmineRequestBuilder(String name, + RestMethod method, + String... action) { super(name, method, action); } + public String getScope() { + return ModelHelper.ISSUE_SCOPE; + } + @Override public String[] getParameters(Object... args) { Modified: trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-13 16:48:19 UTC (rev 288) @@ -24,6 +24,7 @@ */ import org.nuiton.io.rest.RestMethod; +import org.nuiton.jredmine.model.ModelHelper; /** * To build request with a project scope. @@ -35,10 +36,16 @@ private static final long serialVersionUID = 1L; - public ProjectScopeRedmineRequestBuilder(String name,RestMethod method, String... action) { - super(name,method, action); + public ProjectScopeRedmineRequestBuilder(String name, + RestMethod method, + String... action) { + super(name, method, action); } + public String getScope() { + return ModelHelper.PROJECT_SCOPE; + } + @Override public String[] getPath(Object... args) { @@ -46,7 +53,7 @@ String projectName = (String) args[0]; - String[] result = new String[action.length+1]; + String[] result = new String[action.length + 1]; System.arraycopy(action, 0, result, 0, action.length); result[action.length] = projectName; return result; Modified: trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-client-api/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-13 16:48:19 UTC (rev 288) @@ -24,6 +24,7 @@ */ import org.nuiton.io.rest.RestMethod; +import org.nuiton.jredmine.model.ModelHelper; /** * To build request with a project and version scope. @@ -35,10 +36,16 @@ private static final long serialVersionUID = 1L; - public VersionScopeRedmineRequestBuilder(String name,RestMethod method, String... action) { - super(name, method,action); + public VersionScopeRedmineRequestBuilder(String name, + RestMethod method, + String... action) { + super(name, method, action); } + public String getScope() { + return ModelHelper.VERSION_SCOPE; + } + @Override public String[] getParameters(Object... args) { Modified: trunk/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java =================================================================== --- trunk/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2012-07-13 16:30:51 UTC (rev 287) +++ trunk/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2012-07-13 16:48:19 UTC (rev 288) @@ -26,6 +26,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import org.apache.commons.collections.CollectionUtils; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -44,9 +45,6 @@ import org.nuiton.jredmine.model.Tracker; import org.nuiton.jredmine.model.User; import org.nuiton.jredmine.model.Version; -import org.nuiton.jredmine.request.ProjectScopeRedmineRequestBuilder; -import org.nuiton.jredmine.request.VersionScopeRedmineRequestBuilder; -import org.nuiton.jredmine.v1_3_x.RedmineRequestFactoryImpl; import org.nuiton.plugin.PluginHelper; import java.util.Arrays; @@ -66,10 +64,6 @@ @Mojo(name = "display-data", requiresOnline = true, requiresProject = true) public class DisplayDataMojo extends AbstractRedmineMojo { - public static final String VERSION_SCOPE = "version"; - - public static final String PROJECT_SCOPE = "project"; - /** * The data types to display : {@code issueSatus}, {@code issuePriority}, * {@code issueCategory}, {@code tracker} and {@code user}. @@ -119,15 +113,15 @@ public DisplayDataMojo() { super(false, false, false); typesToRequestName = Maps.newHashMap(); - typesToRequestName.put(Project.class, RedmineRequestFactoryImpl.GET_PROJECT_LIST); - typesToRequestName.put(Version.class, RedmineRequestFactoryImpl.GET_VERSION_LIST); - typesToRequestName.put(Issue.class, RedmineRequestFactoryImpl.GET_ISSUE_LIST); - typesToRequestName.put(News.class, RedmineRequestFactoryImpl.GET_NEWS_LIST); - typesToRequestName.put(IssueStatus.class, RedmineRequestFactoryImpl.GET_ISSUE_STATUS_LIST); - typesToRequestName.put(IssuePriority.class, RedmineRequestFactoryImpl.GET_ISSUE_PRIORITY_LIST); - typesToRequestName.put(IssueCategory.class, RedmineRequestFactoryImpl.GET_ISSUE_CATEGORY_LIST); - typesToRequestName.put(Tracker.class, RedmineRequestFactoryImpl.GET_TRACKER_LIST); - typesToRequestName.put(User.class, RedmineRequestFactoryImpl.GET_USER_LIST); + typesToRequestName.put(Project.class, ModelHelper.GET_ALL_PROJECT_REQUEST_NAME); + typesToRequestName.put(Version.class, ModelHelper.GET_ALL_VERSION_REQUEST_NAME); + typesToRequestName.put(Issue.class, ModelHelper.GET_ALL_ISSUES_REQUEST_NAME); + typesToRequestName.put(News.class, ModelHelper.GET_ALL_NEWS_REQUEST_NAME); + typesToRequestName.put(IssueStatus.class, ModelHelper.GET_ALL_ISSUE_STATUS_REQUEST_NAME); + typesToRequestName.put(IssuePriority.class, ModelHelper.GET_ALL_ISSUE_PRIORITY_REQUEST_NAME); + typesToRequestName.put(IssueCategory.class, ModelHelper.GET_ALL_ISSUE_CATEGORY_REQUEST_NAME); + typesToRequestName.put(Tracker.class, ModelHelper.GET_ALL_TRACKER_REQUEST_NAME); + typesToRequestName.put(User.class, ModelHelper.GET_ALL_USER_REQUEST_NAME); namesToType = Maps.newHashMap(); namesToType.put("project", Project.class); @@ -184,7 +178,7 @@ @Override protected boolean checkSkip() { - if (actions == null || actions.isEmpty()) { + if (CollectionUtils.isEmpty(actions)) { // no data to treate getLog().warn("No data types detected, you must fill the required parameter types, will skip goal"); return false; @@ -197,18 +191,16 @@ protected void doAction() throws Exception { StringBuilder buffer = new StringBuilder("\n"); - RequestFactory requestFactory = - ((RedmineServiceImplementor) service).getSession().getRequestFactory(); for (Class<?> type : actions) { - String scope = getScope(requestFactory, type); + String scope = getDataScope(type); String requestName = typesToRequestName.get(type); IdAble[] datas; - if (VERSION_SCOPE.equals(scope)) { + if (ModelHelper.VERSION_SCOPE.equals(scope)) { datas = (IdAble[]) ((RedmineServiceImplementor) service).getDatas(requestName, type, projectId, versionId); - } else if (PROJECT_SCOPE.equals(scope)) { + } else if (ModelHelper.PROJECT_SCOPE.equals(scope)) { datas = (IdAble[]) ((RedmineServiceImplementor) service).getDatas(requestName, type, projectId); } else { datas = (IdAble[]) ((RedmineServiceImplementor) service).getDatas(requestName, type); @@ -218,46 +210,30 @@ Collections.sort(list, ModelHelper.ID_ABLE_COMPARATOR); } buffer.append("\nValues of '").append(requestName).append('\''); - if (VERSION_SCOPE.equals(scope) || PROJECT_SCOPE.equals(scope)) { + if (ModelHelper.VERSION_SCOPE.equals(scope) || ModelHelper.PROJECT_SCOPE.equals(scope)) { buffer.append(" for project '").append(projectId).append("'"); } - if (VERSION_SCOPE.equals(scope)) { + if (ModelHelper.VERSION_SCOPE.equals(scope)) { buffer.append(" and version '").append(versionId).append("'"); } buffer.append('\n'); for (IdAble data : list) { - buffer.append(" - ").append(data.getId()).append(" = ").append(((I18nAble) data).getName()).append('\n'); + buffer.append(" - "); + buffer.append(data.getId()); + buffer.append(" = "); + buffer.append(((I18nAble) data).getName()); + buffer.append('\n'); } } System.out.println(buffer.toString()); } - protected String getScope(RequestFactory requestFactory, Class<?> type) { - String scope; - - String requestName = typesToRequestName.get(type); - RestRequestBuilder requestBuilder = - requestFactory.getRequestBuilder(requestName); - - if (requestBuilder instanceof VersionScopeRedmineRequestBuilder) { - scope = VERSION_SCOPE; - } else if (requestBuilder instanceof ProjectScopeRedmineRequestBuilder) { - scope = PROJECT_SCOPE; - } else { - scope = null; - } - return scope; - } - protected List<Class<?>> getDownloadActions() throws MojoFailureException { List<Class<?>> results = Lists.newArrayList(); List<Class<?>> universeList = Lists.newArrayList(typesToRequestName.keySet()); - RequestFactory requestFactory = - ((RedmineServiceImplementor) service).getSession().getRequestFactory(); - for (String dataType : types.split(",")) { dataType = dataType.toLowerCase(Locale.ENGLISH); @@ -266,22 +242,31 @@ if (result == null || !universeList.contains(result)) { // can not accept these value - throw new MojoFailureException("The data type '" + result + "' can not be used, Accepted types are : " + universeList); + throw new MojoFailureException( + "The data type '" + result + + "' can not be used, Accepted types are : " + + universeList); } - String scope = getScope(requestFactory, result); + String scope = getDataScope(result); - if (VERSION_SCOPE.equals(scope) || PROJECT_SCOPE.equals(scope)) { + if (ModelHelper.VERSION_SCOPE.equals(scope) || ModelHelper.PROJECT_SCOPE.equals(scope)) { // check projectId used if (projectId == null || projectId.isEmpty()) { - throw new MojoFailureException("The data type '" + result + "', depends on a project, but the 'projectId' was not filled."); + throw new MojoFailureException( + "The data type '" + result + + "', depends on a project, but the 'projectId' was " + + "not filled."); } } - if (VERSION_SCOPE.equals(scope)) { + if (ModelHelper.VERSION_SCOPE.equals(scope)) { // check versionId use if (versionId == null || versionId.isEmpty()) { - throw new MojoFailureException("The data type '" + result + "', depends on a version, but the 'versionId' was not filled."); + throw new MojoFailureException( + "The data type '" + result + + "', depends on a version, but the 'versionId' was " + + "not filled."); } } results.add(result); @@ -289,46 +274,20 @@ return results; } -// protected List<RedmineModelEnum> getDownloadActions(String dataTypes, RedmineModelEnum... universe) throws MojoFailureException { -// -// if (universe.length == 0) { -// throw new MojoFailureException("List of accepted data types is empty!"); -// } -// -// List<RedmineModelEnum> results = new ArrayList<RedmineModelEnum>(); -// -// List<RedmineModelEnum> universeList = new ArrayList<RedmineModelEnum>(Arrays.asList(universe)); -// -// for (String dataType : dataTypes.split(",")) { -// -// RedmineModelEnum result; -// try { -// result = RedmineModelEnum.valueOf(dataType.trim()); -// } catch (Exception e) { -// throw new MojoFailureException("Unkown data type '" + dataType + "', Accepted types are : " + universeList); -// } -// if (!universeList.contains(result)) { -// // can not accept these value -// throw new MojoFailureException("The data type '" + result + "' can not be used, Accepted types are : " + universeList); -// } -// -// RedmineModelScope scope = result.getScope(); -// -// if (scope == RedmineModelScope.project || scope == RedmineModelScope.version) { -// -// // check projectId used -// if (projectId == null || projectId.isEmpty()) { -// throw new MojoFailureException("The data type '" + result + "', depends on a project, but the 'projectId' was not filled."); -// } -// } -// if (scope == RedmineModelScope.version) { -// // check versionId use -// if (versionId == null || versionId.isEmpty()) { -// throw new MojoFailureException("The data type '" + result + "', depends on a version, but the 'versionId' was not filled."); -// } -// } -// results.add(result); -// } -// return results; -// } + protected String getDataScope(Class<?> type) { + + RequestFactory requestFactory = + ((RedmineServiceImplementor) service).getSession().getRequestFactory(); + + + String scope; + + String requestName = typesToRequestName.get(type); + RestRequestBuilder requestBuilder = + requestFactory.getRequestBuilder(requestName); + + return ModelHelper.getRequestScope(requestBuilder); + } + + }
participants (1)
-
tchemit@users.nuiton.org