mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Fix dspace-api module per new code style
This commit is contained in:
@@ -26,12 +26,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Support to install an Item in the archive.
|
||||
*
|
||||
*
|
||||
* @author dstuve
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class InstallItemServiceImpl implements InstallItemService
|
||||
{
|
||||
public class InstallItemServiceImpl implements InstallItemService {
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ContentServiceFactory contentServiceFactory;
|
||||
@@ -44,30 +43,26 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
@Autowired(required = true)
|
||||
protected ItemService itemService;
|
||||
|
||||
protected InstallItemServiceImpl()
|
||||
{
|
||||
protected InstallItemServiceImpl() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item installItem(Context c, InProgressSubmission is)
|
||||
throws SQLException, AuthorizeException
|
||||
{
|
||||
throws SQLException, AuthorizeException {
|
||||
return installItem(c, is, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item installItem(Context c, InProgressSubmission is,
|
||||
String suppliedHandle) throws SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
String suppliedHandle) throws SQLException,
|
||||
AuthorizeException {
|
||||
Item item = is.getItem();
|
||||
Collection collection = is.getCollection();
|
||||
try {
|
||||
if(suppliedHandle == null)
|
||||
{
|
||||
if (suppliedHandle == null) {
|
||||
identifierService.register(c, item);
|
||||
}else{
|
||||
} else {
|
||||
identifierService.register(c, item, suppliedHandle);
|
||||
}
|
||||
} catch (IdentifierException e) {
|
||||
@@ -89,16 +84,14 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
|
||||
@Override
|
||||
public Item restoreItem(Context c, InProgressSubmission is,
|
||||
String suppliedHandle)
|
||||
throws SQLException, IOException, AuthorizeException
|
||||
{
|
||||
String suppliedHandle)
|
||||
throws SQLException, IOException, AuthorizeException {
|
||||
Item item = is.getItem();
|
||||
|
||||
try {
|
||||
if(suppliedHandle == null)
|
||||
{
|
||||
if (suppliedHandle == null) {
|
||||
identifierService.register(c, item);
|
||||
}else{
|
||||
} else {
|
||||
identifierService.register(c, item, suppliedHandle);
|
||||
}
|
||||
} catch (IdentifierException e) {
|
||||
@@ -108,35 +101,32 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
// Even though we are restoring an item it may not have the proper dates. So let's
|
||||
// double check its associated date(s)
|
||||
DCDate now = DCDate.getCurrent();
|
||||
|
||||
|
||||
// If the item doesn't have a date.accessioned, set it to today
|
||||
List<MetadataValue> dateAccessioned = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "accessioned", Item.ANY);
|
||||
if (dateAccessioned.isEmpty())
|
||||
{
|
||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "accessioned", null, now.toString());
|
||||
List<MetadataValue> dateAccessioned = itemService
|
||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "accessioned", Item.ANY);
|
||||
if (dateAccessioned.isEmpty()) {
|
||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "accessioned", null, now.toString());
|
||||
}
|
||||
|
||||
|
||||
// If issue date is set as "today" (literal string), then set it to current date
|
||||
// In the below loop, we temporarily clear all issued dates and re-add, one-by-one,
|
||||
// replacing "today" with today's date.
|
||||
// NOTE: As of DSpace 4.0, DSpace no longer sets an issue date by default
|
||||
List<MetadataValue> currentDateIssued = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
||||
List<MetadataValue> currentDateIssued = itemService
|
||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
||||
itemService.clearMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
||||
for (MetadataValue dcv : currentDateIssued)
|
||||
{
|
||||
if(dcv.getValue()!=null && dcv.getValue().equalsIgnoreCase("today"))
|
||||
{
|
||||
DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1);
|
||||
for (MetadataValue dcv : currentDateIssued) {
|
||||
if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) {
|
||||
DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1);
|
||||
itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), issued.toString());
|
||||
}
|
||||
else if(dcv.getValue()!=null)
|
||||
{
|
||||
} else if (dcv.getValue() != null) {
|
||||
itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), dcv.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Record that the item was restored
|
||||
String provDescription = "Restored into DSpace on "+ now + " (GMT).";
|
||||
String provDescription = "Restored into DSpace on " + now + " (GMT).";
|
||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
|
||||
|
||||
return finishItem(c, item, is);
|
||||
@@ -144,8 +134,7 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
|
||||
|
||||
protected void populateMetadata(Context c, Item item)
|
||||
throws SQLException, AuthorizeException
|
||||
{
|
||||
throws SQLException, AuthorizeException {
|
||||
// create accession date
|
||||
DCDate now = DCDate.getCurrent();
|
||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "accessioned", null, now.toString());
|
||||
@@ -154,8 +143,7 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
// be set when the embargo is lifted.
|
||||
// this will flush out fatal embargo metadata
|
||||
// problems before we set inArchive.
|
||||
if (embargoService.getEmbargoTermsAsDate(c, item) == null)
|
||||
{
|
||||
if (embargoService.getEmbargoTermsAsDate(c, item) == null) {
|
||||
itemService.addMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "available", null, now.toString());
|
||||
}
|
||||
|
||||
@@ -163,34 +151,29 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
// In the below loop, we temporarily clear all issued dates and re-add, one-by-one,
|
||||
// replacing "today" with today's date.
|
||||
// NOTE: As of DSpace 4.0, DSpace no longer sets an issue date by default
|
||||
List<MetadataValue> currentDateIssued = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
||||
List<MetadataValue> currentDateIssued = itemService
|
||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
||||
itemService.clearMetadata(c, item, MetadataSchema.DC_SCHEMA, "date", "issued", Item.ANY);
|
||||
for (MetadataValue dcv : currentDateIssued)
|
||||
{
|
||||
if(dcv.getValue()!=null && dcv.getValue().equalsIgnoreCase("today"))
|
||||
{
|
||||
DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1);
|
||||
for (MetadataValue dcv : currentDateIssued) {
|
||||
if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) {
|
||||
DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1);
|
||||
itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), issued.toString());
|
||||
}
|
||||
else if(dcv.getValue()!=null)
|
||||
{
|
||||
} else if (dcv.getValue() != null) {
|
||||
itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), dcv.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
String provDescription = "Made available in DSpace on " + now
|
||||
+ " (GMT). " + getBitstreamProvenanceMessage(c, item);
|
||||
String provDescription = "Made available in DSpace on " + now
|
||||
+ " (GMT). " + getBitstreamProvenanceMessage(c, item);
|
||||
|
||||
// If an issue date was passed in and it wasn't set to "today" (literal string)
|
||||
// then note this previous issue date in provenance message
|
||||
if (!currentDateIssued.isEmpty())
|
||||
{
|
||||
if (!currentDateIssued.isEmpty()) {
|
||||
String previousDateIssued = currentDateIssued.get(0).getValue();
|
||||
if(previousDateIssued!=null && !previousDateIssued.equalsIgnoreCase("today"))
|
||||
{
|
||||
if (previousDateIssued != null && !previousDateIssued.equalsIgnoreCase("today")) {
|
||||
DCDate d = new DCDate(previousDateIssued);
|
||||
provDescription = provDescription + " Previous issue date: "
|
||||
+ d.toString();
|
||||
+ d.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,16 +186,15 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
* This method is used by *both* installItem() and restoreItem(),
|
||||
* so all actions here will be run for a newly added item or a restored item.
|
||||
*
|
||||
* @param c DSpace Context
|
||||
* @param c DSpace Context
|
||||
* @param item Item in question
|
||||
* @param is InProgressSubmission object
|
||||
* @param is InProgressSubmission object
|
||||
* @return final "archived" Item
|
||||
* @throws SQLException if database error
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
protected Item finishItem(Context c, Item item, InProgressSubmission is)
|
||||
throws SQLException, AuthorizeException
|
||||
{
|
||||
throws SQLException, AuthorizeException {
|
||||
// create collection2item mapping
|
||||
collectionService.addItem(c, is.getCollection(), item);
|
||||
|
||||
@@ -221,13 +203,13 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
|
||||
// set in_archive=true
|
||||
item.setArchived(true);
|
||||
|
||||
|
||||
// save changes ;-)
|
||||
itemService.update(c, item);
|
||||
|
||||
// Notify interested parties of newly archived Item
|
||||
c.addEvent(new Event(Event.INSTALL, Constants.ITEM, item.getID(),
|
||||
item.getHandle(), itemService.getIdentifiers(c, item)));
|
||||
item.getHandle(), itemService.getIdentifiers(c, item)));
|
||||
|
||||
// remove in-progress submission
|
||||
contentServiceFactory.getInProgressSubmissionService(is).deleteWrapper(c, is);
|
||||
@@ -240,8 +222,7 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
|
||||
@Override
|
||||
public String getBitstreamProvenanceMessage(Context context, Item myitem)
|
||||
throws SQLException
|
||||
{
|
||||
throws SQLException {
|
||||
// Get non-internal format bitstreams
|
||||
List<Bitstream> bitstreams = itemService.getNonInternalBitstreams(context, myitem);
|
||||
|
||||
@@ -250,12 +231,11 @@ public class InstallItemServiceImpl implements InstallItemService
|
||||
myMessage.append("No. of bitstreams: ").append(bitstreams.size()).append("\n");
|
||||
|
||||
// Add sizes and checksums of bitstreams
|
||||
for (Bitstream bitstream : bitstreams)
|
||||
{
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
myMessage.append(bitstream.getName()).append(": ")
|
||||
.append(bitstream.getSize()).append(" bytes, checksum: ")
|
||||
.append(bitstream.getChecksum()).append(" (")
|
||||
.append(bitstream.getChecksumAlgorithm()).append(")\n");
|
||||
.append(bitstream.getSize()).append(" bytes, checksum: ")
|
||||
.append(bitstream.getChecksum()).append(" (")
|
||||
.append(bitstream.getChecksumAlgorithm()).append(")\n");
|
||||
}
|
||||
|
||||
return myMessage.toString();
|
||||
|
Reference in New Issue
Block a user