mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
Use contextPath to link out
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package org.dspace.rest;
|
package org.dspace.rest;
|
||||||
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.core.Context;
|
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -17,9 +17,9 @@ http://localhost:8080/<webapp>/collections
|
|||||||
*/
|
*/
|
||||||
@Path("/collections")
|
@Path("/collections")
|
||||||
public class CollectionsResource {
|
public class CollectionsResource {
|
||||||
final String collectionsPath = "/dspace-rest/collections/";
|
@javax.ws.rs.core.Context ServletContext servletContext;
|
||||||
|
|
||||||
private static Context context;
|
private static org.dspace.core.Context context;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The "GET" annotation indicates this method will respond to HTTP Get requests.
|
The "GET" annotation indicates this method will respond to HTTP Get requests.
|
||||||
@@ -31,11 +31,11 @@ public class CollectionsResource {
|
|||||||
public String listHTML() {
|
public String listHTML() {
|
||||||
StringBuilder everything = new StringBuilder();
|
StringBuilder everything = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
Context context = new Context();
|
org.dspace.core.Context context = new org.dspace.core.Context();
|
||||||
|
|
||||||
Collection[] collections = Collection.findAll(context);
|
Collection[] collections = Collection.findAll(context);
|
||||||
for(Collection collection : collections) {
|
for(Collection collection : collections) {
|
||||||
everything.append("<li><a href='" + collectionsPath + collection.getID() + "'>" + collection.getID() + " - " + collection.getName() + "</a></li>\n");
|
everything.append("<li><a href='" + servletContext.getContextPath() + "/collections/" + collection.getID() + "'>" + collection.getID() + " - " + collection.getName() + "</a></li>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -51,7 +51,7 @@ public class CollectionsResource {
|
|||||||
public org.dspace.rest.common.Collection[] list(@QueryParam("expand") String expand) {
|
public org.dspace.rest.common.Collection[] list(@QueryParam("expand") String expand) {
|
||||||
try {
|
try {
|
||||||
if(context == null || !context.isValid() ) {
|
if(context == null || !context.isValid() ) {
|
||||||
context = new Context();
|
context = new org.dspace.core.Context();
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection[] collections = Collection.findAll(context);
|
Collection[] collections = Collection.findAll(context);
|
||||||
|
Reference in New Issue
Block a user