[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,
request, context);
bitstream = new Bitstream(dspaceBitstream, expand, context);
bitstream = new Bitstream(dspaceBitstream, servletContext, expand, context);
context.complete();
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);
List<org.dspace.authorize.ResourcePolicy> resourcePolicies = authorizeService.getPolicies(context, dspaceBitstream);
//TODO why isn't the above used...
policies = new Bitstream(dspaceBitstream,"policies", context).getPolicies();
policies = new Bitstream(dspaceBitstream, servletContext, "policies", context).getPolicies();
context.complete();
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)
{ // To eliminate bitstreams which cause exception, because of
// 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,
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,
headers, request, context);
collection = new Collection(dspaceCollection, expand, context, limit, offset);
collection = new Collection(dspaceCollection, servletContext, expand, context, limit, offset);
context.complete();
}
@@ -192,7 +192,7 @@ public class CollectionsResource extends Resource
{
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);
collections.add(collection);
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();
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,
headers, request, context);
}
@@ -373,7 +373,7 @@ public class CollectionsResource extends Resource
dspaceItem = installItemService.installItem(context, workspaceItem);
workspaceItemService.update(context, workspaceItem);
returnItem = new Item(dspaceItem, "", context);
returnItem = new Item(dspaceItem, servletContext, "", context);
context.complete();
@@ -686,7 +686,7 @@ public class CollectionsResource extends Resource
{
if (dspaceCollection.getName().equals(name))
{
collection = new Collection(dspaceCollection, "", context, 100, 0);
collection = new Collection(dspaceCollection, servletContext, "", context, 100, 0);
break;
}
}

View File

@@ -88,7 +88,7 @@ public class CommunitiesResource extends Resource
writeStats(dspaceCommunity, UsageEvent.Action.VIEW, user_ip, user_agent, xforwardedfor, headers,
request, context);
community = new Community(dspaceCommunity, expand, context);
community = new Community(dspaceCommunity, servletContext, expand, context);
context.complete();
}
@@ -164,7 +164,7 @@ public class CommunitiesResource extends Resource
{
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,
xforwardedfor, headers, request, context);
communities.add(community);
@@ -246,7 +246,7 @@ public class CommunitiesResource extends Resource
{
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,
xforwardedfor, headers, request, context);
communities.add(community);
@@ -331,7 +331,7 @@ public class CommunitiesResource extends Resource
{
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,
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))
{
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,
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.update(context, dspaceCommunity);
retCommunity = new Community(dspaceCommunity, "", context);
retCommunity = new Community(dspaceCommunity, servletContext, "", context);
context.complete();
}
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.update(context, dspaceCollection);
communityService.update(context, dspaceCommunity);
retCollection = new Collection(dspaceCollection, "", context, 100, 0);
retCollection = new Collection(dspaceCollection, servletContext, "", context, 100, 0);
context.complete();
}
@@ -654,7 +654,7 @@ public class CommunitiesResource extends Resource
communityService.update(context, dspaceCommunity);
communityService.update(context, dspaceParentCommunity);
retCommunity = new Community(dspaceCommunity, "", context);
retCommunity = new Community(dspaceCommunity, servletContext, "", context);
context.complete();
}

View File

@@ -7,7 +7,6 @@ import org.springframework.web.filter.RequestContextFilter;
public class DSpaceRestApplication extends ResourceConfig {
public DSpaceRestApplication() {
register(RequestContextFilter.class);
register(JacksonFeature.class);
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)) {
switch(dso.getType()) {
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;
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;
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;
default:
dSpaceObject = new DSpaceObject(dso);
dSpaceObject = new DSpaceObject(dso, servletContext);
return dSpaceObject;
}
} 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);
item = new Item(dspaceItem, expand, context);
item = new Item(dspaceItem, servletContext, expand, context);
context.complete();
log.trace("Item(id=" + itemId + ") was successfully read.");
@@ -178,7 +178,7 @@ public class ItemsResource extends Resource
{
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,
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);
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();
}
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);
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))
{
@@ -540,7 +540,7 @@ public class ItemsResource extends Resource
}
dspaceBitstream = bitstreamService.find(context, dspaceBitstream.getID());
bitstream = new Bitstream(dspaceBitstream, "", context);
bitstream = new Bitstream(dspaceBitstream, servletContext, "", context);
context.complete();
@@ -933,7 +933,7 @@ public class ItemsResource extends Resource
while (itemIterator.hasNext())
{
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,
request, context);
items.add(item);

