port pr1839 minus xmlui

This commit is contained in:
Terry Brady
2018-08-03 17:15:23 -07:00
parent 3eb16056c6
commit 77d67537f7
9 changed files with 34 additions and 47 deletions

View File

@@ -271,9 +271,8 @@ public class ItemExportServiceImpl implements ItemExportService {
("date".equals(metadataField.getElement()) && "accessioned".equals(qualifier)) ||
("date".equals(metadataField.getElement()) && "available".equals(qualifier)) ||
("identifier".equals(metadataField.getElement()) && "uri".equals(qualifier) &&
(dcv.getValue() != null && dcv.getValue().startsWith("http://hdl.handle.net/" +
handleService
.getPrefix() + "/"))) ||
(dcv.getValue() != null && dcv.getValue().startsWith(
handleService.getCanonicalPrefix() + handleService.getPrefix() + "/"))) ||
("description".equals(metadataField.getElement()) && "provenance".equals(qualifier)) ||
("format".equals(metadataField.getElement()) && "extent".equals(qualifier)) ||
("format".equals(metadataField.getElement()) && "mimetype".equals(qualifier))))) {

View File

@@ -31,11 +31,12 @@ import org.apache.commons.cli.PosixParser;
import org.dspace.content.Item;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.eperson.service.EPersonService;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
/**
* Provides some batch editing capabilities for items in DSpace:
@@ -78,6 +79,7 @@ public class ItemUpdate {
protected static final EPersonService epersonService = EPersonServiceFactory.getInstance().getEPersonService();
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
protected static final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
static {
filterAliases.put("ORIGINAL", "org.dspace.app.itemupdate.OriginalBitstreamFilter");
@@ -330,10 +332,7 @@ public class ItemUpdate {
iu.setEPerson(context, iu.eperson);
context.turnOffAuthorisationSystem();
HANDLE_PREFIX = ConfigurationManager.getProperty("handle.canonical.prefix");
if (HANDLE_PREFIX == null || HANDLE_PREFIX.length() == 0) {
HANDLE_PREFIX = "http://hdl.handle.net/";
}
HANDLE_PREFIX = handleService.getCanonicalPrefix();
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);

View File

@@ -37,6 +37,8 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.SelfNamedPlugin;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
@@ -95,6 +97,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
protected final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
protected final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
protected final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
/**
* Fill in the plugin alias table from DSpace configuration entries
@@ -418,7 +421,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
protected List<MockMetadataValue> site2Metadata(Site site) {
List<MockMetadataValue> metadata = new ArrayList<>();
String identifier_uri = "http://hdl.handle.net/"
String identifier_uri = handleService.getCanonicalPrefix()
+ site.getHandle();
String title = site.getName();
String url = site.getURL();
@@ -452,7 +455,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String description = communityService.getMetadata(community, "introductory_text");
String description_abstract = communityService.getMetadata(community, "short_description");
String description_table = communityService.getMetadata(community, "side_bar_text");
String identifier_uri = "http://hdl.handle.net/"
String identifier_uri = handleService.getCanonicalPrefix()
+ community.getHandle();
String rights = communityService.getMetadata(community, "copyright_text");
String title = communityService.getMetadata(community, "name");
@@ -495,7 +498,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String description = collectionService.getMetadata(collection, "introductory_text");
String description_abstract = collectionService.getMetadata(collection, "short_description");
String description_table = collectionService.getMetadata(collection, "side_bar_text");
String identifier_uri = "http://hdl.handle.net/"
String identifier_uri = handleService.getCanonicalPrefix()
+ collection.getHandle();
String provenance = collectionService.getMetadata(collection, "provenance_description");
String rights = collectionService.getMetadata(collection, "copyright_text");

View File

@@ -1395,10 +1395,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
if (values != null && values.size() > 0 && values.get(0) != null && values.get(0).getValue() != null) {
// group on parent
String handlePrefix = ConfigurationManager.getProperty("handle.canonical.prefix");
if (handlePrefix == null || handlePrefix.length() == 0) {
handlePrefix = "http://hdl.handle.net/";
}
String handlePrefix = handleService.getCanonicalPrefix();
doc.addField("publication_grp", values.get(0).getValue().replaceFirst(handlePrefix, ""));

View File

@@ -113,8 +113,7 @@ public class HandleServiceImpl implements HandleService {
}
@Override
public String getCanonicalForm(String handle) {
public String getCanonicalPrefix() {
// Let the admin define a new prefix, if not then we'll use the
// CNRI default. This allows the admin to use "hdl:" if they want to or
// use a locally branded prefix handle.myuni.edu.
@@ -123,7 +122,12 @@ public class HandleServiceImpl implements HandleService {
handlePrefix = "http://hdl.handle.net/";
}
return handlePrefix + handle;
return handlePrefix;
}
@Override
public String getCanonicalForm(String handle) {
return getCanonicalPrefix() + handle;
}
@Override

View File

@@ -98,7 +98,7 @@ public class UpdateHandlePrefix {
MetadataValueService metadataValueService = ContentServiceFactory.getInstance()
.getMetadataValueService();
String handlePrefix = configurationService.getProperty("handle.canonical.prefix");
String handlePrefix = handleService.getCanonicalPrefix();
Iterator<MetadataValue> metadataValues = metadataValueService
.findByValueLike(context, handlePrefix + oldH);

View File

@@ -55,6 +55,17 @@ public interface HandleService {
public String resolveUrlToHandle(Context context, String url)
throws SQLException;
/**
* Provides handle canonical prefix using http://hdl.handle.net if not
* overridden by the configuration property handle.canonical.prefix.
*
* No attempt is made to verify that handle is in fact valid.
*
* @param handle The handle
* @return The canonical form
*/
public String getCanonicalPrefix();
/**
* Transforms handle into a URI using http://hdl.handle.net if not
* overridden by the configuration property handle.canonical.prefix.

View File

@@ -364,19 +364,6 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
return prefix;
}
protected static String getCanonicalForm(String handle) {
// Let the admin define a new prefix, if not then we'll use the
// CNRI default. This allows the admin to use "hdl:" if they want to or
// use a locally branded prefix handle.myuni.edu.
String handlePrefix = ConfigurationManager.getProperty("handle.canonical.prefix");
if (handlePrefix == null || handlePrefix.length() == 0) {
handlePrefix = "http://hdl.handle.net/";
}
return handlePrefix + handle;
}
protected String createNewIdentifier(Context context, DSpaceObject dso, String handleId) throws SQLException {
if (handleId == null) {
return handleService.createHandle(context, dso);
@@ -425,7 +412,7 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
protected void populateHandleMetadata(Context context, Item item, String handle)
throws SQLException, IOException, AuthorizeException {
String handleref = getCanonicalForm(handle);
String handleref = handleService.getCanonicalForm(handle);
// we want to remove the old handle and insert the new. To do so, we
// load all identifiers, clear the metadata field, re add all
// identifiers which are not from type handle and add the new handle.

View File

@@ -411,19 +411,6 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
return prefix;
}
protected static String getCanonicalForm(String handle) {
// Let the admin define a new prefix, if not then we'll use the
// CNRI default. This allows the admin to use "hdl:" if they want to or
// use a locally branded prefix handle.myuni.edu.
String handlePrefix = ConfigurationManager.getProperty("handle.canonical.prefix");
if (handlePrefix == null || handlePrefix.length() == 0) {
handlePrefix = "http://hdl.handle.net/";
}
return handlePrefix + handle;
}
protected String createNewIdentifier(Context context, DSpaceObject dso, String handleId) throws SQLException {
if (handleId == null) {
return handleService.createHandle(context, dso);
@@ -503,7 +490,7 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
// we want to exchange the old handle against the new one. To do so, we
// load all identifiers, clear the metadata field, re add all
// identifiers which are not from type handle and add the new handle.
String handleref = getCanonicalForm(handle);
String handleref = handleService.getCanonicalForm(handle);
List<MetadataValue> identifiers = itemService
.getMetadata(item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY);
itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY);