mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 13:03:11 +00:00
Fix dspace-api module per new code style
This commit is contained in:
@@ -7,19 +7,6 @@
|
||||
*/
|
||||
package org.dspace.curate;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.BundleService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.disseminate.factory.DisseminateServiceFactory;
|
||||
import org.dspace.disseminate.service.CitationDocumentService;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
@@ -28,6 +15,21 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.BundleService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.disseminate.factory.DisseminateServiceFactory;
|
||||
import org.dspace.disseminate.service.CitationDocumentService;
|
||||
|
||||
/**
|
||||
* CitationPage
|
||||
*
|
||||
@@ -54,8 +56,6 @@ public class CitationPage extends AbstractCurationTask {
|
||||
protected StringBuilder resBuilder;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The name to give the bundle we add the cited pages to.
|
||||
*/
|
||||
@@ -71,6 +71,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see CurationTask#perform(DSpaceObject)
|
||||
*/
|
||||
@Override
|
||||
@@ -88,6 +89,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see AbstractCurationTask#performItem(Item)
|
||||
*/
|
||||
@Override
|
||||
@@ -97,10 +99,10 @@ public class CitationPage extends AbstractCurationTask {
|
||||
Bundle dBundle = null;
|
||||
if (dBundles == null || dBundles.size() == 0) {
|
||||
try {
|
||||
dBundle = bundleService.create(Curator.curationContext(), item ,CitationPage.DISPLAY_BUNDLE_NAME);
|
||||
dBundle = bundleService.create(Curator.curationContext(), item, CitationPage.DISPLAY_BUNDLE_NAME);
|
||||
} catch (AuthorizeException e) {
|
||||
log.error("User not authroized to create bundle on item \""
|
||||
+ item.getName() + "\": " + e.getMessage());
|
||||
+ item.getName() + "\": " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
dBundle = dBundles.get(0);
|
||||
@@ -108,7 +110,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
|
||||
//Create a map of the bitstreams in the displayBundle. This is used to
|
||||
//check if the bundle being cited is already in the display bundle.
|
||||
Map<String,Bitstream> displayMap = new HashMap<String,Bitstream>();
|
||||
Map<String, Bitstream> displayMap = new HashMap<String, Bitstream>();
|
||||
for (Bitstream bs : dBundle.getBitstreams()) {
|
||||
displayMap.put(bs.getName(), bs);
|
||||
}
|
||||
@@ -128,7 +130,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
pBundle = bundleService.create(Curator.curationContext(), item, CitationPage.PRESERVATION_BUNDLE_NAME);
|
||||
} catch (AuthorizeException e) {
|
||||
log.error("User not authroized to create bundle on item \""
|
||||
+ item.getName() + "\": " + e.getMessage());
|
||||
+ item.getName() + "\": " + e.getMessage());
|
||||
}
|
||||
bundles = itemService.getBundles(item, "ORIGINAL");
|
||||
}
|
||||
@@ -144,17 +146,19 @@ public class CitationPage extends AbstractCurationTask {
|
||||
BitstreamFormat format = bitstream.getFormat(Curator.curationContext());
|
||||
|
||||
//If bitstream is a PDF document then it is citable.
|
||||
CitationDocumentService citationDocument = DisseminateServiceFactory.getInstance().getCitationDocumentService();
|
||||
CitationDocumentService citationDocument = DisseminateServiceFactory.getInstance()
|
||||
.getCitationDocumentService();
|
||||
|
||||
if(citationDocument.canGenerateCitationVersion(Curator.curationContext(), bitstream)) {
|
||||
if (citationDocument.canGenerateCitationVersion(Curator.curationContext(), bitstream)) {
|
||||
this.resBuilder.append(item.getHandle() + " - "
|
||||
+ bitstream.getName() + " is citable.");
|
||||
+ bitstream.getName() + " is citable.");
|
||||
try {
|
||||
//Create the cited document
|
||||
Pair<InputStream, Long> citedDocument = citationDocument.makeCitedDocument(Curator.curationContext(), bitstream);
|
||||
Pair<InputStream, Long> citedDocument =
|
||||
citationDocument.makeCitedDocument(Curator.curationContext(), bitstream);
|
||||
//Add the cited document to the approiate bundle
|
||||
this.addCitedPageToItem(citedDocument.getLeft(), bundle, pBundle,
|
||||
dBundle, displayMap, item, bitstream);
|
||||
dBundle, displayMap, item, bitstream);
|
||||
} catch (Exception e) {
|
||||
//Could be many things, but nothing that should be
|
||||
//expected.
|
||||
@@ -177,7 +181,7 @@ public class CitationPage extends AbstractCurationTask {
|
||||
} else {
|
||||
//bitstream is not a document
|
||||
this.resBuilder.append(item.getHandle() + " - "
|
||||
+ bitstream.getName() + " is not citable.\n");
|
||||
+ bitstream.getName() + " is not citable.\n");
|
||||
this.status = Curator.CURATE_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -194,16 +198,16 @@ public class CitationPage extends AbstractCurationTask {
|
||||
* put in here if it is not already.
|
||||
* @param dBundle The display bundle. The cited document gets put in here.
|
||||
* @param displayMap The map of bitstream names to bitstreams in the display
|
||||
* bundle.
|
||||
* @param item The item containing the bundles being used.
|
||||
* @param bitstream The original source bitstream.
|
||||
* @throws SQLException if database error
|
||||
* bundle.
|
||||
* @param item The item containing the bundles being used.
|
||||
* @param bitstream The original source bitstream.
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @throws IOException if IO error
|
||||
* @throws IOException if IO error
|
||||
*/
|
||||
protected void addCitedPageToItem(InputStream citedDoc, Bundle bundle, Bundle pBundle,
|
||||
Bundle dBundle, Map<String,Bitstream> displayMap, Item item,
|
||||
Bitstream bitstream) throws SQLException, AuthorizeException, IOException {
|
||||
Bundle dBundle, Map<String,Bitstream> displayMap, Item item,
|
||||
Bitstream bitstream) throws SQLException, AuthorizeException, IOException {
|
||||
//If we are modifying a file that is not in the
|
||||
//preservation bundle then we have to move it there.
|
||||
Context context = Curator.curationContext();
|
||||
@@ -232,8 +236,8 @@ public class CitationPage extends AbstractCurationTask {
|
||||
citedBitstream.setDescription(context, bitstream.getDescription());
|
||||
|
||||
this.resBuilder.append(" Added "
|
||||
+ citedBitstream.getName()
|
||||
+ " to the " + CitationPage.DISPLAY_BUNDLE_NAME + " bundle.\n");
|
||||
+ citedBitstream.getName()
|
||||
+ " to the " + CitationPage.DISPLAY_BUNDLE_NAME + " bundle.\n");
|
||||
|
||||
//Run update to propagate changes to the
|
||||
//database.
|
||||
|
Reference in New Issue
Block a user