fix problem with xml representation of collections

This commit is contained in:
Sebastian Sdorra
2011-02-16 17:18:00 +01:00
parent 49f0fd5a81
commit 53c0883454
6 changed files with 84 additions and 11 deletions

View File

@@ -60,6 +60,7 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.EntityTag;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
@@ -93,6 +94,19 @@ public abstract class AbstractManagerResource<T extends ModelObject,
this.manager = manager;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param items
*
* @return
*/
protected abstract GenericEntity<Collection<T>> createGenericEntity(
Collection<T> items);
//~--- get methods ----------------------------------------------------------
/**
@@ -271,14 +285,15 @@ public abstract class AbstractManagerResource<T extends ModelObject,
}
Response response = null;
Object entity = createGenericEntity(items);
if (disableCache)
{
response = Response.ok(items).build();
response = Response.ok(entity).build();
}
else
{
response = createCacheResponse(request, manager, items);
response = createCacheResponse(request, manager, entity);
}
return response;

View File

@@ -44,7 +44,10 @@ import sonia.scm.group.GroupManager;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
import javax.ws.rs.Path;
import javax.ws.rs.core.GenericEntity;
/**
*
@@ -73,6 +76,24 @@ public class GroupResource
super(groupManager);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param items
*
* @return
*/
@Override
protected GenericEntity<Collection<Group>> createGenericEntity(
Collection<Group> items)
{
return new GenericEntity<Collection<Group>>(items) {}
;
}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -58,6 +58,7 @@ import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.GenericEntity;
/**
*
@@ -99,6 +100,22 @@ public class RepositoryResource
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param items
*
* @return
*/
@Override
protected GenericEntity<Collection<Repository>> createGenericEntity(
Collection<Repository> items)
{
return new GenericEntity<Collection<Repository>>(items) {}
;
}
/**
* Method description
*

View File

@@ -50,6 +50,7 @@ import sonia.scm.util.Util;
import java.util.Collection;
import javax.ws.rs.Path;
import javax.ws.rs.core.GenericEntity;
/**
*
@@ -85,6 +86,22 @@ public class UserResource extends AbstractManagerResource<User, UserException>
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param items
*
* @return
*/
@Override
protected GenericEntity<Collection<User>> createGenericEntity(
Collection<User> items)
{
return new GenericEntity<Collection<User>>(items) {}
;
}
/**
* Method description
*