diff --git a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUrlProvider.java b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUrlProvider.java index ae03d54157..c956735a5b 100644 --- a/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUrlProvider.java +++ b/scm-clients/scm-client-api/src/main/java/sonia/scm/client/ScmUrlProvider.java @@ -55,12 +55,24 @@ public class ScmUrlProvider public static final String URLPART_AUTHENTICATION_LOGIN = "authentication/login"; + /** Field description */ + public static final String URLPART_GROUP = "groups/"; + + /** Field description */ + public static final String URLPART_GROUPS = "groups"; + /** Field description */ public static final String URLPART_REPOSITORIES = "repositories"; /** Field description */ public static final String URLPART_REPOSITORY = "repositories/"; + /** Field description */ + public static final String URLPART_USER = "users/"; + + /** Field description */ + public static final String URLPART_USERS = "users"; + /** the logger for classVar */ private static final Logger logger = LoggerFactory.getLogger(ScmUrlProvider.class); @@ -136,6 +148,30 @@ public class ScmUrlProvider return extension; } + /** + * Method description + * + * + * @param name + * + * @return + */ + public String getGroupUrl(String name) + { + return getResourceUrl(URLPART_GROUP.concat(name)); + } + + /** + * Method description + * + * + * @return + */ + public String getGroupsUrl() + { + return getResourceUrl(URLPART_GROUPS); + } + /** * Method description * @@ -180,6 +216,30 @@ public class ScmUrlProvider return resourceUrl; } + /** + * Method description + * + * + * @param name + * + * @return + */ + public String getUserUrl(String name) + { + return getResourceUrl(URLPART_USER.concat(name)); + } + + /** + * Method description + * + * + * @return + */ + public String getUsersUrl() + { + return getResourceUrl(URLPART_USERS); + } + //~--- set methods ---------------------------------------------------------- /** diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java index ded3967637..ef68d7936f 100644 --- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java +++ b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyGroupClientHandler.java @@ -39,13 +39,16 @@ import sonia.scm.group.Group; //~--- JDK imports ------------------------------------------------------------ +import com.sun.jersey.api.client.GenericType; + import java.util.List; /** * * @author Sebastian Sdorra */ -public class JerseyGroupClientHandler implements GroupClientHandler +public class JerseyGroupClientHandler extends AbstractClientHandler + implements GroupClientHandler { /** @@ -56,7 +59,7 @@ public class JerseyGroupClientHandler implements GroupClientHandler */ public JerseyGroupClientHandler(JerseyClientSession session) { - this.session = session; + super(session, Group.class); } //~--- methods -------------------------------------------------------------- @@ -65,48 +68,13 @@ public class JerseyGroupClientHandler implements GroupClientHandler * Method description * * - * @param item + * @return */ @Override - public void create(Group item) + protected GenericType> createGenericListType() { - throw new UnsupportedOperationException("Not supported yet."); - } - - /** - * Method description - * - * - * @param id - */ - @Override - public void delete(String id) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - /** - * Method description - * - * - * @param item - */ - @Override - public void delete(Group item) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - /** - * Method description - * - * - * @param item - */ - @Override - public void modify(Group item) - { - throw new UnsupportedOperationException("Not supported yet."); + return new GenericType>() {} + ; } //~--- get methods ---------------------------------------------------------- @@ -115,14 +83,14 @@ public class JerseyGroupClientHandler implements GroupClientHandler * Method description * * - * @param id + * @param itemId * * @return */ @Override - public Group get(String id) + protected String getItemUrl(String itemId) { - throw new UnsupportedOperationException("Not supported yet."); + return urlProvider.getGroupUrl(itemId); } /** @@ -132,13 +100,8 @@ public class JerseyGroupClientHandler implements GroupClientHandler * @return */ @Override - public List getAll() + protected String getItemsUrl() { - throw new UnsupportedOperationException("Not supported yet."); + return urlProvider.getGroupsUrl(); } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private JerseyClientSession session; } diff --git a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java index f3ee4b780d..2b60649297 100644 --- a/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java +++ b/scm-clients/scm-client-impl/src/main/java/sonia/scm/client/JerseyUserClientHandler.java @@ -39,13 +39,16 @@ import sonia.scm.user.User; //~--- JDK imports ------------------------------------------------------------ +import com.sun.jersey.api.client.GenericType; + import java.util.List; /** * * @author Sebastian Sdorra */ -public class JerseyUserClientHandler implements UserClientHandler +public class JerseyUserClientHandler extends AbstractClientHandler + implements UserClientHandler { /** @@ -56,7 +59,7 @@ public class JerseyUserClientHandler implements UserClientHandler */ public JerseyUserClientHandler(JerseyClientSession session) { - this.session = session; + super(session, User.class); } //~--- methods -------------------------------------------------------------- @@ -65,48 +68,13 @@ public class JerseyUserClientHandler implements UserClientHandler * Method description * * - * @param item + * @return */ @Override - public void create(User item) + protected GenericType> createGenericListType() { - throw new UnsupportedOperationException("Not supported yet."); - } - - /** - * Method description - * - * - * @param id - */ - @Override - public void delete(String id) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - /** - * Method description - * - * - * @param item - */ - @Override - public void delete(User item) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - /** - * Method description - * - * - * @param item - */ - @Override - public void modify(User item) - { - throw new UnsupportedOperationException("Not supported yet."); + return new GenericType>() {} + ; } //~--- get methods ---------------------------------------------------------- @@ -115,14 +83,14 @@ public class JerseyUserClientHandler implements UserClientHandler * Method description * * - * @param id + * @param itemId * * @return */ @Override - public User get(String id) + protected String getItemUrl(String itemId) { - throw new UnsupportedOperationException("Not supported yet."); + return urlProvider.getUserUrl(itemId); } /** @@ -132,13 +100,8 @@ public class JerseyUserClientHandler implements UserClientHandler * @return */ @Override - public List getAll() + protected String getItemsUrl() { - throw new UnsupportedOperationException("Not supported yet."); + return urlProvider.getUsersUrl(); } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private JerseyClientSession session; }