Author: tchemit Date: 2012-07-13 01:01:25 +0200 (Fri, 13 Jul 2012) New Revision: 272 Url: http://nuiton.org/repositories/revision/jredmine/272 Log: - remove all the jersey code - request can now have multiple action (to be able to use or not the jredmine plugin) Modified: trunk/jredmine-domain/pom.xml trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 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/VersionScopeRedmineRequestBuilder.java Modified: trunk/jredmine-domain/pom.xml =================================================================== --- trunk/jredmine-domain/pom.xml 2012-07-12 17:59:35 UTC (rev 271) +++ trunk/jredmine-domain/pom.xml 2012-07-12 23:01:25 UTC (rev 272) @@ -45,11 +45,6 @@ <dependencies> <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-client</artifactId> - </dependency> - - <dependency> <groupId>org.nuiton</groupId> <artifactId>helper-maven-plugin</artifactId> <scope>compile</scope> Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2012-07-12 17:59:35 UTC (rev 271) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/RedmineServiceImplementor.java 2012-07-12 23:01:25 UTC (rev 272) @@ -23,9 +23,6 @@ * #L% */ -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). @@ -37,36 +34,7 @@ */ 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). @@ -154,12 +122,10 @@ * @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; + <T> T sendData(String requestName, Class<T> type, Object... args) throws RedmineServiceException; /** @@ -168,13 +134,11 @@ * * @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; + <T> T[] sendDatas(String requestName, Class<T> type, Object... args) throws RedmineServiceException; /** * Checks if the current session is not a anonymous one. Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-12 17:59:35 UTC (rev 271) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/DefaultRedmineRequestBuilder.java 2012-07-12 23:01:25 UTC (rev 272) @@ -25,11 +25,11 @@ import com.google.common.base.Joiner; import org.apache.commons.lang3.ArrayUtils; +import org.nuiton.io.rest.RestMethod; import org.nuiton.io.rest.RestRequest; import org.nuiton.io.rest.RestRequestBuilder; import java.io.File; -import java.net.URL; import java.util.Map; /** @@ -46,11 +46,14 @@ protected final String name; - protected final String action; + protected final String[] action; - public DefaultRedmineRequestBuilder(String name, String action) { + protected final RestMethod method; + + public DefaultRedmineRequestBuilder(String name, RestMethod method, String... action) { this.name = name; this.action = action; + this.method = method; } @Override @@ -74,7 +77,7 @@ public String[] getPath(Object... args) { // by default, path is action - return new String[]{action}; + return action; } public Map<String, File> getAttachments(Object... args) { @@ -109,11 +112,16 @@ } @Override - public String toPath(URL redmineUrl) { + public String toPath(String redmineUrl) { String result = redmineUrl + "/" + Joiner.on('/').join(getPath()); return result; } + + @Override + public RestMethod getMethod() { + return method; + } }; } } Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-12 17:59:35 UTC (rev 271) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/IssueScopeRedmineRequestBuilder.java 2012-07-12 23:01:25 UTC (rev 272) @@ -23,6 +23,8 @@ * #L% */ +import org.nuiton.io.rest.RestMethod; + /** * To build request with a project and issue scope. * @@ -33,8 +35,8 @@ private static final long serialVersionUID = 1L; - public IssueScopeRedmineRequestBuilder(String name, String action) { - super(name, action); + public IssueScopeRedmineRequestBuilder(String name, RestMethod method, String... action) { + super(name, method, action); } @Override Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-12 17:59:35 UTC (rev 271) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/ProjectScopeRedmineRequestBuilder.java 2012-07-12 23:01:25 UTC (rev 272) @@ -23,6 +23,8 @@ * #L% */ +import org.nuiton.io.rest.RestMethod; + /** * To build request with a project scope. * @@ -33,8 +35,8 @@ private static final long serialVersionUID = 1L; - public ProjectScopeRedmineRequestBuilder(String name, String action) { - super(name, action); + public ProjectScopeRedmineRequestBuilder(String name,RestMethod method, String... action) { + super(name,method, action); } @Override @@ -44,9 +46,9 @@ String projectName = (String) args[0]; - return new String[]{ - action, - projectName - }; + String[] result = new String[action.length+1]; + System.arraycopy(action, 0, result, 0, action.length); + result[action.length] = projectName; + return result; } } Modified: trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java =================================================================== --- trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-12 17:59:35 UTC (rev 271) +++ trunk/jredmine-domain/src/main/java/org/nuiton/jredmine/request/VersionScopeRedmineRequestBuilder.java 2012-07-12 23:01:25 UTC (rev 272) @@ -23,6 +23,8 @@ * #L% */ +import org.nuiton.io.rest.RestMethod; + /** * To build request with a project and version scope. * @@ -33,8 +35,8 @@ private static final long serialVersionUID = 1L; - public VersionScopeRedmineRequestBuilder(String name, String action) { - super(name, action); + public VersionScopeRedmineRequestBuilder(String name,RestMethod method, String... action) { + super(name, method,action); } @Override