mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
use collection instead of arrays
This commit is contained in:
@@ -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