[DS-2784] jersey update to 2.22

This commit is contained in:
aleksanderkotbury
2015-10-10 16:24:40 +02:00
parent 7abdb6dca6
commit 0925f43308
14 changed files with 75 additions and 76 deletions

View File

@@ -116,7 +116,7 @@ public class BitstreamResource extends Resource
writeStats(dspaceBitstream, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, writeStats(dspaceBitstream, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers,
request, context); request, context);
bitstream = new Bitstream(dspaceBitstream, expand, context); bitstream = new Bitstream(dspaceBitstream, servletContext, expand, context);
context.complete(); context.complete();
log.trace("Bitsream(id=" + bitstreamId + ") was successfully read."); log.trace("Bitsream(id=" + bitstreamId + ") was successfully read.");
@@ -167,7 +167,7 @@ public class BitstreamResource extends Resource
org.dspace.content.Bitstream dspaceBitstream = findBitstream(context, bitstreamId, org.dspace.core.Constants.READ); org.dspace.content.Bitstream dspaceBitstream = findBitstream(context, bitstreamId, org.dspace.core.Constants.READ);
List<org.dspace.authorize.ResourcePolicy> resourcePolicies = authorizeService.getPolicies(context, dspaceBitstream); List<org.dspace.authorize.ResourcePolicy> resourcePolicies = authorizeService.getPolicies(context, dspaceBitstream);
//TODO why isn't the above used... //TODO why isn't the above used...
policies = new Bitstream(dspaceBitstream,"policies", context).getPolicies(); policies = new Bitstream(dspaceBitstream, servletContext, "policies", context).getPolicies();
context.complete(); context.complete();
log.trace("Policies for bitstream(id=" + bitstreamId + ") was successfully read."); log.trace("Policies for bitstream(id=" + bitstreamId + ") was successfully read.");
@@ -243,7 +243,7 @@ public class BitstreamResource extends Resource
if (bitstreamService.getParentObject(context, dspaceBitstreams.get(i)) != null) if (bitstreamService.getParentObject(context, dspaceBitstreams.get(i)) != null)
{ // To eliminate bitstreams which cause exception, because of { // To eliminate bitstreams which cause exception, because of
// reading under administrator permissions // reading under administrator permissions
bitstreams.add(new Bitstream(dspaceBitstreams.get(i), expand, context)); bitstreams.add(new Bitstream(dspaceBitstreams.get(i), servletContext, expand, context));
writeStats(dspaceBitstreams.get(i), UsageEvent.Action.VIEW, user_ip, user_agent, writeStats(dspaceBitstreams.get(i), UsageEvent.Action.VIEW, user_ip, user_agent,
xforwardedfor, headers, request, context); xforwardedfor, headers, request, context);
} }

View File

