mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 18:51:10 +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.Trace", "true");
|
||||||
* params.put("com.sun.jersey.config.feature.TracePerRequest", "true");
|
* params.put("com.sun.jersey.config.feature.TracePerRequest", "true");
|
||||||
*/
|
*/
|
||||||
params.put(JSONConfiguration.FEATURE_POJO_MAPPING,
|
params.put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE.toString());
|
||||||
Boolean.TRUE.toString());
|
|
||||||
params.put(ResourceConfig.FEATURE_REDIRECT, Boolean.TRUE.toString());
|
params.put(ResourceConfig.FEATURE_REDIRECT, Boolean.TRUE.toString());
|
||||||
params.put(ServletContainer.RESOURCE_CONFIG_CLASS,
|
params.put(ServletContainer.RESOURCE_CONFIG_CLASS,
|
||||||
UriExtensionsConfig.class.getName());
|
UriExtensionsConfig.class.getName());
|
||||||
|
|||||||
@@ -71,12 +71,11 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
|||||||
*/
|
*/
|
||||||
public JsonJaxbContextResolver() throws Exception
|
public JsonJaxbContextResolver() throws Exception
|
||||||
{
|
{
|
||||||
this.context = new JSONJAXBContext(
|
this.context =
|
||||||
JSONConfiguration.mapped().rootUnwrapping(true).arrays(
|
new JSONJAXBContext(JSONConfiguration.mapped().arrays("member", "groups",
|
||||||
"member", "groups", "permissions", "repositories", "repositoryTypes",
|
"permissions", "repositories", "repositoryTypes", "users",
|
||||||
"users", "plugin-information").nonStrings(
|
"plugin-information").nonStrings("readable", "writeable",
|
||||||
"readable", "writeable", "groupPermission",
|
"groupPermission", "admin").build(), types.toArray(new Class[0]));
|
||||||
"admin").build(), types.toArray(new Class[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
@@ -97,7 +98,7 @@ public abstract class AbstractResource<T>
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract T[] getAllItems();
|
protected abstract Collection<T> getAllItems();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
@@ -248,7 +249,7 @@ public abstract class AbstractResource<T>
|
|||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public T[] getAll()
|
public Collection<T> getAll()
|
||||||
{
|
{
|
||||||
return getAllItems();
|
return getAllItems();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,11 +144,9 @@ public class RepositoryResource extends AbstractResource<Repository>
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Repository[] getAllItems()
|
protected Collection<Repository> getAllItems()
|
||||||
{
|
{
|
||||||
Collection<Repository> repositoryCollection = repositoryManager.getAll();
|
Collection<Repository> repositories = repositoryManager.getAll();
|
||||||
Repository[] repositories =
|
|
||||||
repositoryCollection.toArray(new Repository[repositoryCollection.size()]);
|
|
||||||
|
|
||||||
for (Repository repository : repositories)
|
for (Repository repository : repositories)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,24 +149,15 @@ public class UserResource extends AbstractResource<User>
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected User[] getAllItems()
|
protected Collection<User> getAllItems()
|
||||||
{
|
{
|
||||||
User[] users = null;
|
Collection<User> users = userManager.getAll();
|
||||||
Collection<User> userCollection = userManager.getAll();
|
|
||||||
|
|
||||||
if (Util.isNotEmpty(userCollection))
|
if (Util.isNotEmpty(users))
|
||||||
{
|
{
|
||||||
int size = userCollection.size();
|
for (User u : users)
|
||||||
|
|
||||||
users = new User[size];
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (User u : userCollection)
|
|
||||||
{
|
{
|
||||||
u.setPassword(DUMMY_PASSWORT);
|
u.setPassword(DUMMY_PASSWORT);
|
||||||
users[i] = u;
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ Sonia.plugin.Store = Ext.extend(Sonia.rest.JsonStore, {
|
|||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
var baseConfig = {
|
var baseConfig = {
|
||||||
root: 'plugin-information',
|
|
||||||
fields: [ 'name', 'author', 'description', 'url', 'version', 'state', 'groupId', 'artifactId' ],
|
fields: [ 'name', 'author', 'description', 'url', 'version', 'state', 'groupId', 'artifactId' ],
|
||||||
sortInfo: {
|
sortInfo: {
|
||||||
field: 'name'
|
field: 'name'
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
|
|
||||||
var repositoryStore = new Sonia.rest.JsonStore({
|
var repositoryStore = new Sonia.rest.JsonStore({
|
||||||
url: restUrl + 'repositories.json',
|
url: restUrl + 'repositories.json',
|
||||||
root: 'repositories',
|
|
||||||
fields: [ 'id', 'name', 'type', 'contact', 'description', 'creationDate', 'url', 'permissions' ],
|
fields: [ 'id', 'name', 'type', 'contact', 'description', 'creationDate', 'url', 'permissions' ],
|
||||||
sortInfo: {
|
sortInfo: {
|
||||||
field: 'name'
|
field: 'name'
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
|
|
||||||
var userStore = new Sonia.rest.JsonStore({
|
var userStore = new Sonia.rest.JsonStore({
|
||||||
url: restUrl + 'users.json',
|
url: restUrl + 'users.json',
|
||||||
root: 'users',
|
|
||||||
fields: [ 'name', 'displayName', 'mail', 'admin', 'creationDate', 'lastLogin', 'type'],
|
fields: [ 'name', 'displayName', 'mail', 'admin', 'creationDate', 'lastLogin', 'type'],
|
||||||
sortInfo: {
|
sortInfo: {
|
||||||
field: 'name'
|
field: 'name'
|
||||||
|
|||||||
Reference in New Issue
Block a user