mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
changes to bring SWORD into line with current working practices on the trunk
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2911 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -48,7 +48,9 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.handle.HandleManager;
|
||||
import org.dspace.uri.IdentifierService;
|
||||
import org.dspace.uri.IdentifierException;
|
||||
import org.dspace.uri.ResolvableIdentifier;
|
||||
|
||||
/**
|
||||
* This class provides a single point of contact for
|
||||
@@ -75,7 +77,7 @@ public class CollectionLocation
|
||||
public String getLocation(Collection collection)
|
||||
throws DSpaceSWORDException
|
||||
{
|
||||
return this.getBaseUrl() + "/" + collection.getHandle();
|
||||
return IdentifierService.getURL(this.getBaseUrl(), collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,17 +99,9 @@ public class CollectionLocation
|
||||
{
|
||||
throw new DSpaceSWORDException("The deposit URL is incomplete");
|
||||
}
|
||||
String handle = location.substring(baseUrl.length());
|
||||
if (handle.startsWith("/"))
|
||||
{
|
||||
handle = handle.substring(1);
|
||||
}
|
||||
if ("".equals(handle))
|
||||
{
|
||||
throw new DSpaceSWORDException("The deposit URL is incomplete");
|
||||
}
|
||||
|
||||
DSpaceObject dso = HandleManager.resolveToObject(context, handle);
|
||||
ResolvableIdentifier ri = IdentifierService.resolve(context, location);
|
||||
DSpaceObject dso = (DSpaceObject) IdentifierService.getResource(context, ri);
|
||||
|
||||
if (!(dso instanceof Collection))
|
||||
{
|
||||
@@ -116,7 +110,7 @@ public class CollectionLocation
|
||||
|
||||
return (Collection) dso;
|
||||
}
|
||||
catch (SQLException e)
|
||||
catch (IdentifierException e)
|
||||
{
|
||||
log.error("Caught exception:", e);
|
||||
throw new DSpaceSWORDException("There was a problem resolving the collection", e);
|
||||
|
@@ -47,7 +47,7 @@ import org.dspace.content.DCDate;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.handle.HandleManager;
|
||||
import org.dspace.uri.IdentifierService;
|
||||
|
||||
import org.purl.sword.base.SWORDEntry;
|
||||
|
||||
@@ -192,17 +192,14 @@ public class DSpaceATOMEntry
|
||||
{
|
||||
if (!noOp)
|
||||
{
|
||||
if (item.getHandle() != null)
|
||||
{
|
||||
handle = item.getHandle();
|
||||
}
|
||||
handle = IdentifierService.getCanonicalForm(item);
|
||||
|
||||
if (handle != null && !"".equals(handle))
|
||||
{
|
||||
Content content = new Content();
|
||||
// content.setType("application/zip");
|
||||
content.setType("text/html");
|
||||
content.setSource(HandleManager.getCanonicalForm(handle));
|
||||
content.setSource(handle);
|
||||
entry.setContent(content);
|
||||
}
|
||||
}
|
||||
@@ -247,14 +244,11 @@ public class DSpaceATOMEntry
|
||||
// it's possible that the item hasn't been assigned a handle yet
|
||||
if (!noOp)
|
||||
{
|
||||
if (item.getHandle() != null)
|
||||
{
|
||||
handle = item.getHandle();
|
||||
}
|
||||
handle = IdentifierService.getCanonicalForm(item);
|
||||
|
||||
if (handle != null && !"".equals(handle))
|
||||
{
|
||||
entry.setId(HandleManager.getCanonicalForm(handle));
|
||||
entry.setId(handle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -276,8 +270,6 @@ public class DSpaceATOMEntry
|
||||
*/
|
||||
protected void addLinks(String handle)
|
||||
throws DSpaceSWORDException
|
||||
{
|
||||
try
|
||||
{
|
||||
// if there is no handle, we can't generate links
|
||||
if (handle == null)
|
||||
@@ -285,8 +277,6 @@ public class DSpaceATOMEntry
|
||||
return;
|
||||
}
|
||||
|
||||
String base = ConfigurationManager.getProperty("dspace.url");
|
||||
|
||||
// in the default set up we just pass urls to all of the
|
||||
// inidivual files in the item
|
||||
Bundle[] bundles = item.getBundles("ORIGINAL");
|
||||
@@ -296,17 +286,12 @@ public class DSpaceATOMEntry
|
||||
for (int j = 0; j < bss.length; j++)
|
||||
{
|
||||
Link link = new Link();
|
||||
String url = base + "/bitstream/" + handle + "/" + bss[j].getSequenceID() + "/" + bss[j].getName();
|
||||
String url = IdentifierService.getURL(bss[j]).toString(); // base + "/bitstream/" + handle + "/" + bss[j].getSequenceID() + "/" + bss[j].getName();
|
||||
link.setHref(url);
|
||||
entry.addLink(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DSpaceSWORDException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the date of publication from the bibliographic metadata
|
||||
@@ -337,8 +322,6 @@ public class DSpaceATOMEntry
|
||||
*
|
||||
*/
|
||||
protected void addRights(String handle)
|
||||
{
|
||||
try
|
||||
{
|
||||
// if there's no handle, we can't give a link
|
||||
if (handle == null)
|
||||
@@ -346,14 +329,6 @@ public class DSpaceATOMEntry
|
||||
return;
|
||||
}
|
||||
|
||||
String base = ConfigurationManager.getProperty("dspace.url");
|
||||
|
||||
// if there's no base URL, we are stuck
|
||||
if (base == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder rightsString = new StringBuilder();
|
||||
Bundle[] bundles = item.getBundles("LICENSE");
|
||||
for (int i = 0; i < bundles.length; i++)
|
||||
@@ -361,7 +336,7 @@ public class DSpaceATOMEntry
|
||||
Bitstream[] bss = bundles[i].getBitstreams();
|
||||
for (int j = 0; j < bss.length; j++)
|
||||
{
|
||||
String url = base + "/bitstream/" + handle + "/" + bss[j].getSequenceID() + "/" + bss[j].getName();
|
||||
String url = IdentifierService.getURL(bss[j]).toString(); //base + "/bitstream/" + handle + "/" + bss[j].getSequenceID() + "/" + bss[j].getName();
|
||||
rightsString.append(url + " ");
|
||||
}
|
||||
}
|
||||
@@ -371,11 +346,6 @@ public class DSpaceATOMEntry
|
||||
rights.setType(ContentType.TEXT);
|
||||
entry.setRights(rights);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the source of the bibliographic metadata.
|
||||
|
@@ -256,8 +256,7 @@ public class DSpaceSWORDServer implements SWORDServer
|
||||
}
|
||||
|
||||
log.info(LogManager.getHeader(context, "sword_authenticate", "username=" + un + ",on_behalf_of=" + obo));
|
||||
try
|
||||
{
|
||||
|
||||
// attempt to authenticate the primary user
|
||||
SWORDContext sc = new SWORDContext();
|
||||
SWORDAuthentication auth = new SWORDAuthentication();
|
||||
@@ -314,15 +313,4 @@ public class DSpaceSWORDServer implements SWORDServer
|
||||
|
||||
return sc;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.error("caught exception: ", e);
|
||||
throw new SWORDException("There was a problem accessing the repository user database", e);
|
||||
}
|
||||
catch (AuthorizeException e)
|
||||
{
|
||||
log.error("caught exception: ", e);
|
||||
throw new SWORDAuthenticationException("There was a problem authenticating or authorising the user", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,6 @@
|
||||
package org.dspace.sword;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -266,11 +265,6 @@ public class DepositManager
|
||||
log.error("authentication problem; caught exception: ", e);
|
||||
throw new DSpaceSWORDException(e);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.error("caught exception: ", e);
|
||||
throw new DSpaceSWORDException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,14 +105,11 @@ public class SWORDContext
|
||||
* as asking the question of whether the given eperson is a member
|
||||
* of the special DSpace group Administrator, with id 1
|
||||
*
|
||||
* @param eperson
|
||||
* @return true if administrator, false if not
|
||||
* @throws SQLException
|
||||
*/
|
||||
public boolean isUserAdmin(Context context)
|
||||
throws DSpaceSWORDException
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.authenticated != null)
|
||||
{
|
||||
@@ -121,25 +118,17 @@ public class SWORDContext
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DSpaceSWORDException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given onBehalfOf user DSpace administrator? This translates
|
||||
* as asking the question of whether the given eperson is a member
|
||||
* of the special DSpace group Administrator, with id 1
|
||||
*
|
||||
* @param eperson
|
||||
* @return true if administrator, false if not
|
||||
* @throws SQLException
|
||||
*/
|
||||
public boolean isOnBehalfOfAdmin(Context context)
|
||||
throws DSpaceSWORDException
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.onBehalfOf != null)
|
||||
{
|
||||
@@ -148,11 +137,6 @@ public class SWORDContext
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DSpaceSWORDException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the authenticated user a member of the given group
|
||||
@@ -236,8 +220,6 @@ public class SWORDContext
|
||||
*/
|
||||
public Collection[] getAllowedCollections(Context context)
|
||||
throws DSpaceSWORDException
|
||||
{
|
||||
try
|
||||
{
|
||||
// locate the collections to which the authenticated user has ADD rights
|
||||
Collection[] cols = Collection.findAuthorized(context, null, Constants.ADD);
|
||||
@@ -276,11 +258,6 @@ public class SWORDContext
|
||||
newCols = colList.toArray((Collection[]) newCols);
|
||||
return newCols;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DSpaceSWORDException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current SWORD Context permit deposit into the given
|
||||
|
@@ -54,9 +54,9 @@ import org.dspace.content.packager.PackageParameters;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.PluginManager;
|
||||
import org.dspace.handle.HandleManager;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
import org.dspace.workflow.WorkflowManager;
|
||||
import org.dspace.uri.IdentifierService;
|
||||
|
||||
import org.purl.sword.base.Deposit;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SWORDMETSIngester implements SWORDIngester
|
||||
CollectionLocation cl = new CollectionLocation();
|
||||
Collection collection = cl.getCollection(context, loc);
|
||||
message("Performing deposit using location: " + loc + "; ");
|
||||
message("Location resolves to collection with handle: " + collection.getHandle() +
|
||||
message("Location resolves to collection with identifier: " + IdentifierService.getCanonicalForm(collection) +
|
||||
" and name: " + collection.getMetadata("name") + "; ");
|
||||
|
||||
// load the plugin manager for the required configuration
|
||||
@@ -143,7 +143,8 @@ public class SWORDMETSIngester implements SWORDIngester
|
||||
|
||||
// for some reason, DSpace will not give you the handle automatically,
|
||||
// so we have to look it up
|
||||
String handle = HandleManager.findHandle(context, installedItem);
|
||||
// String handle = HandleManager.findHandle(context, installedItem);
|
||||
String handle = IdentifierService.getCanonicalForm(installedItem);
|
||||
|
||||
message("Ingest successful; ");
|
||||
message("Item created with internal identifier: " + installedItem.getID() + "; ");
|
||||
|
@@ -44,7 +44,6 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
|
Reference in New Issue
Block a user