r61 - in trunk: jredmine-client/src/main/java/org/nuiton/jredmine jredmine-client/src/main/java/org/nuiton/jredmine/model jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3 jredmine-client/src/main/java/org/nuiton/jredmine/rest jredmine-client/src/main/redmine/jredmine/app/controllers jredmine-client/src/main/resources/META-INF/services jredmine-client/src/site/apt jredmine-client/src/test/java/org/nuiton/jredmine jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp
Author: tchemit Date: 2010-01-01 18:35:21 +0100 (Fri, 01 Jan 2010) New Revision: 61 Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-empty/timeEntrys.xml trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-multi/timeEntrys.xml trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-singleton/timeEntrys.xml trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/single/timeEntry.xml Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Attachment.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/io/xpp3/RedmineXpp3Helper.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/RedmineRestClient.java trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb trunk/jredmine-client/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader trunk/jredmine-client/src/site/apt/index.apt trunk/jredmine-client/src/site/apt/rails_api.apt trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.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 trunk/maven-jredmine-plugin/pom.xml trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AnnouncementGenerator.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojo.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractRedmineReport.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssueReportGenerator.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReport.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByAssignee.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByCategory.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByPriority.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByReporter.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByStatus.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByTracker.java trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByVersion.java trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java Log: - use last version of mavenpom and maven-helper-plugin new api - improve test with a common contract for both rest client and service test - Evolution #144: Am?\195?\169lioration de l'api de gestion des taches Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/DefaultRedmineService.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,33 +20,22 @@ */ package org.nuiton.jredmine; -import java.io.IOException; - -import org.nuiton.io.rest.RestException; -import org.nuiton.jredmine.model.Attachment; -import org.nuiton.jredmine.model.News; -import org.nuiton.jredmine.model.Version; 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; import org.nuiton.io.rest.RestRequest; +import org.nuiton.jredmine.model.*; +import org.nuiton.jredmine.model.io.xpp3.RedmineXpp3Helper; +import org.nuiton.jredmine.rest.RedmineRestClient; +import java.io.IOException; import java.io.InputStream; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.nuiton.io.rest.RestClientConfiguration; -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.Project; -import org.nuiton.jredmine.model.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.io.xpp3.RedmineXpp3Helper; -import org.nuiton.jredmine.rest.RedmineRestClient; - /** - * Default {@link RedmineService} implementation base on a {@link RestClient} + * Default {@link RedmineService} implementation based on a {@link RestClient} * * @author chemit * @plexus.component role="org.nuiton.jredmine.RedmineService" role-hint="default" @@ -161,6 +150,22 @@ } @Override + public TimeEntry addIssueTimeEntry(String projectName, String issueId, TimeEntry entry) throws RedmineServiceException { + checkInit(); + RestRequest r = getRequest(RedmineRestClient.ADD_ISSUE_TIME_ENTRY, projectName, issueId, entry); + + // send data and obtain updated version + try { + + InputStream stream = session.sendData(r); + TimeEntry timeEntry = getDataFromStream(TimeEntry.class, stream); + return timeEntry; + } catch (Exception e) { + throw new RedmineServiceException("could not send for reason " + e.getMessage(), e); + } + } + + @Override public IssueStatus[] getIssueStatuses() throws RedmineServiceException { return getDatas(IssueStatus.class); } @@ -220,6 +225,100 @@ return getDatas(Issue.class, projectName, versionName); } + @Override + public TimeEntry[] getIssueTimeEntries(String projectName, String issueId) throws RedmineServiceException { + return getDatas(TimeEntry.class, projectName, issueId); + } + + @Override + public Project[] getUserProjects() throws RedmineServiceException { + + Class<Project> type = Project.class; + RestRequest r = getRequest(RedmineRestClient.GET_USER_PROJECTS); + + // obtain data from rest client + InputStream stream; + try { + + stream = session.askData(r); + + } catch (Exception e) { + throw new RedmineServiceException("could not obtain data stream for type " + type.getName() + "forUser for reason " + e.getMessage(), e); + } + + if (stream == null) { + return null; + } + Project[] projects = getDatasFromStream(type, stream); + return projects; + } + + @Override + public Issue[] getIssues(String projectName) throws RedmineServiceException { + Class<Issue> type = Issue.class; + RestRequest r = getRequest(RedmineRestClient.GET_PROJECT_ISSUES, projectName); + + // obtain data from rest client + InputStream stream; + try { + + stream = session.askData(r); + + } catch (Exception e) { + throw new RedmineServiceException("could not obtain data stream for type " + r + " for reason " + e.getMessage(), e); + } + + if (stream == null) { + return null; + } + Issue[] issues = getDatasFromStream(type, stream); + return issues; + } + + @Override + public Issue[] getOpenedIssues(String projectName) throws RedmineServiceException { + Class<Issue> type = Issue.class; + RestRequest r = getRequest(RedmineRestClient.GET_PROJECT_OPENED_ISSUES, projectName); + + // obtain data from rest client + InputStream stream; + try { + + stream = session.askData(r); + + } catch (Exception e) { + throw new RedmineServiceException("could not obtain data stream for type " + type.getName() + "forUser for reason " + e.getMessage(), e); + } + + if (stream == null) { + return null; + } + Issue[] issues = getDatasFromStream(type, stream); + return issues; + } + + @Override + public Issue[] getClosedIssues(String projectName) throws RedmineServiceException { + Class<Issue> type = Issue.class; + RestRequest r = getRequest(RedmineRestClient.GET_PROJECT_CLOSED_ISSUES, projectName); + + // obtain data from rest client + InputStream stream; + try { + + stream = session.askData(r); + + } catch (Exception e) { + throw new RedmineServiceException("could not obtain data stream for type " + type.getName() + "forUser for reason " + e.getMessage(), e); + } + + if (stream == null) { + return null; + } + Issue[] issues = getDatasFromStream(type, stream); + return issues; + } + /////////////////////////////////////////////////////////////////////////// /// RedmineServiceImplementor implementation /////////////////////////////////////////////////////////////////////////// Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,16 +20,7 @@ */ package org.nuiton.jredmine; -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.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.*; /** * The service that mirrors the rails {@code jredmine} plugin. @@ -54,6 +45,20 @@ Project[] getProjects() throws RedmineServiceException; /** + * Obtain for the loggued user, all projets where he belongs. + * <p/> + * <b>Note:</b> this method could return less projects than the method + * {@link #getProjects()} since here the user must belongs to the project + * and not just can access it. + * + * @return all the projects belonged by the loggued user + * @throws RedmineServiceException if any pb while retriving datas + * @see Project + * @since 1.0.3 + */ + Project[] getUserProjects() throws RedmineServiceException; + + /** * Obtain all the priorities defined on a {@link Issue}. * <p/> * <b>Note : </b> The priorities are common for all projects. @@ -147,6 +152,39 @@ Version getVersion(String projectName, String versionName) throws RedmineServiceException; /** + * Obtain all issues for a given project + * + * @param projectName the name of the project + * @return the issues + * @throws RedmineServiceException if any pb while retriving datas + * @see Issue + * @since 1.0.3 + */ + Issue[] getIssues(String projectName) throws RedmineServiceException; + + /** + * Obtain all opened issues for a given project + * + * @param projectName the name of the project + * @return the issues + * @throws RedmineServiceException if any pb while retriving datas + * @see Issue + * @since 1.0.3 + */ + Issue[] getOpenedIssues(String projectName) throws RedmineServiceException; + + /** + * Obtain all closed issues for a given project + * + * @param projectName the name of the project + * @return the issues + * @throws RedmineServiceException if any pb while retriving datas + * @see Issue + * @since 1.0.3 + */ + Issue[] getClosedIssues(String projectName) throws RedmineServiceException; + + /** * Obtain all issues for a specific version on a given project * * @param projectName the name of the project @@ -227,4 +265,30 @@ * @see Attachment */ Attachment addAttachment(String projectName, String versionName, Attachment attachement) throws RedmineServiceException; + + /** + * Obtain for a given issue of a given project all the time entries. + * + * @param projectName the name of the project + * @param issueId the id of the issue + * @return the time entries of the issue + * @throws RedmineServiceException if any pb while retrieving time entries of the issue + * @since 1.0.3 + */ + TimeEntry[] getIssueTimeEntries(String projectName, String issueId) throws RedmineServiceException; + + /** + * Add a new time entry to the given issue for the given project and + * return the updated time entry. + * + * @param projectName the name of the project + * @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 + * @see Issue + * @see TimeEntry + * @since 1.0.3 + */ + TimeEntry addIssueTimeEntry(String projectName, String issueId, TimeEntry entry) throws RedmineServiceException; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,17 +20,18 @@ */ package org.nuiton.jredmine; -import java.io.InputStream; import org.nuiton.io.rest.RestClient; import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.jredmine.rest.RedmineRestClient; +import java.io.InputStream; + /** * Technical contrat te be implemented in a {@link RedmineService}. + * <p/> + * Any concrete implentation of a {@link RedmineService} should (must ?) also + * implements this contract. * - * Any concrete implentation of a {@link RedmineService} should also implements - * this service. - * * @author chemit * @since 1.0.0 */ @@ -38,79 +39,79 @@ /** * Tests if the service is loogued to the redmine service. - * + * * @return {@code true} is service is init and loggued to Redmine service, - * {@code false} otherwise. + * {@code false} otherwise. */ boolean isInit(); /** * Initialize the service given a redmine client already initialized. - * + * * @param client the redmine client to be used by the service * @return the initialized service - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb * @see RedmineRestClient */ RedmineServiceImplementor init(RestClient client) throws RedmineServiceException; /** * Initialize the service given a client configuration. - * + * * @param configuration the configuration to be used to init the internal redmine client * @return the initialized service - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb */ RedmineServiceImplementor init(RestClientConfiguration configuration) throws RedmineServiceException; /** - * Close the service and destroy any connexions to the redmine service. + * Close the service and destroy any connexion to the redmine service. * - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb */ void destroy() throws RedmineServiceException; /** * Generic method to obtain a single data from a redmine server. - * - * @param <T> the type of data to obtain + * + * @param <T> the type of data to obtain * @param type the type of data to obtain * @param args the parameters to obtain the data * @return the obtained data - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb */ <T> T getData(Class<T> type, Object... args) throws RedmineServiceException; /** * Generic method to obtain a array of data from a redmine server. * - * @param <T> the type of data to obtain + * @param <T> the type of data to obtain * @param type the type of data to obtain * @param args the parameters to obtain the datas * @return the obtained datas - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb */ <T> T[] getDatas(Class<T> type, Object... args) throws RedmineServiceException; /** * Generic method to obtain an input stream of a data from a redmine server. * - * @param <T> the type of data to obtain + * @param <T> the type of data to obtain * @param type the type of data to obtain * @param args the parameters to obtain the data * @return the input stream containing the data - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb */ <T> InputStream getDataStream(Class<T> type, Object... args) throws RedmineServiceException; /** * Generic method to obtain an input stream of an array of data from a redmine server. * - * @param <T> the type of data to obtain + * @param <T> the type of data to obtain * @param type the type of data to obtain * @param args the parameters to obtain the datas * @return the input stream containing the datas - * @throws RedmineServiceException + * @throws RedmineServiceException if any pb */ <T> InputStream getDatasStream(Class<T> type, Object... args) throws 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Attachment.java 2010-01-01 17:35:21 UTC (rev 61) @@ -31,14 +31,6 @@ */ public class Attachment implements IdAble { -// public static Attachment getAttachmentById(Integer attachmentId, Attachment[] list) { -// for (Attachment i : list) { -// if (i.getId() == attachmentId) { -// return i; -// } -// } -// return null; -// } protected int id; protected int authorId; protected int containerId; 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java 2010-01-01 17:35:21 UTC (rev 61) @@ -37,7 +37,9 @@ news(News.class, RedmineModelScope.project), version(Version.class, RedmineModelScope.project), issue(Issue.class, RedmineModelScope.version), + timeEntry(TimeEntry.class, RedmineModelScope.issue), attachment(Attachment.class, RedmineModelScope.version); + private final Class<?> modelType; private final RedmineModelScope scope; 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java 2010-01-01 17:35:21 UTC (rev 61) @@ -21,19 +21,21 @@ package org.nuiton.jredmine.model; /** - * * Une enumeration pour caracteriser le scope d'une donnée dans le modèle. - * * <p/> + * <p/> * Pour une donnée qui ne dépend de rien, elle est en scope {@link #none}. * <p/> * Pour une donnée qui dépend d'un projet, elle est en scope {@link #project}. * <p/> * Pour une donnée qui dépend d'une version, elle est en scpoe {@link #version}. + * <p/> + * Pour une donnée qui dépend d'une issue, elle est en scpoe {@link #issue}. + * <p/> + * A savoir qu'une donnée de scope {@link #version} (resp. {@link #issue}), + * elle est aussi de scope {@link #project} car la version (resp. l'issue) + * dépend en dépend. * - * A savoir qu'une donnée de scope {@link #version}, elle est aussi de scope - * {@link #project} car la version dépend en dépend. - * * @author chemit * @since 1.0.0 */ @@ -50,5 +52,9 @@ /** * version scope, requires a project and a version */ - version + version, + /** + * issue scope, requires a project and an issue + */ + issue; } Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java (rev 0) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,138 @@ +package org.nuiton.jredmine.model; + +import java.util.Date; + +/** + * Created: 31 déc. 2009 + * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ par : + * $Author: tchemit $ + * @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; + + @Override + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getActivityId() { + return activityId; + } + + public void setActivityId(int activityId) { + this.activityId = activityId; + } + + public int getIssueId() { + return issueId; + } + + public void setIssueId(int issueId) { + this.issueId = issueId; + } + + public int getProjectId() { + return projectId; + } + + public void setProjectId(int projectId) { + this.projectId = projectId; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public Date getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + public float getHours() { + return hours; + } + + public void setHours(float hours) { + this.hours = hours; + } + + public Date getSpentOn() { + return spentOn; + } + + public void setSpentOn(Date spentOn) { + this.spentOn = spentOn; + } + + public int getTmonth() { + return tmonth; + } + + public void setTmonth(int tmonth) { + this.tmonth = tmonth; + } + + public int getTweek() { + return tweek; + } + + public void setTweek(int tweek) { + this.tweek = tweek; + } + + public int getTyear() { + return tyear; + } + + public void setTyear(int tyear) { + this.tyear = tyear; + } + + public Date getUpdatedOn() { + return updatedOn; + } + + public void setUpdatedOn(Date updatedOn) { + this.updatedOn = updatedOn; + } +} Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/TimeEntry.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,20 +20,16 @@ */ package org.nuiton.jredmine.model.io.xpp3; -import java.io.ByteArrayInputStream; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; import org.nuiton.io.xpp3.Xpp3Helper; import org.nuiton.jredmine.model.RedmineModelEnum; +import java.io.*; + /** * Pour construire le modèle à partir de fichiers xml contenant les données. - * + * * @author chemit * @since 1.0.0 */ Added: 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 (rev 0) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,52 @@ +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; + +/** + * Created: 31 déc. 2009 + * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ par : + * $Author: tchemit $ + */ +public class TimeEntryXpp3Reader extends AbstractXpp3Reader<TimeEntry> { + + public TimeEntryXpp3Reader() { + super(TimeEntry.class, "time-entries", "time-entry"); + } + + @Override + protected void initMappers() throws IntrospectionException { + + addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Integer, true, allMappers, + "id", + "activity-id", + "issue-id", + "project-id", + "user-id", + "tyear", + "tmonth", + "tweek" + ); + + addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Float, true, allMappers, + "hours" + ); + + addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Datetime, true, allMappers, + "created-on", + "updated-on"); + + addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Date, true, allMappers, + "spent-on"); + + addTagTextContentMappers(TimeEntry.class, RedmineDataConverter.Text, true, allMappers, + "comments"); + } +} Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java (rev 0) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,33 @@ +package org.nuiton.jredmine.rest; + +/** + * Builder of requests which are in a project and issue context. + * <p/> + * Created: 1 janv. 2010 + * + * @author Tony Chemit <chemit@codelutin.com> Copyright Code Lutin + * @version $Revision$ + * <p/> + * Mise a jour: $Date$ par : + * $Author: tchemit $ + * @since 1.0.3 + */ +public class IssueScopeRequestBuilder extends ProjectScopeRequestBuilder { + + public IssueScopeRequestBuilder(String name, String action) { + super(name, action); + } + + @Override + public String[] getParameters(Object... args) { + + // args 1 = project id + // args 2 = issue id + + String issueId = (String) args[1]; + + return new String[]{ + "issue_id", issueId + }; + } +} Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/IssueScopeRequestBuilder.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/rest/RedmineRestClient.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,13 +20,6 @@ */ package org.nuiton.jredmine.rest; -import java.io.File; -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.HashMap; -import java.util.Map; - import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.StatusLine; @@ -36,17 +29,16 @@ import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.io.rest.RestRequest; import org.nuiton.io.rest.RestSession; -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.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.*; +import java.io.File; +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + /** * Implementation of a {@link RestClient} to access a Redmine server via the * {@code redmine_rest} rails plugin. @@ -63,7 +55,12 @@ 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"; @@ -76,6 +73,7 @@ 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"; @@ -106,24 +104,22 @@ // with no scope addRequestBuilder(new DefaultRequestBuilder(GET_PROJECT_LIST, "get_projects.xml")); + addRequestBuilder(new DefaultRequestBuilder(GET_USER_PROJECTS, "get_user_projects.xml")); addRequestBuilder(new DefaultRequestBuilder(GET_ISSUE_STATUS_LIST, "get_issue_statuses.xml")); addRequestBuilder(new DefaultRequestBuilder(GET_ISSUE_PRIORITY_LIST, "get_issue_priorities.xml")); // with project scope addRequestBuilder(new ProjectScopeRequestBuilder(GET_PROJECT, "get_project.xml")); + addRequestBuilder(new ProjectScopeRequestBuilder(GET_PROJECT_ISSUES, "get_project_issues.xml")); + addRequestBuilder(new ProjectScopeRequestBuilder(GET_PROJECT_OPENED_ISSUES, "get_project_opened_issues.xml")); + addRequestBuilder(new ProjectScopeRequestBuilder(GET_PROJECT_CLOSED_ISSUES, "get_project_closed_issues.xml")); addRequestBuilder(new ProjectScopeRequestBuilder(GET_VERSION_LIST, "get_project_versions.xml")); addRequestBuilder(new ProjectScopeRequestBuilder(GET_ISSUE_CATEGORY_LIST, "get_issue_categories.xml")); addRequestBuilder(new ProjectScopeRequestBuilder(GET_TRACKER_LIST, "get_project_trackers.xml")); addRequestBuilder(new ProjectScopeRequestBuilder(GET_USER_LIST, "get_project_users.xml")); addRequestBuilder(new ProjectScopeRequestBuilder(GET_NEWS_LIST, "get_project_news.xml")); - // with version scope - - addRequestBuilder(new VersionScopeRequestBuilder(GET_VERSION, "get_version.xml")); - addRequestBuilder(new VersionScopeRequestBuilder(GET_ISSUE_LIST, "get_version_issues.xml")); - addRequestBuilder(new VersionScopeRequestBuilder(GET_ATTACHMENTS_LIST, "get_version_attachments.xml")); - addRequestBuilder(new ProjectScopeRequestBuilder(ADD_VERSION, "add_version.xml") { @Override @@ -182,6 +178,13 @@ } }); + // with version scope + + addRequestBuilder(new VersionScopeRequestBuilder(GET_VERSION, "get_version.xml")); + addRequestBuilder(new VersionScopeRequestBuilder(GET_ISSUE_LIST, "get_version_issues.xml")); + addRequestBuilder(new VersionScopeRequestBuilder(GET_ATTACHMENTS_LIST, "get_version_attachments.xml")); + + addRequestBuilder(new VersionScopeRequestBuilder(ADD_ATTACHMENT, "add_version_attachment.xml") { @Override @@ -202,6 +205,33 @@ return upload; } }); + + // with issue scope + + addRequestBuilder(new IssueScopeRequestBuilder(GET_ISSUE_TIME_ENTRY_LIST, "get_issue_times.xml")); + + addRequestBuilder(new IssueScopeRequestBuilder(ADD_ISSUE_TIME_ENTRY, "add_issue_time.xml") { + + @Override + public String[] getParameters(Object... args) { + String issueId = (String) args[1]; + TimeEntry timeEntry = (TimeEntry) args[2]; + Date d = timeEntry.getSpentOn(); + if (d == null) { + d = new Date(); + } + String date = DATE_FORMAT.format(d); + return new String[]{ + "issue_id", issueId, + //"timeEntry[issue_id]", issueId, + "time_entry[activity_id]", timeEntry.getActivityId() + "", + "time_entry[spent_on]", date, + "time_entry[hours]", timeEntry.getHours() + "", + "time_entry[comments]", timeEntry.getComments() == null ? "" : timeEntry.getComments() + }; + } + }); + } @Override Modified: trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb =================================================================== --- trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/redmine/jredmine/app/controllers/jredmine_controller.rb 2010-01-01 17:35:21 UTC (rev 61) @@ -4,13 +4,16 @@ before_filter :find_user, :except => [:ping, :login] # find project and check permission - before_filter :find_project, :except => [:ping, :login, :logout, :get_projects, :get_issue_statuses, :get_issue_priorities] + before_filter :find_project, :except => [:ping, :login, :logout, :get_projects, :get_user_projects, :get_issue_statuses, :get_issue_priorities] # find project's version before_filter :find_version, :only => [:get_version, :get_version_issues, :get_version_attachments, :add_version_attachment] + # find project's issue + before_filter :find_issue, :only => [:get_issue_times, :add_issue_time, :update_time_issue] + # check can edit project before push requests - #before_filter :check_edit, :only => [:add_version, :update_version, :add_news, :add_attachment, :add_version_attachment] + #before_filter :check_edit, :only => [:add_version, :update_version, :add_news, :add_attachment, :add_version_attachment, :add_issue_time, :update_issue_time] # ping service (just to test if service is reachable) def ping @@ -57,7 +60,19 @@ @projects = Project.find(:all) render_array_result @projects, "projects" end - + + # recuperation des projets dont l'utilisateur connecte est membre + def get_user_projects + projectsIds = User.current.memberships.collect{|m| m.project_id} + result = [] + for id in projectsIds + p = @project = Project.find(id) + result << p + end + render_array_result result, "projects" + end + + # recuperation des priorities d'issues def get_issue_priorities get_enumeration "IPRI" @@ -111,6 +126,39 @@ render_array_result @versions, "versions" end + # recuperation de toutes les issues d'un projet + def get_project_issues + r =@project.issues.find(:all) + render_array_result r, "issues" + end + + # recuperation de toutes les issues ouvertes d'un projet + def get_project_opened_issues + r = [] + for i in @project.issues.find(:all) + if !i.closed? && i.status_id != 3 + r << i + end + end + render_array_result r, "issues" + end + + # recuperation de toutes les issues fermees d'un projet + def get_project_closed_issues + r = [] + for i in @project.issues.find(:all) + if i.closed? || i.status_id == 3 + r << i + end + end + render_array_result r, "issues" + end + + # recuperation des temps d'une issue + def get_issue_times + render_array_result @issue.time_entries, "timeEntries" + end + # recuperation de la version d'un projet def get_version render_result @version @@ -294,6 +342,44 @@ end render_result a end + + def add_issue_time(timeEntry = params["time_entry"]) + if !request.post? + render_status 405, "POST method required for action add_issue_time" + return false + end + allowed = User.current.allowed_to?(:log_time, @project) + if !allowed + msg = "No permission to add a issue time entry on project "+ @project.name + render_status 401, msg + end + @notes = params[:notes] + journal = @issue.init_journal(User.current, @notes) + @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today) + @time_entry.attributes = timeEntry + + call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal}) + + if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save + # Log spend time + @time_entry.save + else + render_status 505, "Could not save the time entry " + @time_entry + end + if !journal.new_record? + # Only send notification if something was actually changed + Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') + end + render_result @time_entry + end + + def update_issue_time(timeEntry = params["time_entry"]) + if !request.post? + render_status 405, "POST method required for action update_issue_time" + return false + end + + end private @@ -351,7 +437,14 @@ render_status 404, "#{version} is not a version for project #{@project.name}" end end - + + def find_issue(issue = params[:issue_id]) + @issue = @project.issues.find(issue) + if !@issue + render_status 404, "#{issue} is not an issue for project #{@project.name}" + end + end + def render_status(code,message) render :text => message, :status => code end Modified: trunk/jredmine-client/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader =================================================================== --- trunk/jredmine-client/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/main/resources/META-INF/services/org.nuiton.io.xpp3.Xpp3Reader 2010-01-01 17:35:21 UTC (rev 61) @@ -8,3 +8,4 @@ org.nuiton.jredmine.model.io.xpp3.TrackerXpp3Reader org.nuiton.jredmine.model.io.xpp3.UserXpp3Reader org.nuiton.jredmine.model.io.xpp3.VersionXpp3Reader +org.nuiton.jredmine.model.io.xpp3.TimeEntryXpp3Reader Modified: trunk/jredmine-client/src/site/apt/index.apt =================================================================== --- trunk/jredmine-client/src/site/apt/index.apt 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/site/apt/index.apt 2010-01-01 17:35:21 UTC (rev 61) @@ -64,11 +64,11 @@ -------------------------------------------------------------------------------- # jredmine : ping, login , logout, with no project context... map.connect 'jredmine/:action', :controller => 'jredmine' ,:action => ['ping',\ - 'login', 'logout', 'get_projects', 'get_issue_statuses', \ + 'login', 'logout', 'get_projects', 'get_user_projects', 'get_issue_statuses', \ 'get_issue_priorities'] map.connect 'jredmine/:action.:format', :controller => 'jredmine' ,:action => \ -['get_projects', 'get_issue_statuses', 'get_issue_priorities'], \ -:format => ['xml', 'json'] +['get_projects', 'get_user_projects', 'get_issue_statuses', \ + 'get_issue_priorities'], :format => ['xml', 'json'] # jredmine/action/?? (:project_id) map.connect 'jredmine/:action/:project_id', :controller => 'jredmine' Modified: trunk/jredmine-client/src/site/apt/rails_api.apt =================================================================== --- trunk/jredmine-client/src/site/apt/rails_api.apt 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/site/apt/rails_api.apt 2010-01-01 17:35:21 UTC (rev 61) @@ -77,13 +77,15 @@ API de lecture - On distingue trois niveaux de données récupérables : + On distingue quatre niveaux de données récupérables : * les données qui ne dépendent pas d'un projet * les données qui dépendent d'un projet * les données qui dépendent d'une version d'un projet + + * les données qui dépendent d'une issued'un projet * Services des données indépendantes @@ -92,6 +94,8 @@ *--------------------------*-----------------------------------+ | <<get_projects>> | tous les projets | *--------------------------*-----------------------------------+ +| <<get_user_projects>> | tous les projets dont l'utilisateur connecté est membre | +*--------------------------*-----------------------------------+ | <<get_issue_statuses>> | tous les status de demandes | *--------------------------*-----------------------------------+ | <<get_issue_priorities>> | toutes les prioritiés de demandes | @@ -108,6 +112,17 @@ jredmine/get_projects.json -------------------------------------------------------------------------------- +** get_user_projects + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_user_projects.xml +jredmine/get_user_projects.json +-------------------------------------------------------------------------------- + ** get_issue_statuses Ce service ne requiert pas de paramètre. @@ -132,19 +147,25 @@ * Services des données dépendantes d'un projet -*--------------------------*---------------------------------------+ -| <action[.xml\|.json]> | <données récupérées pour un projet> | -*--------------------------*---------------------------------------+ -| <<get_projet>> | le projet | -*--------------------------*---------------------------------------+ -| <<get_issue_categories>> | touts les catégories de demande | -*--------------------------*---------------------------------------+ -| <<get_project_users>> | tous les membres du projet | -*--------------------------*---------------------------------------+ -| <<get_project_trackers>> | tous les types de tracker | -*--------------------------*---------------------------------------+ -| <<get_project_versions>> | toutes les versions d'un projet | -*--------------------------*---------------------------------------+ +*-------------------------------*---------------------------------------+ +| <action[.xml\|.json]> | <données récupérées pour un projet> | +*-------------------------------*---------------------------------------+ +| <<get_projet>> | le projet | +*-------------------------------*---------------------------------------+ +| <<get_issue_categories>> | touts les catégories de demande | +*-------------------------------*---------------------------------------+ +| <<get_project_users>> | tous les membres du projet | +*-------------------------------*---------------------------------------+ +| <<get_project_trackers>> | tous les types de tracker | +*-------------------------------*---------------------------------------+ +| <<get_project_versions>> | toutes les versions d'un projet | +*-------------------------------*---------------------------------------+ +| <<get_project_issues>> | toutes les issues d'un projet | +*-------------------------------*---------------------------------------+ +| <<get_project_opened_issues>> | toutes les issues ouvertes d'un projet| +*-------------------------------*---------------------------------------+ +| <<get_project_closed_issues>> | toutes les issues fermées d'un projet | +*-------------------------------*---------------------------------------+ ** get_projet @@ -201,6 +222,17 @@ jredmine/get_project_versions.json/myProject -------------------------------------------------------------------------------- +** get_issues + + Ce service ne requiert pas de paramètre. + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_project_issues.xml/myProject +jredmine/get_project_issues.json/myProject +-------------------------------------------------------------------------------- + * Services des données dépendantes d'une version d'un projet *------------------------------*-----------------------------------------------------+ @@ -252,23 +284,48 @@ jredmine/get_versions_attachments.json/myProject?version_name=myVersion -------------------------------------------------------------------------------- +* Services des données dépendantes d'une issue d'un projet + +*--------------------------*---------------------------------------------------+ +| <action[.xml\|.json]> | <données récupérées pour une issue d'un projet> | +*--------------------------*---------------------------------------------------+ +| <<get_issue_times>> | les temps de l'issue | +*--------------------------*---------------------------------------------------+ + +** get_issue_times + + Ce service requiert un paramètre : + + * <<issue_id>> l'id de l'issue + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/get_issue_time.xml/myProject?issue_id=myIssueId +jredmine/get_issue_time.json/myProject?issue_id=myIssueId +-------------------------------------------------------------------------------- + API d'actions -*----------------------------*----------------------------------------------+ -| <action> | <description> | -*----------------------------*----------------------------------------------+ -| <<add_version>> | ajouter une version à un projet | -*----------------------------*----------------------------------------------+ -| <<update_version>> | mettre à jour une version d'un projet | -*----------------------------*----------------------------------------------+ -| <<next_version>> | préparer la prochaine version d'un projet | -*----------------------------*----------------------------------------------+ -| <<add_attachment>> | ajouter un fichier à un projet | -*----------------------------*----------------------------------------------+ -| <<add_version_attachment>> | ajouter un fichier à une version d'un projet | -*----------------------------*----------------------------------------------+ -| <<add_news>> | ajouter une annonce à un projet | -*----------------------------*----------------------------------------------+ +*----------------------------*-----------------------------------------------+ +| <action> | <description> | +*----------------------------*-----------------------------------------------+ +| <<add_version>> | ajouter une version à un projet | +*----------------------------*-----------------------------------------------+ +| <<update_version>> | mettre à jour une version d'un projet | +*----------------------------*-----------------------------------------------+ +| <<next_version>> | préparer la prochaine version d'un projet | +*----------------------------*-----------------------------------------------+ +| <<add_attachment>> | ajouter un fichier à un projet | +*----------------------------*-----------------------------------------------+ +| <<add_version_attachment>> | ajouter un fichier à une version d'un projet | +*----------------------------*-----------------------------------------------+ +| <<add_news>> | ajouter une annonce à un projet | +*----------------------------*-----------------------------------------------+ +| <<add_issue_time>> | ajouter un temps à une issue d'un projet | +*----------------------------*-----------------------------------------------+ +| <<update_issue_time>> | mettre à jour le temps d'une issue d'un projet| +*----------------------------*-----------------------------------------------+ <<Note:>> Toutes ces opérations doivent obligatoirement être exécutées par une méthod http <<POST>> (donc pas réalisable via un navigateur). @@ -378,3 +435,45 @@ jredmine/add_news.xml/myProject jredmine/add_news.json/myProject -------------------------------------------------------------------------------- + +** add_issue_time + + Ce service requiert cinq paramètres : + + * <<issue_id>> l'id de l'issue + + * <<time_entry[activity_id]>> l'id de l'activité du temps à ajouter + + * <<time_entry[hours]>> le nombre d'heures du temps à ajouter + + * <<time_entry[spent_on]>> la date du temps à ajouter (si null, on prend la date du jour) + + * <<time_entry[comments]>> commentaire du temps à ajouter + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/add_issue_time.xml/myProject +jredmine/add_issue_time.json/myProject +-------------------------------------------------------------------------------- + +** update_issue_time + + Ce service requiert cinq paramètres : + + * <<issue_id>> l'id de l'issue + + * <<time_entry[activity_id]>> l'id de l'activité du temps à mettre à jour + + * <<time_entry[hours]>> le nombre d'heures du temps à mettre à jour + + * <<time_entry[spent_on]>> la date du temps à mettre à jour (si null, on prend la date du jour) + + * <<time_entry[comments]>> commentaire du temps à mettre à jour + + Requètes : + +-------------------------------------------------------------------------------- +jredmine/update_issue_time.xml/myProject +jredmine/update_issue_time.json/myProject +-------------------------------------------------------------------------------- Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/DefaultRedmineServiceTest.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,30 +20,16 @@ */ package org.nuiton.jredmine; -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.junit.*; import org.nuiton.io.rest.RestClientConfiguration; -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.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; +import static org.nuiton.jredmine.TestHelper.getTestConfiguration; +import org.nuiton.jredmine.model.*; import org.nuiton.jredmine.rest.RedmineRestClient; /** * @author chemit */ -public class DefaultRedmineServiceTest { +public class DefaultRedmineServiceTest implements RedmineTestContract { /** * shared rest client (open only one session for all the test) @@ -54,9 +40,24 @@ */ RedmineService service; + Project[] projects; + Project project; + Version[] versions; + Version version; + User[] users; + Issue[] issues; + IssuePriority[] issuePriorities; + IssueStatus[] issueStatuses; + IssueCategory[] issueCategories; + Tracker[] trackers; + News[] news; + Attachment[] attachments; + TimeEntry[] timeEntries; + + @BeforeClass public static void setUpClass() throws Exception { - RestClientConfiguration configuration = TestHelper.getTestConfiguration(); + RestClientConfiguration configuration = getTestConfiguration(); client = new RedmineRestClient(configuration); try { @@ -91,95 +92,150 @@ service = null; } + @Test public void isInit() throws Exception { Assert.assertFalse(new DefaultRedmineService().isInit()); - } + @Test + @Override public void getProjects() throws Exception { - Project[] projects = service.getProjects(); + projects = service.getProjects(); } @Test + @Override public void getIssuePriorities() throws Exception { - IssuePriority[] suePriorities = service.getIssuePriorities(); + issuePriorities = service.getIssuePriorities(); } @Test + @Override public void getIssueStatuses() throws Exception { - IssueStatus[] sueStatuses = service.getIssueStatuses(); + issueStatuses = service.getIssueStatuses(); } @Test + @Override public void getProject() throws Exception { - Project project = service.getProject("one"); + project = service.getProject(PROJECT_NAME); } @Test + @Override public void getIssueCategories() throws Exception { - IssueCategory[] sueCategories = service.getIssueCategories("one"); + issueCategories = service.getIssueCategories(PROJECT_NAME); } @Test + @Override public void getTrackers() throws Exception { - Tracker[] trackers = service.getTrackers("one"); + trackers = service.getTrackers(PROJECT_NAME); } @Test + @Override public void getNews() throws Exception { - News[] news = service.getNews("one"); + news = service.getNews(PROJECT_NAME); } @Test + @Override public void getUsers() throws Exception { - User[] users = service.getUsers("one"); + users = service.getUsers(PROJECT_NAME); } @Test + @Override + public void getProjectIssues() throws Exception { + issues = service.getIssues(PROJECT_NAME); + } + + @Test + @Override public void getVersions() throws Exception { - Version[] versions = service.getVersions("one"); + versions = service.getVersions(PROJECT_NAME); } @Test + @Override public void getVersion() throws Exception { - Version version = service.getVersion("one", "1.0.0"); + version = service.getVersion(PROJECT_NAME, VERSION_NAME); } @Test - public void getIssues() throws Exception { - Issue[] sues = service.getIssues("one", "1.0.0"); + @Override + public void getVersionIssues() throws Exception { + issues = service.getIssues(PROJECT_NAME, VERSION_NAME); } @Test + @Override + public void getOpenedIssues() throws Exception { + issues = service.getOpenedIssues(PROJECT_NAME); + } + + @Test + @Override + public void getClosedIssues() throws Exception { + issues = service.getClosedIssues(PROJECT_NAME); + } + + @Test + @Override + public void getIssueTimeEntries() throws Exception { + timeEntries = service.getIssueTimeEntries(PROJECT_NAME, ISSUE_ID); + } + + + @Test + @Override public void getAttachments() throws Exception { - Attachment[] attachments = service.getAttachments("one", "1.0.0"); + attachments = service.getAttachments(PROJECT_NAME, VERSION_NAME); } @Test + @Override public void addVersion() throws Exception { //TODO } @Test + @Override public void addAttachment() throws Exception { //TODO } @Test + @Override public void addNews() throws Exception { //TODO } @Test + @Override public void updateVersion() throws Exception { //TODO } @Test + @Override public void nextVersion() throws Exception { //TODO } + + @Test + @Override + public void addIssueTime() throws Exception { + TimeEntry timeEntry = new TimeEntry(); + timeEntry.setActivityId(9); + timeEntry.setComments("ajout time"); + timeEntry.setHours(3.5f); +// timeEntry.setSpentOn(new Date()); + service.addIssueTimeEntry(PROJECT_NAME, ISSUE_ID, timeEntry); + //TODO + } } Added: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java (rev 0) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,64 @@ +package org.nuiton.jredmine; + +/** + * 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: tchemit $ + * @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; + + void getIssuePriorities() throws Exception; + + void getIssueStatuses() throws Exception; + + void getProject() throws Exception; + + void getIssueCategories() throws Exception; + + void getTrackers() throws Exception; + + void getNews() throws Exception; + + void getUsers() throws Exception; + + void getProjectIssues() throws Exception; + + void getVersions() throws Exception; + + void getVersion() throws Exception; + + void getVersionIssues() throws Exception; + + void getOpenedIssues() throws Exception; + + void getClosedIssues() throws Exception; + + void getIssueTimeEntries() throws Exception; + + void getAttachments() throws Exception; + + void addVersion() throws Exception; + + void addAttachment() throws Exception; + + void addNews() throws Exception; + + void updateVersion() throws Exception; + + void nextVersion() throws Exception; + + void addIssueTime() throws Exception; +} Property changes on: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/RedmineTestContract.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Modified: trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java =================================================================== --- trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/TestHelper.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,37 +20,22 @@ */ package org.nuiton.jredmine; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Date; -import java.util.EnumMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; import junit.framework.Assert; import org.nuiton.io.rest.DefaultRestClientConfiguration; import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.io.xpp3.AbstractXpp3Reader; import org.nuiton.io.xpp3.PropertyMapper; import org.nuiton.io.xpp3.Xpp3Helper; -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.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; +import org.nuiton.jredmine.model.*; 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.*; + /** - * * @author chemit * @since 1.0.0 */ @@ -61,7 +46,7 @@ protected static Properties defaultConfig; protected static Properties userConfig; protected static EnumMap<RedmineModelEnum, List<?>> memoryModel; - + public static void initDefaultConfiguration() throws IOException { if (DEFAULT_CONFIGURATION != null) { @@ -143,7 +128,6 @@ } /** - * * @return the basedir for all tests */ public static File getBasedir() { @@ -174,7 +158,6 @@ public static File getTestDir(String type, String prefix) { String rep = type; -// String rep = type.getName(); rep = rep.replaceAll("\\.", File.separator); File f = new File(getBasedir(), prefix); @@ -229,7 +212,7 @@ throw new RuntimeException(ex); } } - return (List<T>) memoryModel.get(RedmineModelEnum.version.valueOf(type)); + return (List<T>) memoryModel.get(RedmineModelEnum.valueOf(type)); } public static void tearDownClass() throws Exception { @@ -278,7 +261,7 @@ memoryModel = new EnumMap<RedmineModelEnum, List<?>>(RedmineModelEnum.class); list = new ArrayList<Object>(); - Attachment tempA = null; + Attachment tempA; tempA = new Attachment(); tempA.setAuthorId((Integer) RedmineDataConverter.Integer.convert("4")); tempA.setContainerId((Integer) RedmineDataConverter.Integer.convert("1")); @@ -310,7 +293,7 @@ list = new ArrayList<Object>(); - Issue tempI = null; + Issue tempI; tempI = new Issue(); tempI.setAuthorId((Integer) RedmineDataConverter.Integer.convert("5")); tempI.setCategoryId((Integer) RedmineDataConverter.Integer.convert("2")); @@ -350,7 +333,7 @@ list = new ArrayList<Object>(); - Project tempP = null; + Project tempP; tempP = new Project(); tempP.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:11:54+02:00")); tempP.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:11:54+02:00")); @@ -377,7 +360,7 @@ list = new ArrayList<Object>(); - Tracker tempT = null; + Tracker tempT; tempT = new Tracker(); tempT.setId((Integer) RedmineDataConverter.Integer.convert("1")); tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); @@ -411,7 +394,7 @@ list = new ArrayList<Object>(); - User tempU = null; + User tempU; tempU = new User(); tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T17:24:46+02:00")); tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T01:23:59+02:00")); @@ -468,7 +451,7 @@ list = new ArrayList<Object>(); - Version tempV = null; + Version tempV; tempV = new Version(); tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:47:39+02:00")); tempV.setDescription((String) RedmineDataConverter.Text.convert("yo")); @@ -602,7 +585,6 @@ memoryModel.put(RedmineModelEnum.issueStatus, list); - IssuePriority tempIP; list = new ArrayList<Object>(); tempIP = new IssuePriority(); @@ -686,6 +668,45 @@ memoryModel.put(RedmineModelEnum.news, list); + TimeEntry tempE; + list = new ArrayList<Object>(); + tempE = new TimeEntry(); + tempE.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:02:02+01:00")); + tempE.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:02:02+01:00")); + tempE.setSpentOn((Date) RedmineDataConverter.Date.convert("2009-12-31")); + tempE.setId(1); + tempE.setProjectId(1); + tempE.setUserId(4); + tempE.setIssueId(6); + tempE.setActivityId(8); + + tempE.setHours(1); + tempE.setTmonth(12); + tempE.setTyear(2009); + tempE.setTweek(53); + tempE.setComments("Test"); + list.add(tempE); + + tempE = new TimeEntry(); + tempE.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:10:01+01:00")); + tempE.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:10:01+01:00")); + tempE.setSpentOn((Date) RedmineDataConverter.Date.convert("2009-12-31")); + tempE.setId(2); + tempE.setProjectId(1); + tempE.setUserId(4); + tempE.setIssueId(6); + tempE.setActivityId(9); + + tempE.setHours(2); + tempE.setTmonth(12); + tempE.setTyear(2009); + tempE.setTweek(53); + tempE.setComments("deuxième temps"); + list.add(tempE); + + memoryModel.put(RedmineModelEnum.timeEntry, list); + + } } 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3HelperTest.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,27 +20,22 @@ */ package org.nuiton.jredmine.model.io.xpp3; -import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.util.IOUtil; +import org.junit.*; import org.nuiton.jredmine.TestHelper; +import org.nuiton.jredmine.model.*; + import java.beans.Introspector; -import org.nuiton.jredmine.model.*; import java.io.File; import java.io.FileInputStream; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codehaus.plexus.util.IOUtil; -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 java.util.Set; /** - * * @author chemit * @since 1.0.0 */ @@ -49,16 +44,17 @@ 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, - RedmineModelEnum.issue, - RedmineModelEnum.project, - RedmineModelEnum.tracker, - RedmineModelEnum.user, - RedmineModelEnum.version, - RedmineModelEnum.issueStatus, - RedmineModelEnum.issuePriority, - RedmineModelEnum.issueCategory, - RedmineModelEnum.news + RedmineModelEnum.attachment, + RedmineModelEnum.issue, + RedmineModelEnum.project, + RedmineModelEnum.tracker, + RedmineModelEnum.user, + RedmineModelEnum.version, + RedmineModelEnum.issueStatus, + RedmineModelEnum.issuePriority, + RedmineModelEnum.issueCategory, + RedmineModelEnum.news, + RedmineModelEnum.timeEntry }; protected static File testDir; protected static RedmineXpp3Helper builder; @@ -153,7 +149,9 @@ 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(News.class).get(0)), + Arrays.asList(TestHelper.getModel(TimeEntry.class).get(0)) + ); } /** @@ -201,6 +199,7 @@ Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, + Collections.EMPTY_LIST, Collections.EMPTY_LIST); @@ -214,7 +213,9 @@ 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(News.class).get(0)), + Arrays.asList(TestHelper.getModel(TimeEntry.class).get(0)) + ); action.run("array-multi", TestHelper.getModel(Attachment.class), @@ -226,13 +227,14 @@ TestHelper.getModel(IssueStatus.class), TestHelper.getModel(IssuePriority.class), TestHelper.getModel(IssueCategory.class), - TestHelper.getModel(News.class)); + TestHelper.getModel(News.class), + TestHelper.getModel(TimeEntry.class) + ); } /** * A little action wrapper to simplify this test class :) - * */ public static abstract class TestAction { @@ -240,9 +242,9 @@ * Implements the logic of action for the given {@code type} and * the {@code expected} datas. * - * @param <T> the type of data used - * @param rootDir the rootdir file of the local cache - * @param type the type of data used + * @param <T> the type of data used + * @param rootDir the rootdir file of the local cache + * @param type the type of data used * @param expected the list of expected datas * @throws Exception if any pb */ 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 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/jredmine-client/src/test/java/org/nuiton/jredmine/rest/RedmineRestClientTest.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,37 +20,22 @@ */ package org.nuiton.jredmine.rest; -import java.io.IOException; -import java.io.InputStream; import org.codehaus.plexus.util.IOUtil; -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.junit.*; import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.io.rest.RestException; import org.nuiton.io.rest.RestRequest; +import org.nuiton.jredmine.RedmineTestContract; import org.nuiton.jredmine.TestHelper; -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.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; +import java.io.IOException; +import java.io.InputStream; + /** - * * @author chemit * @since 1.0.0 */ -public class RedmineRestClientTest { +public class RedmineRestClientTest implements RedmineTestContract { static RestClientConfiguration configuration; RedmineRestClient client; @@ -107,101 +92,157 @@ Assert.assertFalse(client.isOpen()); } + @Override @Test - public void getDatas() throws Exception { + public void getProjects() throws Exception { - String toString; + doRequest(RedmineRestClient.GET_PROJECT_LIST); + } - // get projects + @Override + @Test + public void getIssuePriorities() throws Exception { - toString = doRequest(Project.class, "list"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_ISSUE_PRIORITY_LIST); + } - // get issue statuses + @Override + @Test + public void getIssueStatuses() throws Exception { - toString = doRequest(IssueStatus.class, "list"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_ISSUE_STATUS_LIST); + } - // get issue priorities + @Override + @Test + public void getProject() throws Exception { - toString = doRequest(IssuePriority.class, "list"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_PROJECT, PROJECT_NAME); + } - // get project + @Override + @Test + public void getIssueCategories() throws Exception { - toString = doRequest(Project.class, "detail", "one"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_ISSUE_CATEGORY_LIST, PROJECT_NAME); + } - // get project issue categories + @Override + @Test + public void getTrackers() throws Exception { - toString = doRequest(IssueCategory.class, "list", "one"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_TRACKER_LIST, PROJECT_NAME); + } - // get project versions + @Override + @Test + public void getNews() throws Exception { - toString = doRequest(Version.class, "list", "one"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_NEWS_LIST, PROJECT_NAME); + } - // get project users + @Override + @Test + public void getUsers() throws Exception { - toString = doRequest(User.class, "list", "one"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_USER_LIST, PROJECT_NAME); + } - // get project trackers + @Override + @Test + public void getProjectIssues() throws Exception { - toString = doRequest(Tracker.class, "list", "one"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_PROJECT_ISSUES, PROJECT_NAME); + } - // get project news + @Override + @Test + public void getVersions() throws Exception { - toString = doRequest(News.class, "list", "one"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_VERSION_LIST, PROJECT_NAME); + } - // get version + @Override + @Test + public void getVersion() throws Exception { - toString = doRequest(Version.class, "detail", "one", "1.0.0"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_VERSION, PROJECT_NAME, VERSION_NAME); + } - // get issues + @Override + @Test + public void getVersionIssues() throws Exception { - toString = doRequest(Issue.class, "list", "one", "1.0.0"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_ISSUE_LIST, PROJECT_NAME, VERSION_NAME); + } - // get attachments + @Override + @Test + public void getOpenedIssues() throws Exception { - toString = doRequest(Attachment.class, "list", "one", "1.0.0"); - if (configuration.isVerbose()) { - System.out.println(toString); - } + doRequest(RedmineRestClient.GET_PROJECT_OPENED_ISSUES, PROJECT_NAME); + } + @Override + @Test + public void getClosedIssues() throws Exception { + + doRequest(RedmineRestClient.GET_PROJECT_CLOSED_ISSUES, PROJECT_NAME); } - protected String doRequest(Class<?> type, String action, Object... params) throws IOException, RestException { + @Override + @Test + public void getIssueTimeEntries() throws Exception { - String requestId = type.getName() + action; + doRequest(RedmineRestClient.GET_ISSUE_TIME_ENTRY_LIST, PROJECT_NAME, ISSUE_ID); + } + + @Override + @Test + public void getAttachments() throws Exception { + + doRequest(RedmineRestClient.GET_ATTACHMENTS_LIST, PROJECT_NAME, VERSION_NAME); + } + + @Override + @Test + public void addVersion() throws Exception { + //TODO + } + + @Override + @Test + public void addAttachment() throws Exception { + //TODO + } + + @Override + @Test + public void addNews() throws Exception { + //TODO + } + + @Override + @Test + public void updateVersion() throws Exception { + //TODO + } + + @Override + @Test + public void nextVersion() throws Exception { + //TODO + } + + @Override + @Test + public void addIssueTime() throws Exception { + //TODO + } + + protected void doRequest(String requestId, Object... params) throws IOException, RestException { + RestRequest request; InputStream askData; String toString; @@ -209,6 +250,8 @@ request = client.getRequest(requestId, params); askData = client.askData(request); toString = IOUtil.toString(askData); - return toString; + if (configuration.isVerbose()) { + System.out.println(toString); + } } } Added: trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-empty/timeEntrys.xml =================================================================== --- trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-empty/timeEntrys.xml (rev 0) +++ trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-empty/timeEntrys.xml 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<time-entries type="array"> +</time-entries> \ No newline at end of file Added: trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-multi/timeEntrys.xml =================================================================== --- trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-multi/timeEntrys.xml (rev 0) +++ trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-multi/timeEntrys.xml 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<time-entries type="array"> + <time-entry> + <activity-id type="integer">8</activity-id> + <comments>Test</comments> + <created-on type="datetime">2009-12-31T23:02:02+01:00</created-on> + <hours type="float">1.0</hours> + <id type="integer">1</id> + <issue-id type="integer">6</issue-id> + <project-id type="integer">1</project-id> + <spent-on type="date">2009-12-31</spent-on> + <tmonth type="integer">12</tmonth> + <tweek type="integer">53</tweek> + <tyear type="integer">2009</tyear> + <updated-on type="datetime">2009-12-31T23:02:02+01:00</updated-on> + <user-id type="integer">4</user-id> + </time-entry> + <time-entry> + <activity-id type="integer">9</activity-id> + <comments>deuxième temps</comments> + <created-on type="datetime">2009-12-31T23:10:01+01:00</created-on> + <hours type="float">2.0</hours> + <id type="integer">2</id> + <issue-id type="integer">6</issue-id> + <project-id type="integer">1</project-id> + <spent-on type="date">2009-12-31</spent-on> + <tmonth type="integer">12</tmonth> + <tweek type="integer">53</tweek> + <tyear type="integer">2009</tyear> + <updated-on type="datetime">2009-12-31T23:10:01+01:00</updated-on> + <user-id type="integer">4</user-id> + </time-entry> +</time-entries> \ No newline at end of file Added: trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-singleton/timeEntrys.xml =================================================================== --- trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-singleton/timeEntrys.xml (rev 0) +++ trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/array-singleton/timeEntrys.xml 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<time-entries type="array"> + <time-entry> + <activity-id type="integer">8</activity-id> + <comments>Test</comments> + <created-on type="datetime">2009-12-31T23:02:02+01:00</created-on> + <hours type="float">1.0</hours> + <id type="integer">1</id> + <issue-id type="integer">6</issue-id> + <project-id type="integer">1</project-id> + <spent-on type="date">2009-12-31</spent-on> + <tmonth type="integer">12</tmonth> + <tweek type="integer">53</tweek> + <tyear type="integer">2009</tyear> + <updated-on type="datetime">2009-12-31T23:02:02+01:00</updated-on> + <user-id type="integer">4</user-id> + </time-entry> +</time-entries> \ No newline at end of file Added: trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/single/timeEntry.xml =================================================================== --- trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/single/timeEntry.xml (rev 0) +++ trunk/jredmine-client/src/test/resources/org/nuiton/jredmine/model/io/xpp3/single/timeEntry.xml 2010-01-01 17:35:21 UTC (rev 61) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<time-entry> + <activity-id type="integer">8</activity-id> + <comments>Test</comments> + <created-on type="datetime">2009-12-31T23:02:02+01:00</created-on> + <hours type="float">1.0</hours> + <id type="integer">1</id> + <issue-id type="integer">6</issue-id> + <project-id type="integer">1</project-id> + <spent-on type="date">2009-12-31</spent-on> + <tmonth type="integer">12</tmonth> + <tweek type="integer">53</tweek> + <tyear type="integer">2009</tyear> + <updated-on type="datetime">2009-12-31T23:02:02+01:00</updated-on> + <user-id type="integer">4</user-id> +</time-entry> + Modified: trunk/maven-jredmine-plugin/pom.xml =================================================================== --- trunk/maven-jredmine-plugin/pom.xml 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/pom.xml 2010-01-01 17:35:21 UTC (rev 61) @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -22,7 +24,7 @@ <artifactId>jredmine-client</artifactId> <version>${project.version}</version> </dependency> - + <dependency> <groupId>${project.groupId}</groupId> <artifactId>jredmine-client</artifactId> @@ -33,7 +35,7 @@ <dependency> <groupId>org.nuiton</groupId> - <artifactId>maven-helper-plugin</artifactId> + <artifactId>maven-helper-plugin</artifactId> </dependency> <!-- FIXME si on ne le rajoute pas, on se retrouve avec la version 1.1 qui ne convient pas --> @@ -56,7 +58,7 @@ <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> </dependency> - + <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-core</artifactId> @@ -99,7 +101,8 @@ <!-- ************************************************************* --> <name>JRedmine :: Maven plugin</name> - <description>JRedmine maven plugin to interacts with Redmine's server</description> + <description>JRedmine maven plugin to interacts with Redmine's server + </description> <!-- ************************************************************* --> <!-- *** Build Settings ****************************************** --> @@ -108,7 +111,7 @@ <packaging>maven-plugin</packaging> <properties> - + </properties> <build> @@ -130,12 +133,6 @@ </plugins> - <pluginManagement> - <plugins> - - </plugins> - </pluginManagement> - </build> <reporting> @@ -194,9 +191,11 @@ <pomInclude>report/pom.xml</pomInclude> </pomIncludes> <postBuildHookScript>verify</postBuildHookScript> - <localRepositoryPath>${basedir}/target/local-repo</localRepositoryPath> + <localRepositoryPath>${basedir}/target/local-repo + </localRepositoryPath> <settingsFile>src/it/settings.xml</settingsFile> - <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo> + <cloneProjectsTo>${project.build.directory}/its + </cloneProjectsTo> </configuration> <executions> <execution> @@ -212,7 +211,7 @@ </plugins> </build> </profile> - + </profiles> </project> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,32 +20,31 @@ */ package org.nuiton.jredmine.plugin; -import java.net.URL; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.IssueManagement; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.nuiton.io.rest.RestClientConfiguration; -import org.nuiton.plugin.AbstractPlugin; +import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.RedmineServiceImplementor; import org.nuiton.jredmine.model.ModelHelper; import org.nuiton.jredmine.model.Project; import org.nuiton.jredmine.model.User; import org.nuiton.jredmine.model.Version; -import org.nuiton.jredmine.RedmineService; -import org.nuiton.jredmine.RedmineServiceException; -import org.nuiton.jredmine.RedmineServiceImplementor; +import org.nuiton.plugin.AbstractPlugin; +import java.net.URL; +import java.text.DateFormat; +import java.text.SimpleDateFormat; + /** * Abstract redmine mojo. - * + * * @author tchemit - * @since 1.0.0 * @requiresOnline true * @requiresProject true + * @since 1.0.0 */ public abstract class AbstractRedmineMojo extends AbstractPlugin implements RestClientConfiguration { @@ -61,7 +60,7 @@ protected MavenProject project; /** * The real basedir redmine url. - * + * <p/> * If no url is given, will use the issue management url. * * @parameter expression="${redmine.url}" @@ -168,7 +167,13 @@ * flag to mark if a runOnce goal was done */ protected boolean runOnceDone; + /** + * flag to mark if service was sucessfull init + */ + protected boolean serviceInit; + protected boolean initOk = true; + public AbstractRedmineMojo(boolean requireProject, boolean requireVersion, boolean requireUser) { super(); this.requireProject = requireProject; @@ -180,24 +185,28 @@ /// AbstractPlugin /////////////////////////////////////////////////////////////////////////// @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { // check issue management IssueManagement issueManagement = project.getIssueManagement(); if (issueManagement == null) { - getLog().error("No Issue Management set."); - - return false; + throw new MojoExecutionException("No Issue Management set."); +// getLog().error("No Issue Management set."); +// +// return false; } else if ((issueManagement.getUrl() == null) || (issueManagement.getUrl().trim().equals(""))) { - getLog().error("No URL set in Issue Management."); - - return false; + throw new MojoExecutionException("No URL set in Issue Management."); +// getLog().error("No URL set in Issue Management."); +// +// return false; } else if ((issueManagement.getSystem() != null) && !(issueManagement.getSystem().equalsIgnoreCase(AbstractRedmineMojo.REDMINE_SYSTEM))) { - getLog().error("Redmine's Plugin only supports 'redmine' Issue Management system."); - - return false; + throw new MojoExecutionException("Redmine's Plugin only supports 'redmine' Issue Management system."); +// getLog().error("Redmine's Plugin only supports 'redmine' Issue Management system."); +// +// return false; } // prepare Redmine service configuration @@ -229,12 +238,17 @@ try { ((RedmineServiceImplementor) service).init(this); - + serviceInit = true; } catch (Exception e) { - if (verbose) { - getLog().error("could not init Redmine service [" + getRestUrl() + "] with user '" + getRestUsername() + "'", e); + if (safe) { + throw e; } - return false; + serviceInit = false; + initOk = false; +// if (verbose) { +// getLog().error("could not init Redmine service [" + getRestUrl() + "] with user '" + getRestUsername() + "'", e); +// } +// return false; } // check project exists @@ -242,9 +256,16 @@ if (requireProject) { boolean r = initReleaseProject(); if (!r) { - getLog().error("the project '" + projectId + "' could not be retrieve from redmine server, goal is skip"); - return false; + if (safe) { + throw new MojoExecutionException("the project '" + projectId + "' could not be retrieve from redmine server, goal is skip"); + } + initOk = false; + return; } +// if (!r) { +// getLog().error("the project '" + projectId + "' could not be retrieve from redmine server, goal is skip"); +// return false; +// } } // check user exists @@ -252,9 +273,16 @@ if (requireUser) { boolean r = initReleaseUser(); if (!r) { - getLog().error("the user '" + this.username + "' could not be retrieve from redmine server, goal is skip"); - return false; + if (safe) { + throw new MojoExecutionException("the user '" + this.username + "' could not be retrieve from redmine server, goal is skip"); + } + initOk = false; + return; } +// if (!r) { +// getLog().error("the user '" + this.username + "' could not be retrieve from redmine server, goal is skip"); +// return false; +// } } // check version exists @@ -262,90 +290,136 @@ if (requireVersion) { boolean r = initReleaseVersion(); if (!r) { - getLog().error("the version '" + versionId + "' could not be retrieve from redmine server, goal is skip"); - return false; + if (safe) { + throw new MojoExecutionException("the version '" + versionId + "' could not be retrieve from redmine server, goal is skip"); + } + initOk = false; } +// if (!r) { +// getLog().error("the version '" + versionId + "' could not be retrieve from redmine server, goal is skip"); +// return false; +// } } - return true; +// return true; } @Override - public final void execute() throws MojoExecutionException, MojoFailureException { + protected boolean checkSkip() { - boolean canContinue = checkPackaging(); - - if (!canContinue) { - getLog().warn("The goal is skip due to packaging '" + getProject().getPackaging() + "'"); - return; + if (isGoalSkip()) { + getLog().warn("The goal is skip due to the skipGoal flag on"); + return false; } - if (isGoalSkip()) { - getLog().warn("The goal is skip due to skipGoal flag on"); - return; + if (!serviceInit) { + getLog().error("could not init Redmine service [" + getRestUrl() + "] with user '" + getRestUsername() + "'"); + return false; } - Exception error = null; - try { + if (requireProject && releaseProject == null) { - try { + getLog().error("the project '" + projectId + "' could not be retrieve from redmine server, goal is skip"); + return false; + } + if (requireUser && releaseUser == null) { + getLog().error("the user '" + this.username + "' could not be retrieve from redmine server, goal is skip"); + return false; + } - canContinue = init(); + if (requireVersion && releaseVersion == null) { + getLog().error("the version '" + versionId + "' could not be retrieve from redmine server, goal is skip"); + return false; + } - } catch (Exception e) { - error = e; + if (isRunOnce() && isRunOnceDone()) { - // none safe execution, just warn and not failed the build - canContinue = false; - } + } - if (!canContinue) { + return true; + } + @Override + protected void afterExecute() { + closeService(); + } - if (isSafe()) { - String message; - if (error != null) { - message = "safe mode is on and could not init goal [" + getClass().getSimpleName() + "] for reason " + error.getMessage(); - } else { - message = "safe mode is on and could not init goal [" + getClass().getSimpleName() + "]"; - } - if (isVerbose()) { - if (error != null) { - getLog().error(message, error); - } else { - getLog().error(message); - } - } +// @Override +// public final void execute() throws MojoExecutionException, MojoFailureException { +// +// boolean canContinue = checkPackaging(); +// +// if (!canContinue) { +// getLog().warn("The goal is skip due to packaging '" + getProject().getPackaging() + "'"); +// return; +// } +// +// if (isGoalSkip()) { +// getLog().warn("The goal is skip due to skipGoal flag on"); +// return; +// } +// +// Exception error = null; +// try { +// +// try { +// +// canContinue = init(); +// +// } catch (Exception e) { +// error = e; +// +// // none safe execution, just warn and not failed the build +// canContinue = false; +// } +// +// if (!canContinue) { +// +// +// if (isSafe()) { +// String message; +// if (error != null) { +// message = "safe mode is on and could not init goal [" + getClass().getSimpleName() + "] for reason " + error.getMessage(); +// } else { +// message = "safe mode is on and could not init goal [" + getClass().getSimpleName() + "]"; +// } +// if (isVerbose()) { +// if (error != null) { +// getLog().error(message, error); +// } else { +// getLog().error(message); +// } +// } +// +// if (error != null) { +// if (error instanceof MojoExecutionException) { +// throw (MojoExecutionException) error; +// } +// throw new MojoExecutionException(message, error); +// } +// throw new MojoExecutionException(message); +// } +// +// getLog().warn(skipAfterInitMessage); +// return; +// } +// +// try { +// +// doAction(); +// +// } catch (MojoExecutionException e) { +// throw e; +// } catch (Exception e) { +// throw new MojoExecutionException("could not execute goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e); +// } +// +// } finally { +// // always close service (it will release connections to redmine) +// closeService(); +// } +// } - if (error != null) { - if (error instanceof MojoExecutionException) { - throw (MojoExecutionException) error; - } - throw new MojoExecutionException(message, error); - } - throw new MojoExecutionException(message); - } - - getLog().warn(skipAfterInitMessage); - return; - } - - try { - - doAction(); - - } catch (MojoExecutionException e) { - throw e; - } catch (Exception e) { - throw new MojoExecutionException("could not execute goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e); - } - - } finally { - // always close service (it will release connections to redmine) - closeService(); - } - } - /** * Re-expose the protected method for test purposes... * @@ -436,10 +510,17 @@ throw new MojoExecutionException("required a projectId parameter"); } try { - this.releaseProject = service.getProject(projectId); - return releaseProject != null; + Project p = service.getProject(projectId); + + if (p == null) { + + return false; + } + + this.releaseProject = p; + return true; } catch (RedmineServiceException e) { - getLog().warn("could not retreave project '" + projectId + "', goal is skip"); +// getLog().warn("could not retreave project '" + projectId + "', goal is skip"); if (verbose) { getLog().error(e); } @@ -465,7 +546,7 @@ this.releaseVersion = v; return true; } catch (RedmineServiceException e) { - getLog().warn("could not retreave version " + versionId + ", goal is skip"); +// getLog().warn("could not retreave version " + versionId + ", goal is skip"); if (verbose) { getLog().error(e); } @@ -484,16 +565,16 @@ return false; } + this.releaseUser = user; + return true; } catch (RedmineServiceException e) { - getLog().warn("could not retreave user '" + username + "', goal is skip"); +// getLog().warn("could not retreave user '" + username + "', goal is skip"); if (verbose) { getLog().error(e); } return false; } - - return true; } protected void closeService() { Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,22 +20,22 @@ */ package org.nuiton.jredmine.plugin; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import org.apache.maven.plugin.MojoFailureException; +import org.nuiton.jredmine.RedmineServiceImplementor; import org.nuiton.jredmine.model.I18nAble; import org.nuiton.jredmine.model.IdAble; import org.nuiton.jredmine.model.RedmineModelEnum; import org.nuiton.jredmine.model.RedmineModelScope; -import org.nuiton.jredmine.RedmineServiceImplementor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * Display in console some data from redmine's server. * + * @author tchemit * @goal display-data - * - * @author tchemit * @since 1.0.0 */ public class DisplayDataMojo extends AbstractRedmineMojo { @@ -83,25 +83,44 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { - boolean init = super.init(); - if (init) { + super.init(); +// boolean init = super.init(); +// if (init) { + if (!safe && !initOk) { + // we are in none safe mode but init is not ok... + return; + } + actions = getDownloadActions(types, + RedmineModelEnum.issueStatus, + RedmineModelEnum.issuePriority, + RedmineModelEnum.issueCategory, + RedmineModelEnum.tracker, + RedmineModelEnum.user); - actions = getDownloadActions(types, - RedmineModelEnum.issueStatus, - RedmineModelEnum.issuePriority, - RedmineModelEnum.issueCategory, - RedmineModelEnum.tracker, - RedmineModelEnum.user); +// if (actions.isEmpty()) { +// // no data to treate +// getLog().warn("no data types detected, you must fill the required parameter dataTypes"); +// init = false; +// } +// } +// return init; + } - if (actions.isEmpty()) { - // no data to treate - getLog().warn("no data types detected, you must fill the required parameter dataTypes"); - init = false; - } + @Override + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { + return false; } - return init; + if (actions == null || actions.isEmpty()) { + // no data to treate + getLog().warn("no data types detected, you must fill the required parameter dataTypes, will skip goal"); + return false; + } + return true; } @Override Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/GenerateChangesMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -191,7 +191,8 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { if (xmlPath == null || xmlPath.getAbsolutePath().trim().isEmpty()) { throw new MojoExecutionException("required a xmlPath parameter"); @@ -208,224 +209,249 @@ if (isRunOnce()) { runOnceDone = checkRunOnceDone(); if (runOnceDone) { - return true; + return; +// return true; } } - boolean result = super.init(); - if (!result) { - return false; + super.init(); + if (!safe && !initOk) { + // we are in none safe mode but init is not ok... + return; } +// boolean result = super.init(); +// if (!result) { +// return false; +// } - try { +// try { - // get trackers + // get trackers - Tracker[] releaseTrackers; - try { + Tracker[] releaseTrackers; + try { - releaseTrackers = service.getTrackers(projectId); + releaseTrackers = service.getTrackers(projectId); - } catch (RedmineServiceException e) { - throw new MojoExecutionException("could not obtain trackers for reason " + e.getMessage(), e); - } + } catch (RedmineServiceException e) { + throw new MojoExecutionException("could not obtain trackers for reason " + e.getMessage(), e); + } - // get statuses + // get statuses - IssueStatus[] statuses; - try { + IssueStatus[] statuses; + try { - statuses = service.getIssueStatuses(); + statuses = service.getIssueStatuses(); - } catch (RedmineServiceException e) { - throw new MojoExecutionException("could not obtain statuses for reason " + e.getMessage(), e); - } + } catch (RedmineServiceException e) { + throw new MojoExecutionException("could not obtain statuses for reason " + e.getMessage(), e); + } - // get categories + // get categories - IssueCategory[] categories; - try { + IssueCategory[] categories; + try { - categories = service.getIssueCategories(projectId); + categories = service.getIssueCategories(projectId); - } catch (RedmineServiceException e) { - throw new MojoExecutionException("could not obtain categories for reason " + e.getMessage(), e); - } + } catch (RedmineServiceException e) { + throw new MojoExecutionException("could not obtain categories for reason " + e.getMessage(), e); + } - // get versions + // get versions - try { + try { - versions = service.getVersions(projectId); + versions = service.getVersions(projectId); - } catch (RedmineServiceException e) { - throw new MojoExecutionException("could not obtain versions for reason " + e.getMessage(), e); - } + } catch (RedmineServiceException e) { + throw new MojoExecutionException("could not obtain versions for reason " + e.getMessage(), e); + } - filters = new HashMap<String, String>(); + filters = new HashMap<String, String>(); - // build trackerToAction and tracker filter + // build trackerToAction and tracker filter - trackerToAction = new HashMap<Integer, String>(); + trackerToAction = new HashMap<Integer, String>(); - String[] entries = actionMapping.split(","); - StringBuilder buffer = new StringBuilder(); - for (String entry : entries) { - String[] parts = entry.split(":"); - if (parts.length != 2) { - // error in syntax - throw new MojoExecutionException("the trackerMapping entry " + Arrays.toString(parts) + " is not well formed"); - } - String action = parts[0].trim().toLowerCase(); + String[] entries = actionMapping.split(","); + StringBuilder buffer = new StringBuilder(); + for (String entry : entries) { + String[] parts = entry.split(":"); + if (parts.length != 2) { + // error in syntax + throw new MojoExecutionException("the trackerMapping entry " + Arrays.toString(parts) + " is not well formed"); + } + String action = parts[0].trim().toLowerCase(); - try { - Actions.valueOf(action); - } catch (Exception e) { - throw new MojoExecutionException("the action " + action + " is unknown... authorized : " + Arrays.toString(Actions.values())); - } + try { + Actions.valueOf(action); + } catch (Exception e) { + throw new MojoExecutionException("the action " + action + " is unknown... authorized : " + Arrays.toString(Actions.values())); + } - Integer id = Integer.valueOf(parts[1].trim()); + Integer id = Integer.valueOf(parts[1].trim()); - Tracker t = ModelHelper.byId(id, releaseTrackers); + Tracker t = ModelHelper.byId(id, releaseTrackers); - if (t == null) { - throw new MojoExecutionException("could not obtain the tracker with id " + id); - } - - trackerToAction.put(id, action); - buffer.append(",").append(id); + if (t == null) { + throw new MojoExecutionException("could not obtain the tracker with id " + id); } - filters.put("tracker", buffer.substring(1)); + trackerToAction.put(id, action); + buffer.append(",").append(id); + } - // create status filters - if (statusIds != null && !statusIds.trim().isEmpty()) { + filters.put("tracker", buffer.substring(1)); - for (String s : statusIds.split(",")) { - Integer id = Integer.valueOf(s.trim()); + // create status filters + if (statusIds != null && !statusIds.trim().isEmpty()) { - IssueStatus t = ModelHelper.byId(id, statuses); + for (String s : statusIds.split(",")) { + Integer id = Integer.valueOf(s.trim()); - if (t == null) { - throw new MojoExecutionException("could not obtain the status with id " + id); - } + IssueStatus t = ModelHelper.byId(id, statuses); + + if (t == null) { + throw new MojoExecutionException("could not obtain the status with id " + id); } - } - filters.put("status", statusIds); + } - if (categoryIds != null && !categoryIds.trim().isEmpty()) { + filters.put("status", statusIds); - // create category filters + // create category filters + if (categoryIds != null && !categoryIds.trim().isEmpty()) { - for (String s : categoryIds.split(",")) { - Integer id = Integer.valueOf(s.trim()); - IssueCategory t = ModelHelper.byId(id, categories); + for (String s : categoryIds.split(",")) { + Integer id = Integer.valueOf(s.trim()); - if (t == null) { - throw new MojoExecutionException("could not obtain the category with id " + id); - } + IssueCategory t = ModelHelper.byId(id, categories); + + if (t == null) { + throw new MojoExecutionException("could not obtain the category with id " + id); } - - filters.put("category", categoryIds); } - // create version filters + filters.put("category", categoryIds); + } - List<Version> versionList = new ArrayList<Version>(); + // create version filters - boolean versionExist = true; + List<Version> versionList = new ArrayList<Version>(); - releaseVersion = ModelHelper.byVersionName(versionId, versions); + boolean versionExist = true; - if (releaseVersion == null) { - versionExist = false; + releaseVersion = ModelHelper.byVersionName(versionId, versions); - // la version n'existe pas encore sur redmine - getLog().warn("The version " + versionId + " does not exist on redmine"); + if (releaseVersion == null) { + versionExist = false; - releaseVersion = new Version(); - releaseVersion.setName(versionId); - releaseVersion.setProjectId(releaseProject.getId()); - } + // la version n'existe pas encore sur redmine + getLog().warn("The version " + versionId + " does not exist on redmine"); - if (onlyCurrentVersion) { + releaseVersion = new Version(); + releaseVersion.setName(versionId); + releaseVersion.setProjectId(releaseProject.getId()); + } - // just release version - versionList.add(releaseVersion); - } else { + if (onlyCurrentVersion) { - // obtain all released versions (just a effective-date) + // just release version + versionList.add(releaseVersion); + } else { - buffer = new StringBuilder(); + // obtain all released versions (just a effective-date) - for (Version v : versions) { + buffer = new StringBuilder(); - String versionName = v.getName(); + for (Version v : versions) { - boolean keep = true; - if (!versionId.equals(versionName)) { + String versionName = v.getName(); - //TODO TC-20090914 make this better, since this is a - // very soft test to test only the effective date + boolean keep = true; + if (!versionId.equals(versionName)) { - if (v.getEffectiveDate() == null) { - // skip this unclosed version - keep = false; - } - } + //TODO TC-20090914 make this better, since this is a + // very soft test to test only the effective date - if (keep) { - - buffer.append(",").append(v.getName()); - versionList.add(v); + if (v.getEffectiveDate() == null) { + // skip this unclosed version + keep = false; } } - if (!versionExist) { - versionList.add(releaseVersion); + if (keep) { + + buffer.append(",").append(v.getName()); + versionList.add(v); } } - versions = versionList.toArray(new Version[versionList.size()]); - - if (!onlyCurrentVersion) { - filters.put("version", buffer.substring(1)); + if (!versionExist) { + versionList.add(releaseVersion); } + } - } catch (Exception e) { - if (verbose) { - getLog().warn("could not init the plugin for reason " + e.getMessage(), e); - } else { - getLog().warn("could not init the plugin for reason " + e.getMessage()); + versions = versionList.toArray(new Version[versionList.size()]); + + if (!onlyCurrentVersion) { + filters.put("version", buffer.substring(1)); + } + +// } catch (Exception e) { +// if (verbose) { +// getLog().warn("could not init the plugin for reason " + e.getMessage(), e); +// } else { +// getLog().warn("could not init the plugin for reason " + e.getMessage()); +// } +//// result = false; +// } +// return result; + } + + @Override + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { + return false; + } + + if (isRunOnceDone()) { + + if (!xmlPath.exists()) { + getLog().info("skip goal, work already done."); + return false; } - result = false; } - return result; + + return true; } @Override protected void doAction() throws Exception { File xmlParent = xmlPath.getParentFile(); - if (!xmlParent.exists()) { - xmlParent.mkdirs(); - } + createDirectoryIfNecessary(xmlParent); +// if (!xmlParent.exists()) { +// xmlParent.mkdirs(); +// } if (isRunOnceDone()) { - if (!xmlPath.exists()) { - // just copy the already generated changes.xml fil +// if (!xmlPath.exists()) { + // just copy the already generated changes.xml fil - getLog().info("Use already generated " + xmlPath.getName() + " (" + cacheChangesFile + ")"); + getLog().info("Use already generated " + xmlPath.getName() + " (" + cacheChangesFile + ")"); - copyFile(cacheChangesFile, xmlPath); - } else { - - getLog().info("skip goal, work already done."); - } + copyFile(cacheChangesFile, xmlPath); +// } else { +// +// getLog().info("skip goal, work already done."); +// } return; } Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssueCollectorConfiguration.java 2010-01-01 17:35:21 UTC (rev 61) @@ -22,9 +22,9 @@ /** * A simple contract to define the configuration of an issues collector. + * <p/> + * TODO javadoc * - * TODO javadoc - * * @author chemit * @since 1.0.0 */ Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/IssuesCollector.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,20 +20,15 @@ */ package org.nuiton.jredmine.plugin; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import org.apache.maven.plugin.logging.Log; -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.Tracker; -import org.nuiton.jredmine.model.Version; import org.nuiton.jredmine.RedmineService; import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.model.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * A class to collect some issues due to given filters. * @@ -86,10 +81,9 @@ /** * Collects the issues given the configuration passed. - * - * @param service redmine service to obtain datas - * @param config the collector configuration * + * @param service redmine service to obtain datas + * @param config the collector configuration * @throws RedmineServiceException if any pb while retreave datas from redmine */ public void collect(RedmineService service, IssueCollectorConfiguration config) throws RedmineServiceException { @@ -172,7 +166,7 @@ /** * clean all internal states. - * + * <p/> * Note : this method is invoked at the begin of each * {@link #collect(org.nuiton.jredmine.RedmineService, org.nuiton.jredmine.plugin.IssueCollectorConfiguration)} method. */ @@ -190,7 +184,7 @@ * Prepare the collector filters due to the given collector configuration. * * @param service redmine service to obtain datas - * @param config the collector configuration + * @param config the collector configuration * @throws RedmineServiceException if any pb whiile retreaving redmine's datas */ protected void prepareFilters(RedmineService service, IssueCollectorConfiguration config) throws RedmineServiceException { @@ -323,7 +317,7 @@ * * @param i the issue ti test * @return <code>true</code> if the issue can be collected, <code>false</code> - * otherwise. + * otherwise. */ protected boolean canIncludeIssue(Issue i) { if (statusIds != null) { Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/NextVersionMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,30 +20,30 @@ */ package org.nuiton.jredmine.plugin; -import java.text.ParseException; -import java.util.Date; import org.apache.maven.plugin.MojoExecutionException; import org.nuiton.jredmine.model.ModelHelper; import org.nuiton.jredmine.model.Version; import org.nuiton.plugin.PluginHelper; +import java.text.ParseException; +import java.util.Date; + /** * Prepare the next version to be used. * </p> * If a previous version is given, then move all unclosed issues from the * previous version to the new one. - *<p/> - * - * @goal next-version + * <p/> * * @author tchemit + * @goal next-version * @since 1.0.0 */ public class NextVersionMojo extends AbstractRedmineMojo { /** * The news description to update to redmine server. - * + * <p/> * Note : if not set, no update of the description will be made. * * @parameter expression="${redmine.versionDescription}" @@ -55,13 +55,13 @@ * <p/> * The format of the date is {@code yyyy-mm-dd}. * <p/> - * If not Set - will use current day date only if {@link #closeVersion} + * If not Set - will use current day date. * flag is on. * * @parameter expression="${redmine.effectiveDate}" * @since 1.0.0 */ - private String effectiveDate; + protected String effectiveDate; /** * The name of a previous version. * <p/> @@ -70,14 +70,14 @@ * @parameter expression="${redmine.previousVersionName}" * @since 1.0.0 */ - private String previousVersionName; + protected String previousVersionName; /** * A flag to skip the goal. * * @parameter expression="${redmine.skipNextVersion}" default-value="false" * @since 1.0.0 */ - private boolean skipNextVersion; + protected boolean skipNextVersion; /** * A flag to test plugin but send nothing to redmine. * @@ -91,7 +91,7 @@ * @parameter expression="${redmine.runOnce}" default-value="true" * @since 1.0.0 */ - private boolean runOnce; + protected boolean runOnce; /** * effective date to set */ @@ -118,8 +118,22 @@ } @Override - protected boolean init() throws Exception { + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { + return false; + } + if (isRunOnceDone()) { + getLog().info("runOnce flag is on and goal was already executed, will skip the goal."); + return false; + } + return true; + } + @Override + protected void init() throws Exception { +// protected boolean init() throws Exception { + if (versionId == null || versionId.trim().isEmpty()) { throw new MojoExecutionException("required a versionId parameter"); } @@ -131,7 +145,8 @@ if (isRunOnce()) { runOnceDone = checkRunOnceDone(); if (runOnceDone) { - return true; + return; +// return true; } } @@ -142,15 +157,16 @@ throw new MojoExecutionException("could not parse effectivate date " + effectiveDate + " for reason " + e.getMessage(), e); } } - return super.init(); + super.init(); +// return super.init(); } @Override protected void doAction() throws Exception { - if (isRunOnceDone()) { - getLog().info("skip goal, runOnce flag is on, and was already executed."); - return; - } +// if (isRunOnceDone()) { +// getLog().info("skip goal, runOnce flag is on, and was already executed."); +// return; +// } if (dryRun) { getLog().info("\n dryRun flag is on, no data will be send!\n"); Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -21,23 +21,23 @@ package org.nuiton.jredmine.plugin; +import org.apache.maven.plugin.MojoExecutionException; +import org.nuiton.helper.plugin.CollectFilesMojo; +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.plugin.PluginHelper; + import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; -import org.apache.maven.plugin.MojoExecutionException; -import org.nuiton.jredmine.model.Attachment; -import org.nuiton.helper.plugin.CollectFilesMojo; -import org.nuiton.plugin.PluginHelper; /** * Publish files for a given project and version on redmine server. * + * @author tchemit * @goal publish-attachments - * - * @author tchemit * @since 1.0.0 */ public class PublishAttachmentsMojo extends AbstractRedmineMojo { @@ -59,7 +59,7 @@ * A list of files to deploy. * <p/> * If no Set - will not use this source - * + * * @parameter expression="${redmine.files}" * @since 1.0.0 */ @@ -110,7 +110,8 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { versionId = PluginHelper.removeSnapshotSuffix(versionId); @@ -119,15 +120,22 @@ if (isRunOnce()) { runOnceDone = checkRunOnceDone(); if (runOnceDone) { - return true; + return; +// return true; } } - if (!super.init()) { - - return false; + super.init(); + if (!safe && !initOk) { + // we are in none safe mode but init is not ok... + return; } +// if (!super.init()) { +// +// return false; +// } + if (filesFromProperties != null && !filesFromProperties.exists()) { // no file to publish... getLog().warn("could not find the properties file " + filesFromProperties); @@ -136,8 +144,9 @@ } if (filesFromProperties != null && files != null && files.length > 0) { - getLog().warn("can not use both sources files and filesFromProperties"); - return false; + throw new MojoExecutionException("can not use both sources files and filesFromProperties"); +// getLog().warn("can not use both sources files and filesFromProperties"); +// return false; } if (filesFromProperties != null) { @@ -148,11 +157,29 @@ allFiles = Arrays.asList(files); } - if (allFiles.isEmpty()) { - getLog().warn("No files to send."); - getLog().warn("will skip publish news to redmine..."); +// if (allFiles.isEmpty()) { +// getLog().warn("No files to send."); +// getLog().warn("will skip publish news to redmine..."); +// return false; +// } + +// return true; + } + + @Override + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { return false; } + if (isRunOnceDone()) { + getLog().info("runOnce flag is on and goal was already executed, will skip the goal."); + return false; + } + if (allFiles == null || allFiles.isEmpty()) { + getLog().warn("No attachment to publish, will skip the goal."); + return false; + } return true; } @@ -160,10 +187,10 @@ @Override protected void doAction() throws Exception { - if (isRunOnceDone()) { - getLog().info("Skipping goal, runOnce flag is on and goal was already executed."); - return; - } +// if (isRunOnceDone()) { +// getLog().info("Skipping goal, runOnce flag is on and goal was already executed."); +// return; +// } if (dryRun) { getLog().info("\n dryRun flag is on, no data will be send!\n"); @@ -211,7 +238,7 @@ protected List<File> getFilesToDeploy() throws MojoExecutionException { // load definition file - List<File> incoming = null; + List<File> incoming; try { incoming = new CollectFilesMojo().getFiles(filesFromProperties); Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/PublishNewsMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,16 +20,17 @@ */ package org.nuiton.jredmine.plugin; -import java.io.File; +import org.apache.maven.plugin.MojoExecutionException; import org.nuiton.jredmine.model.News; import org.nuiton.plugin.PluginHelper; +import java.io.File; + /** * Publish a news on redmine server. * + * @author tchemit * @goal publish-news - * - * @author tchemit * @since 1.0.0 */ public class PublishNewsMojo extends AbstractRedmineMojo { @@ -41,32 +42,32 @@ * @required * @since 1.0.0 */ - private File newsContentFile; + protected File newsContentFile; /** * Short description or introduction of the released artifact. * * @parameter expression="${redmine.newsSummary}" * @since 1.0.0 */ - private String newsSummary; + protected String newsSummary; /** * The title of the news to create on redmine server. - * - * <b>Note : </b> the size can not be more than 60 caracters (due to a + * <p/> + * <b>Note : </b> the size can not be more than 60 caracters (due to a * redmine limitation). * * @parameter expression="${redmine.newsTitle}" * @required * @since 1.0.0 */ - private String newsTitle; + protected String newsTitle; /** * A flag to skip the goal. * * @parameter expression="${redmine.skipPublishNews}" default-value="false" * @since 1.0.0 */ - private boolean skipPublishNews; + protected boolean skipPublishNews; /** * A flag to test plugin but send nothing to redmine. * @@ -80,7 +81,7 @@ * @parameter expression="${redmine.runOnce}" default-value="true" * @since 1.0.0 */ - private boolean runOnce; + protected boolean runOnce; public PublishNewsMojo() { super(true, false, true); @@ -102,47 +103,70 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { runOnceDone = false; if (isRunOnce()) { runOnceDone = checkRunOnceDone(); if (runOnceDone) { - return true; + return; +// return true; } } - if (!super.init()) { - return false; + + super.init(); + if (!safe && !initOk) { + // we are in none safe mode but init is not ok... + return; } +// if (!super.init()) { +// return false; +// } + if (newsSummary == null || newsSummary.trim().isEmpty()) { newsSummary = project.getUrl(); } if (!newsContentFile.exists()) { // no file to publish... - getLog().warn("could not find the template " + newsContentFile); - return false; + throw new MojoExecutionException("could not find the template " + newsContentFile); +// getLog().warn("could not find the template " + newsContentFile); +// return false; } newsTitle = newsTitle.trim(); if (newsTitle.length() > 60) { - getLog().warn("News title can not be longer than 60 cars, but was " + newsTitle.length()); + getLog().warn("News title can not be longer than 60 caracters, but was " + newsTitle.length()); newsTitle = newsTitle.substring(0, 59); getLog().warn("will use the restricted title : " + newsTitle); } +// return true; + } + + @Override + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { + return false; + } + if (isRunOnceDone()) { + getLog().info("runOnce flag is on and goal was already executed, will skip the goal."); + return false; + } return true; } @Override protected void doAction() throws Exception { - if (isRunOnceDone()) { - getLog().info("skip goal, runOnce flag is on, and was already executed."); - return; - } +// if (isRunOnceDone()) { +// getLog().info("skip goal, runOnce flag is on, and was already executed."); +// return; +// } if (dryRun) { getLog().info("\n dryRun flag is on, no data will be send!\n"); Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/UpdateVersionMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,28 +20,28 @@ */ package org.nuiton.jredmine.plugin; -import java.text.ParseException; -import java.util.Date; import org.apache.maven.plugin.MojoExecutionException; import org.nuiton.jredmine.model.ModelHelper; import org.nuiton.jredmine.model.Version; import org.nuiton.plugin.PluginHelper; +import java.text.ParseException; +import java.util.Date; + /** * Create or update a version on redmine server. - *<p/> + * <p/> * Will add a the version if not existing, otherwise, will update the version. - * - * @goal update-version * * @author tchemit + * @goal update-version * @since 1.0.0 */ public class UpdateVersionMojo extends AbstractRedmineMojo { /** * The news description to update to redmine server. - * + * <p/> * Note : if not set, no update of the description will be made. * * @parameter expression="${redmine.versionDescription}" @@ -54,7 +54,7 @@ * @parameter expression="${redmine.closeVersion}" default-value="false" * @since 1.0.0 */ - private boolean closeVersion; + protected boolean closeVersion; /** * The effective date to set on the version. * <p/> @@ -66,14 +66,14 @@ * @parameter expression="${redmine.effectiveDate}" * @since 1.0.0 */ - private String effectiveDate; + protected String effectiveDate; /** * A flag to skip the goal. * * @parameter expression="${redmine.skipUpdateVersion}" default-value="false" * @since 1.0.0 */ - private boolean skipUpdateVersion; + protected boolean skipUpdateVersion; /** * A flag to test plugin but send nothing to redmine. * @@ -87,7 +87,7 @@ * @parameter expression="${redmine.runOnce}" default-value="true" * @since 1.0.0 */ - private boolean runOnce; + protected boolean runOnce; /** * effective date to set */ @@ -113,7 +113,8 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { if (versionId == null || versionId.trim().isEmpty()) { throw new MojoExecutionException("required a versionId parameter"); @@ -126,7 +127,8 @@ if (isRunOnce()) { runOnceDone = checkRunOnceDone(); if (runOnceDone) { - return true; + return; +// return true; } } @@ -139,17 +141,31 @@ } else if (closeVersion) { date = new Date(); } + super.init(); - return super.init(); +// return super.init(); } @Override - protected void doAction() throws Exception { + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { + return false; + } if (isRunOnceDone()) { getLog().info("skip goal, runOnce flag is on, and was already executed."); - return; + return false; } - + return true; + } + + @Override + protected void doAction() throws Exception { +// if (isRunOnceDone()) { +// getLog().info("skip goal, runOnce flag is on, and was already executed."); +// return; +// } + if (dryRun) { getLog().info("\n dryRun flag is on, no data will be send!\n"); } Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,11 +20,6 @@ */ package org.nuiton.jredmine.plugin.announcement; -import java.io.File; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.changes.ChangesXML; import org.apache.maven.plugins.changes.model.Release; @@ -37,8 +32,13 @@ import org.nuiton.jredmine.plugin.AbstractRedmineMojo; import org.nuiton.plugin.PluginHelper; +import java.io.File; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; + /** - * * @author chemit * @requiresOnline true */ @@ -51,7 +51,7 @@ * @required * @since 1.0.0 */ - private File templateOutputDirectory; + protected File templateOutputDirectory; /** * The path of the changes.xml file. * @@ -59,7 +59,7 @@ * @required * @since 1.0.0 */ - private File xmlPath; + protected File xmlPath; /** * Directory that contains the template. * <p> @@ -71,27 +71,28 @@ * @required * @since 1.0.0 */ - private String templateDirectory; + protected String templateDirectory; /** * The template encoding. * * @parameter expression="${redmine.templateEncoding}" default-value="${project.build.sourceEncoding}" * @since 1.0.0 */ - private String templateEncoding; + protected String templateEncoding; /** * Map which will be pass to the velocity context + * * @parameter * @since 1.0.0 */ - private Map<String, Object> announceParameters; + protected Map<String, Object> announceParameters; // /** // * Template strings per system that is used to discover the URL to use to display an attchment. Each key in this // * map denotes the (case-sensitive) identifier of the issue tracking system and its value gives the URL template. // * <p> // * There are 2 template tokens you can use. <code>%URL%</code>: this is computed by getting the // * <code><issueManagement>/<url></code> value from the POM, and removing the last '/' -// * and everything that comes after it. <code>%FILE%</code>: this is the issue number. + // * and everything that comes after it. <code>%FILE%</code>: this is the issue number. // * </p> // * // * @parameter expression="${redmine.attachmentLinkTemplate}" @@ -103,13 +104,13 @@ * @readonly * @since 1.0.0 */ - private String groupId; + protected String groupId; /** * @parameter expression="${project.artifactId}" * @readonly * @since 1.0.0 */ - private String artifactId; + protected String artifactId; /** * Distribution url of the artifact. * @@ -117,7 +118,7 @@ * @required * @since 1.0.0 */ - private String projectUrl; + protected String projectUrl; /** * Packaging structure for the artifact. * @@ -125,7 +126,7 @@ * @readonly * @since 1.0.0 */ - private String packaging; + protected String packaging; /** * The name of the artifact to be used in the announcement. * @@ -133,7 +134,7 @@ * @required * @since 1.0.0 */ - private String finalName; + protected String finalName; /** * The current project base directory. * @@ -141,7 +142,7 @@ * @required * @since 1.0.0 */ - private String basedir; + protected String basedir; /** * URL where the artifact can be downloaded. If not specified, * no URL is used. @@ -149,7 +150,7 @@ * @parameter * @since 1.0.0 */ - private String urlDownload; + protected String urlDownload; /** * Name of the team that develops the artifact. * @@ -157,27 +158,27 @@ * @required * @since 1.0.0 */ - private String developmentTeam; + protected String developmentTeam; /** * Short description or introduction of the released artifact. * * @parameter expression="${redmine.introduction}" default-value="${project.description}" * @since 1.0.0 */ - private String introduction; + protected String introduction; /** * A flag to restirct only one run in a build (for multi-module context). * * @parameter expression="${redmine.runOnce}" default-value="true" * @since 1.0.0 */ - private boolean runOnce; + protected boolean runOnce; /** * Velocity Component. * * @component roleHint="maven-helper-plugin" */ - private VelocityComponent velocity; + protected VelocityComponent velocity; protected abstract String getAnnouncementTemplate(); @@ -191,7 +192,6 @@ } /** - * * @return {@code true} if the goal was already invoked */ @Override @@ -207,7 +207,8 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { versionId = PluginHelper.removeSnapshotSuffix(versionId); @@ -216,17 +217,19 @@ if (isRunOnce()) { runOnceDone = checkRunOnceDone(); if (runOnceDone) { - return true; + return; +// return true; } } - if (!super.init()) { - return false; - } +// if (!super.init()) { +// return false; +// } if (!xmlPath.exists()) { - getLog().warn("can not find redmine-template at " + xmlPath + ", goal is skip"); - return false; + throw new MojoExecutionException("can not find redmine-template at " + xmlPath); +// getLog().warn("can not find redmine-template at " + xmlPath + ", goal is skip"); +// return false; } if (StringUtils.isEmpty(templateEncoding)) { @@ -239,17 +242,32 @@ introduction = project.getUrl(); } - return true; + super.init(); + +// return true; } @Override - protected void doAction() throws Exception { - + protected boolean checkSkip() { + boolean b = super.checkSkip(); + if (!b) { + return false; + } if (isRunOnceDone()) { getLog().info("skip goal, runOnce flag is on, and was already executed."); - return; + return false; } + return true; + } + @Override + protected void doAction() throws Exception { + +// if (isRunOnceDone()) { +// getLog().info("skip goal, runOnce flag is on, and was already executed."); +// return; +// } + ChangesXML changesXml = new ChangesXML(xmlPath, getLog()); List<?> releases = changesXml.getReleaseList(); Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AnnouncementGenerator.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AnnouncementGenerator.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AnnouncementGenerator.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,14 +20,6 @@ */ package org.nuiton.jredmine.plugin.announcement; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.changes.model.Action; @@ -39,8 +31,15 @@ import org.codehaus.plexus.util.StringUtils; import org.nuiton.jredmine.model.Attachment; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** - * * @author chemit * @since 1.0.0 */ @@ -57,11 +56,11 @@ /** * the redmine url */ - private final String url; + protected final String url; /** * the redmine attachment url template */ - private final String attachmentLinkTemplate; + protected final String attachmentLinkTemplate; /** * logger */ @@ -149,7 +148,7 @@ * Get the latest release by matching the supplied releases * with the version from the pom. * - * @param releases list of releases + * @param releases list of releases * @param releaseVersion the release version * @return A <code>Release</code> that matches the next release of the current project * @throws MojoExecutionException Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -23,9 +23,8 @@ /** * Generate the content of the release email announcement. * - * @goal generate-email-announcement - * * @author tchemit + * @goal generate-email-announcement * @since 1.0.0 */ public class GenerateEmailAnnouncementMojo extends AbstractAnnouncementMojo { @@ -37,14 +36,14 @@ * @required * @since 1.0.0 */ - private String emailAnnouncementTemplate; + protected String emailAnnouncementTemplate; /** * A flag to enable or disable the goal. * * @parameter expression="${changes.skipGenerateEmailAnnouncement}" default-value="false" * @since 1.0.0 */ - private boolean skipGenerateEmailAnnouncement; + protected boolean skipGenerateEmailAnnouncement; @Override protected String getAnnouncementTemplate() { Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojo.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojo.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojo.java 2010-01-01 17:35:21 UTC (rev 61) @@ -23,9 +23,8 @@ /** * Generate the content of the release announcement news for Redmine. * - * @goal generate-news-announcement - * * @author tchemit + * @goal generate-news-announcement * @since 1.0.0 */ public class GenerateNewsAnnouncementMojo extends AbstractAnnouncementMojo { @@ -37,14 +36,14 @@ * @required * @since 1.0.0 */ - private String newsAnnouncementTemplate; + protected String newsAnnouncementTemplate; /** * A flag to enable or disable the goal. * * @parameter expression="${redmine.skipGenerateNewsAnnouncement}" default-value="false" * @since 1.0.0 */ - private boolean skipGenerateNewsAnnouncement; + protected boolean skipGenerateNewsAnnouncement; @Override protected String getAnnouncementTemplate() { Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReport.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,15 +20,16 @@ */ package org.nuiton.jredmine.plugin.report; -import org.nuiton.jredmine.plugin.IssuesCollector; -import org.nuiton.jredmine.plugin.IssueCollectorConfiguration; -import java.util.Locale; -import java.util.Map; import org.apache.maven.reporting.MavenReportException; +import org.nuiton.jredmine.RedmineServiceException; import org.nuiton.jredmine.model.Issue; -import org.nuiton.jredmine.RedmineServiceException; +import org.nuiton.jredmine.plugin.IssueCollectorConfiguration; +import org.nuiton.jredmine.plugin.IssuesCollector; import org.nuiton.plugin.PluginHelper; +import java.util.Locale; +import java.util.Map; + /** * Abstract Generates a report for issues from Redmine's server * @@ -90,18 +91,20 @@ /// Plugin /////////////////////////////////////////////////////////////////////////// @Override - public boolean init() throws Exception { + public void init() throws Exception { +// public boolean init() throws Exception { setVersionId(PluginHelper.removeSnapshotSuffix(getVersionId())); - boolean result = super.init(); + super.init(); +// boolean result = super.init(); // if (result) { // // setVersionId(PluginHelper.removeSnapshotSuffix(getVersionId())); // // } - return result; +// return result; } /////////////////////////////////////////////////////////////////////////// Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractRedmineReport.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractRedmineReport.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/AbstractRedmineReport.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,14 +20,6 @@ */ package org.nuiton.jredmine.plugin.report; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -50,16 +42,24 @@ import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.i18n.I18N; import org.nuiton.io.rest.RestClientConfiguration; +import org.nuiton.jredmine.plugin.AbstractRedmineMojo; import org.nuiton.plugin.Plugin; -import org.nuiton.jredmine.plugin.AbstractRedmineMojo; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + /** * Abstract redmine report mojo. * * @author chemit + * @requiresReports true * @since 1.0.0 - * - * @requiresReports true */ public abstract class AbstractRedmineReport extends AbstractRedmineMojo implements MavenReport, Plugin, RestClientConfiguration { @@ -154,7 +154,8 @@ SiteRendererSink newSink = new SiteRendererSink(context); generate(newSink, currentLocale); - outputDirectory.mkdirs(); + createDirectoryIfNecessary(outputDirectory); +// outputDirectory.mkdirs(); Writer writer = new FileWriter(new File(outputDirectory, getOutputName() + ".html")); @@ -183,28 +184,29 @@ /////////////////////////////////////////////////////////////////////////// @Override public boolean canGenerateReport() { - boolean init = false; + boolean init; if (getLog().isDebugEnabled()) { getLog().debug("check can use report"); } if (session.getSettings().isOffline()) { // skip when offline getLog().info("Skipped \"" + getName(Locale.ENGLISH) + "\" report in offline mode."); - } else { - try { - init = init(); - } catch (Exception ex) { - if (isVerbose()) { - getLog().error("could not init report goal for reason " + ex.getMessage(), ex); - } else { - getLog().error("could not init report goal for reason " + ex.getMessage()); - } - init = false; + return false; + } + try { + init(); + init = true; + } catch (Exception ex) { + if (isVerbose()) { + getLog().error("could not init report goal for reason " + ex.getMessage(), ex); + } else { + getLog().error("could not init report goal for reason " + ex.getMessage()); } - if (!init) { - getLog().info("Skipped \"" + getName(Locale.ENGLISH) + "\" report, goal could be initialized."); - } + init = false; } + if (!init) { + getLog().info("Skipped \"" + getName(Locale.ENGLISH) + "\" report, goal could be initialized."); + } if (getLog().isDebugEnabled()) { getLog().debug("check can use report : " + init); } Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssueReportGenerator.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssueReportGenerator.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssueReportGenerator.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,30 +20,17 @@ */ package org.nuiton.jredmine.plugin.report; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.reporting.MavenReportException; +import org.codehaus.plexus.util.StringUtils; +import org.nuiton.jredmine.model.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.Map.Entry; -import java.util.ResourceBundle; -import java.util.TreeMap; -import org.codehaus.plexus.util.StringUtils; -import org.nuiton.jredmine.model.I18nAble; -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.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; /** * Generates a Redmine report. @@ -68,7 +55,7 @@ /** * Universe of columns of the report. - * + * <p/> * Can retreave th i18n header key by {@link #getI18nKey()} and have the * logic of each cell generation in the method * {@link #sinkInsideCell(org.apache.maven.doxia.sink.Sink, org.nuiton.jredmine.plugin.report.IssueReportGenerator, org.nuiton.jredmine.model.Issue)} @@ -279,6 +266,7 @@ } } } + private ReportColumn[] columns; private ReportColumn groupColumn; private String url; @@ -297,10 +285,9 @@ } /** - * - * @param log the logger + * @param log the logger * @param columnNames The names of the columns to include in the report - * @param groupBy the group by column name (or null if not grouped) + * @param groupBy the group by column name (or null if not grouped) * @throws MavenReportException if any pb */ public IssueReportGenerator(Log log, String columnNames, String groupBy) @@ -422,10 +409,7 @@ * @return <code>true</code> if issue links can be generated, <code>false</code> otherwise. */ public boolean canGenerateIssueLinks() { - if (!StringUtils.isEmpty(issueLinkTemplate)) { - return false; - } - return !StringUtils.isBlank(issueLinkTemplate) && (!StringUtils.isBlank(getUrl()) || issueLinkTemplate.indexOf(URL_TOKEN) < 0); + return !StringUtils.isEmpty(issueLinkTemplate) && (!StringUtils.isBlank(getUrl()) || issueLinkTemplate.indexOf(URL_TOKEN) < 0); } /** @@ -434,10 +418,7 @@ * @return <code>true</code> if issue links can be generated, <code>false</code> otherwise. */ public boolean canGenerateVersionLinks() { - if (!StringUtils.isEmpty(versionLinkTemplate)) { - return false; - } - return !StringUtils.isBlank(versionLinkTemplate) && (!StringUtils.isBlank(getUrl()) || versionLinkTemplate.indexOf(URL_TOKEN) < 0); + return !StringUtils.isEmpty(versionLinkTemplate) && (!StringUtils.isBlank(getUrl()) || versionLinkTemplate.indexOf(URL_TOKEN) < 0); } public void setUrl(String url) { Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReport.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReport.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReport.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server * - * @goal issues-report - * * @author tchemit + * @goal issues-report * @since 1.0.0 */ public class IssuesReport extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -52,7 +51,7 @@ protected boolean onlyCurrentVersion; /** * Sets some filters on issues to include. - * the possible keys are : + * the possible keys are : * <ul> * <li><b>version</b> : to restrict on version fixed </li> * <li><b>status</b> : to restrict on some status</li> @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * - * <b>Note :</b> If a value is set to empty - that means to not filter on + * <p/> + * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByAssignee.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByAssignee.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByAssignee.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by assignee. * - * @goal issues-report-by-assignee - * * @author tchemit + * @goal issues-report-by-assignee * @since 1.0.0 */ public class IssuesReportByAssignee extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByCategory.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByCategory.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByCategory.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by category. * - * @goal issues-report-by-category - * * @author tchemit + * @goal issues-report-by-category * @since 1.0.0 */ public class IssuesReportByCategory extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByPriority.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByPriority.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByPriority.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by priority. * - * @goal issues-report-by-priority - * * @author tchemit + * @goal issues-report-by-priority * @since 1.0.0 */ public class IssuesReportByPriority extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByReporter.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByReporter.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByReporter.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by reporter. * - * @goal issues-report-by-reporter - * * @author tchemit + * @goal issues-report-by-reporter * @since 1.0.0 */ public class IssuesReportByReporter extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByStatus.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByStatus.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByStatus.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by status. * - * @goal issues-report-by-status - * * @author tchemit + * @goal issues-report-by-status * @since 1.0.0 */ public class IssuesReportByStatus extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByTracker.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByTracker.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByTracker.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by tracker. * - * @goal issues-report-by-tracker - * * @author tchemit + * @goal issues-report-by-tracker * @since 1.0.0 */ public class IssuesReportByTracker extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByVersion.java =================================================================== --- trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByVersion.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/report/IssuesReportByVersion.java 2010-01-01 17:35:21 UTC (rev 61) @@ -25,16 +25,15 @@ /** * Generates a report for issues from Redmine's server group by version. * - * @goal issues-report-by-version - * * @author tchemit + * @goal issues-report-by-version * @since 1.0.0 */ public class IssuesReportByVersion extends AbstractIssuesReport { /** * Maximum number of entries to be fetched from redmine. - * + * <p/> * <b>Note:</b> use value 0 to have no limits * * @parameter expression="${redmine.maxEntries}" default-value="100" @@ -66,11 +65,11 @@ * <p/> * Multiple values can be separated by commas. * <p/> - * + * <p/> * <b>Note :</b> If a value is set to empty - that means to not filter on * that property. * <p/> - * + * <p/> * To see the internal ids, use the command : * <pre> * mvn redmine:display-ids -Dtype=<entry key> Modified: trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java =================================================================== --- trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java 2010-01-01 17:25:37 UTC (rev 60) +++ trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java 2010-01-01 17:35:21 UTC (rev 61) @@ -20,18 +20,18 @@ */ package org.nuiton.jredmine.plugin; -import java.io.File; -import java.io.IOException; import org.apache.maven.model.IssueManagement; import org.junit.Assert; import org.junit.BeforeClass; import org.nuiton.jredmine.TestHelper; import org.nuiton.plugin.AbstractMojoTest; +import java.io.File; +import java.io.IOException; + /** - * + * @author chemit * @param <P> type of mojo to test - * @author chemit * @since 1.0.0 */ public abstract class AbstractRedmineMojoTest<P extends AbstractRedmineMojo> extends AbstractMojoTest<P> { @@ -44,6 +44,7 @@ // load basedir TestHelper.getBasedir(); } + protected boolean canContinue; protected void beforeMojoInit(P mojo, File pomFile) throws Exception { @@ -64,7 +65,12 @@ beforeMojoInit(mojo, pomFile); - canContinue = mojo.init(); + try { + mojo.init(); + canContinue = mojo.checkSkip(); + } catch (Exception e) { + canContinue = false; + } if (canContinue) { if (mojo.isVerbose()) { log.info("setup done for " + mojo.getProject().getFile().getName()); @@ -78,7 +84,12 @@ if (!canContinue) { return; } - Assert.assertNotNull(getMojo()); - getMojo().doAction(); + P mojo = getMojo(); + Assert.assertNotNull(mojo); + try { + mojo.doAction(); + } finally { + mojo.afterExecute(); + } } }
participants (1)
-
tchemit@users.nuiton.org