mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
use collection instead of arrays
This commit is contained in:
@@ -204,8 +204,7 @@ public class ScmServletModule extends ServletModule
|
||||
* params.put("com.sun.jersey.config.feature.Trace", "true");
|
||||
* params.put("com.sun.jersey.config.feature.TracePerRequest", "true");
|
||||
*/
|
||||
params.put(JSONConfiguration.FEATURE_POJO_MAPPING,
|
||||
Boolean.TRUE.toString());
|
||||
params.put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE.toString());
|
||||
params.put(ResourceConfig.FEATURE_REDIRECT, Boolean.TRUE.toString());
|
||||
params.put(ServletContainer.RESOURCE_CONFIG_CLASS,
|
||||
UriExtensionsConfig.class.getName());
|
||||
|
||||
@@ -71,12 +71,11 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
||||
*/
|
||||
public JsonJaxbContextResolver() throws Exception
|
||||
{
|
||||
this.context = new JSONJAXBContext(
|
||||
JSONConfiguration.mapped().rootUnwrapping(true).arrays(
|
||||
"member", "groups", "permissions", "repositories", "repositoryTypes",
|
||||
"users", "plugin-information").nonStrings(
|
||||
"readable", "writeable", "groupPermission",
|
||||
"admin").build(), types.toArray(new Class[0]));
|
||||
this.context =
|
||||
new JSONJAXBContext(JSONConfiguration.mapped().arrays("member", "groups",
|
||||
"permissions", "repositories", "repositoryTypes", "users",
|
||||
"plugin-information").nonStrings("readable", "writeable",
|
||||
"groupPermission", "admin").build(), types.toArray(new Class[0]));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
@@ -35,6 +35,7 @@ package sonia.scm.api.rest.resources;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
@@ -97,7 +98,7 @@ public abstract class AbstractResource<T>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract T[] getAllItems();
|
||||
protected abstract Collection<T> getAllItems();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -248,7 +249,7 @@ public abstract class AbstractResource<T>
|
||||
*/
|
||||
@GET
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
public T[] getAll()
|
||||
public Collection<T> getAll()
|
||||
{
|
||||
return getAllItems();
|
||||
}
|
||||
|
||||
@@ -144,11 +144,9 @@ public class RepositoryResource extends AbstractResource<Repository>
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected Repository[] getAllItems()
|
||||
protected Collection<Repository> getAllItems()
|
||||
{
|
||||
Collection<Repository> repositoryCollection = repositoryManager.getAll();
|
||||
Repository[] repositories =
|
||||
repositoryCollection.toArray(new Repository[repositoryCollection.size()]);
|
||||
Collection<Repository> repositories = repositoryManager.getAll();
|
||||
|
||||
for (Repository repository : repositories)
|
||||
{
|
||||
|
||||
@@ -149,24 +149,15 @@ public class UserResource extends AbstractResource<User>
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected User[] getAllItems()
|
||||
protected Collection<User> getAllItems()
|
||||
{
|
||||
User[] users = null;
|
||||
Collection<User> userCollection = userManager.getAll();
|
||||
Collection<User> users = userManager.getAll();
|
||||
|
||||
if (Util.isNotEmpty(userCollection))
|
||||
if (Util.isNotEmpty(users))
|
||||
{
|
||||
int size = userCollection.size();
|
||||
|
||||
users = new User[size];
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (User u : userCollection)
|
||||
for (User u : users)
|
||||
{
|
||||
u.setPassword(DUMMY_PASSWORT);
|
||||
users[i] = u;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user