r265 - 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/request jredmine-client/src/test/java/org/nuiton/jredmine/model jredmine-domain/src/main/java/org/nuiton/jredmine jredmine-domain/src/main/java/org/nuiton/jredmine/model jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3 jredmine-domain/src/main/java/org/nuiton/jredmine/request
Author: tchemit Date: 2012-07-12 15:35:20 +0200 (Thu, 12 Jul 2012) New Revision: 265 Url: http://nuiton.org/repositories/revision/jredmine/265 Log: move some stuff from client to domain module Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineRestUnavailable.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineService.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceException.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/DefaultRedmineXpp3Helper.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java Removed: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java trunk/jredmine-client/src/test/java/org/nuiton/jredmine/model/io/ Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Attachment.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/CustomField.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/I18nAble.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IdAble.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Issue.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueCategory.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssuePriority.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueStatus.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ModelHelper.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/News.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Project.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ProjectRef.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/TimeEntry.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Tracker.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/User.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/UserRef.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Version.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/CustomFieldXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectRefXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserRefXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,223 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -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.TimeEntry; -import org.nuiton.jredmine.model.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; - -/** - * Contract of all redmine operations which do not requires any login to server. - * <p/> - * A default implementation is {@link DefaultRedmineAnonymousService}. - * <p/> - * Created: 2 janv. 2010 - * - * @author tchemit <chemit@codelutin.com> - * @see DefaultRedmineAnonymousService - * @since 1.0.3 - */ -public interface RedmineAnonymousService { - - /** - * Obtain all accessible projects. - * - * @return all the projects - * @throws RedmineServiceException if any pb while retriving datas - * @see Project - */ - Project[] getProjects() throws RedmineServiceException; - - /** - * Obtain all the priorities defined on a {@link Issue}. - * <p/> - * <b>Note : </b> The priorities are common for all projects. - * - * @return all the issue properties - * @throws RedmineServiceException if any pb while retriving datas - * @see IssuePriority - */ - IssuePriority[] getIssuePriorities() throws RedmineServiceException; - - /** - * Obtain all the statuses defined on a {@link Issue}. - * <p/> - * <b>Note : </b> The statuses are common for all projects. - * - * @return all the issue statuses - * @throws RedmineServiceException if any pb while retriving datas - * @see IssueStatus - */ - IssueStatus[] getIssueStatuses() throws RedmineServiceException; - - /** - * Obtain a project given his name. - * - * @param projectName the name of the project - * @return the project - * @throws RedmineServiceException if any pb while retriving datas - * @see Project - */ - Project getProject(String projectName) throws RedmineServiceException; - - /** - * Obtain all categories defined on issues for a given project. - * - * @param projectName the name of the project - * @return the categories of issues for the given project. - * @throws RedmineServiceException if any pb while retriving datas - * @see IssueCategory - */ - IssueCategory[] getIssueCategories(String projectName) throws RedmineServiceException; - - /** - * Obtain all trackers defined on a given project. - * - * @param projectName the name of the project - * @return the trackers for the given project. - * @throws RedmineServiceException if any pb while retriving datas - * @see Tracker - */ - Tracker[] getTrackers(String projectName) throws RedmineServiceException; - - /** - * Obtain all news defined on a given project. - * - * @param projectName the name of the project - * @return the news for the given project. - * @throws RedmineServiceException if any pb while retriving datas - * @see News - */ - News[] getNews(String projectName) throws RedmineServiceException; - - /** - * Obtain all users defined on a given project. - * - * @param projectName the name of the project - * @return the users for the given project. - * @throws RedmineServiceException if any pb while retriving datas - * @see User - */ - User[] getProjectMembers(String projectName) throws RedmineServiceException; - - /** - * Obtain all versions defined on a given project. - * - * @param projectName the name of the project - * @return the versions of the given project. - * @throws RedmineServiceException if any pb while retriving datas - * @see Version - */ - Version[] getVersions(String projectName) throws RedmineServiceException; - - /** - * Obtain a specific version for a given project. - * - * @param projectName the name of the project - * @param versionName the name of the version - * @return the version - * @throws RedmineServiceException if any pb while retriving datas - * @see Version - */ - 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 - * @param versionName the name of the version - * @return the issues - * @throws RedmineServiceException if any pb while retriving datas - * @see Issue - */ - Issue[] getIssues(String projectName, - String versionName) 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; - - /** - * Obtain all attachments for a specific version on a given project. - * - * @param projectName the name of the project - * @param versionName the name of the version - * @return the attachments - * @throws RedmineServiceException if any pb while retriving datas - * @see Attachment - */ - Attachment[] getAttachments(String projectName, - String versionName) throws RedmineServiceException; -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,161 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine; - -import org.nuiton.jredmine.model.Attachment; -import org.nuiton.jredmine.model.Issue; -import org.nuiton.jredmine.model.News; -import org.nuiton.jredmine.model.Project; -import org.nuiton.jredmine.model.TimeEntry; -import org.nuiton.jredmine.model.Version; - - -/** - * Contract of all redmine operations that needs a login to be performed. - * <p/> - * A default implementation is offered in {@link DefaultRedmineService}. - * <p/> - * Created: 2 janv. 2010 - * - * @author tchemit <chemit@codelutin.com> - * @see RedmineAnonymousService - * @see RedmineService - * @since 1.0.3 - */ -public interface RedmineLogguedService { - - /** - * Obtain for the loggued user, all projets where he belongs. - * <p/> - * <b>Note:</b> This method requires to be loggued on redmine server. - * - * @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; - - /** - * Add a version for a given project. - * <p/> - * b>Note:</b> This method requires to be loggued on redmine server. - * - * @param projectName the name of the project - * @param version the version to add - * @return the added version - * @throws RedmineServiceException if any pb while sending and retriving - * datas to redmine server - * @see Version - */ - Version addVersion(String projectName, - Version version) throws RedmineServiceException; - - /** - * Update a version for a given project. - * <p/> - * b>Note:</b> This method requires to be loggued on redmine server. - * - * @param projectName the name of the project - * @param version the version to update - * @return the updated version - * @throws RedmineServiceException if any pb while sending and retriving - * datas to redmine server - * @see Version - */ - Version updateVersion(String projectName, - Version version) throws RedmineServiceException; - - /** - * Prepare a new version (create it or update it). - * <p/> - * If the {@code oldVersionName} is given, then all issues unclosed from this - * old version will be move to the new version. - * <p/> - * b>Note:</b> This method requires to be loggued on redmine server. - * - * @param projectName the name of the project - * @param oldVersionName the name of the old version (optional) - * @param newVersion the newVersion to create or update - * @return the created version - * @throws RedmineServiceException if any pb while sending and retriving - * datas to redmine server - * @see Version - */ - Version nextVersion(String projectName, - String oldVersionName, - Version newVersion) throws RedmineServiceException; - - /** - * Add a news for a given project. - * <p/> - * b>Note:</b> This method requires to be loggued on redmine server. - * - * @param projectName the name of the project - * @param news the news to add - * @return the added news. - * @throws RedmineServiceException if any pb while sending and retriving - * datas to redmine server - * @see News - */ - News addNews(String projectName, News news) throws RedmineServiceException; - - /** - * Add a attachment for a given version of a given project. - * <p/> - * b>Note:</b> This method requires to be loggued on redmine server. - * - * @param projectName the name of the project - * @param versionName the name of the version - * @param attachement the attachment to add - * @return the added attachment - * @throws RedmineServiceException if any pb while sending and retriving - * datas to redmine server - * @see Attachment - */ - Attachment addAttachment(String projectName, - String versionName, - Attachment attachement) throws RedmineServiceException; - - /** - * Add a new time entry to the given issue for the given project and - * return the updated time entry. - * <p/> - * b>Note:</b> This method requires to be loggued on redmine server. - * - * @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; -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,42 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine; - -/** - * The full redmine service with anonymous and loggued methods. - * <p/> - * <b>Note:</b> A default implementation is offered : - * {@link DefaultRedmineService} - * - * @author tchemit <chemit@codelutin.com> - * @see DefaultRedmineService - * @since 1.0.0 - */ -public interface RedmineService extends RedmineAnonymousService, RedmineLogguedService { - - /** Plexus lookup name. */ - String ROLE = RedmineService.class.getName(); - -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,62 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine; - -import org.nuiton.io.rest.RestClientConfiguration; - -import java.net.URL; - -/** - * Contract of a redmine service configuration. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public interface RedmineServiceConfiguration extends RestClientConfiguration { - - String getEncoding(); - - void setEncoding(String encoding); - - String getRestPassword(); - - void setRestPassword(String restPassword); - - URL getRestUrl(); - - void setRestUrl(URL restUrl); - - String getRestUsername(); - - void setRestUsername(String restUsername); - - boolean isVerbose(); - - void setVerbose(boolean verbose); - - boolean isAnonymous(); - - void setAnonymous(boolean anonymous); -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,51 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine; - -/** - * An exception to throw when something is wrong in a {@link RedmineService}. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.0 - */ -public class RedmineServiceException extends Exception { - - private static final long serialVersionUID = 1L; - - public RedmineServiceException(Throwable cause) { - super(cause); - } - - public RedmineServiceException(String message, Throwable cause) { - super(message, cause); - } - - public RedmineServiceException(String message) { - super(message); - } - - public RedmineServiceException() { - } -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,142 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine; - -import org.nuiton.jredmine.rest.RedmineRestClient; - -/** - * Technical contract to implements a redmine service which wrap the - * {@link RedmineRestClient}. - * <p/> - * A default implementation is offered in {@link DefaultRedmineServiceImplementor}. - * <p/> - * Any concrete implentation of a redmine service should implements this.. - * - * @author tchemit <chemit@codelutin.com> - * @see DefaultRedmineServiceImplementor - * @since 1.0.0 - */ -public interface RedmineServiceImplementor { - - /** - * 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. - */ - boolean isInit(); - - /** - * 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 if any pb - */ - RedmineServiceImplementor init(RedmineServiceConfiguration configuration) throws RedmineServiceException; - - /** - * Close the service and destroy any connexion to the redmine service. - * - * @throws RedmineServiceException if any pb - */ - void destroy() throws RedmineServiceException; - - /** - * Try to ping the redmine remote service and return his status. - * - * @return status code of the ping request, or {@code -1} if something was - * wrong (unknown host,...). - */ - int ping(); - - /** - * Generic method to obtain a single data from a redmine server. - * - * @param <T> the type of data to obtain - * @param requestName the name of the request to use - * @param type the type of data to obtain - * @param args the parameters to obtain the data - * @return the obtained data - * @throws RedmineServiceException if any pb - */ - <T> T getData(String requestName, 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 requestName the name of the request to use - * @param type the type of data to obtain - * @param args the parameters to obtain the datas - * @return the obtained datas - * @throws RedmineServiceException if any pb - */ - <T> T[] getDatas(String requestName, Class<T> type, Object... args) throws RedmineServiceException; - - /** - * Generic method to send a data to a redmine server and return the single - * data updated from the redmine server. - * - * @param requestName the name of the request used - * @param klazz the type of data to treate - * @param args the parameters of the request - * @param <T> the type of data to treate - * @return the updated data - * @throws RedmineServiceException if any pb - */ - <T> T sendData(String requestName, Class<T> klazz, Object... args) throws RedmineServiceException; - - - /** - * Generic method to send a data (or more ) to a redmine server and - * return the array of data from the redmine server. - * - * @param requestName the name of the request used - * @param klazz the type of data to treate - * @param args the parameters of the request - * @param <T> the type of data to treate - * @return the updated data - * @throws RedmineServiceException if any pb - */ - <T> T[] sendDatas(String requestName, Class<T> klazz, Object... args) throws RedmineServiceException; - - /** - * Checks if the current session is not a anonymous one. - * - * @throws IllegalStateException if service not init - * @throws RedmineServiceLoginException if not loggued - * @throws NullPointerException if something is null - */ - void checkLoggued() throws IllegalStateException, RedmineServiceLoginException, NullPointerException; - - /** - * Checks if the current session is anonymous. - * - * @throws RedmineServiceLoginException if not anonymous - * @throws NullPointerException if something is null - */ - void checkNotLoggued() throws RedmineServiceLoginException, NullPointerException; -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,54 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine; - -/** - * An exception to be thrown when a problem with authentication state in a - * {@link RedmineService}. - * <p/> - * Created: 2 janv. 2010 - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.3 - */ -public class RedmineServiceLoginException extends RedmineServiceException { - - private static final long serialVersionUID = 1L; - - public RedmineServiceLoginException() { - } - - public RedmineServiceLoginException(Throwable cause) { - super(cause); - } - - public RedmineServiceLoginException(String message) { - super(message); - } - - public RedmineServiceLoginException(String message, Throwable cause) { - super(message, cause); - } -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelEnum.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,97 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-domain/src/main/java/org/n... $ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.model; - -import org.nuiton.jredmine.rest.RedmineRestClient; - -/** - * Un énumération pour connaitre l'ensemble des classes du modèle. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.0 - */ -public enum RedmineModelEnum { - - issueStatus(IssueStatus.class, RedmineModelScope.none, RedmineRestClient.GET_ISSUE_STATUS_LIST), - issuePriority(IssuePriority.class, RedmineModelScope.none, RedmineRestClient.GET_ISSUE_PRIORITY_LIST), - project(Project.class, RedmineModelScope.none, RedmineRestClient.GET_PROJECT_LIST), - issueCategory(IssueCategory.class, RedmineModelScope.project, RedmineRestClient.GET_ISSUE_CATEGORY_LIST), - tracker(Tracker.class, RedmineModelScope.project, RedmineRestClient.GET_TRACKER_LIST), - user(User.class, RedmineModelScope.project, RedmineRestClient.GET_USER_LIST), - news(News.class, RedmineModelScope.project, RedmineRestClient.GET_NEWS_LIST), - version(Version.class, RedmineModelScope.project, RedmineRestClient.GET_VERSION_LIST), - issue(Issue.class, RedmineModelScope.version, RedmineRestClient.GET_ISSUE_LIST), - timeEntry(TimeEntry.class, RedmineModelScope.issue, RedmineRestClient.GET_ISSUE_TIME_ENTRY_LIST), - attachment(Attachment.class, RedmineModelScope.version, RedmineRestClient.GET_ATTACHMENTS_LIST); - - private final Class<?> modelType; - - private final RedmineModelScope scope; - - private final String requestAll; - - RedmineModelEnum(Class<?> modelType, RedmineModelScope scope, String requestAll) { - this.modelType = modelType; - this.scope = scope; - this.requestAll = requestAll; - } - - - public Class<?> getModelType() { - return modelType; - } - - public RedmineModelScope getScope() { - return scope; - } - - public String getRequestAll() { - return requestAll; - } - - public static RedmineModelEnum valueOf(Class<?> type) { - for (RedmineModelEnum e : values()) { - if (e.getModelType().equals(type)) { - return e; - } - } - return null; - } - - public static RedmineModelEnum safeValueOf(Class<?> type) { - if (type == null) { - throw new NullPointerException("klass parameter can not be null"); - } - - // check dataType is authorized - - RedmineModelEnum r = valueOf(type); - if (r == null) { - throw new IllegalArgumentException("the type " + type.getName() + " is not allowed!"); - } - - return r; - } -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/RedmineModelScope.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,56 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL: http://svn.nuiton.org/svn/jredmine/trunk/jredmine-domain/src/main/java/org/n... $ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -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. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.0 - */ -public enum RedmineModelScope { - - /** none scope, requires nothing. */ - none, - /** project scope, requires a project. */ - project, - /** version scope, requires a project and a version. */ - version, - /** issue scope, requires a project and an issue. */ - issue -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,107 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -import org.apache.commons.lang.ArrayUtils; - -import java.io.File; -import java.util.Map; - -/** - * The default implementation of the redmine request builder. - * - * @author tchemit <chemit@codelutin.com> - * @see RedmineRequestBuilder - * @see RedmineRequest - * @since 1.4 - */ -public class DefaultRedmineRequestBuilder implements RedmineRequestBuilder { - - private static final long serialVersionUID = 1L; - - protected final String name; - - protected final String action; - - public DefaultRedmineRequestBuilder(String action) { - this(action, action); - } - - public DefaultRedmineRequestBuilder(String name, String action) { - this.name = name; - this.action = action; - } - - @Override - public String getName() { - return name; - } - - /** - * Compute a array of pair (key-value) from the given arguments. - * <p/> - * Order is important to do this, define it. - * - * @param args the args of the request - * @return parameters to use in request by pari of key-value - * (key,value,key2, value2) - */ - public String[] getParameters(Object... args) { - // by default, no parameter - return ArrayUtils.EMPTY_STRING_ARRAY; - } - - public String[] getPath(Object... args) { - // by default, path is action - return new String[]{action}; - } - - public Map<String, File> getAttachments(Object... args) { - // by default, no attachments - return null; - } - - @Override - public RedmineRequest create(final Object... args) { - - return new RedmineRequest() { - - @Override - public String[] getPath() { - return DefaultRedmineRequestBuilder.this.getPath(args); - } - - @Override - public String[] getParameters() { - return DefaultRedmineRequestBuilder.this.getParameters(args); - } - - @Override - public Map<String, File> getAttachments() { - return DefaultRedmineRequestBuilder.this.getAttachments(args); - } - }; - } -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,57 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -/** - * To build request with a project and issue scope. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class IssueScopeRedmineRequestBuilder extends ProjectScopeRedmineRequestBuilder { - - private static final long serialVersionUID = 1L; - - public IssueScopeRedmineRequestBuilder(String name, String action) { - super(name, action); - } - - public IssueScopeRedmineRequestBuilder(String action) { - super(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 - }; - } -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,57 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -/** - * To build request with a project scope. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class ProjectScopeRedmineRequestBuilder extends DefaultRedmineRequestBuilder { - - private static final long serialVersionUID = 1L; - - public ProjectScopeRedmineRequestBuilder(String name, String action) { - super(name, action); - } - - public ProjectScopeRedmineRequestBuilder(String action) { - super(action); - } - - @Override - public String[] getPath(Object... args) { - - // one args : projectName - - String projectName = (String) args[0]; - - return new String[]{ - action, - projectName - }; - } -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,49 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -import java.io.File; -import java.util.Map; - -/** - * To define a redmine request. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public interface RedmineRequest { - - /** @return the splitted path to add to url */ - String[] getPath(); - - /** - * @return an array of pair (parameter name - parameter value) to pass - * to request - */ - String[] getParameters(); - - /** @return the map of attachment to pass to request */ - Map<String, File> getAttachments(); -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,47 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -import java.io.Serializable; - -/** - * The contract of a redmine request builder. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public interface RedmineRequestBuilder extends Serializable { - - /** @return the unique name of the request builder */ - String getName(); - - /** - * Create the request given the {@code args}. - * - * @param args args to create the request - * @return the created request - */ - RedmineRequest create(Object... args); -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,292 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -import com.google.common.base.Strings; -import com.google.common.collect.Maps; -import org.nuiton.jredmine.model.Attachment; -import org.nuiton.jredmine.model.News; -import org.nuiton.jredmine.model.TimeEntry; -import org.nuiton.jredmine.model.Version; -import org.nuiton.jredmine.model.VersionStatusEnum; - -import java.io.File; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * Factory of {@link RedmineRequest}. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class RedmineRequestFactory { - - public static final DateFormat DATE_FORMAT = - new SimpleDateFormat("yyyy-MM-dd"); - - /** registred requests */ - protected final Map<String, RedmineRequestBuilder> requestBuilders; - - public RedmineRequestFactory() { - requestBuilders = Maps.newTreeMap(); - } - - public void addDefaultRequests() { - for (DEFAULT_REQUESTS request : DEFAULT_REQUESTS.values()) { - addRequestBuilder(request.requestBuilder); - } - } - - /** - * Add a request into the factory. - * - * @param builder the new request to add - */ - public void addRequestBuilder(RedmineRequestBuilder builder) { - String name = builder.getName(); - if (requestBuilders.containsKey(name)) { - throw new IllegalArgumentException("a request builder with name " + - name + " already exists."); - } - requestBuilders.put(name, builder); - } - - /** - * Obtain a request given his id and the args given. - * - * @param id id of the request - * @param args args passed to build the request - * @return the new request - */ - public RedmineRequest getRequest(String id, Object... args) { - - RedmineRequest r; - RedmineRequestBuilder builder = requestBuilders.get(id); - if (builder == null) { - - throw new IllegalArgumentException( - "Could not find any request builder for request named '" + - id + "'"); - } - r = builder.create(args); - if (r == null) { - throw new IllegalArgumentException( - "Could not find any request named '" + id + - "' using builder " + builder); - } - return r; - } - - public enum DEFAULT_REQUESTS { - - // misc requests - - PING(new DefaultRedmineRequestBuilder("ping")), - LOGOUT(new DefaultRedmineRequestBuilder("logout")), - LOGIN(new DefaultRedmineRequestBuilder("login") { - private static final long serialVersionUID = 1L; - - @Override - public String[] getParameters(Object... args) { - String login = (String) args[0]; - String password = (String) args[1]; - return new String[]{"username", login, "password", password}; - } - }), - - // with no scope - - GET_PROJECT_LIST(new DefaultRedmineRequestBuilder("get_projects.xml")), - GET_USER_PROJECTS(new DefaultRedmineRequestBuilder("get_user_projects.xml")), - GET_ISSUE_STATUS_LIST(new DefaultRedmineRequestBuilder("get_issue_statuses.xml")), - GET_ISSUE_PRIORITY_LIST(new DefaultRedmineRequestBuilder("get_issue_priorities.xml")), - - // with project scope - - GET_PROJECT(new ProjectScopeRedmineRequestBuilder("get_project.xml")), - GET_PROJECT_ISSUES(new ProjectScopeRedmineRequestBuilder("get_project_issues.xml")), - GET_PROJECT_OPENED_ISSUES(new ProjectScopeRedmineRequestBuilder("get_project_opened_issues.xml")), - GET_PROJECT_CLOSED_ISSUES(new ProjectScopeRedmineRequestBuilder("get_project_closed_issues.xml")), - GET_VERSION_LIST(new ProjectScopeRedmineRequestBuilder("get_project_versions.xml")), - GET_ISSUE_CATEGORY_LIST(new ProjectScopeRedmineRequestBuilder("get_issue_categories.xml")), - GET_TRACKER_LIST(new ProjectScopeRedmineRequestBuilder("get_project_trackers.xml")), - GET_USER_LIST(new ProjectScopeRedmineRequestBuilder("get_project_users.xml")), - GET_NEWS_LIST(new ProjectScopeRedmineRequestBuilder("get_project_news.xml")), - - ADD_VERSION(new ProjectScopeRedmineRequestBuilder("add_version.xml") { - private static final long serialVersionUID = 1L; - - @Override - public String[] getParameters(Object... args) { - Version version = (Version) args[1]; - String date = getVersionEffectiveDate(version); - String status = getVersionStatus(version); - return new String[]{ - "version[name]", version.getName(), - "version[description]", version.getDescription(), - "version[effective_date]", date, - "version[status]", status - }; - } - }), - UPDATE_VERSION(new ProjectScopeRedmineRequestBuilder("update_version.xml") { - private static final long serialVersionUID = 1L; - - @Override - public String[] getParameters(Object... args) { - Version version = (Version) args[1]; - String date = getVersionEffectiveDate(version); - String status = getVersionStatus(version); - return new String[]{ - "version[name]", version.getName(), - "version[description]", version.getDescription(), - "version[effective_date]", date, - "version[status]", status - }; - } - }), - NEXT_VERSION(new ProjectScopeRedmineRequestBuilder("next_version.xml") { - private static final long serialVersionUID = 1L; - - @Override - public String[] getParameters(Object... args) { - - - Version version = (Version) args[1]; - String date = getVersionEffectiveDate(version); - String status = getVersionStatus(version); - String oldVersionName = (String) args[2]; - return new String[]{ - "oldVersionName", oldVersionName, - "version[name]", version.getName(), - "version[description]", version.getDescription(), - "version[effective_date]", date, - "version[status]", status - }; - } - }), - ADD_NEWS(new ProjectScopeRedmineRequestBuilder("add_news.xml") { - private static final long serialVersionUID = 1L; - - @Override - public String[] getParameters(Object... args) { - News news = (News) args[1]; - return new String[]{ - "news[title]", news.getTitle(), - "news[summary]", news.getSummary(), - "news[description]", news.getDescription() - }; - } - }), - - // version scope - GET_VERSION(new VersionScopeRedmineRequestBuilder("get_version.xml")), - GET_ISSUE_LIST(new VersionScopeRedmineRequestBuilder("get_version_issues.xml")), - GET_ATTACHMENTS_LIST(new VersionScopeRedmineRequestBuilder("get_version_attachments.xml")), - ADD_ATTACHMENT(new VersionScopeRedmineRequestBuilder("add_version_attachment.xml") { - private static final long serialVersionUID = 1L; - - @Override - public String[] getParameters(Object... args) { - String versionId = (String) args[1]; - Attachment attachment = (Attachment) args[2]; - return new String[]{ - "version_name", versionId, - "attachment[description]", attachment.getDescription() - }; - } - - @Override - public Map<String, File> getAttachments(Object... args) { - Map<String, File> upload = new HashMap<String, File>(); - Attachment attachment = (Attachment) args[2]; - upload.put("attachment[file]", attachment.getToUpload()); - return upload; - } - }), - - // issue scope - - GET_ISSUE_TIME_ENTRY_LIST(new IssueScopeRedmineRequestBuilder("get_issue_times.xml")), - - ADD_ISSUE_TIME_ENTRY(new IssueScopeRedmineRequestBuilder("add_issue_time.xml") { - private static final long serialVersionUID = 1L; - - @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() - }; - } - }); - - private final RedmineRequestBuilder requestBuilder; - - DEFAULT_REQUESTS(RedmineRequestBuilder requestBuilder) { - this.requestBuilder = requestBuilder; - } - - public RedmineRequestBuilder getRequestBuilder() { - return requestBuilder; - } - - public String requestName() { - return requestBuilder.getName(); - } - } - - protected static String getVersionStatus(Version version) { - String status = version.getStatus(); - if (Strings.isNullOrEmpty(status)) { - - // use default open status - status = VersionStatusEnum.open.name(); - } - return status; - } - - protected static String getVersionEffectiveDate(Version version) { - return version.getEffectiveDate() == null ? "" : - DATE_FORMAT.format(version.getEffectiveDate()); - } - - -} Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,57 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.jredmine.request; - -/** - * To build request with a project and version scope. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class VersionScopeRedmineRequestBuilder extends ProjectScopeRedmineRequestBuilder { - - private static final long serialVersionUID = 1L; - - public VersionScopeRedmineRequestBuilder(String name, String action) { - super(name, action); - } - - public VersionScopeRedmineRequestBuilder(String action) { - super(action); - } - - @Override - public String[] getParameters(Object... args) { - - // args 1 = project id - // args 2 = version name - - String versionName = (String) args[1]; - - return new String[]{ - "version_name", versionName - }; - } -} Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,220 @@ +/* + * #%L + * JRedmine :: Client + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +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.TimeEntry; +import org.nuiton.jredmine.model.Tracker; +import org.nuiton.jredmine.model.User; +import org.nuiton.jredmine.model.Version; + +/** + * Contract of all redmine operations which do not requires any login to server. + * <p/> + * Created: 2 janv. 2010 + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.3 + */ +public interface RedmineAnonymousService { + + /** + * Obtain all accessible projects. + * + * @return all the projects + * @throws RedmineServiceException if any pb while retriving datas + * @see Project + */ + Project[] getProjects() throws RedmineServiceException; + + /** + * Obtain all the priorities defined on a {@link Issue}. + * <p/> + * <b>Note : </b> The priorities are common for all projects. + * + * @return all the issue properties + * @throws RedmineServiceException if any pb while retriving datas + * @see IssuePriority + */ + IssuePriority[] getIssuePriorities() throws RedmineServiceException; + + /** + * Obtain all the statuses defined on a {@link Issue}. + * <p/> + * <b>Note : </b> The statuses are common for all projects. + * + * @return all the issue statuses + * @throws RedmineServiceException if any pb while retriving datas + * @see IssueStatus + */ + IssueStatus[] getIssueStatuses() throws RedmineServiceException; + + /** + * Obtain a project given his name. + * + * @param projectName the name of the project + * @return the project + * @throws RedmineServiceException if any pb while retriving datas + * @see Project + */ + Project getProject(String projectName) throws RedmineServiceException; + + /** + * Obtain all categories defined on issues for a given project. + * + * @param projectName the name of the project + * @return the categories of issues for the given project. + * @throws RedmineServiceException if any pb while retriving datas + * @see IssueCategory + */ + IssueCategory[] getIssueCategories(String projectName) throws RedmineServiceException; + + /** + * Obtain all trackers defined on a given project. + * + * @param projectName the name of the project + * @return the trackers for the given project. + * @throws RedmineServiceException if any pb while retriving datas + * @see Tracker + */ + Tracker[] getTrackers(String projectName) throws RedmineServiceException; + + /** + * Obtain all news defined on a given project. + * + * @param projectName the name of the project + * @return the news for the given project. + * @throws RedmineServiceException if any pb while retriving datas + * @see News + */ + News[] getNews(String projectName) throws RedmineServiceException; + + /** + * Obtain all users defined on a given project. + * + * @param projectName the name of the project + * @return the users for the given project. + * @throws RedmineServiceException if any pb while retriving datas + * @see User + */ + User[] getProjectMembers(String projectName) throws RedmineServiceException; + + /** + * Obtain all versions defined on a given project. + * + * @param projectName the name of the project + * @return the versions of the given project. + * @throws RedmineServiceException if any pb while retriving datas + * @see Version + */ + Version[] getVersions(String projectName) throws RedmineServiceException; + + /** + * Obtain a specific version for a given project. + * + * @param projectName the name of the project + * @param versionName the name of the version + * @return the version + * @throws RedmineServiceException if any pb while retriving datas + * @see Version + */ + 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 + * @param versionName the name of the version + * @return the issues + * @throws RedmineServiceException if any pb while retriving datas + * @see Issue + */ + Issue[] getIssues(String projectName, + String versionName) 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; + + /** + * Obtain all attachments for a specific version on a given project. + * + * @param projectName the name of the project + * @param versionName the name of the version + * @return the attachments + * @throws RedmineServiceException if any pb while retriving datas + * @see Attachment + */ + Attachment[] getAttachments(String projectName, + String versionName) throws RedmineServiceException; +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineAnonymousService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,135 @@ +package org.nuiton.jredmine; + +import org.nuiton.jredmine.model.Attachment; +import org.nuiton.jredmine.model.Issue; +import org.nuiton.jredmine.model.News; +import org.nuiton.jredmine.model.Project; +import org.nuiton.jredmine.model.TimeEntry; +import org.nuiton.jredmine.model.Version; + + +/** + * Contract of all redmine operations that needs a login to be performed. + * <p/> + * Created: 2 janv. 2010 + * + * @author tchemit <chemit@codelutin.com> + * @see RedmineAnonymousService + * @see RedmineService + * @since 1.0.3 + */ +public interface RedmineLogguedService { + + /** + * Obtain for the loggued user, all projets where he belongs. + * <p/> + * <b>Note:</b> This method requires to be loggued on redmine server. + * + * @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; + + /** + * Add a version for a given project. + * <p/> + * b>Note:</b> This method requires to be loggued on redmine server. + * + * @param projectName the name of the project + * @param version the version to add + * @return the added version + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server + * @see Version + */ + Version addVersion(String projectName, + Version version) throws RedmineServiceException; + + /** + * Update a version for a given project. + * <p/> + * b>Note:</b> This method requires to be loggued on redmine server. + * + * @param projectName the name of the project + * @param version the version to update + * @return the updated version + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server + * @see Version + */ + Version updateVersion(String projectName, + Version version) throws RedmineServiceException; + + /** + * Prepare a new version (create it or update it). + * <p/> + * If the {@code oldVersionName} is given, then all issues unclosed from this + * old version will be move to the new version. + * <p/> + * b>Note:</b> This method requires to be loggued on redmine server. + * + * @param projectName the name of the project + * @param oldVersionName the name of the old version (optional) + * @param newVersion the newVersion to create or update + * @return the created version + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server + * @see Version + */ + Version nextVersion(String projectName, + String oldVersionName, + Version newVersion) throws RedmineServiceException; + + /** + * Add a news for a given project. + * <p/> + * b>Note:</b> This method requires to be loggued on redmine server. + * + * @param projectName the name of the project + * @param news the news to add + * @return the added news. + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server + * @see News + */ + News addNews(String projectName, News news) throws RedmineServiceException; + + /** + * Add a attachment for a given version of a given project. + * <p/> + * b>Note:</b> This method requires to be loggued on redmine server. + * + * @param projectName the name of the project + * @param versionName the name of the version + * @param attachement the attachment to add + * @return the added attachment + * @throws RedmineServiceException if any pb while sending and retriving + * datas to redmine server + * @see Attachment + */ + Attachment addAttachment(String projectName, + String versionName, + Attachment attachement) throws RedmineServiceException; + + /** + * Add a new time entry to the given issue for the given project and + * return the updated time entry. + * <p/> + * b>Note:</b> This method requires to be loggued on redmine server. + * + * @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; +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineLogguedService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineRestUnavailable.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineRestUnavailable.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineRestUnavailable.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,22 @@ +package org.nuiton.jredmine; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * To mark service that does not use the redmine rest api but still the + * jredmine rest api. + * <p/> + * Ath the end this will disappear if everything in available in redmine. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.METHOD) +public @interface RedmineRestUnavailable { +} Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineService.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineService.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineService.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineService.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,14 @@ +package org.nuiton.jredmine; + +/** + * The full redmine service with anonymous and loggued methods. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public interface RedmineService extends RedmineAnonymousService, RedmineLogguedService { + + /** Plexus lookup name. */ + String ROLE = RedmineService.class.getName(); + +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,38 @@ +package org.nuiton.jredmine; + +import org.nuiton.io.rest.RestClientConfiguration; + +import java.net.URL; + +/** + * Contract of a redmine service configuration. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public interface RedmineServiceConfiguration extends RestClientConfiguration { + + String getEncoding(); + + void setEncoding(String encoding); + + String getRestPassword(); + + void setRestPassword(String restPassword); + + URL getRestUrl(); + + void setRestUrl(URL restUrl); + + String getRestUsername(); + + void setRestUsername(String restUsername); + + boolean isVerbose(); + + void setVerbose(boolean verbose); + + boolean isAnonymous(); + + void setAnonymous(boolean anonymous); +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceConfiguration.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceException.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceException.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceException.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceException.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,27 @@ +package org.nuiton.jredmine; + +/** + * An exception to throw when something is wrong in a {@link RedmineService}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public class RedmineServiceException extends Exception { + + private static final long serialVersionUID = 1L; + + public RedmineServiceException(Throwable cause) { + super(cause); + } + + public RedmineServiceException(String message, Throwable cause) { + super(message, cause); + } + + public RedmineServiceException(String message) { + super(message); + } + + public RedmineServiceException() { + } +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,164 @@ +package org.nuiton.jredmine; + +import com.google.common.base.Preconditions; +import com.sun.jersey.api.client.UniformInterface; + +/** + * Technical contract to implements a redmine service (will box the transport + * layer). + * <p/> + * Any concrete implentation of a redmine service should implements this.. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public interface RedmineServiceImplementor { + + /** + * Usable Rest methods. + * + * @since 1.4 + */ + enum RestMethod { + GET, POST, PUT, DELETE, HEAD; + + public <T> T execute(UniformInterface request, + Class<T> type) { + + Preconditions.checkNotNull(request); + Preconditions.checkNotNull(type); + T response = request.method(name(), type); + + return response; + } + + public <T> T execute(UniformInterface request, + Class<T> type, + Object o) { + Preconditions.checkNotNull(request); + Preconditions.checkNotNull(type); + Preconditions.checkNotNull(o); + T response; + response = request.method(name(), type, o); + return response; + } + } + + /** + * Tests if the service is init (says method + * {@link #init(RedmineServiceConfiguration)} was invoked). + * + * @return {@code true} is service is init, + * {@code false} otherwise. + */ + boolean isInit(); + + /** + * Tests if the service is loggued (says method {@link #login()} was + * invoked). + * + * @return {@code true} is service is loggued to Redmine service, + * {@code false} otherwise. + */ + boolean isLoggued(); + + /** + * 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 if any pb + */ + RedmineServiceImplementor init(RedmineServiceConfiguration configuration) throws RedmineServiceException; + + /** + * Close the service and destroy any connexion to the redmine service. + * + * @throws RedmineServiceException if any pb + */ + void destroy() throws RedmineServiceException; + + /** + * Try to ping the redmine remote service and return his status. + * + * @return status code of the ping request, or {@code -1} if something was + * wrong (unknown host,...). + */ + int ping(); + + /** + * Log in using configuration authentication datas. + * + * @throws RedmineServiceLoginException if could not log in + */ + void login() throws RedmineServiceLoginException; + + /** + * Log out. + * + * @throws RedmineServiceLoginException if could not log out + */ + void logout() throws RedmineServiceLoginException; + + /** + * Generic method to obtain a single data from a redmine server. + * + * @param <T> the type of data to obtain + * @param requestName the name of the request to use + * @param type the type of data to obtain + * @param args the parameters to obtain the data + * @return the obtained data + * @throws RedmineServiceException if any pb + */ + <T> T getData(String requestName, 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 requestName the name of the request to use + * @param type the type of data to obtain + * @param args the parameters to obtain the datas + * @return the obtained datas + * @throws RedmineServiceException if any pb + */ + <T> T[] getDatas(String requestName, Class<T> type, Object... args) throws RedmineServiceException; + + /** + * Generic method to send a data to a redmine server and return the single + * data updated from the redmine server. + * + * @param requestName the name of the request used + * @param type the type of data to treate + * @param args the parameters of the request + * @param method method used to send data + * @param <T> the type of data to treate + * @return the updated data + * @throws RedmineServiceException if any pb + */ + <T> T sendData(String requestName, Class<T> type, RestMethod method, Object... args) throws RedmineServiceException; + + + /** + * Generic method to send a data (or more ) to a redmine server and + * return the array of data from the redmine server. + * + * @param requestName the name of the request used + * @param type the type of data to treate + * @param method method used to send data + * @param args the parameters of the request + * @param <T> the type of data to treate + * @return the updated data + * @throws RedmineServiceException if any pb + */ + <T> T[] sendDatas(String requestName, Class<T> type, RestMethod method, Object... args) throws RedmineServiceException; + + /** + * Checks if the current session is not a anonymous one. + * + * @throws IllegalStateException if service not init + * @throws RedmineServiceLoginException if not loggued + * @throws NullPointerException if something is null + */ + void checkLoggued() throws IllegalStateException, RedmineServiceLoginException, NullPointerException; +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java (from rev 258, trunk/jredmine-client/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java) =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,30 @@ +package org.nuiton.jredmine; + +/** + * An exception to be thrown when a problem with authentication state in a + * {@link RedmineService}. + * <p/> + * Created: 2 janv. 2010 + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.3 + */ +public class RedmineServiceLoginException extends RedmineServiceException { + + private static final long serialVersionUID = 1L; + + public RedmineServiceLoginException() { + } + + public RedmineServiceLoginException(Throwable cause) { + super(cause); + } + + public RedmineServiceLoginException(String message) { + super(message); + } + + public RedmineServiceLoginException(String message, Throwable cause) { + super(message, cause); + } +} Property changes on: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceLoginException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Attachment.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Attachment.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Attachment.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.io.File; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/CustomField.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/CustomField.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/CustomField.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/I18nAble.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/I18nAble.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/I18nAble.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IdAble.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IdAble.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IdAble.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Issue.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Issue.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Issue.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.util.Date; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueCategory.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueCategory.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueCategory.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssuePriority.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssuePriority.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssuePriority.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueStatus.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueStatus.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/IssueStatus.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ModelHelper.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.lang.reflect.Array; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/News.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/News.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/News.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.util.Date; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Project.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Project.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Project.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.util.Date; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ProjectRef.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ProjectRef.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/ProjectRef.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/TimeEntry.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/TimeEntry.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/TimeEntry.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.util.Date; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Tracker.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Tracker.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Tracker.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/User.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/User.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/User.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.util.Date; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/UserRef.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/UserRef.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/UserRef.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Version.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Version.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/Version.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; import java.util.Date; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/VersionStatusEnum.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2011 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model; /** Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/AttachmentXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/CustomFieldXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/CustomFieldXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/CustomFieldXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/DefaultRedmineXpp3Helper.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/DefaultRedmineXpp3Helper.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/DefaultRedmineXpp3Helper.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,210 @@ +package org.nuiton.jredmine.model.io.xpp3; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.nuiton.io.xpp3.Xpp3Helper; +import org.nuiton.io.xpp3.Xpp3Reader; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; + +/** + * Pour construire le modèle à partir de fichiers xml contenant les données. + * + * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.jredmine.model.io.xpp3.RedmineXpp3Helper" role-hint="default" + * @since 1.0.0 + */ +public class DefaultRedmineXpp3Helper implements RedmineXpp3Helper { + + /** Logger. */ + private static final Log log = LogFactory.getLog(DefaultRedmineXpp3Helper.class); + + public <O> O readObject(Class<O> klass, + String txt, + boolean strict) throws IOException, XmlPullParserException { + O result = readObject(klass, + new ByteArrayInputStream(txt.getBytes()), + strict + ); + return result; + } + + public <O> O[] readObjects(Class<O> klass, + String txt, + boolean strict) throws IOException, XmlPullParserException { + O[] results = readObjects(klass, + new ByteArrayInputStream(txt.getBytes()), + strict + ); + return results; + } + + public <O> O readObject(Class<O> klass, + File file, + boolean strict) throws IOException, XmlPullParserException { + FileInputStream stream = new FileInputStream(file); + try { + O result = readObject(klass, stream, strict); + return result; + } finally { + stream.close(); + } + } + + public <O> O[] readObjects(Class<O> klass, + File file, + boolean strict) throws IOException, XmlPullParserException { + FileInputStream stream = new FileInputStream(file); + try { + O[] results = readObjects(klass, stream, strict); + return results; + } finally { + stream.close(); + } + } + + public <O> O readObject(Class<O> klass, + InputStream stream, + boolean strict) throws IOException, XmlPullParserException { + +// RedmineModelEnum.safeValueOf(klass); + + O result = readObject(klass, + ReaderFactory.newXmlReader(stream), + strict + ); + + return result; + } + + public <O> O[] readObjects(Class<O> klass, + InputStream stream, + boolean strict) throws IOException, XmlPullParserException { + +// RedmineModelEnum.safeValueOf(klass); + + O[] results = readObjects(klass, + ReaderFactory.newXmlReader(stream), + strict + ); + return results; + } + + /** + * Read an array of objects from a xml stream. + * + * @param <O> the type of objects to return + * @param klass the type of object to read + * @param reader the reader where to parse the xml + * @param strict a flag to have a strict reading of input source + * @return the loaded objects + * @throws IOException if any io pb + * @throws XmlPullParserException if any parsing pb + */ + public <O> O[] readObjects(Class<O> klass, Reader reader, boolean strict) + throws IOException, XmlPullParserException { + + if (klass == null) { + throw new NullPointerException("klass parameter can not be null"); + } + + if (reader == null) { + throw new NullPointerException("reader parameter can not be null"); + } + + Xpp3Reader<O> modelReader = Xpp3Helper.getReader(klass); + + if (modelReader == null) { + throw new IllegalArgumentException( + "could not find xpp3Reader for type " + klass); + } + + O[] result = null; + + try { + + + if (log.isDebugEnabled()) { + + StringWriter sWriter = new StringWriter(); + + IOUtil.copy(reader, sWriter); + + String rawInput = sWriter.toString(); + + log.debug("content to read : \n" + rawInput); + reader = new StringReader(rawInput); + } + + result = modelReader.readArray(reader, strict); + + } finally { + IOUtil.close(reader); + } + + return result; + } + + /** + * Read a single object from a xml stream. + * + * @param <O> the type of object to read + * @param klass the type of object to read + * @param reader the reader where to parse the xml + * @param strict a flag to have a strict reading of input source + * @return the loaded object + * @throws IOException if any io pb + * @throws XmlPullParserException if any parsing pb + */ + public <O> O readObject(Class<O> klass, Reader reader, boolean strict) + throws IOException, XmlPullParserException { + + if (klass == null) { + throw new NullPointerException("klass parameter can not be null"); + } + + if (reader == null) { + throw new NullPointerException("reader parameter can not be null"); + } + + Xpp3Reader<O> modelReader = Xpp3Helper.getReader(klass); + + if (modelReader == null) { + throw new IllegalArgumentException( + "could not find xpp3Reader for type " + klass); + } + + O result = null; + + try { + + + if (log.isDebugEnabled()) { + StringWriter sWriter = new StringWriter(); + + IOUtil.copy(reader, sWriter); + + String rawInput = sWriter.toString(); + log.debug("content to read : \n" + rawInput); + reader = new StringReader(rawInput); + } + + result = modelReader.read(reader, strict); + + } finally { + IOUtil.close(reader); + } + + return result; + } +} Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueCategoryXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssuePriorityXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueStatusXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/IssueXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/NewsXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectRefXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectRefXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectRefXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/ProjectXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineDataConverter.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.DataConverter; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/RedmineXpp3Helper.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,45 +1,11 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.nuiton.io.xpp3.Xpp3Helper; -import org.nuiton.io.xpp3.Xpp3Reader; -import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; /** * Pour construire le modèle à partir de fichiers xml contenant les données. @@ -47,82 +13,32 @@ * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class RedmineXpp3Helper { +public interface RedmineXpp3Helper { - /** Logger. */ - private static final Log log = LogFactory.getLog(RedmineXpp3Helper.class); + <O> O readObject(Class<O> klass, + String txt, + boolean strict) throws IOException, XmlPullParserException; - public <O> O readObject(Class<O> klass, - String txt, - boolean strict) throws IOException, XmlPullParserException { - O result = readObject(klass, - new ByteArrayInputStream(txt.getBytes()), - strict - ); - return result; - } + <O> O[] readObjects(Class<O> klass, + String txt, + boolean strict) throws IOException, XmlPullParserException; - public <O> O[] readObjects(Class<O> klass, - String txt, - boolean strict) throws IOException, XmlPullParserException { - O[] results = readObjects(klass, - new ByteArrayInputStream(txt.getBytes()), - strict - ); - return results; - } + <O> O readObject(Class<O> klass, + File file, + boolean strict) throws IOException, XmlPullParserException; - public <O> O readObject(Class<O> klass, - File file, - boolean strict) throws IOException, XmlPullParserException { - FileInputStream stream = new FileInputStream(file); - try { - O result = readObject(klass, stream, strict); - return result; - } finally { - stream.close(); - } - } + <O> O[] readObjects(Class<O> klass, + File file, + boolean strict) throws IOException, XmlPullParserException; - public <O> O[] readObjects(Class<O> klass, - File file, - boolean strict) throws IOException, XmlPullParserException { - FileInputStream stream = new FileInputStream(file); - try { - O[] results = readObjects(klass, stream, strict); - return results; - } finally { - stream.close(); - } - } + <O> O readObject(Class<O> klass, + InputStream stream, + boolean strict) throws IOException, XmlPullParserException; - public <O> O readObject(Class<O> klass, - InputStream stream, - boolean strict) throws IOException, XmlPullParserException { + <O> O[] readObjects(Class<O> klass, + InputStream stream, + boolean strict) throws IOException, XmlPullParserException; -// RedmineModelEnum.safeValueOf(klass); - - O result = readObject(klass, - ReaderFactory.newXmlReader(stream), - strict - ); - - return result; - } - - public <O> O[] readObjects(Class<O> klass, - InputStream stream, - boolean strict) throws IOException, XmlPullParserException { - -// RedmineModelEnum.safeValueOf(klass); - - O[] results = readObjects(klass, - ReaderFactory.newXmlReader(stream), - strict - ); - return results; - } - /** * Read an array of objects from a xml stream. * @@ -134,50 +50,9 @@ * @throws IOException if any io pb * @throws XmlPullParserException if any parsing pb */ - public <O> O[] readObjects(Class<O> klass, Reader reader, boolean strict) - throws IOException, XmlPullParserException { + <O> O[] readObjects(Class<O> klass, Reader reader, boolean strict) + throws IOException, XmlPullParserException; - if (klass == null) { - throw new NullPointerException("klass parameter can not be null"); - } - - if (reader == null) { - throw new NullPointerException("reader parameter can not be null"); - } - - Xpp3Reader<O> modelReader = Xpp3Helper.getReader(klass); - - if (modelReader == null) { - throw new IllegalArgumentException( - "could not find xpp3Reader for type " + klass); - } - - O[] result = null; - - try { - - - if (log.isDebugEnabled()) { - - StringWriter sWriter = new StringWriter(); - - IOUtil.copy(reader, sWriter); - - String rawInput = sWriter.toString(); - - log.debug("content to read : \n" + rawInput); - reader = new StringReader(rawInput); - } - - result = modelReader.readArray(reader, strict); - - } finally { - IOUtil.close(reader); - } - - return result; - } - /** * Read a single object from a xml stream. * @@ -189,45 +64,6 @@ * @throws IOException if any io pb * @throws XmlPullParserException if any parsing pb */ - public <O> O readObject(Class<O> klass, Reader reader, boolean strict) - throws IOException, XmlPullParserException { - - if (klass == null) { - throw new NullPointerException("klass parameter can not be null"); - } - - if (reader == null) { - throw new NullPointerException("reader parameter can not be null"); - } - - Xpp3Reader<O> modelReader = Xpp3Helper.getReader(klass); - - if (modelReader == null) { - throw new IllegalArgumentException( - "could not find xpp3Reader for type " + klass); - } - - O result = null; - - try { - - - if (log.isDebugEnabled()) { - StringWriter sWriter = new StringWriter(); - - IOUtil.copy(reader, sWriter); - - String rawInput = sWriter.toString(); - log.debug("content to read : \n" + rawInput); - reader = new StringReader(rawInput); - } - - result = modelReader.read(reader, strict); - - } finally { - IOUtil.close(reader); - } - - return result; - } + <O> O readObject(Class<O> klass, Reader reader, boolean strict) + throws IOException, XmlPullParserException; } Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TimeEntryXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/TrackerXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserRefXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserRefXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserRefXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/UserXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java 2012-07-12 13:33:21 UTC (rev 264) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/model/io/xpp3/VersionXpp3Reader.java 2012-07-12 13:35:20 UTC (rev 265) @@ -1,27 +1,3 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2010 Tony Chemit, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ package org.nuiton.jredmine.model.io.xpp3; import org.nuiton.io.xpp3.AbstractXpp3Reader; Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,98 @@ +package org.nuiton.jredmine.request; + +import com.google.common.base.Joiner; +import org.apache.commons.lang.ArrayUtils; + +import java.io.File; +import java.net.URL; +import java.util.Map; + +/** + * The default implementation of the redmine request builder. + * + * @author tchemit <chemit@codelutin.com> + * @see RedmineRequestBuilder + * @see RedmineRequest + * @since 1.4 + */ +public class DefaultRedmineRequestBuilder implements RedmineRequestBuilder { + + private static final long serialVersionUID = 1L; + + protected final String name; + + protected final String action; + + public DefaultRedmineRequestBuilder(String action) { + this(action, action); + } + + public DefaultRedmineRequestBuilder(String name, String action) { + this.name = name; + this.action = action; + } + + @Override + public String getName() { + return name; + } + + /** + * Compute a array of pair (key-value) from the given arguments. + * <p/> + * Order is important to do this, define it. + * + * @param args the args of the request + * @return parameters to use in request by pari of key-value + * (key,value,key2, value2) + */ + public String[] getParameters(Object... args) { + // by default, no parameter + return ArrayUtils.EMPTY_STRING_ARRAY; + } + + public String[] getPath(Object... args) { + // by default, path is action + return new String[]{action}; + } + + public Map<String, File> getAttachments(Object... args) { + // by default, no attachments + return null; + } + + @Override + public RedmineRequest create(final Object... args) { + + return new RedmineRequest() { + + @Override + public String[] getPath() { + return DefaultRedmineRequestBuilder.this.getPath(args); + } + + @Override + public String[] getParameters() { + return DefaultRedmineRequestBuilder.this.getParameters(args); + } + + @Override + public Map<String, File> getAttachments() { + return DefaultRedmineRequestBuilder.this.getAttachments(args); + } + + @Override + public boolean containsAttachments() { + Map<String, File> attachments = getAttachments(); + return attachments != null && !attachments.isEmpty(); + } + + @Override + public String toPath(URL redmineUrl) { + String result = redmineUrl + "/" + + Joiner.on('/').join(getPath()); + return result; + } + }; + } +} Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,33 @@ +package org.nuiton.jredmine.request; + +/** + * To build request with a project and issue scope. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class IssueScopeRedmineRequestBuilder extends ProjectScopeRedmineRequestBuilder { + + private static final long serialVersionUID = 1L; + + public IssueScopeRedmineRequestBuilder(String name, String action) { + super(name, action); + } + + public IssueScopeRedmineRequestBuilder(String action) { + super(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 + }; + } +} Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,33 @@ +package org.nuiton.jredmine.request; + +/** + * To build request with a project scope. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class ProjectScopeRedmineRequestBuilder extends DefaultRedmineRequestBuilder { + + private static final long serialVersionUID = 1L; + + public ProjectScopeRedmineRequestBuilder(String name, String action) { + super(name, action); + } + + public ProjectScopeRedmineRequestBuilder(String action) { + super(action); + } + + @Override + public String[] getPath(Object... args) { + + // one args : projectName + + String projectName = (String) args[0]; + + return new String[]{ + action, + projectName + }; + } +} Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequest.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,34 @@ +package org.nuiton.jredmine.request; + +import java.io.File; +import java.net.URL; +import java.util.Map; + +/** + * To define a redmine request. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public interface RedmineRequest { + + /** @return the splitted path to add to url */ + String[] getPath(); + + /** + * @return an array of pair (parameter name - parameter value) to pass + * to request + */ + String[] getParameters(); + + /** @return the map of attachment to pass to request */ + Map<String, File> getAttachments(); + + /** + * @return {@code true} if request has some attachments. + * @since 1.4 + */ + boolean containsAttachments(); + + String toPath(URL redmineUrl); +} Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,23 @@ +package org.nuiton.jredmine.request; + +import java.io.Serializable; + +/** + * The contract of a redmine request builder. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public interface RedmineRequestBuilder extends Serializable { + + /** @return the unique name of the request builder */ + String getName(); + + /** + * Create the request given the {@code args}. + * + * @param args args to create the request + * @return the created request + */ + RedmineRequest create(Object... args); +} Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/RedmineRequestFactory.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,35 @@ +package org.nuiton.jredmine.request; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +/** + * Factory of {@link RedmineRequest}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public interface RedmineRequestFactory { + + public static final DateFormat DATE_FORMAT = + new SimpleDateFormat("yyyy-MM-dd"); + + void addDefaultRequests(); + + /** + * Add a request into the factory. + * + * @param builder the new request to add + */ + void addRequestBuilder(RedmineRequestBuilder builder); + + /** + * Obtain a request given his id and the args given. + * + * @param id id of the request + * @param args args passed to build the request + * @return the new request + */ + RedmineRequest getRequest(String id, Object... args); + +} Added: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java (rev 0) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-12 13:35:20 UTC (rev 265) @@ -0,0 +1,33 @@ +package org.nuiton.jredmine.request; + +/** + * To build request with a project and version scope. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class VersionScopeRedmineRequestBuilder extends ProjectScopeRedmineRequestBuilder { + + private static final long serialVersionUID = 1L; + + public VersionScopeRedmineRequestBuilder(String name, String action) { + super(name, action); + } + + public VersionScopeRedmineRequestBuilder(String action) { + super(action); + } + + @Override + public String[] getParameters(Object... args) { + + // args 1 = project id + // args 2 = version name + + String versionName = (String) args[1]; + + return new String[]{ + "version_name", versionName + }; + } +}
participants (1)
-
tchemit@users.nuiton.org