Author: tchemit Date: 2012-10-17 01:21:58 +0200 (Wed, 17 Oct 2012) New Revision: 371 Url: http://nuiton.org/repositories/revision/jredmine/371 Log: - add missing svn properties and license headers - improve some code (remove the ModelHelper class) - use apiKey to test the redmine-1.4.x client it - improve test configuration Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAbles.java Removed: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java Modified: trunk/jredmine-client/src/it/redmine-1.4.x/pom.xml trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineClient.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequest.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequestHelper.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/AbstractRedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineAnonymousService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineService.java trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/RedmineConfigurationUtil.java Modified: trunk/jredmine-client/src/it/redmine-1.4.x/pom.xml =================================================================== --- trunk/jredmine-client/src/it/redmine-1.4.x/pom.xml 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/it/redmine-1.4.x/pom.xml 2012-10-16 23:21:58 UTC (rev 371) @@ -88,7 +88,7 @@ </goals> <phase>initialize</phase> <configuration> - <serverId>jredmine-test-it</serverId> + <serverId>jredmine-test-it-1.4.x</serverId> <usernameOut>jredmine-test.username</usernameOut> <passwordOut>jredmine-test.password</passwordOut> <privateKeyOut>jredmine-test.apiKey</privateKeyOut> Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineClient.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineClient.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineClient.java 2012-10-16 23:21:58 UTC (rev 371) @@ -173,7 +173,7 @@ getConfiguration().getAuthConfiguration(); RedmineRequest<Void> loginRequest; - if (false && conf.isUseApiKey()) { + if (conf.isUseApiKey()) { // use api key to login loginRequest = RedmineRequestHelper.postAction("login", void.class). Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequest.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequest.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequest.java 2012-10-16 23:21:58 UTC (rev 371) @@ -1,5 +1,29 @@ package org.nuiton.jredmine.client; +/* + * #%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% + */ + import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Maps; Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequest.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequestHelper.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequestHelper.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequestHelper.java 2012-10-16 23:21:58 UTC (rev 371) @@ -1,5 +1,29 @@ package org.nuiton.jredmine.client; +/* + * #%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% + */ + /** * Helper around {@link RedmineRequest}. * Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/client/RedmineRequestHelper.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Added: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAbles.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAbles.java (rev 0) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAbles.java 2012-10-16 23:21:58 UTC (rev 371) @@ -0,0 +1,68 @@ +package org.nuiton.jredmine.model; + +/* + * #%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% + */ + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +/** + * Helper methods around {@link IdAble}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.5 + */ +public class IdAbles { + public static final Comparator<IdAble> ID_ABLE_COMPARATOR = new Comparator<IdAble>() { + + @Override + public int compare(IdAble o1, IdAble o2) { + return o1.getId() - o2.getId(); + } + }; + + public static <T extends IdAble> T byId(int id, T... datas) { + for (T data : datas) { + if (data.getId() == id) { + return data; + } + } + return null; + } + + public static <T extends IdAble> T[] byIds(Class<T> type, T[] result, Integer... ids) { + + List<Integer> lIds = Arrays.asList(ids); + List<T> filter = new ArrayList<T>(lIds.size()); + for (T v : result) { + if (lIds.contains(v.getId())) { + filter.add(v); + } + } + return filter.toArray((T[]) Array.newInstance(type, filter.size())); + } +} Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/IdAbles.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Issue.java 2012-10-16 23:21:58 UTC (rev 371) @@ -24,7 +24,9 @@ */ package org.nuiton.jredmine.model; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * An issue on redmine's server. @@ -80,6 +82,26 @@ protected boolean isPrivate; + public static Issue[] byTrackerId(int trackerId, Issue... issues) { + List<Issue> result = new ArrayList<Issue>(); + for (Issue i : issues) { + if (i.getTrackerId() == trackerId) { + result.add(i); + } + } + return result.toArray(new Issue[result.size()]); + } + + public static Issue[] byVersionId(int versionId, Issue... issues) { + List<Issue> result = new ArrayList<Issue>(); + for (Issue i : issues) { + if (i.getFixedVersionId() == versionId) { + result.add(i); + } + } + return result.toArray(new Issue[result.size()]); + } + @Override public int getId() { return id; Deleted: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/ModelHelper.java 2012-10-16 23:21:58 UTC (rev 371) @@ -1,167 +0,0 @@ -/* - * #%L - * JRedmine :: Client - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 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; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -/** - * Some usefull methods on redmine's entities, mainly to filter datas. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0.0 - */ -public class ModelHelper { - - public static final String GET_ALL_ISSUE_STATUS_REQUEST_NAME = "IssueStatus/all"; - - public static final String GET_ALL_ISSUE_PRIORITY_REQUEST_NAME = "IssuePriority/all"; - - public static final String GET_ALL_ISSUE_CATEGORY_REQUEST_NAME = "IssueCategory/all"; - - public static final String GET_USER_PROJECTS_REQUEST_NAME = "User/Project/all"; - - public static final String GET_ALL_PROJECT_REQUEST_NAME = "Project/all"; - - public static final String GET_PROJECT_REQUEST_NAME = "Project/detail"; - - public static final String GET_ALL_VERSION_REQUEST_NAME = "Project/Version/all"; - - public static final String GET_ALL_TRACKER_REQUEST_NAME = "Project/Tracker/all"; - - public static final String GET_ALL_PROJECT_ISSUES_REQUEST_NAME = "Project/Issue/all"; - - public static final String GET_ALL_PROJECT_OPENED_ISSUES_REQUEST_NAME = "Project/Issue/opened"; - - public static final String GET_ALL_PROJECT_CLOSED_ISSUES_REQUEST_NAME = "Project/Issue/closed"; - - public static final String GET_ALL_USER_REQUEST_NAME = "Project/User/all"; - - public static final String GET_ALL_NEWS_REQUEST_NAME = "Project/News/all"; - - public static final String GET_VERSION_REQUEST_NAME = "Project/Version/detail"; - - public static final String GET_ALL_ISSUES_REQUEST_NAME = "Project/Version/Issue/all"; - - public static final String GET_ALL_ATTACHMENTS_REQUEST_NAME = "Project/Version/Attachment/all"; - - public static final String ADD_ATTACHMENT_REQUEST_NAME = "Project/Version/Attachment/add"; - - public static final String ADD_VERSION_REQUEST_NAME = "Project/Version/add"; - - public static final String UPDATE_VERSION_REQUEST_NAME = "Project/Version/update"; - - public static final String NEXT_VERSION_REQUEST_NAME = "Project/Version/next"; - - public static final String ADD_NEWS_REQUEST_NAME = "Project/News/add"; - - public static final String GET_ALL_ISSUE_TIME_ENTRY_REQUEST_NAME = "Project/Issue/TimeEntry/all"; - - public static final String ADD_ISSUE_TIME_ENTRY_REQUEST_NAME = "Project/Issue/TimeEntry/add"; - - public static final String LOGIN_REQUEST_NAME = "Login"; - - public static final String LOGIN_BY_API_KEY_REQUEST_NAME = "LoginByAPiKey"; - - public static final String LOGOUT_REQUEST_NAME = "Logout"; - - public static final String PING_REQUEST_NAME = "Ping"; - - public static final String VERSION_SCOPE = "version"; - - public static final String PROJECT_SCOPE = "project"; - - public static final String ISSUE_SCOPE = "issue"; - - public static <T extends IdAble> T byId(int id, T... datas) { - for (T data : datas) { - if (data.getId() == id) { - return data; - } - } - return null; - } - - public static User byLogin(String login, User... users) { - for (User u : users) { - if (u.getLogin().equals(login)) { - return u; - } - } - return null; - } - - public static Version byVersionName(String name, Version... versions) { - for (Version u : versions) { - if (u.getName().equals(name)) { - return u; - } - } - return null; - } - - public static Issue[] byTrackerId(int trackerId, Issue... issues) { - List<Issue> result = new ArrayList<Issue>(); - for (Issue i : issues) { - if (i.getTrackerId() == trackerId) { - result.add(i); - } - } - return result.toArray(new Issue[result.size()]); - } - - public static Issue[] byVersionId(int versionId, Issue... issues) { - List<Issue> result = new ArrayList<Issue>(); - for (Issue i : issues) { - if (i.getFixedVersionId() == versionId) { - result.add(i); - } - } - return result.toArray(new Issue[result.size()]); - } - - public static <T extends IdAble> T[] byIds(Class<T> type, T[] result, Integer... ids) { - - List<Integer> lIds = Arrays.asList(ids); - List<T> filter = new ArrayList<T>(lIds.size()); - for (T v : result) { - if (lIds.contains(v.getId())) { - filter.add(v); - } - } - return filter.toArray((T[]) Array.newInstance(type, filter.size())); - } - - public static final Comparator<IdAble> ID_ABLE_COMPARATOR = new Comparator<IdAble>() { - - @Override - public int compare(IdAble o1, IdAble o2) { - return o1.getId() - o2.getId(); - } - }; -} Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/User.java 2012-10-16 23:21:58 UTC (rev 371) @@ -68,6 +68,15 @@ protected String salt; + public static User byLogin(String login, User... users) { + for (User u : users) { + if (u.getLogin().equals(login)) { + return u; + } + } + return null; + } + public boolean isAdmin() { return admin; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/model/Version.java 2012-10-16 23:21:58 UTC (rev 371) @@ -52,6 +52,15 @@ protected int projectId; + public static Version byVersionName(String name, Version... versions) { + for (Version u : versions) { + if (u.getName().equals(name)) { + return u; + } + } + return null; + } + public Date getCreatedOn() { return createdOn; } Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/AbstractRedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/AbstractRedmineService.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/AbstractRedmineService.java 2012-10-16 23:21:58 UTC (rev 371) @@ -1,5 +1,29 @@ package org.nuiton.jredmine.service; +/* + * #%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% + */ + import com.google.common.base.Preconditions; import org.nuiton.jredmine.client.RedmineClient; import org.nuiton.jredmine.client.RedmineRequest; Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/AbstractRedmineService.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineAnonymousService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineAnonymousService.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineAnonymousService.java 2012-10-16 23:21:58 UTC (rev 371) @@ -1,5 +1,29 @@ package org.nuiton.jredmine.service; +/* + * #%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% + */ + import com.google.common.base.Preconditions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineAnonymousService.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineService.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineService.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineService.java 2012-10-16 23:21:58 UTC (rev 371) @@ -1,5 +1,29 @@ package org.nuiton.jredmine.service; +/* + * #%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% + */ + import com.google.common.base.Strings; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; Property changes on: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/DefaultRedmineService.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Modified: trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/RedmineConfigurationUtil.java =================================================================== --- trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/RedmineConfigurationUtil.java 2012-10-16 23:15:36 UTC (rev 370) +++ trunk/jredmine-client/src/main/java/org/nuiton/jredmine/service/RedmineConfigurationUtil.java 2012-10-16 23:21:58 UTC (rev 371) @@ -163,6 +163,9 @@ overridePropertyFromProperties(result, "url", props); overridePropertyFromProperties(result, "encoding", props); overridePropertyFromProperties(result, "verbose", props); + overridePropertyFromProperties(authConfiguration, "username", props); + overridePropertyFromProperties(authConfiguration, "password", props); + overridePropertyFromProperties(authConfiguration, "apiKey", props); overridePropertyFromEnv(result, "url"); overridePropertyFromEnv(result, "encoding");