@@ -115,7 +115,7 @@ public class CollectionsResource extends Resource
writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor,
headers, request, context); headers, request, context);
collection = new Collection(dspaceCollection, expand, context, limit, offset); collection = new Collection(dspaceCollection, servletContext, expand, context, limit, offset);
context.complete(); context.complete();
} }
@@ -192,7 +192,7 @@ public class CollectionsResource extends Resource
{ {
if (authorizeService.authorizeActionBoolean(context, dspaceCollection, org.dspace.core.Constants.READ)) if (authorizeService.authorizeActionBoolean(context, dspaceCollection, org.dspace.core.Constants.READ))
{ {
Collection collection = new org.dspace.rest.common.Collection(dspaceCollection, null, context, limit, Collection collection = new org.dspace.rest.common.Collection(dspaceCollection, servletContext, null, context, limit,
offset); offset);
collections.add(collection); collections.add(collection);
writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent, writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent,
@@ -279,7 +279,7 @@ public class CollectionsResource extends Resource
org.dspace.content.Item dspaceItem = dspaceItems.next(); org.dspace.content.Item dspaceItem = dspaceItems.next();
if (itemService.isItemListedForUser(context, dspaceItem)) if (itemService.isItemListedForUser(context, dspaceItem))
{ {
items.add(new Item(dspaceItem, expand, context)); items.add(new Item(dspaceItem, servletContext, expand, context));
writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor,
headers, request, context); headers, request, context);
} }
@@ -373,7 +373,7 @@ public class CollectionsResource extends Resource
dspaceItem = installItemService.installItem(context, workspaceItem); dspaceItem = installItemService.installItem(context, workspaceItem);
workspaceItemService.update(context, workspaceItem); workspaceItemService.update(context, workspaceItem);
returnItem = new Item(dspaceItem, "", context); returnItem = new Item(dspaceItem, servletContext, "", context);
context.complete(); context.complete();
@@ -686,7 +686,7 @@ public class CollectionsResource extends Resource
{ {
if (dspaceCollection.getName().equals(name)) if (dspaceCollection.getName().equals(name))
{ {
collection = new Collection(dspaceCollection, "", context, 100, 0); collection = new Collection(dspaceCollection, servletContext, "", context, 100, 0);
break; break;
} }
} }

View File

@@ -88,7 +88,7 @@ public class CommunitiesResource extends Resource
writeStats(dspaceCommunity, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, writeStats(dspaceCommunity, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers,
request, context); request, context);
community = new Community(dspaceCommunity, expand, context); community = new Community(dspaceCommunity, servletContext, expand, context);
context.complete(); context.complete();
} }
@@ -164,7 +164,7 @@ public class CommunitiesResource extends Resource
{ {
if (authorizeService.authorizeActionBoolean(context, dspaceCommunities.get(i), org.dspace.core.Constants.READ)) if (authorizeService.authorizeActionBoolean(context, dspaceCommunities.get(i), org.dspace.core.Constants.READ))
{ {
Community community = new Community(dspaceCommunities.get(i), expand, context); Community community = new Community(dspaceCommunities.get(i), servletContext, expand, context);
writeStats(dspaceCommunities.get(i), UsageEvent.Action.VIEW, user_ip, user_agent, writeStats(dspaceCommunities.get(i), UsageEvent.Action.VIEW, user_ip, user_agent,
xforwardedfor, headers, request, context); xforwardedfor, headers, request, context);
communities.add(community); communities.add(community);
@@ -246,7 +246,7 @@ public class CommunitiesResource extends Resource
{ {
if (authorizeService.authorizeActionBoolean(context, dspaceCommunities.get(i), org.dspace.core.Constants.READ)) if (authorizeService.authorizeActionBoolean(context, dspaceCommunities.get(i), org.dspace.core.Constants.READ))
{ {
Community community = new Community(dspaceCommunities.get(i), expand, context); Community community = new Community(dspaceCommunities.get(i), servletContext, expand, context);
writeStats(dspaceCommunities.get(i), UsageEvent.Action.VIEW, user_ip, user_agent, writeStats(dspaceCommunities.get(i), UsageEvent.Action.VIEW, user_ip, user_agent,
xforwardedfor, headers, request, context); xforwardedfor, headers, request, context);
communities.add(community); communities.add(community);
@@ -331,7 +331,7 @@ public class CommunitiesResource extends Resource
{ {
if (authorizeService.authorizeActionBoolean(context, dspaceCollections.get(i), org.dspace.core.Constants.READ)) if (authorizeService.authorizeActionBoolean(context, dspaceCollections.get(i), org.dspace.core.Constants.READ))
{ {
collections.add(new Collection(dspaceCollections.get(i), expand, context, 20, 0)); collections.add(new Collection(dspaceCollections.get(i), servletContext, expand, context, 20, 0));
writeStats(dspaceCollections.get(i), UsageEvent.Action.VIEW, user_ip, user_agent, writeStats(dspaceCollections.get(i), UsageEvent.Action.VIEW, user_ip, user_agent,
xforwardedfor, headers, request, context); xforwardedfor, headers, request, context);
} }
@@ -417,7 +417,7 @@ public class CommunitiesResource extends Resource
{ {
if (authorizeService.authorizeActionBoolean(context, dspaceCommunities.get(i), org.dspace.core.Constants.READ)) if (authorizeService.authorizeActionBoolean(context, dspaceCommunities.get(i), org.dspace.core.Constants.READ))
{ {
communities.add(new Community(dspaceCommunities.get(i), expand, context)); communities.add(new Community(dspaceCommunities.get(i), servletContext, expand, context));
writeStats(dspaceCommunities.get(i), UsageEvent.Action.VIEW, user_ip, user_agent, writeStats(dspaceCommunities.get(i), UsageEvent.Action.VIEW, user_ip, user_agent,
xforwardedfor, headers, request, context); xforwardedfor, headers, request, context);
} }
@@ -498,7 +498,7 @@ public class CommunitiesResource extends Resource
communityService.setMetadata(context, dspaceCommunity, org.dspace.content.Community.SIDEBAR_TEXT, community.getSidebarText()); communityService.setMetadata(context, dspaceCommunity, org.dspace.content.Community.SIDEBAR_TEXT, community.getSidebarText());
communityService.update(context, dspaceCommunity); communityService.update(context, dspaceCommunity);
retCommunity = new Community(dspaceCommunity, "", context); retCommunity = new Community(dspaceCommunity, servletContext, "", context);
context.complete(); context.complete();
} }
catch (SQLException e) catch (SQLException e)
@@ -572,7 +572,7 @@ public class CommunitiesResource extends Resource
collectionService.setMetadata(context, dspaceCollection, org.dspace.content.Collection.SIDEBAR_TEXT, collection.getSidebarText()); collectionService.setMetadata(context, dspaceCollection, org.dspace.content.Collection.SIDEBAR_TEXT, collection.getSidebarText());
collectionService.update(context, dspaceCollection); collectionService.update(context, dspaceCollection);
communityService.update(context, dspaceCommunity); communityService.update(context, dspaceCommunity);
retCollection = new Collection(dspaceCollection, "", context, 100, 0); retCollection = new Collection(dspaceCollection, servletContext, "", context, 100, 0);
context.complete(); context.complete();
} }
@@ -654,7 +654,7 @@ public class CommunitiesResource extends Resource
communityService.update(context, dspaceCommunity); communityService.update(context, dspaceCommunity);
communityService.update(context, dspaceParentCommunity); communityService.update(context, dspaceParentCommunity);
retCommunity = new Community(dspaceCommunity, "", context); retCommunity = new Community(dspaceCommunity, servletContext, "", context);
context.complete(); context.complete();
} }

View File

@@ -7,7 +7,6 @@ import org.springframework.web.filter.RequestContextFilter;
public class DSpaceRestApplication extends ResourceConfig { public class DSpaceRestApplication extends ResourceConfig {
public DSpaceRestApplication() { public DSpaceRestApplication() {
register(RequestContextFilter.class);
register(JacksonFeature.class); register(JacksonFeature.class);
packages("org.dspace.rest"); packages("org.dspace.rest");
} }

View File

@@ -61,16 +61,16 @@ public class HandleResource extends Resource {
if(authorizeService.authorizeActionBoolean(context, dso, org.dspace.core.Constants.READ)) { if(authorizeService.authorizeActionBoolean(context, dso, org.dspace.core.Constants.READ)) {
switch(dso.getType()) { switch(dso.getType()) {
case Constants.COMMUNITY: case Constants.COMMUNITY:
dSpaceObject = new Community((org.dspace.content.Community) dso, expand, context); dSpaceObject = new Community((org.dspace.content.Community) dso, servletContext, expand, context);
return dSpaceObject; return dSpaceObject;
case Constants.COLLECTION: case Constants.COLLECTION:
dSpaceObject = new Collection((org.dspace.content.Collection) dso, expand, context, null, null); dSpaceObject = new Collection((org.dspace.content.Collection) dso, servletContext, expand, context, null, null);
return dSpaceObject; return dSpaceObject;
case Constants.ITEM: case Constants.ITEM:
dSpaceObject = new Item((org.dspace.content.Item) dso, expand, context); dSpaceObject = new Item((org.dspace.content.Item) dso, servletContext, expand, context);
return dSpaceObject; return dSpaceObject;
default: default:
dSpaceObject = new DSpaceObject(dso); dSpaceObject = new DSpaceObject(dso, servletContext);
return dSpaceObject; return dSpaceObject;
} }
} else { } else {

View File

@@ -104,7 +104,7 @@ public class ItemsResource extends Resource
writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, request, context); writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, request, context);
item = new Item(dspaceItem, expand, context); item = new Item(dspaceItem, servletContext, expand, context);
context.complete(); context.complete();
log.trace("Item(id=" + itemId + ") was successfully read."); log.trace("Item(id=" + itemId + ") was successfully read.");
@@ -178,7 +178,7 @@ public class ItemsResource extends Resource
{ {
if (itemService.isItemListedForUser(context, dspaceItem)) if (itemService.isItemListedForUser(context, dspaceItem))
{ {
items.add(new Item(dspaceItem, expand, context)); items.add(new Item(dspaceItem, servletContext, expand, context));
writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor,
headers, request, context); headers, request, context);
} }
@@ -240,7 +240,7 @@ public class ItemsResource extends Resource
writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, request, context); writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, request, context);
metadata = new org.dspace.rest.common.Item(dspaceItem, "metadata", context).getMetadata(); metadata = new org.dspace.rest.common.Item(dspaceItem, servletContext, "metadata", context).getMetadata();
context.complete(); context.complete();
} }
catch (SQLException e) catch (SQLException e)
@@ -299,7 +299,7 @@ public class ItemsResource extends Resource
writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, request, context); writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, request, context);
List<Bitstream> itemBitstreams = new Item(dspaceItem, "bitstreams", context).getBitstreams(); List<Bitstream> itemBitstreams = new Item(dspaceItem, servletContext, "bitstreams", context).getBitstreams();
if ((offset + limit) > (itemBitstreams.size() - offset)) if ((offset + limit) > (itemBitstreams.size() - offset))
{ {
@@ -540,7 +540,7 @@ public class ItemsResource extends Resource
} }
dspaceBitstream = bitstreamService.find(context, dspaceBitstream.getID()); dspaceBitstream = bitstreamService.find(context, dspaceBitstream.getID());
bitstream = new Bitstream(dspaceBitstream, "", context); bitstream = new Bitstream(dspaceBitstream, servletContext, "", context);
context.complete(); context.complete();
@@ -933,7 +933,7 @@ public class ItemsResource extends Resource
while (itemIterator.hasNext()) while (itemIterator.hasNext())
{ {
org.dspace.content.Item dspaceItem = itemIterator.next(); org.dspace.content.Item dspaceItem = itemIterator.next();
Item item = new Item(dspaceItem, "", context); Item item = new Item(dspaceItem, servletContext, "", context);
writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers, writeStats(dspaceItem, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers,
request, context); request, context);
items.add(item); items.add(item);

View File

@@ -37,7 +37,7 @@ import org.dspace.utils.DSpace;
public class Resource public class Resource
{ {
@javax.ws.rs.core.Context public static ServletContext servletContext; @javax.ws.rs.core.Context public ServletContext servletContext;
private static Logger log = Logger.getLogger(Resource.class); private static Logger log = Logger.getLogger(Resource.class);
@@ -47,9 +47,6 @@ public class Resource
writeStatistics = ConfigurationManager.getBooleanProperty("rest", "stats", false); writeStatistics = ConfigurationManager.getBooleanProperty("rest", "stats", false);
} }
static public String getServletContextPath() {
return servletContext.getContextPath();
}
/** /**
* Create context to work with DSpace database. It can create context * Create context to work with DSpace database. It can create context
* with or without a logged in user (parameter user is null). Throws * with or without a logged in user (parameter user is null). Throws

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.ServletContext;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@@ -52,12 +53,12 @@ public class Bitstream extends DSpaceObject {
} }
public Bitstream(org.dspace.content.Bitstream bitstream, String expand, Context context) throws SQLException{ public Bitstream(org.dspace.content.Bitstream bitstream, ServletContext servletContext, String expand, Context context) throws SQLException{
super(bitstream); super(bitstream, servletContext);
setup(bitstream, expand, context); setup(bitstream, servletContext, expand, context);
} }
public void setup(org.dspace.content.Bitstream bitstream, String expand, Context context) throws SQLException{ public void setup(org.dspace.content.Bitstream bitstream, ServletContext servletContext, String expand, Context context) throws SQLException{
List<String> expandFields = new ArrayList<String>(); List<String> expandFields = new ArrayList<String>();
if(expand != null) { if(expand != null) {
expandFields = Arrays.asList(expand.split(",")); expandFields = Arrays.asList(expand.split(","));
@@ -82,7 +83,7 @@ public class Bitstream extends DSpaceObject {
this.setCheckSum(checkSum); this.setCheckSum(checkSum);
if(expandFields.contains("parent") || expandFields.contains("all")) { if(expandFields.contains("parent") || expandFields.contains("all")) {
parentObject = new DSpaceObject(bitstreamService.getParentObject(context, bitstream)); parentObject = new DSpaceObject(bitstreamService.getParentObject(context, bitstream), servletContext);
} else { } else {
this.addExpand("parent"); this.addExpand("parent");
} }

View File

@@ -13,6 +13,7 @@ import org.dspace.content.service.CollectionService;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.Context; import org.dspace.core.Context;
import javax.servlet.ServletContext;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.sql.SQLException; import java.sql.SQLException;
@@ -51,12 +52,12 @@ public class Collection extends DSpaceObject {
public Collection(){} public Collection(){}
public Collection(org.dspace.content.Collection collection, String expand, Context context, Integer limit, Integer offset) throws SQLException, WebApplicationException{ public Collection(org.dspace.content.Collection collection, ServletContext servletContext, String expand, Context context, Integer limit, Integer offset) throws SQLException, WebApplicationException{
super(collection); super(collection, servletContext);
setup(collection, expand, context, limit, offset); setup(collection, servletContext, expand, context, limit, offset);
} }
private void setup(org.dspace.content.Collection collection, String expand, Context context, Integer limit, Integer offset) throws SQLException{ private void setup(org.dspace.content.Collection collection, ServletContext servletContext, String expand, Context context, Integer limit, Integer offset) throws SQLException{
List<String> expandFields = new ArrayList<String>(); List<String> expandFields = new ArrayList<String>();
if(expand != null) { if(expand != null) {
expandFields = Arrays.asList(expand.split(",")); expandFields = Arrays.asList(expand.split(","));
@@ -70,7 +71,7 @@ public class Collection extends DSpaceObject {
if(expandFields.contains("parentCommunityList") || expandFields.contains("all")) { if(expandFields.contains("parentCommunityList") || expandFields.contains("all")) {
List<org.dspace.content.Community> parentCommunities = collection.getCommunities(); List<org.dspace.content.Community> parentCommunities = collection.getCommunities();
for(org.dspace.content.Community parentCommunity : parentCommunities) { for(org.dspace.content.Community parentCommunity : parentCommunities) {
this.addParentCommunityList(new Community(parentCommunity, null, context)); this.addParentCommunityList(new Community(parentCommunity, servletContext, null, context));
} }
} else { } else {
this.addExpand("parentCommunityList"); this.addExpand("parentCommunityList");
@@ -78,7 +79,7 @@ public class Collection extends DSpaceObject {
if(expandFields.contains("parentCommunity") | expandFields.contains("all")) { if(expandFields.contains("parentCommunity") | expandFields.contains("all")) {
org.dspace.content.Community parentCommunity = (org.dspace.content.Community) collectionService.getParentObject(context, collection); org.dspace.content.Community parentCommunity = (org.dspace.content.Community) collectionService.getParentObject(context, collection);
this.setParentCommunity(new Community(parentCommunity, null, context)); this.setParentCommunity(new Community(parentCommunity, servletContext, null, context));
} else { } else {
this.addExpand("parentCommunity"); this.addExpand("parentCommunity");
} }
@@ -92,7 +93,7 @@ public class Collection extends DSpaceObject {
org.dspace.content.Item item = childItems.next(); org.dspace.content.Item item = childItems.next();
if(itemService.isItemListedForUser(context, item)) { if(itemService.isItemListedForUser(context, item)) {
items.add(new Item(item, null, context)); items.add(new Item(item, servletContext, null, context));
} }
} }
} else { } else {
@@ -107,7 +108,7 @@ public class Collection extends DSpaceObject {
if(expandFields.contains("logo") || expandFields.contains("all")) { if(expandFields.contains("logo") || expandFields.contains("all")) {
if(collection.getLogo() != null) { if(collection.getLogo() != null) {
this.logo = new Bitstream(collection.getLogo(), null, context); this.logo = new Bitstream(collection.getLogo(), servletContext, null, context);
} }
} }
else { else {

View File

@@ -15,6 +15,7 @@ import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.Context; import org.dspace.core.Context;
import javax.servlet.ServletContext;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@@ -52,12 +53,12 @@ public class Community extends DSpaceObject{
public Community(){} public Community(){}
public Community(org.dspace.content.Community community, String expand, Context context) throws SQLException, WebApplicationException{ public Community(org.dspace.content.Community community, ServletContext servletContext, String expand, Context context) throws SQLException, WebApplicationException{
super(community); super(community, servletContext);
setup(community, expand, context); setup(community,servletContext, expand, context);
} }
private void setup(org.dspace.content.Community community, String expand, Context context) throws SQLException{ private void setup(org.dspace.content.Community community, ServletContext servletContext, String expand, Context context) throws SQLException{
List<String> expandFields = new ArrayList<String>(); List<String> expandFields = new ArrayList<String>();
if(expand != null) { if(expand != null) {
expandFields = Arrays.asList(expand.split(",")); expandFields = Arrays.asList(expand.split(","));
@@ -72,7 +73,7 @@ public class Community extends DSpaceObject{
if(expandFields.contains("parentCommunity") || expandFields.contains("all")) { if(expandFields.contains("parentCommunity") || expandFields.contains("all")) {
org.dspace.content.Community parentCommunity = (org.dspace.content.Community) communityService.getParentObject(context, community); org.dspace.content.Community parentCommunity = (org.dspace.content.Community) communityService.getParentObject(context, community);
if(parentCommunity != null) { if(parentCommunity != null) {
setParentCommunity(new Community(parentCommunity, null, context)); setParentCommunity(new Community(parentCommunity,servletContext, null, context));
} }
} else { } else {
this.addExpand("parentCommunity"); this.addExpand("parentCommunity");
@@ -84,7 +85,7 @@ public class Community extends DSpaceObject{
for(org.dspace.content.Collection collection : collections) { for(org.dspace.content.Collection collection : collections) {
if(authorizeService.authorizeActionBoolean(context, collection, org.dspace.core.Constants.READ)) { if(authorizeService.authorizeActionBoolean(context, collection, org.dspace.core.Constants.READ)) {
restCollections.add(new Collection(collection, null, context, null, null)); restCollections.add(new Collection(collection,servletContext, null, context, null, null));
} else { } else {
log.info("Omitted restricted collection: " + collection.getID() + " _ " + collection.getName()); log.info("Omitted restricted collection: " + collection.getID() + " _ " + collection.getName());
} }
@@ -99,7 +100,7 @@ public class Community extends DSpaceObject{
subcommunities = new ArrayList<Community>(); subcommunities = new ArrayList<Community>();
for(org.dspace.content.Community subCommunity : communities) { for(org.dspace.content.Community subCommunity : communities) {
if(authorizeService.authorizeActionBoolean(context, subCommunity, org.dspace.core.Constants.READ)) { if(authorizeService.authorizeActionBoolean(context, subCommunity, org.dspace.core.Constants.READ)) {
subcommunities.add(new Community(subCommunity, null, context)); subcommunities.add(new Community(subCommunity, servletContext, null, context));
} else { } else {
log.info("Omitted restricted subCommunity: " + subCommunity.getID() + " _ " + subCommunity.getName()); log.info("Omitted restricted subCommunity: " + subCommunity.getID() + " _ " + subCommunity.getName());
} }
@@ -110,7 +111,7 @@ public class Community extends DSpaceObject{
if(expandFields.contains("logo") || expandFields.contains("all")) { if(expandFields.contains("logo") || expandFields.contains("all")) {
if(community.getLogo() != null) { if(community.getLogo() != null) {
logo = new Bitstream(community.getLogo(), null, context); logo = new Bitstream(community.getLogo(),servletContext, null, context);
} }
} else { } else {
this.addExpand("logo"); this.addExpand("logo");

View File

@@ -38,8 +38,8 @@ public class DSpaceObject {
private String handle; private String handle;
private String type; private String type;
// @XmlElement(name = "link", required = true) @XmlElement(name = "link", required = true)
// private String link; private String link;
@XmlElement(required = true) @XmlElement(required = true)
private ArrayList<String> expand = new ArrayList<String>(); private ArrayList<String> expand = new ArrayList<String>();
@@ -48,14 +48,14 @@ public class DSpaceObject {
} }
public DSpaceObject(org.dspace.content.DSpaceObject dso) { public DSpaceObject(org.dspace.content.DSpaceObject dso, ServletContext servletContext) {
//setId(); legacyID //setId(); legacyID
setUUID(dso.getID().toString()); setUUID(dso.getID().toString());
setName(dso.getName()); setName(dso.getName());
setHandle(dso.getHandle()); setHandle(dso.getHandle());
DSpaceObjectService dspaceObjectService = ContentServiceFactory.getInstance().getDSpaceObjectService(dso); DSpaceObjectService dspaceObjectService = ContentServiceFactory.getInstance().getDSpaceObjectService(dso);
setType(dspaceObjectService.getTypeText(dso).toLowerCase()); setType(dspaceObjectService.getTypeText(dso).toLowerCase());
// link = createLink(context) link = createLink(servletContext);
} }
public Integer getId() { public Integer getId() {
@@ -83,7 +83,7 @@ public class DSpaceObject {
} }
public String getLink() { public String getLink() {
return ""; return link;
} }
public String getType() { public String getType() {

View File

@@ -19,6 +19,7 @@ import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.Context; import org.dspace.core.Context;
import javax.servlet.ServletContext;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@@ -56,12 +57,12 @@ public class Item extends DSpaceObject {
public Item(){} public Item(){}
public Item(org.dspace.content.Item item, String expand, Context context) throws SQLException, WebApplicationException{ public Item(org.dspace.content.Item item, ServletContext servletContext, String expand, Context context) throws SQLException, WebApplicationException{
super(item); super(item, servletContext);
setup(item, expand, context); setup(item, servletContext, expand, context);
} }
private void setup(org.dspace.content.Item item, String expand, Context context) throws SQLException{ private void setup(org.dspace.content.Item item, ServletContext servletContext, String expand, Context context) throws SQLException{
List<String> expandFields = new ArrayList<String>(); List<String> expandFields = new ArrayList<String>();
if(expand != null) { if(expand != null) {
expandFields = Arrays.asList(expand.split(",")); expandFields = Arrays.asList(expand.split(","));
@@ -86,7 +87,7 @@ public class Item extends DSpaceObject {
this.setLastModified(item.getLastModified().toString()); this.setLastModified(item.getLastModified().toString());
if(expandFields.contains("parentCollection") || expandFields.contains("all")) { if(expandFields.contains("parentCollection") || expandFields.contains("all")) {
this.parentCollection = new Collection(item.getOwningCollection(), null, context, null, null); this.parentCollection = new Collection(item.getOwningCollection(), servletContext, null, context, null, null);
} else { } else {
this.addExpand("parentCollection"); this.addExpand("parentCollection");
} }
@@ -95,7 +96,7 @@ public class Item extends DSpaceObject {
this.parentCollectionList = new ArrayList<Collection>(); this.parentCollectionList = new ArrayList<Collection>();
List<org.dspace.content.Collection> collections = item.getCollections(); List<org.dspace.content.Collection> collections = item.getCollections();
for(org.dspace.content.Collection collection : collections) { for(org.dspace.content.Collection collection : collections) {
this.parentCollectionList.add(new Collection(collection, null, context, null, null)); this.parentCollectionList.add(new Collection(collection, servletContext, null, context, null, null));
} }
} else { } else {
this.addExpand("parentCollectionList"); this.addExpand("parentCollectionList");
@@ -106,7 +107,7 @@ public class Item extends DSpaceObject {
List<org.dspace.content.Community> communities = itemService.getCommunities(context, item); List<org.dspace.content.Community> communities = itemService.getCommunities(context, item);
for(org.dspace.content.Community community : communities) { for(org.dspace.content.Community community : communities) {
this.parentCommunityList.add(new Community(community, null, context)); this.parentCommunityList.add(new Community(community, servletContext, null, context));
} }
} else { } else {
this.addExpand("parentCommunityList"); this.addExpand("parentCommunityList");
@@ -122,7 +123,7 @@ public class Item extends DSpaceObject {
List<org.dspace.content.Bitstream> itemBitstreams = bundle.getBitstreams(); List<org.dspace.content.Bitstream> itemBitstreams = bundle.getBitstreams();
for(org.dspace.content.Bitstream itemBitstream : itemBitstreams) { for(org.dspace.content.Bitstream itemBitstream : itemBitstreams) {
if(authorizeService.authorizeActionBoolean(context, itemBitstream, org.dspace.core.Constants.READ)) { if(authorizeService.authorizeActionBoolean(context, itemBitstream, org.dspace.core.Constants.READ)) {
bitstreams.add(new Bitstream(itemBitstream, null, context)); bitstreams.add(new Bitstream(itemBitstream, servletContext, null, context));
} }
} }
} }

View File

@@ -16,7 +16,6 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.dspace.rest" />
<!-- Acquires the DSpace Utility Class with initialized Service Manager --> <!-- Acquires the DSpace Utility Class with initialized Service Manager -->
<bean id="dspace" class="org.dspace.utils.DSpace"/> <bean id="dspace" class="org.dspace.utils.DSpace"/>

View File

@@ -31,16 +31,16 @@
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- Security settings and mapping --> <!--Security settings and mapping -->
<!--<security-constraint>--> <security-constraint>
<!--<web-resource-collection>--> <web-resource-collection>
<!--<web-resource-name>DSpace REST API</web-resource-name>--> <web-resource-name>DSpace REST API</web-resource-name>
<!--<url-pattern>/*</url-pattern>--> <url-pattern>/*</url-pattern>
<!--</web-resource-collection>--> </web-resource-collection>
<!--<user-data-constraint>--> <user-data-constraint>
<!--<transport-guarantee>CONFIDENTIAL</transport-guarantee>--> <transport-guarantee>CONFIDENTIAL</transport-guarantee>
<!--</user-data-constraint>--> </user-data-constraint>
<!--</security-constraint>--> </security-constraint>
<!-- DSpace Configuration Information --> <!-- DSpace Configuration Information -->
<context-param> <context-param>