View File

@@ -37,7 +37,7 @@ import org.dspace.utils.DSpace;
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);
@@ -47,9 +47,6 @@ public class Resource
writeStatistics = ConfigurationManager.getBooleanProperty("rest", "stats", false);
}
static public String getServletContextPath() {
return servletContext.getContextPath();
}
/**
* Create context to work with DSpace database. It can create context
* 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.List;
import javax.servlet.ServletContext;
import javax.xml.bind.annotation.XmlRootElement;
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{
super(bitstream);
setup(bitstream, expand, context);
public Bitstream(org.dspace.content.Bitstream bitstream, ServletContext servletContext, String expand, Context context) throws SQLException{
super(bitstream, servletContext);
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>();
if(expand != null) {
expandFields = Arrays.asList(expand.split(","));
@@ -82,7 +83,7 @@ public class Bitstream extends DSpaceObject {
this.setCheckSum(checkSum);
if(expandFields.contains("parent") || expandFields.contains("all")) {
parentObject = new DSpaceObject(bitstreamService.getParentObject(context, bitstream));
parentObject = new DSpaceObject(bitstreamService.getParentObject(context, bitstream), servletContext);
} else {
this.addExpand("parent");
}

View File

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

View File

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

View File

@@ -38,8 +38,8 @@ public class DSpaceObject {
private String handle;
private String type;
// @XmlElement(name = "link", required = true)
// private String link;
@XmlElement(name = "link", required = true)
private String link;
@XmlElement(required = true)
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
setUUID(dso.getID().toString());
setName(dso.getName());
setHandle(dso.getHandle());
DSpaceObjectService dspaceObjectService = ContentServiceFactory.getInstance().getDSpaceObjectService(dso);
setType(dspaceObjectService.getTypeText(dso).toLowerCase());
// link = createLink(context)
link = createLink(servletContext);
}
public Integer getId() {
@@ -83,7 +83,7 @@ public class DSpaceObject {
}
public String getLink() {
return "";
return link;
}
public String getType() {

View File

@@ -19,6 +19,7 @@ import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService;
import org.dspace.core.Context;
import javax.servlet.ServletContext;
import javax.ws.rs.WebApplicationException;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -56,12 +57,12 @@ public class Item extends DSpaceObject {
public Item(){}
public Item(org.dspace.content.Item item, String expand, Context context) throws SQLException, WebApplicationException{
super(item);
setup(item, expand, context);
public Item(org.dspace.content.Item item, ServletContext servletContext, String expand, Context context) throws SQLException, WebApplicationException{
super(item, servletContext);
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>();
if(expand != null) {
expandFields = Arrays.asList(expand.split(","));
@@ -86,7 +87,7 @@ public class Item extends DSpaceObject {
this.setLastModified(item.getLastModified().toString());
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 {
this.addExpand("parentCollection");
}
@@ -95,7 +96,7 @@ public class Item extends DSpaceObject {
this.parentCollectionList = new ArrayList<Collection>();
List<org.dspace.content.Collection> collections = item.getCollections();
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 {
this.addExpand("parentCollectionList");
@@ -106,7 +107,7 @@ public class Item extends DSpaceObject {
List<org.dspace.content.Community> communities = itemService.getCommunities(context, item);
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 {
this.addExpand("parentCommunityList");
@@ -122,7 +123,7 @@ public class Item extends DSpaceObject {
List<org.dspace.content.Bitstream> itemBitstreams = bundle.getBitstreams();
for(org.dspace.content.Bitstream itemBitstream : itemBitstreams) {
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/spring-context-3.0.xsd">
<context:component-scan base-package="org.dspace.rest" />
<!-- Acquires the DSpace Utility Class with initialized Service Manager -->
<bean id="dspace" class="org.dspace.utils.DSpace"/>

View File

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