Merge branch 'master' into DS-2784-jersey2

Conflicts:
	dspace-rest/src/main/java/org/dspace/rest/BitstreamResource.java
This commit is contained in:
aleksanderkotbury
2015-12-11 19:28:09 +01:00
208 changed files with 2363 additions and 1849 deletions

View File

@@ -185,7 +185,7 @@ public class MetadataImporter
{
// Schema does not exist - create
log.info("Registering Schema " + name + " (" + namespace + ")");
MetadataSchema schema = metadataSchemaService.create(context, name, namespace);
metadataSchemaService.create(context, name, namespace);
}
else
{

View File

@@ -9,12 +9,8 @@ package org.dspace.app.bulkedit;
import org.apache.commons.lang3.StringUtils;
import org.dspace.authority.AuthorityValue;
import org.dspace.app.bulkedit.DSpaceCSVLine;
import org.dspace.app.bulkedit.MetadataImport;
import org.dspace.app.bulkedit.MetadataImportInvalidHeadingException;
import org.dspace.authority.factory.AuthorityServiceFactory;
import org.dspace.authority.service.AuthorityValueService;
import org.dspace.content.Collection;
import org.dspace.content.*;
import org.dspace.content.Collection;
import org.dspace.content.factory.ContentServiceFactory;
@@ -73,10 +69,10 @@ public class DSpaceCSV implements Serializable
/** The authority separator in an escaped form for using in regexes */
protected String escapedAuthoritySeparator;
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
protected final MetadataSchemaService metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
protected final MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
protected transient final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
protected transient final MetadataSchemaService metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
protected transient final MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
protected transient final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
/** Whether to export all metadata such as handles and provenance information */
@@ -262,16 +258,16 @@ public class DSpaceCSV implements Serializable
setAuthoritySeparator();
// Create the headings
headings = new ArrayList<String>();
headings = new ArrayList<>();
// Create the blank list of items
lines = new ArrayList<DSpaceCSVLine>();
lines = new ArrayList<>();
// Initialise the counter
counter = 0;
// Set the metadata fields to ignore
ignore = new HashMap<String, String>();
ignore = new HashMap<>();
String toIgnore = ConfigurationManager.getProperty("bulkedit", "ignore-on-export");
if ((toIgnore == null) || ("".equals(toIgnore.trim())))
{
@@ -495,7 +491,7 @@ public class DSpaceCSV implements Serializable
// Split up on field separator
String[] parts = line.split(escapedFieldSeparator);
ArrayList<String> bits = new ArrayList<String>();
ArrayList<String> bits = new ArrayList<>();
bits.addAll(Arrays.asList(parts));
// Merge parts with embedded separators
@@ -624,7 +620,7 @@ public class DSpaceCSV implements Serializable
// Create the headings line
String[] csvLines = new String[counter + 1];
csvLines[0] = "id" + fieldSeparator + "collection";
List<String> headingsCopy = new ArrayList<String>(headings);
List<String> headingsCopy = new ArrayList<>(headings);
Collections.sort(headingsCopy);
for (String value : headingsCopy)
{
@@ -701,10 +697,11 @@ public class DSpaceCSV implements Serializable
*
* @return The formatted String as a csv
*/
@Override
public final String toString()
{
// Return the csv as one long string
StringBuffer csvLines = new StringBuffer();
StringBuilder csvLines = new StringBuilder();
String[] lines = this.getCSVLinesAsStringArray();
for (String line : lines)
{

View File

@@ -22,15 +22,16 @@ import java.util.*;
public class DSpaceCSVLine implements Serializable
{
/** The item id of the item represented by this line. -1 is for a new item */
private UUID id;
private final UUID id;
/** The elements in this line in a hashtable, keyed by the metadata type */
private Map<String, ArrayList> items;
private final Map<String, ArrayList> items;
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
protected transient final AuthorityValueService authorityValueService
= AuthorityServiceFactory.getInstance().getAuthorityValueService();
/** ensuring that the order-sensible columns of the csv are processed in the correct order */
private final Comparator<? super String> headerComparator = new Comparator<String>() {
private transient final Comparator<? super String> headerComparator = new Comparator<String>() {
@Override
public int compare(String md1, String md2) {
// The metadata coming from an external source should be processed after the others
@@ -60,7 +61,7 @@ public class DSpaceCSVLine implements Serializable
{
// Store the ID + separator, and initialise the hashtable
this.id = itemId;
items = new TreeMap<String, ArrayList>(headerComparator);
items = new TreeMap<>(headerComparator);
// this.items = new HashMap<String, ArrayList>();
}
@@ -71,7 +72,7 @@ public class DSpaceCSVLine implements Serializable
{
// Set the ID to be null, and initialise the hashtable
this.id = null;
this.items = new TreeMap<String, ArrayList>(headerComparator);
this.items = new TreeMap<>(headerComparator);
}
/**
@@ -149,6 +150,7 @@ public class DSpaceCSVLine implements Serializable
* Write this line out as a CSV formatted string, in the order given by the headings provided
*
* @param headings The headings which define the order the elements must be presented in
* @param fieldSeparator
* @return The CSV formatted String
*/
protected String toCSV(List<String> headings, String fieldSeparator)
@@ -177,6 +179,7 @@ public class DSpaceCSVLine implements Serializable
* Internal method to create a CSV formatted String joining a given set of elements
*
* @param values The values to create the string from
* @param valueSeparator
* @return The line as a CSV formatted String
*/
protected String valueToCSV(List<String> values, String valueSeparator)

View File

@@ -483,7 +483,7 @@ public class MetadataImport
",looking_for_element=" + element +
",looking_for_qualifier=" + qualifier +
",looking_for_language=" + language));
String[] dcvalues = new String[0];
String[] dcvalues;
if(fromAuthority==null) {
List<MetadataValue> current = itemService.getMetadata(item, schema, element, qualifier, language);
dcvalues = new String[current.size()];

View File

@@ -71,6 +71,10 @@ public class ItemExportCLITool {
options.addOption("z", "zip", true, "export as zip file (specify filename e.g. export.zip)");
options.addOption("h", "help", false, "help");
// as pointed out by Peter Dietz this provides similar functionality to export metadata
// but it is needed since it directly exports to Simple Archive Format (SAF)
options.addOption("x", "exclude-bitstreams", false, "do not export bitstreams");
CommandLine line = parser.parse(options, argv);
String typeString = null;
@@ -137,6 +141,12 @@ public class ItemExportCLITool {
zipFileName = line.getOptionValue('z');
}
boolean excludeBitstreams = false;
if (line.hasOption('x'))
{
excludeBitstreams = true;
}
// now validate the args
if (myType == -1)
{
@@ -234,14 +244,14 @@ public class ItemExportCLITool {
System.out.println("Exporting from collection: " + myIDString);
items = itemService.findByCollection(c, mycollection);
}
itemExportService.exportAsZip(c, items, destDirName, zipFileName, seqStart, migrate);
itemExportService.exportAsZip(c, items, destDirName, zipFileName, seqStart, migrate, excludeBitstreams);
}
else
{
if (myItem != null)
{
// it's only a single item
itemExportService.exportItem(c, Collections.singletonList(myItem).iterator(), destDirName, seqStart, migrate);
itemExportService.exportItem(c, Collections.singletonList(myItem).iterator(), destDirName, seqStart, migrate, excludeBitstreams);
}
else
{
@@ -249,7 +259,7 @@ public class ItemExportCLITool {
// it's a collection, so do a bunch of items
Iterator<Item> i = itemService.findByCollection(c, mycollection);
itemExportService.exportItem(c, i, destDirName, seqStart, migrate);
itemExportService.exportItem(c, i, destDirName, seqStart, migrate, excludeBitstreams);
}
}

View File

@@ -88,7 +88,8 @@ public class ItemExportServiceImpl implements ItemExportService
@Override
public void exportItem(Context c, Iterator<Item> i,
String destDirName, int seqStart, boolean migrate) throws Exception
String destDirName, int seqStart, boolean migrate,
boolean excludeBitstreams) throws Exception
{
int mySequenceNumber = seqStart;
int counter = SUBDIR_LIMIT - 1;
@@ -123,13 +124,13 @@ public class ItemExportServiceImpl implements ItemExportService
}
System.out.println("Exporting item to " + mySequenceNumber);
exportItem(c, i.next(), fullPath, mySequenceNumber, migrate);
exportItem(c, i.next(), fullPath, mySequenceNumber, migrate, excludeBitstreams);
mySequenceNumber++;
}
}
protected void exportItem(Context c, Item myItem, String destDirName,
int seqStart, boolean migrate) throws Exception
int seqStart, boolean migrate, boolean excludeBitstreams) throws Exception
{
File destDir = new File(destDirName);
@@ -138,8 +139,9 @@ public class ItemExportServiceImpl implements ItemExportService
// now create a subdirectory
File itemDir = new File(destDir + "/" + seqStart);
System.out.println("Exporting Item " + myItem.getID() + " to "
+ itemDir);
System.out.println("Exporting Item " + myItem.getID() +
(myItem.getHandle() != null ? ", handle " + myItem.getHandle() : "") +
" to " + itemDir);
if (itemDir.exists())
{
@@ -151,7 +153,7 @@ public class ItemExportServiceImpl implements ItemExportService
{
// make it this far, now start exporting
writeMetadata(c, myItem, itemDir, migrate);
writeBitstreams(c, myItem, itemDir);
writeBitstreams(c, myItem, itemDir, excludeBitstreams);
if (!migrate)
{
writeHandle(c, myItem, itemDir);
@@ -354,8 +356,8 @@ public class ItemExportServiceImpl implements ItemExportService
* @throws Exception
* if there is any problem writing to the export directory
*/
protected void writeBitstreams(Context c, Item i, File destDir)
throws Exception
protected void writeBitstreams(Context c, Item i, File destDir,
boolean excludeBitstreams) throws Exception
{
File outFile = new File(destDir, "contents");
@@ -389,12 +391,10 @@ public class ItemExportServiceImpl implements ItemExportService
int myPrefix = 1; // only used with name conflict
InputStream is = bitstreamService.retrieve(c, bitstream);
boolean isDone = false; // done when bitstream is finally
// written
while (!isDone) {
while (!excludeBitstreams && !isDone) {
if (myName.contains(File.separator)) {
String dirs = myName.substring(0, myName
.lastIndexOf(File.separator));
@@ -408,12 +408,24 @@ public class ItemExportServiceImpl implements ItemExportService
File fout = new File(destDir, myName);
if (fout.createNewFile()) {
InputStream is = bitstreamService.retrieve(c, bitstream);
FileOutputStream fos = new FileOutputStream(fout);
Utils.bufferedCopy(is, fos);
// close streams
is.close();
fos.close();
isDone = true;
} else {
myName = myPrefix + "_" + oldName; // keep
// appending
// numbers to the
// filename until
// unique
myPrefix++;
}
}
// write the manifest file entry
if (bitstreamService.isRegisteredBitstream(bitstream)) {
out.println("-r -s " + bitstream.getStoreNumber()
@@ -425,16 +437,6 @@ public class ItemExportServiceImpl implements ItemExportService
primary + description);
}
isDone = true;
} else {
myName = myPrefix + "_" + oldName; // keep
// appending
// numbers to the
// filename until
// unique
myPrefix++;
}
}
}
}
@@ -450,7 +452,9 @@ public class ItemExportServiceImpl implements ItemExportService
@Override
public void exportAsZip(Context context, Iterator<Item> items,
String destDirName, String zipFileName,
int seqStart, boolean migrate) throws Exception
int seqStart, boolean migrate,
boolean excludeBitstreams) throws Exception
{
String workDir = getExportWorkDirectory() +
System.getProperty("file.separator") +
@@ -469,7 +473,7 @@ public class ItemExportServiceImpl implements ItemExportService
}
// export the items using normal export method
exportItem(context, items, workDir, seqStart, migrate);
exportItem(context, items, workDir, seqStart, migrate, excludeBitstreams);
// now zip up the export directory created above
zip(workDir, destDirName + System.getProperty("file.separator") + zipFileName);
@@ -716,7 +720,7 @@ public class ItemExportServiceImpl implements ItemExportService
// export the items using normal export method
exportItem(context, iitems, workDir, 1, migrate);
exportItem(context, iitems, workDir, 1, migrate, false);
}
// now zip up the export directory created above

View File

@@ -47,7 +47,8 @@ public interface ItemExportService {
public static final String COMPRESSED_EXPORT_MIME_TYPE = "application/zip";
public void exportItem(Context c, Iterator<Item> i,
String destDirName, int seqStart, boolean migrate) throws Exception;
String destDirName, int seqStart, boolean migrate,
boolean excludeBitstreams) throws Exception;
/**
* Method to perform an export and save it as a zip file.
@@ -62,7 +63,8 @@ public interface ItemExportService {
*/
public void exportAsZip(Context context, Iterator<Item> items,
String destDirName, String zipFileName,
int seqStart, boolean migrate) throws Exception;
int seqStart, boolean migrate,
boolean excludeBitstreams) throws Exception;
/**
* Convenience methot to create export a single Community, Collection, or

View File

@@ -275,7 +275,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
File outFile = null;
PrintWriter mapOut = null;
try {
Map<String, String> skipItems = new HashMap<String, String>(); // set of items to skip if in 'resume'
Map<String, String> skipItems = new HashMap<>(); // set of items to skip if in 'resume'
// mode
System.out.println("Adding items from directory: " + sourceDir);
@@ -595,7 +595,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
// read in the map file and generate a hashmap of (file,handle) pairs
protected Map<String, String> readMapFile(String filename) throws Exception
{
Map<String, String> myHash = new HashMap<String, String>();
Map<String, String> myHash = new HashMap<>();
BufferedReader is = null;
try
@@ -893,7 +893,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
{
File contentsFile = new File(path + File.separatorChar + filename);
String line = "";
List<String> options = new ArrayList<String>();
List<String> options = new ArrayList<>();
System.out.println("\tProcessing contents file: " + contentsFile);
@@ -1228,7 +1228,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
Bitstream bs = null;
String newBundleName = bundleName;
if (bundleName == null)
if (StringUtils.isBlank(bundleName))
{
// is it license.txt?
if (bitstreamPath.endsWith("license.txt"))
@@ -1260,7 +1260,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
}
// now add the bitstream
bs = bitstreamService.register(c, assetstore, bitstreamPath);
bs = bitstreamService.register(c, targetBundle, assetstore, bitstreamPath);
// set the name to just the filename
int iLastSlash = bitstreamPath.lastIndexOf('/');
@@ -1658,7 +1658,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
//regex supports either windows or *nix file paths
String[] entryChunks = entry.getName().split("/|\\\\");
if(entryChunks.length > 2) {
if(sourceDirForZip == sourcedir) {
if(StringUtils.equals(sourceDirForZip, sourcedir)) {
sourceDirForZip = sourcedir + "/" + entryChunks[0];
}
}
@@ -1682,7 +1682,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
//Close zip file
zf.close();
if(sourceDirForZip != sourcedir) {
if(!StringUtils.equals(sourceDirForZip, sourcedir)) {
sourcedir = sourceDirForZip;
System.out.println("Set sourceDir using path inside of Zip: " + sourcedir);
log.info("Set sourceDir using path inside of Zip: " + sourcedir);
@@ -1840,6 +1840,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
List<Collection> finalCollections = null;
if (theOwningCollection != null){
finalCollections = new ArrayList<>();
finalCollections.add(theOwningCollection);
finalCollections.addAll(collectionList);
}
@@ -1948,7 +1949,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
return null;
}
Map<String, BatchUpload> fileNames = new TreeMap<String, BatchUpload>();
Map<String, BatchUpload> fileNames = new TreeMap<>();
for (String fileName : uploadDir.list())
{
@@ -1963,7 +1964,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
if (fileNames.size() > 0)
{
return new ArrayList<BatchUpload>(fileNames.values());
return new ArrayList<>(fileNames.values());
}
return null;

View File

@@ -55,8 +55,6 @@ public class SHERPAResponse
Document inDoc = db.parse(xmlData);
Element xmlRoot = inDoc.getDocumentElement();
Element dataRoot = XMLUtils.getSingleElement(xmlRoot, "romeoapi");
Element headersElement = XMLUtils.getSingleElement(xmlRoot,
"header");
Element journalsElement = XMLUtils.getSingleElement(xmlRoot,

View File

@@ -26,7 +26,7 @@ public class SHERPAService
private int maxNumberOfTries;
private long sleepBetweenTimeouts;
private int timeout;
private int timeout = 5000;
/** log4j category */
private static final Logger log = Logger.getLogger(SHERPAService.class);

View File

@@ -347,8 +347,7 @@ public class GoogleMetadata
{
configFilter = configFilter.trim();
}
ArrayList<ArrayList<String>> parsedOptions = new ArrayList<ArrayList<String>>();
parsedOptions = parseOptions(configFilter);
ArrayList<ArrayList<String>> parsedOptions = parseOptions(configFilter);
if (log.isDebugEnabled())
{

View File

@@ -20,6 +20,7 @@ import java.util.Properties;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.content.Collection;
@@ -249,6 +250,10 @@ public class Util {
public static UUID getUUIDParameter(HttpServletRequest request, String param)
{
String val = request.getParameter(param);
if (StringUtils.isEmpty(val))
{
return null;
}
try
{

View File

@@ -360,9 +360,6 @@ public class AuthorizeServiceImpl implements AuthorizeService
return false;
}
// is eperson set? if not, userid = 0 (anonymous)
EPerson e = c.getCurrentUser();
//
// First, check all Resource Policies directly on this object
//

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.dspace.core.ConfigurationManager;
import org.dspace.sort.SortOption;
@@ -95,17 +96,30 @@ public final class BrowseIndex
/**
* Create a new BrowseIndex object using the definition from the configuration,
* and the number of the configuration option. The definition should be of
* the form:
* and the number of the configuration option. The definition should follow
* one of the following forms:
*
* <code>
* [name]:[metadata]:[data type]:[display type]
* [name]:item:[sort option]:[order]
* </code>
*
* or
*
* <code>
* [name]:metadata:[metadata]:[data type]:[order]:[sort option]
* </code>
*
* [name] is a freetext name for the field
* item or metadata defines the display type
* [metadata] is the usual format of the metadata such as dc.contributor.author
* [sort option] is the name of a separately defined sort option
* [order] must be either asc or desc
* [data type] must be either "title", "date" or "text"
* [display type] must be either "single" or "full"
*
* If you use the first form (to define an index of type item), the order
* is facultative. If you use the second form (for type metadata), the order
* and sort option are facultative, but you must configure the order if you
* want to configure the sort option.
*
* @param definition the configuration definition of this index
* @param number the configuration number of this index
@@ -120,7 +134,7 @@ public final class BrowseIndex
this.defaultOrder = SortOption.ASCENDING;
this.number = number;
String rx = "(\\w+):(\\w+):([\\w\\.\\*,]+):?(\\w*):?(\\w*)";
String rx = "(\\w+):(\\w+):([\\w\\.\\*,]+):?(\\w*):?(\\w*):?(\\w*)";
Pattern pattern = Pattern.compile(rx);
Matcher matcher = pattern.matcher(definition);
@@ -160,6 +174,30 @@ public final class BrowseIndex
}
}
if (matcher.groupCount() > 5)
{
String sortName = matcher.group(6).trim();
if (sortName.length() > 0)
{
for (SortOption so : SortOption.getSortOptions())
{
if (so.getName().equals(sortName))
{
sortOption = so;
}
}
// for backward compatability we ignore the keywords
// single and full here
if (!sortName.equalsIgnoreCase("single")
&& !sortName.equalsIgnoreCase("full")
&& sortOption == null)
{
valid = false;
}
}
}
tableBaseName = getItemBrowseIndex().tableBaseName;
}
else if (isItemIndex())

View File

@@ -106,8 +106,7 @@ public class ItemCountDAOSolr implements ItemCountDAO
public int getCount(DSpaceObject dso) throws ItemCountException
{
loadCount();
DiscoverQuery query = new DiscoverQuery();
Integer val = null;
Integer val;
if (dso instanceof Collection)
{
val = collectionsCount.get(String.valueOf(((Collection) dso).getID()));

View File

@@ -7,6 +7,7 @@
*/
package org.dspace.browse;
import java.io.Serializable;
import java.util.*;
import org.apache.log4j.Logger;
@@ -40,7 +41,8 @@ public class SolrBrowseDAO implements BrowseDAO
this.context = context;
}
static private class FacetValueComparator implements Comparator
static private class FacetValueComparator
implements Comparator, Serializable
{
@Override
public int compare(Object o1, Object o2)
@@ -64,10 +66,10 @@ public class SolrBrowseDAO implements BrowseDAO
}
/** Log4j log */
private static Logger log = Logger.getLogger(SolrBrowseDAO.class);
private static final Logger log = Logger.getLogger(SolrBrowseDAO.class);
/** The DSpace context */
private Context context;
private final Context context;
// SQL query related attributes for this class
@@ -254,7 +256,7 @@ public class SolrBrowseDAO implements BrowseDAO
int count = doCountQuery();
int start = offset > 0 ? offset : 0;
int max = limit > 0 ? limit : count; //if negative, return everything
List<String[]> result = new ArrayList<String[]>();
List<String[]> result = new ArrayList<>();
if (ascending)
{
for (int i = start; i < (start + max) && i < count; i++)

View File

@@ -7,6 +7,7 @@
*/
package org.dspace.checker;
import java.io.Serializable;
import javax.persistence.*;
/**
@@ -16,7 +17,8 @@ import javax.persistence.*;
*/
@Entity
@Table(name="checksum_results")
public final class ChecksumResult
public class ChecksumResult
implements Serializable
{
@Id
@Column(name="result_code")

View File

@@ -71,7 +71,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
private Collection collection;
@Transient
private BitstreamService bitstreamService;
private transient BitstreamService bitstreamService;
public Bitstream()

View File

@@ -7,6 +7,7 @@
*/
package org.dspace.content;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
@@ -31,7 +32,7 @@ import javax.persistence.*;
*/
@Entity
@Table(name="bitstreamformatregistry")
public class BitstreamFormat
public class BitstreamFormat implements Serializable
{
@Id
@@ -71,7 +72,7 @@ public class BitstreamFormat
private List<String> fileExtensions;
@Transient
private BitstreamFormatService bitstreamFormatService;
private transient BitstreamFormatService bitstreamFormatService;
/**
* The "unknown" support level - for bitstream formats that are unknown to
@@ -109,7 +110,7 @@ public class BitstreamFormat
*
* @return the short description
*/
public final String getShortDescription()
public String getShortDescription()
{
return shortDescription;
}
@@ -127,7 +128,7 @@ public class BitstreamFormat
*
* @return the description
*/
public final String getDescription()
public String getDescription()
{
return description;
}
@@ -139,7 +140,7 @@ public class BitstreamFormat
* @param s
* the new description
*/
public final void setDescription(String s)
public void setDescription(String s)
{
this.description = s;
}
@@ -172,7 +173,7 @@ public class BitstreamFormat
*
* @return the support level
*/
public final int getSupportLevel()
public int getSupportLevel()
{
return supportLevel;
}
@@ -194,7 +195,7 @@ public class BitstreamFormat
*
* @return <code>true</code> if the bitstream format is an internal type
*/
public final boolean isInternal()
public boolean isInternal()
{
return internal;
}
@@ -206,7 +207,7 @@ public class BitstreamFormat
* pass in <code>true</code> if the bitstream format is an
* internal type
*/
public final void setInternal(boolean b)
public void setInternal(boolean b)
{
internal = b;
}

View File

@@ -47,7 +47,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
inverseJoinColumns={@JoinColumn(name="bitstream_id") }
)
@OrderColumn(name="bitstream_order")
private List<Bitstream> bitstreams = new ArrayList<>();
private final List<Bitstream> bitstreams = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
@@ -55,10 +55,10 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
joinColumns = {@JoinColumn(name = "bundle_id", referencedColumnName = "uuid") },
inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "uuid") }
)
private List<Item> items = new ArrayList<>();
private final List<Item> items = new ArrayList<>();
@Transient
protected BundleService bundleService;
protected transient BundleService bundleService;
protected Bundle()
{

View File

@@ -83,10 +83,10 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
joinColumns = {@JoinColumn(name = "collection_id") },
inverseJoinColumns = {@JoinColumn(name = "community_id") }
)
private List<Community> communities = new ArrayList<>();
private final List<Community> communities = new ArrayList<>();
@Transient
private CollectionService collectionService;
private transient CollectionService collectionService;
// Keys for accessing Collection metadata
@Transient

View File

@@ -7,9 +7,15 @@
*/
package org.dspace.content;
import java.io.Serializable;
import java.util.Comparator;
public class CollectionNameComparator implements Comparator<Collection> {
/**
* Compares the names of two {@link Collection}s.
*/
public class CollectionNameComparator
implements Comparator<Collection>, Serializable
{
@Override
public int compare(Collection collection1, Collection collection2) {
return collection1.getName().compareTo(collection2.getName());

View File

@@ -23,7 +23,6 @@ import org.dspace.eperson.Group;
import org.dspace.eperson.service.GroupService;
import org.dspace.eperson.service.SubscribeService;
import org.dspace.event.Event;
import org.dspace.handle.service.HandleService;
import org.dspace.workflow.factory.WorkflowServiceFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,7 +41,7 @@ import java.util.*;
public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> implements CollectionService {
/** log4j category */
private static Logger log = Logger.getLogger(CollectionServiceImpl.class);
private static final Logger log = Logger.getLogger(CollectionServiceImpl.class);
@Autowired(required = true)
protected CollectionDAO collectionDAO;
@@ -58,8 +57,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
@Autowired(required = true)
protected GroupService groupService;
@Autowired(required = true)
protected HandleService handleService;
@Autowired(required = true)
protected LicenseService licenseService;
@Autowired(required = true)
@@ -135,7 +132,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
return findAuthorized(context, null, actionID);
}
List<Collection> myResults = new ArrayList<Collection>();
List<Collection> myResults = new ArrayList<>();
if(authorizeService.isAdmin(context))
{
@@ -340,7 +337,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
collection.setWorkflowStep3(group);
break;
default:
new IllegalAccessException("Illegal step count: " + step);
throw new IllegalArgumentException("Illegal step count: " + step);
}
}
@@ -362,6 +359,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
/**
* Get the value of a metadata field
*
* @param collection
* @param field
* the name of the metadata field to get
*
@@ -549,7 +547,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
item.removeCollection(collection);
//Check if we orphaned our poor item
if (item.getCollections().size() == 0)
if (item.getCollections().isEmpty())
{
// Orphan; delete it
itemService.delete(context, item);
@@ -736,9 +734,9 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
@Override
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
List<Collection> myResults = new ArrayList<Collection>();
List<Collection> myResults = new ArrayList<>();
List<Collection> myCollections = null;
List<Collection> myCollections;
if (community != null)
{

View File

@@ -33,7 +33,7 @@ import java.util.*;
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
{
/** log4j category */
private static Logger log = Logger.getLogger(Community.class);
private static final Logger log = Logger.getLogger(Community.class);
@Column(name="community_id", insertable = false, updatable = false)
private Integer legacyId;
@@ -44,13 +44,13 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
joinColumns = {@JoinColumn(name = "parent_comm_id") },
inverseJoinColumns = {@JoinColumn(name = "child_comm_id") }
)
private final List<Community> subCommunities = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "subCommunities")
private List<Community> parentCommunities = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "parentCommunities")
private List<Community> subCommunities = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "communities", cascade = {CascadeType.PERSIST})
private List<Collection> collections = new ArrayList<>();
private final List<Collection> collections = new ArrayList<>();
@OneToOne
@JoinColumn(name = "admin")
@@ -69,7 +69,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
public static final String SIDEBAR_TEXT = "side_bar_text";
@Transient
protected CommunityService communityService;
protected transient CommunityService communityService;
protected Community() {
}
@@ -207,6 +207,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
return true;
}
@Override
public int hashCode()
{
return new HashCodeBuilder().append(getID()).toHashCode();

View File

@@ -24,7 +24,6 @@ import org.dspace.core.LogManager;
import org.dspace.eperson.Group;
import org.dspace.eperson.service.GroupService;
import org.dspace.event.Event;
import org.dspace.handle.service.HandleService;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
@@ -51,8 +50,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
@Autowired(required = true)
protected CollectionService collectionService;
@Autowired(required = true)
protected HandleService handleService;
@Autowired(required = true)
protected GroupService groupService;
@Autowired(required = true)
protected AuthorizeService authorizeService;
@@ -203,12 +200,13 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
}
// First, delete any existing logo
if (community.getLogo() != null)
Bitstream oldLogo = community.getLogo();
if (oldLogo != null)
{
log.info(LogManager.getHeader(context, "remove_logo",
"community_id=" + community.getID()));
community.setLogo(null);
bitstreamService.delete(context, community.getLogo());
bitstreamService.delete(context, oldLogo);
}
if (is != null)

View File

@@ -78,13 +78,13 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
joinColumns = {@JoinColumn(name = "item_id") },
inverseJoinColumns = {@JoinColumn(name = "collection_id") }
)
private List<Collection> collections = new ArrayList<>();
private final List<Collection> collections = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "items")
private List<Bundle> bundles = new ArrayList<>();
private final List<Bundle> bundles = new ArrayList<>();
@Transient
private ItemService itemService;
private transient ItemService itemService;
protected Item() {
}

View File

@@ -40,7 +40,8 @@ public class ItemComparator implements Comparator, Serializable
/** Whether maximum or minimum value will be used */
protected boolean max;
protected ItemService itemService;
protected transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
/**
* Constructor.
@@ -63,7 +64,6 @@ public class ItemComparator implements Comparator, Serializable
this.qualifier = qualifier;
this.language = language;
this.max = max;
this.itemService = ContentServiceFactory.getInstance().getItemService();
}
/**
@@ -127,6 +127,7 @@ public class ItemComparator implements Comparator, Serializable
* The object to compare to.
* @return True if the other object is equal to this one, false otherwise.
*/
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemComparator))
@@ -141,13 +142,16 @@ public class ItemComparator implements Comparator, Serializable
&& equalsWithNull(language, other.language) && (max == other.max);
}
@Override
public int hashCode()
{
return new HashCodeBuilder().append(element).append(qualifier).append(language).append(max).toHashCode();
}
/**
* Return true if the first string is equal to the second. Either or both
* @param first
* @param second
* @return true if the first string is equal to the second. Either or both
* may be null.
*/
protected boolean equalsWithNull(String first, String second)
@@ -180,7 +184,7 @@ public class ItemComparator implements Comparator, Serializable
// The overall array and each element are guaranteed non-null
List<MetadataValue> dcvalues = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, element, qualifier, language);
if (dcvalues.size() == 0)
if (dcvalues.isEmpty())
{
return null;
}
@@ -192,7 +196,7 @@ public class ItemComparator implements Comparator, Serializable
// We want to sort using Strings, but also keep track of
// which Metadatum the value came from.
Map<String, Integer> values = new HashMap<String, Integer>();
Map<String, Integer> values = new HashMap<>();
for (int i = 0; i < dcvalues.size(); i++)
{
@@ -204,7 +208,7 @@ public class ItemComparator implements Comparator, Serializable
}
}
if (values.size() == 0)
if (values.isEmpty())
{
return null;
}
@@ -220,6 +224,8 @@ public class ItemComparator implements Comparator, Serializable
/**
* Normalize the title of a Metadatum.
* @param value
* @return
*/
protected String normalizeTitle(MetadataValue value)
{

View File

@@ -26,7 +26,6 @@ import org.dspace.core.LogManager;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.event.Event;
import org.dspace.handle.service.HandleService;
import org.dspace.identifier.IdentifierException;
import org.dspace.identifier.service.IdentifierService;
import org.dspace.versioning.service.VersioningService;
@@ -57,16 +56,12 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
@Autowired(required = true)
protected CommunityService communityService;
@Autowired(required = true)
protected HandleService handleService;
@Autowired(required = true)
protected AuthorizeService authorizeService;
@Autowired(required = true)
protected BundleService bundleService;
@Autowired(required = true)
protected BitstreamFormatService bitstreamFormatService;
@Autowired(required = true)
protected ChoiceAuthorityService choiceAuthorityService;
@Autowired(required = true)
protected MetadataSchemaService metadataSchemaService;
@Autowired(required = true)
protected BitstreamService bitstreamService;

View File

@@ -26,7 +26,7 @@ public class Site extends DSpaceObject
{
@Transient
private SiteService siteService;
private transient SiteService siteService;
/**
* Get the type of this object, found in Constants

View File

@@ -15,7 +15,6 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.event.Event;
import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,9 +34,6 @@ public class SiteServiceImpl extends DSpaceObjectServiceImpl<Site> implements Si
@Autowired(required = true)
protected AuthorizeService authorizeService;
@Autowired(required = true)
protected HandleService handleService;
@Autowired(required = true)
protected ConfigurationService configurationService;

View File

@@ -7,6 +7,7 @@
*/
package org.dspace.content;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@@ -26,7 +27,7 @@ import javax.persistence.*;
*/
@Entity
@Table(name = "workspaceitem")
public class WorkspaceItem implements InProgressSubmission
public class WorkspaceItem implements InProgressSubmission, Serializable
{
@Id
@@ -67,7 +68,7 @@ public class WorkspaceItem implements InProgressSubmission
joinColumns = {@JoinColumn(name = "workspace_item_id") },
inverseJoinColumns = {@JoinColumn(name = "eperson_group_id") }
)
private List<Group> supervisorGroups = new ArrayList<>();
private final List<Group> supervisorGroups = new ArrayList<>();
/**
@@ -131,6 +132,7 @@ public class WorkspaceItem implements InProgressSubmission
* @param o The other workspace item to compare to
* @return If they are equal or not
*/
@Override
public boolean equals(Object o) {
if (this == o)
{
@@ -150,6 +152,7 @@ public class WorkspaceItem implements InProgressSubmission
return true;
}
@Override
public int hashCode()
{
return new HashCodeBuilder().append(getID()).toHashCode();

View File

@@ -70,7 +70,7 @@ public class CrosswalkUtils {
if (mdField == null) {
if (forceCreate && fieldChoice.equals("add")) {
try {
mdField = metadataFieldService.create(context, mdSchema, element, qualifier, null);
metadataFieldService.create(context, mdSchema, element, qualifier, null);
} catch (NonUniqueMetadataException e) {
// This case should also not be possible
e.printStackTrace();

View File

@@ -375,7 +375,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
// only complain about missing elements in the DC schema:
if (elt == null)
{
if (metadataField.getMetadataSchema().equals(MetadataSchema.DC_SCHEMA))
if (metadataField.getMetadataSchema().getName().equals(MetadataSchema.DC_SCHEMA))
{
log.warn("WARNING: " + myName + ": No QDC mapping for \"" + qdc + "\"");
}

View File

@@ -15,6 +15,7 @@ import org.dspace.core.GenericDAO;
* All DSpaceObject DAO classes should implement this class since it ensures that the T object is of type DSpaceObject
*
* @author kevinvandevelde at atmire.com
* @param <T>
*/
public interface DSpaceObjectDAO<T extends DSpaceObject> extends GenericDAO<T> {
}

View File

@@ -17,6 +17,7 @@ import java.sql.SQLException;
* to identify DSpaceObjects prior to DSpace 6.0
*
* @author kevinvandevelde at atmire.com
* @param <T>
*/
public interface DSpaceObjectLegacySupportDAO<T extends DSpaceObject> extends DSpaceObjectDAO<T> {

View File

@@ -77,8 +77,7 @@ public class BitstreamDAOImpl extends AbstractHibernateDSODAO<Bitstream> impleme
public Iterator<Bitstream> findByCommunity(Context context, Community community) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b " +
"join b.bundles bitBundles " +
"join bitBundles.bundle bundle " +
"join bundle.items item " +
"join bitBundles.items item " +
"join item.collections itemColl " +
"join itemColl.communities community " +
"WHERE :community IN community");
@@ -92,8 +91,7 @@ public class BitstreamDAOImpl extends AbstractHibernateDSODAO<Bitstream> impleme
public Iterator<Bitstream> findByCollection(Context context, Collection collection) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b " +
"join b.bundles bitBundles " +
"join bitBundles.bundle bundle " +
"join bundle.items item " +
"join bitBundles.items item " +
"join item.collections c " +
"WHERE :collection IN c");
@@ -106,8 +104,7 @@ public class BitstreamDAOImpl extends AbstractHibernateDSODAO<Bitstream> impleme
public Iterator<Bitstream> findByItem(Context context, Item item) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b " +
"join b.bundles bitBundles " +
"join bitBundles.bundle bundle " +
"join bundle.items item " +
"join bitBundles.items item " +
"WHERE :item IN item");
query.setParameter("item", item);

View File

@@ -677,7 +677,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
owningCollection = inProgressSubmission.getCollection();
}
addLicense(context, item, license, (Collection) ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getParentObject(context, dso)
addLicense(context, item, license, owningCollection
, params);
// FIXME ?

View File

@@ -11,6 +11,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
@@ -256,12 +258,23 @@ public class RoleIngester implements PackageIngester
{ // Group already exists, so empty it
if (params.replaceModeEnabled()) // -r -f
{
for (Group member : collider.getMemberGroups())
// Get a *copy* of our group list to avoid ConcurrentModificationException
// when we remove these groups from the parent Group obj
List<Group> groupRemovalList = new ArrayList<>(collider.getMemberGroups());
Iterator<Group> groupIterator = groupRemovalList.iterator();
while(groupIterator.hasNext())
{
Group member = groupIterator.next();
groupService.removeMember(context, collider, member);
}
for (EPerson member : collider.getMembers())
// Get a *copy* of our eperson list to avoid ConcurrentModificationException
// when we remove these epersons from the parent Group obj
List<EPerson> epersonRemovalList = new ArrayList<>(collider.getMembers());
Iterator<EPerson> epersonIterator = epersonRemovalList.iterator();
while(epersonIterator.hasNext())
{
EPerson member = epersonIterator.next();
// Remove all group members *EXCEPT* we don't ever want
// to remove the current user from the list of Administrators
// (otherwise remainder of ingest will fail)

View File

@@ -35,7 +35,6 @@ public class MicrosoftTranslator extends AbstractTranslator
protected final String PLUGIN_PREFIX = "translator";
protected final String baseUrl = "http://api.microsofttranslator.com/V2/Http.svc/Translate";
protected String apiKey = "";
private static final Logger log = Logger.getLogger(MicrosoftTranslator.class);

View File

@@ -218,10 +218,20 @@ public class DiscoverQuery {
this.facetOffset = facetOffset;
}
/**
* Sets the fields which you want Discovery to return in the search results.
* It is HIGHLY recommended to limit the fields returned, as by default
* some backends (like Solr) will return everything.
* @param field field to add to the list of fields returned
*/
public void addSearchField(String field){
this.searchFields.add(field);
}
/**
* Get list of fields which Discovery will return in the search results
* @return List of field names
*/
public List<String> getSearchFields() {
return searchFields;
}

View File

@@ -90,6 +90,9 @@ public class SolrServiceImpl implements SearchService, IndexingService {
private static final Logger log = Logger.getLogger(SolrServiceImpl.class);
protected static final String LAST_INDEXED_FIELD = "SolrIndexer.lastIndexed";
protected static final String HANDLE_FIELD = "handle";
protected static final String RESOURCE_TYPE_FIELD = "search.resourcetype";
protected static final String RESOURCE_ID_FIELD = "search.resourceid";
public static final String FILTER_SEPARATOR = "\n|||\n";
@@ -135,9 +138,11 @@ public class SolrServiceImpl implements SearchService, IndexingService {
solr.setBaseURL(solrService);
solr.setUseMultiPartPost(true);
// Dummy/test query to search for Item (type=2) of ID=1
SolrQuery solrQuery = new SolrQuery()
.setQuery("search.resourcetype:2 AND search.resourceid:1");
.setQuery(RESOURCE_TYPE_FIELD + ":2 AND " + RESOURCE_ID_FIELD + ":1");
// Only return obj identifier fields in result doc
solrQuery.setFields(RESOURCE_TYPE_FIELD, RESOURCE_ID_FIELD);
solr.query(solrQuery);
// As long as Solr initialized, check with DatabaseUtils to see
@@ -309,7 +314,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
try {
if(getSolr() != null){
getSolr().deleteByQuery("handle:\"" + handle + "\"");
getSolr().deleteByQuery(HANDLE_FIELD + ":\"" + handle + "\"");
if(commit)
{
getSolr().commit();
@@ -437,10 +442,13 @@ public class SolrServiceImpl implements SearchService, IndexingService {
}
if (force)
{
getSolr().deleteByQuery("search.resourcetype:[2 TO 4]");
getSolr().deleteByQuery(RESOURCE_TYPE_FIELD + ":[2 TO 4]");
} else {
SolrQuery query = new SolrQuery();
query.setQuery("search.resourcetype:[2 TO 4]");
// Query for all indexed Items, Collections and Communities,
// returning just their handle
query.setFields(HANDLE_FIELD);
query.setQuery(RESOURCE_TYPE_FIELD + ":[2 TO 4]");
QueryResponse rsp = getSolr().query(query);
SolrDocumentList docs = rsp.getResults();
@@ -450,7 +458,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
SolrDocument doc = (SolrDocument) iter.next();
String handle = (String) doc.getFieldValue("handle");
String handle = (String) doc.getFieldValue(HANDLE_FIELD);
DSpaceObject o = handleService.resolveToObject(context, handle);
@@ -590,9 +598,9 @@ public class SolrServiceImpl implements SearchService, IndexingService {
boolean inIndex = false;
SolrQuery query = new SolrQuery();
query.setQuery("handle:" + handle);
query.setQuery(HANDLE_FIELD + ":" + handle);
// Specify that we ONLY want the LAST_INDEXED_FIELD returned in the field list (fl)
query.setParam(CommonParams.FL, LAST_INDEXED_FIELD);
query.setFields(LAST_INDEXED_FIELD);
QueryResponse rsp;
try {
@@ -1415,9 +1423,8 @@ public class SolrServiceImpl implements SearchService, IndexingService {
// New fields to weaken the dependence on handles, and allow for faster
// list display
doc.addField("search.uniqueid", type+"-"+id);
doc.addField("search.resourcetype", Integer.toString(type));
doc.addField("search.resourceid", id.toString());
doc.addField(RESOURCE_TYPE_FIELD, Integer.toString(type));
doc.addField(RESOURCE_ID_FIELD, id.toString());
// want to be able to search for handle, so use keyword
// (not tokenized, but it is indexed)
@@ -1425,7 +1432,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
{
// want to be able to search for handle, so use keyword
// (not tokenized, but it is indexed)
doc.addField("handle", handle);
doc.addField(HANDLE_FIELD, handle);
}
if (locations != null)
@@ -1529,7 +1536,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
return value;
}
//******** SearchService implementation
//========== SearchService implementation
@Override
public DiscoverResult search(Context context, DiscoverQuery query) throws SearchServiceException
{
@@ -1556,7 +1563,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
discoveryQuery.addFilterQueries("location:l" + dso.getID());
} else if (dso instanceof Item)
{
discoveryQuery.addFilterQueries("handle:" + dso.getHandle());
discoveryQuery.addFilterQueries(HANDLE_FIELD + ":" + dso.getHandle());
}
}
return search(context, discoveryQuery, includeUnDiscoverable);
@@ -1593,6 +1600,18 @@ public class SolrServiceImpl implements SearchService, IndexingService {
}
solrQuery.setQuery(query);
// Add any search fields to our query. This is the limited list
// of fields that will be returned in the solr result
for(String fieldName : discoveryQuery.getSearchFields())
{
solrQuery.addField(fieldName);
}
// Also ensure a few key obj identifier fields are returned with every query
solrQuery.addField(HANDLE_FIELD);
solrQuery.addField(RESOURCE_TYPE_FIELD);
solrQuery.addField(RESOURCE_ID_FIELD);
if(discoveryQuery.isSpellCheck())
{
solrQuery.setParam(SpellingParams.SPELLCHECK_Q, query);
@@ -1613,7 +1632,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
}
if(discoveryQuery.getDSpaceObjectFilter() != -1)
{
solrQuery.addFilterQuery("search.resourcetype:" + discoveryQuery.getDSpaceObjectFilter());
solrQuery.addFilterQuery(RESOURCE_TYPE_FIELD + ":" + discoveryQuery.getDSpaceObjectFilter());
}
for (int i = 0; i < discoveryQuery.getFieldPresentQueries().size(); i++)
@@ -1726,7 +1745,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
query.addFilterQueries("location:l" + dso.getID());
} else if (dso instanceof Item)
{
query.addFilterQueries("handle:" + dso.getHandle());
query.addFilterQueries(HANDLE_FIELD + ":" + dso.getHandle());
}
}
return searchJSON(context, query, jsonIdentifier);
@@ -1781,7 +1800,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
{
result.addDSpaceObject(dso);
} else {
log.error(LogManager.getHeader(context, "Error while retrieving DSpace object from discovery index", "Handle: " + doc.getFirstValue("handle")));
log.error(LogManager.getHeader(context, "Error while retrieving DSpace object from discovery index", "Handle: " + doc.getFirstValue(HANDLE_FIELD)));
continue;
}
@@ -1900,9 +1919,9 @@ public class SolrServiceImpl implements SearchService, IndexingService {
protected DSpaceObject findDSpaceObject(Context context, SolrDocument doc) throws SQLException {
Integer type = (Integer) doc.getFirstValue("search.resourcetype");
UUID id = UUID.fromString((String) doc.getFirstValue("search.resourceid"));
String handle = (String) doc.getFirstValue("handle");
Integer type = (Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD);
UUID id = UUID.fromString((String) doc.getFirstValue(RESOURCE_ID_FIELD));
String handle = (String) doc.getFirstValue(HANDLE_FIELD);
if (type != null && id != null)
{
@@ -1956,7 +1975,8 @@ public class SolrServiceImpl implements SearchService, IndexingService {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(query);
solrQuery.setFields("search.resourceid", "search.resourcetype");
//Only return obj identifier fields in result doc
solrQuery.setFields(RESOURCE_ID_FIELD, RESOURCE_TYPE_FIELD);
solrQuery.setStart(offset);
solrQuery.setRows(max);
if (orderfield != null)
@@ -1976,7 +1996,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
{
SolrDocument doc = (SolrDocument) iter.next();
DSpaceObject o = contentServiceFactory.getDSpaceObjectService((Integer) doc.getFirstValue("search.resourcetype")).find(context, UUID.fromString((String) doc.getFirstValue("search.resourceid")));
DSpaceObject o = contentServiceFactory.getDSpaceObjectService((Integer) doc.getFirstValue(RESOURCE_TYPE_FIELD)).find(context, UUID.fromString((String) doc.getFirstValue(RESOURCE_ID_FIELD)));
if (o != null)
{
@@ -2065,7 +2085,9 @@ public class SolrServiceImpl implements SearchService, IndexingService {
try{
SolrQuery solrQuery = new SolrQuery();
//Set the query to handle since this is unique
solrQuery.setQuery("handle: " + item.getHandle());
solrQuery.setQuery(HANDLE_FIELD + ": " + item.getHandle());
//Only return obj identifier fields in result doc
solrQuery.setFields(HANDLE_FIELD, RESOURCE_TYPE_FIELD, RESOURCE_ID_FIELD);
//Add the more like this parameters !
solrQuery.setParam(MoreLikeThisParams.MLT, true);
//Add a comma separated list of the similar fields

View File

@@ -64,7 +64,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
private String digestAlgorithm;
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "epeople")
private List<Group> groups = new ArrayList<>();
private final List<Group> groups = new ArrayList<>();
/** The e-mail field (for sorting) */
public static final int EMAIL = 1;
@@ -82,7 +82,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
public static final int LANGUAGE = 5;
@Transient
protected EPersonService ePersonService;
protected transient EPersonService ePersonService;
protected EPerson() {
}
@@ -198,10 +198,10 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
/**
* Set the EPerson's netid
*
* @param s
* @param netid
* the new netid
*/
public void setNetid(String s) {
public void setNetid(String netid) {
this.netid = netid;
setModified();
}

View File

@@ -99,7 +99,11 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
@Override
public List<EPerson> search(Context context, String query) throws SQLException {
if(StringUtils.isBlank(query)) query = null;
if(StringUtils.isBlank(query))
{
//If we don't have a query, just return everything.
return findAll(context, EPerson.EMAIL);
}
return search(context, query, -1, -1);
}
@@ -116,7 +120,10 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
} catch(IllegalArgumentException e) {
MetadataField firstNameField = metadataFieldService.findByElement(context, "eperson", "firstname", null);
MetadataField lastNameField = metadataFieldService.findByElement(context, "eperson", "lastname", null);
if (StringUtils.isBlank(query)) query = null;
if (StringUtils.isBlank(query))
{
query = null;
}
return ePersonDAO.search(context, query, Arrays.asList(firstNameField, lastNameField), Arrays.asList(firstNameField, lastNameField), offset, limit);
}
}

View File

@@ -52,7 +52,7 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
joinColumns = {@JoinColumn(name = "eperson_group_id") },
inverseJoinColumns = {@JoinColumn(name = "eperson_id") }
)
private List<EPerson> epeople = new ArrayList<>();
private final List<EPerson> epeople = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
@@ -60,19 +60,19 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
joinColumns = {@JoinColumn(name = "parent_id") },
inverseJoinColumns = {@JoinColumn(name = "child_id") }
)
private List<Group> groups = new ArrayList<>();
private final List<Group> groups = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "groups")
private List<Group> parentGroups = new ArrayList<>();
private final List<Group> parentGroups = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "supervisorGroups")
private List<WorkspaceItem> supervisedItems = new ArrayList<>();
private final List<WorkspaceItem> supervisedItems = new ArrayList<>();
@Transient
private boolean groupsChanged;
@Transient
private GroupService groupService;
private transient GroupService groupService;
public Group() {
}

View File

@@ -134,8 +134,6 @@ public class SubscribeCLITool {
// Truncation will actually pass in "Midnight of yesterday in UTC", which will be,
// at least in CDT, "7pm, the day before yesterday, in my current timezone".
cal.add(Calendar.HOUR, -24);
Date thisTimeYesterday = cal.getTime();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

View File

@@ -836,7 +836,7 @@ public class OAIHarvester {
// First, see if we can contact the target server at all.
try {
Identify idenTest = new Identify(oaiSource);
new Identify(oaiSource);
}
catch (Exception ex) {
errorSet.add(OAI_ADDRESS_ERROR + ": OAI server could not be reached.");

View File

@@ -330,14 +330,7 @@ public class CCLookup {
// Example: http://api.creativecommons.org/rest/1.5/details?
// license-uri=http://creativecommons.org/licenses/by-nc-sa/3.0/
String issueUrl = cc_root + "/details?license-uri=" + licenseURI;
// todo : modify for post as in the above issue
String post_data;
try {
post_data = URLEncoder.encode("license-uri", "UTF-8") + "=" + URLEncoder.encode(licenseURI, "UTF-8");
} catch (UnsupportedEncodingException e) {
return;
}
//end todo
URL request_url;
try {
request_url = new URL(issueUrl);
@@ -434,8 +427,7 @@ public class CCLookup {
public boolean isSuccess() {
setSuccess(false);
java.io.ByteArrayOutputStream outputstream = new java.io.ByteArrayOutputStream();
JDOMXPath xp_Success = null;
JDOMXPath xp_Success;
String text = null;
try {
xp_Success = new JDOMXPath("//message");

View File

@@ -179,7 +179,7 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
bs_format = bitstreamFormatService.findByShortDescription(context, "License");
}
Bitstream bs = bitstreamService.create(context, licenseStm);
Bitstream bs = bitstreamService.create(context, bundle, licenseStm);
bs.setSource(context, CC_BS_SOURCE);
bs.setName(context, (mimeType != null &&
(mimeType.equalsIgnoreCase("text/xml") ||
@@ -270,7 +270,6 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
@Override
public String fetchLicenseRdf(String ccResult) {
StringWriter result = new StringWriter();
String licenseRdfString = new String("");
try {
InputStream inputstream = new ByteArrayInputStream(ccResult.getBytes("UTF-8"));
templates.newTransformer().transform(new StreamSource(inputstream), new StreamResult(result));

View File

@@ -489,7 +489,6 @@ public class RDFizer {
builder.append(argument);
}
String argumentsLine = builder.toString().trim();
argumentsLine.substring(0, argumentsLine.length() - 1);
System.err.print("Cannot recognize the following argument");
if (remainingArgs.length >= 2) System.err.print("s");
System.err.println(": " + argumentsLine + ".");

View File

@@ -227,8 +227,12 @@ public class MetadataConverterPlugin implements ConverterPlugin
}
config.read(is, "file://" + mappingPath, FileUtils.guessLang(mappingPath));
try {
// Make sure that we have an input stream to avoid NullPointer
if(is != null)
{
is.close();
}
}
catch (IOException ex)
{
// nothing to do here.

View File

@@ -83,8 +83,6 @@ public class MediaRange
throws IllegalArgumentException, IllegalStateException
{
Pattern mediaRangePattern = Pattern.compile("^" + mediaRangeRegex + "$");
Pattern nonQualityParamPattern = Pattern.compile(nonQualityParam);
Pattern qualityParamPattern = Pattern.compile(qualityParam);
Matcher rangeMatcher = mediaRangePattern.matcher(mediarange.trim());
if (!rangeMatcher.matches())

View File

@@ -641,11 +641,6 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
{
return currentValsStored;
}
// We have at least one document good
SolrDocument document = response.getResults().get(0);
// System.out.println("HERE");
// Get the info we need
}
catch (SolrServerException e)
{

View File

@@ -186,7 +186,7 @@ public class StatisticsDataWorkflow extends StatisticsData {
} catch (ConfigurationException e) {
log.error("Error while storing workflow start date", e);
}
//ALso store it in our local config !
//Also store it in our local config !
configurationService.setProperty("usage-statistics.workflow-start-date", new DCDate(oldestDate).toString());
//Write to file

View File

@@ -99,7 +99,7 @@ public class SpiderDetector {
* private loader to populate the table from files.
*/
private static void loadSpiderIpAddresses() {
private synchronized static void loadSpiderIpAddresses() {
if (table == null) {
table = new IPTable();

View File

@@ -115,7 +115,6 @@ public class StatisticsImporterElasticSearch {
DNSCache dnsCache = new DNSCache(2500, 0.75f, 2500);
Object fromCache;
Random rand = new Random();
ContentServiceFactory contentServiceFactory = ContentServiceFactory.getInstance();
while ((line = input.readLine()) != null)

View File

@@ -301,7 +301,7 @@ public class DatabaseUtils
System.out.println("\nERROR: The database user '" + username + "' does not have sufficient privileges to run a 'database clean' (via Flyway).");
System.out.println("\nIn order to run a 'clean', the database user MUST have 'superuser' privileges");
System.out.println("OR the '" + PostgresUtils.PGCRYPTO + "' extension must be installed in a separate schema (see documentation).");
System.out.println("\nOptionally, you could also manually remove the '" + PostgresUtils.PGCRYPTO + "' extension first (DROP EXTENSION '" + PostgresUtils.PGCRYPTO + "' CASCADE), then rerun the 'clean'");
System.out.println("\nOptionally, you could also manually remove the '" + PostgresUtils.PGCRYPTO + "' extension first (DROP EXTENSION " + PostgresUtils.PGCRYPTO + " CASCADE), then rerun the 'clean'");
System.exit(1);
}
}
@@ -368,7 +368,7 @@ public class DatabaseUtils
* DataSource object initialized by DatabaseManager
* @return initialized Flyway object
*/
private static Flyway setupFlyway(DataSource datasource)
private synchronized static Flyway setupFlyway(DataSource datasource)
{
if (flywaydb==null)
{

View File

@@ -52,8 +52,6 @@ public class V5_0_2014_11_04__Enable_XMLWorkflow_Migration
public void migrate(Connection connection)
throws IOException, SQLException
{
String currentFlyWayState = DatabaseUtils.getCurrentFlywayState(connection);
// Make sure XML Workflow is enabled in workflow.cfg before proceeding
if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("xmlworkflow")
// If your database was upgraded to DSpace 6 prior to enabling XML Workflow, we MUST skip this 5.x migration, as it is incompatible

View File

@@ -425,7 +425,7 @@ public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator
if (mdfield == null)
{
mdfield = metadataFieldService.create(context, mdschema, element, qualifier,
metadataFieldService.create(context, mdschema, element, qualifier,
"Campo utilizzato per la cache del provider submission-lookup: "
+ schema);
create = true;

View File

@@ -14,10 +14,7 @@ import gr.ekt.bte.core.Value;
import gr.ekt.bte.exceptions.MalformedSourceException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpException;
@@ -78,7 +75,7 @@ public abstract class NetworkSubmissionLookupDataLoader implements
: null;
String year = getSearchTerms().get("year") != null ? getSearchTerms()
.get("year").iterator().next()
: null;
: String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
int yearInt = Integer.parseInt(year);
results = search(null, title, authors, yearInt);
}

View File

@@ -236,7 +236,6 @@ public class CCLicenseStep extends AbstractProcessingStep
throws ServletException, IOException, SQLException,
AuthorizeException {
String ccLicenseUrl = request.getParameter("cc_license_url");
HttpSession session = request.getSession();
Map<String, String> map = new HashMap<String, String>();
String licenseclass = (request.getParameter("licenseclass_chooser") != null) ? request.getParameter("licenseclass_chooser") : "";

View File

@@ -11,12 +11,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@@ -26,6 +29,7 @@ import org.dspace.authorize.AuthorizeException;
import org.dspace.content.*;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamFormatService;
import org.dspace.content.service.BitstreamService;
import org.dspace.core.Context;
import org.dspace.core.ConfigurationManager;
import org.dspace.curate.Curator;
@@ -264,6 +268,44 @@ public class UploadStep extends AbstractProcessingStep
// -------------------------------------------------
// Step #3: Check for a change in file description
// -------------------------------------------------
// We have to check for descriptions from users using the resumable upload
// and from users using the simple upload.
// Beginning with the resumable ones.
Enumeration<String> parameterNames = request.getParameterNames();
Map<String, String> descriptions = new HashMap<>();
while (parameterNames.hasMoreElements())
{
String name = parameterNames.nextElement();
if (StringUtils.startsWithIgnoreCase(name, "description["))
{
descriptions.put(
name.substring("description[".length(), name.length()-1),
request.getParameter(name));
}
}
if (!descriptions.isEmpty())
{
// we got descriptions from the resumable upload
if (item != null)
{
List<Bundle> bundles = itemService.getBundles(item, "ORIGINAL");
for (Bundle bundle : bundles)
{
List<Bitstream> bitstreams = bundle.getBitstreams();
for (Bitstream bitstream : bitstreams)
{
if (descriptions.containsKey(bitstream.getName()))
{
bitstream.setDescription(context, descriptions.get(bitstream.getName()));
bitstreamService.update(context, bitstream);
}
}
}
}
return STATUS_COMPLETE;
}
// Going on with descriptions from the simple upload
String fileDescription = request.getParameter("description");
if (fileDescription != null && fileDescription.length() > 0)

View File

@@ -10,6 +10,11 @@ package org.dspace.submit.step;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
@@ -20,6 +25,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.app.util.SubmissionInfo;
import org.dspace.app.util.Util;
@@ -28,8 +34,6 @@ import org.dspace.authorize.ResourcePolicy;
import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.ResourcePolicyService;
import org.dspace.content.*;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamFormatService;
import org.dspace.core.Context;
import org.dspace.core.ConfigurationManager;
import org.dspace.curate.Curator;
@@ -70,7 +74,6 @@ public class UploadWithEmbargoStep extends UploadStep
/** log4j logger */
private static Logger log = Logger.getLogger(UploadWithEmbargoStep.class);
protected BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance().getBitstreamFormatService();
protected HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
protected GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
protected ResourcePolicyService resourcePolicyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService();
@@ -244,6 +247,44 @@ public class UploadWithEmbargoStep extends UploadStep
// -------------------------------------------------
// Step #3: Check for a change in file description
// -------------------------------------------------
// We have to check for descriptions from users using the resumable upload
// and from users using the simple upload.
// Beginning with the resumable ones.
Enumeration<String> parameterNames = request.getParameterNames();
Map<String, String> descriptions = new HashMap<String, String>();
while (parameterNames.hasMoreElements())
{
String name = parameterNames.nextElement();
if (StringUtils.startsWithIgnoreCase(name, "description["))
{
descriptions.put(
name.substring("description[".length(), name.length()-1),
request.getParameter(name));
}
}
if (!descriptions.isEmpty())
{
// we got descriptions from the resumable upload
if (item != null)
{
List<Bundle> bundles = itemService.getBundles(item, "ORIGINAL");
for (Bundle bundle : bundles)
{
List<Bitstream> bitstreams = bundle.getBitstreams();
for (Bitstream bitstream : bitstreams)
{
if (descriptions.containsKey(bitstream.getName()))
{
bitstream.setDescription(context, descriptions.get(bitstream.getName()));
bitstreamService.update(context, bitstream);
}
}
}
}
return STATUS_COMPLETE;
}
// Going on with descriptions from the simple upload
String fileDescription = request.getParameter("description");
if (fileDescription != null && fileDescription.length() > 0)

View File

@@ -15,103 +15,118 @@ import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.services.ConfigurationService;
import org.dspace.services.model.Event;
import org.dspace.utils.DSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Serialize AbstractUsageEvent data to a file as Tab deliminated. Requires
* configuration: in dspace.cfg specify the path to the file as the value of
* {@code usageEvent.tabFileLogger.file}.
* Serialize {@link UsageEvent} data to a file as Tab delimited. In dspace.cfg
* specify the path to the file as the value of
* {@code usageEvent.tabFileLogger.file}. If that path is not absolute, it
* will be interpreted as relative to the directory named in {@code log.dir}.
* If no name is configured, it defaults to "usage-events.tsv". If the file is
* new or empty, a column heading record will be written when the file is opened.
*
* @author Mark H. Wood
* @author Mark Diggory
* @version $Revision: 3734 $
*/
public class TabFileUsageEventListener extends AbstractUsageEventListener
public class TabFileUsageEventListener
extends AbstractUsageEventListener
{
/** log4j category */
private static Logger errorLog = Logger
/** log category. */
private static final Logger errorLog = LoggerFactory
.getLogger(TabFileUsageEventListener.class);
/** File on which to write event records */
static PrintWriter log = null;
/** ISO 8601 Basic string format for record timestamps. */
private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyyMMdd'T'HHmmssSSS");
public TabFileUsageEventListener()
{
/** File on which to write event records. */
private PrintWriter eventLog;
if (null == log)
{
boolean appending;
/** Is this instance initialized? */
private boolean initialized = false;
String logPath = ConfigurationManager
.getProperty("usageEvent.tabFileLogger.file");
if (null == logPath)
/**
* Set up a usage event listener for writing TSV records to a file.
*/
private void init()
{
errorLog
.error("UsageEventTabFileLogger unconfigured, will not log events");
return;
}
ConfigurationService configurationService
= new DSpace().getConfigurationService();
String logPath = configurationService.getPropertyAsType(
"usageEvent.tabFileLogger.file",
"usage-events.tsv");
String logDir = null;
if (!new File(logPath).isAbsolute())
{
logDir = ConfigurationManager.getProperty("log.dir");
logDir = configurationService.getProperty("log.dir");
}
File logFile = new File(logDir, logPath);
appending = logFile.length() > 0;
try
{
log = new PrintWriter(new OutputStreamWriter(
eventLog = new PrintWriter(new OutputStreamWriter(
new FileOutputStream(logFile, true)));
errorLog.debug("Writing to {}", logFile.getAbsolutePath());
}
catch (FileNotFoundException e)
{
errorLog
.error(
"UsageEventTabFileLogger cannot open file, will not log events",
e);
return;
errorLog.error("{} cannot open file, will not log events: {}",
TabFileUsageEventListener.class.getName(),
e.getMessage());
throw new IllegalArgumentException("Cannot open event log file", e);
}
if (!appending)
if (logFile.length() <= 0)
{
log.println("date event objectType objectId sessionId sourceAddress eperson");
eventLog.println("date"
+ '\t' + "event"
+ '\t' + "objectType"
+ '\t' + "objectId"
+ '\t' + "sessionId"
+ '\t' + "sourceAddress"
+ '\t' + "eperson");
}
}
initialized = true;
}
@Override
public void receiveEvent(Event event) {
System.out.println("got: " + event.toString());
if(event instanceof UsageEvent)
public synchronized void receiveEvent(Event event)
{
if (!initialized)
init();
if (errorLog.isDebugEnabled())
errorLog.debug("got: {}", event.toString());
if(!(event instanceof UsageEvent))
return;
if (null == eventLog)
return;
UsageEvent ue = (UsageEvent)event;
if (null == log)
{
return;
}
eventLog.append(dateFormat.format(new Date()))
.append('\t').append(ue.getName()) // event type
.append('\t').append(Constants.typeText[ue.getObject().getType()])
.append('\t').append(ue.getObject().getID().toString())
.append('\t').append(ue.getRequest().getSession().getId())
.append('\t').append(ue.getRequest().getRemoteAddr());
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyyMMdd'T'HHmmssSSS");
String epersonName = (null == ue.getContext().getCurrentUser()
? "anonymous"
: ue.getContext().getCurrentUser().getEmail());
eventLog.append('\t').append(epersonName);
String string = dateFormat.format(new Date());
string += "\t" + ue.getName(); // event type
string += "\t" + ue.getObject().getType();
string += "\t" + ue.getObject().getID();
string += "\t" + ue.getRequest().getSession().getId();
string += "\t" + ue.getRequest().getRequestURI();
String epersonName = (null == ue.getContext().getCurrentUser() ? "anonymous" : ue.getContext().getCurrentUser().getEmail());
string += "\t" + epersonName;
log.println(string);
log.flush();
}
eventLog.println();
eventLog.flush();
}
}

View File

@@ -50,17 +50,17 @@ public class UsageEvent extends Event {
*/
private static final long serialVersionUID = 1L;
private transient HttpServletRequest request;
private HttpServletRequest request;
private transient String ip;
private String ip;
private transient String userAgent;
private String userAgent;
private transient String xforwardedfor;
private String xforwardedfor;
private transient Context context;
private Context context;
private transient DSpaceObject object;
private DSpaceObject object;
private Action action;

View File

@@ -0,0 +1,33 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
/**
* Capture of "usage events". A {@link org.dspace.usage.UsageEvent} represents
* something like a download or viewing of a Bitstream -- that is, the
* <em>use</em> of content as opposed to its ingestion or alteration. Usage
* events are meant to be useful for statistical analysis of content usage.
*
* <p>
* Multiple {@link org.dspace.usage.AbstractUsageEventListener} implementations
* may be configured for processing these events. When an event is "fired",
* it is passed to each configured listener. Several stock listeners are provided,
* in this package and others, for doing common tasks.
* </p>
*
* <p>
* To add a usage event listener to the bus, configure it as a new {@code <bean>}
* in a web application's {@code applicationContext.xml} and inject the
* {@code EventService}, as with the stock listeners.
* </p>
*
* @see org.dspace.statistics.ElasticSearchLoggerEventListener
* @see org.dspace.google.GoogleRecorderEventListener
* @see org.dspace.statistics.SolrLoggerUsageEventListener
*/
package org.dspace.usage;

View File

@@ -116,7 +116,7 @@ public class MultiFormatDateParser
public static void main(String[] args)
throws IOException
{
DSpaceKernel kernel = DSpaceKernelInit.getKernel(null); // Mainly to initialize Spring
DSpaceKernelInit.getKernel(null); // Mainly to initialize Spring
// TODO direct log to stdout/stderr somehow
if (args.length > 0) // Test data supplied on the command line

View File

@@ -8,7 +8,6 @@
package org.dspace.versioning;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.content.Item;
import org.dspace.content.WorkspaceItem;
import org.dspace.content.service.WorkspaceItemService;
@@ -39,8 +38,6 @@ public class DefaultItemVersionProvider extends AbstractVersionProvider implemen
protected VersionHistoryService versionHistoryService;
@Autowired(required = true)
protected IdentifierService identifierService;
@Autowired(required = true)
protected AuthorizeService authorizeService;
@Override
public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) {

View File

@@ -420,6 +420,11 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService
//Gather our old data for launching the workflow event
int oldState = workflowItem.getState();
// in case we don't want to inform reviewers about tasks returned to
// the pool by other reviewers, we'll ne to know whether they were owned
// before. => keep this information before setting the new owner.
EPerson oldOwner = workflowItem.getOwner();
workflowItem.setState(newstate);
switch (newstate)
@@ -443,9 +448,14 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService
createTasks(context, workflowItem, epa);
workflowItemService.update(context, workflowItem);
if (ConfigurationManager.getBooleanProperty("workflow", "notify.returned.tasks", true)
|| oldState != WFSTATE_STEP1
|| oldOwner == null)
{
// email notification
notifyGroupOfTask(context, workflowItem, mygroup, epa);
}
}
else
{
// no reviewers, skip ahead
@@ -484,9 +494,14 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService
// timestamp, and add them to the list
createTasks(context, workflowItem, epa);
if (ConfigurationManager.getBooleanProperty("workflow", "notify.returned.tasks", true)
|| oldState != WFSTATE_STEP2
|| oldOwner == null)
{
// email notification
notifyGroupOfTask(context, workflowItem, mygroup, epa);
}
}
else
{
// no reviewers, skip ahead
@@ -521,9 +536,14 @@ public class BasicWorkflowServiceImpl implements BasicWorkflowService
// timestamp, and add them to the list
createTasks(context, workflowItem, epa);
if (ConfigurationManager.getBooleanProperty("workflow", "notify.returned.tasks", true)
|| oldState != WFSTATE_STEP3
|| oldOwner == null)
{
// email notification
notifyGroupOfTask(context, workflowItem, mygroup, epa);
}
}
else
{
// no editors, skip ahead

View File

@@ -361,7 +361,7 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
e.printStackTrace();
}
finally {
if((nextStep != null && nextActionConfig != null) || wfi.getItem().isArchived()){
if((nextStep != null && currentStep != null && nextActionConfig != null) || (wfi.getItem().isArchived() && currentStep != null)){
logWorkflowEvent(c, currentStep.getWorkflow().getID(), currentStep.getId(), currentActionConfig.getId(), wfi, user, nextStep, nextActionConfig);
}
}

View File

@@ -89,12 +89,17 @@ public class AssignOriginalSubmitterAction extends UserSelectionAction{
@Override
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request) throws SQLException, AuthorizeException, IOException, WorkflowException {
EPerson submitter = wfi.getSubmitter();
Step currentStep = getParent().getStep();
WorkflowActionConfig nextAction = getParent().getStep().getNextAction(this.getParent());
//Retrieve the action which has a user interface
while(nextAction != null && !nextAction.requiresUI()){
nextAction = nextAction.getStep().getNextAction(nextAction);
}
if(nextAction == null)
{
//Should never occur, but just in case
log.error("Could not find next action for step with id: " + step.getId() + " to assign a submitter to. Aborting the action.");
throw new IllegalStateException();
}
createTaskForEPerson(c, wfi, step, nextAction, submitter);

View File

@@ -0,0 +1,64 @@
--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--
-- ===============================================================
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
--
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
-- http://flywaydb.org/
-- ===============================================================
-- Special case of migration, we need to the EPerson schema in order to get our metadata for all queries to work
-- but we cannot a DB connection until our database is up to date, so we need to create our registries manually in sql
INSERT INTO metadataschemaregistry (metadata_schema_id, namespace, short_id) SELECT metadataschemaregistry_seq.nextval, 'http://dspace.org/eperson' as namespace, 'eperson' as short_id FROM dual
WHERE NOT EXISTS (SELECT metadata_schema_id,namespace,short_id FROM metadataschemaregistry WHERE namespace = 'http://dspace.org/eperson' AND short_id = 'eperson');
-- Insert eperson.firstname
INSERT INTO metadatafieldregistry (metadata_field_id, metadata_schema_id, element)
SELECT metadatafieldregistry_seq.nextval,
(SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'firstname' FROM dual
WHERE NOT EXISTS
(SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'firstname' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert eperson.lastname
INSERT INTO metadatafieldregistry (metadata_field_id, metadata_schema_id, element)
SELECT metadatafieldregistry_seq.nextval,
(SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'lastname' FROM dual
WHERE NOT EXISTS
(SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'lastname' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert eperson.phone
INSERT INTO metadatafieldregistry (metadata_field_id, metadata_schema_id, element)
SELECT metadatafieldregistry_seq.nextval,
(SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'phone' FROM dual
WHERE NOT EXISTS
(SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'phone' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert eperson.language
INSERT INTO metadatafieldregistry (metadata_field_id, metadata_schema_id, element)
SELECT metadatafieldregistry_seq.nextval,
(SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'language' FROM dual
WHERE NOT EXISTS
(SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'language' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert into dc.provenance
INSERT INTO metadatafieldregistry (metadata_field_id, metadata_schema_id, element)
SELECT metadatafieldregistry_seq.nextval,
(SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'), 'provenance' FROM dual
WHERE NOT EXISTS
(SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'provenance' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'));
-- Insert into dc.rights.license
INSERT INTO metadatafieldregistry (metadata_field_id, metadata_schema_id, element, qualifier)
SELECT metadatafieldregistry_seq.nextval,
(SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'), 'rights', 'license' FROM dual
WHERE NOT EXISTS
(SELECT metadata_field_id,element,qualifier FROM metadatafieldregistry WHERE element = 'rights' AND qualifier='license' AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'));

View File

@@ -0,0 +1,52 @@
--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--
-- ===============================================================
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
--
-- DO NOT MANUALLY RUN THIS DATABASE MIGRATION. IT WILL BE EXECUTED
-- AUTOMATICALLY (IF NEEDED) BY "FLYWAY" WHEN YOU STARTUP DSPACE.
-- http://flywaydb.org/
-- ===============================================================
-- Special case of migration, we need to the EPerson schema in order to get our metadata for all queries to work
-- but we cannot a DB connection until our database is up to date, so we need to create our registries manually in sql
INSERT INTO metadataschemaregistry (namespace, short_id) SELECT 'http://dspace.org/eperson', 'eperson'
WHERE NOT EXISTS (SELECT metadata_schema_id,namespace,short_id FROM metadataschemaregistry WHERE namespace = 'http://dspace.org/eperson' AND short_id = 'eperson');
-- Insert eperson.firstname
INSERT INTO metadatafieldregistry (metadata_schema_id, element)
SELECT (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'firstname'
WHERE NOT EXISTS (SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'firstname' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert eperson.lastname
INSERT INTO metadatafieldregistry (metadata_schema_id, element)
SELECT (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'lastname'
WHERE NOT EXISTS (SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'lastname' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert eperson.phone
INSERT INTO metadatafieldregistry (metadata_schema_id, element)
SELECT (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'phone'
WHERE NOT EXISTS (SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'phone' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert eperson.language
INSERT INTO metadatafieldregistry (metadata_schema_id, element)
SELECT (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'), 'language'
WHERE NOT EXISTS (SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'language' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='eperson'));
-- Insert into dc.provenance
INSERT INTO metadatafieldregistry (metadata_schema_id, element)
SELECT (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'), 'provenance'
WHERE NOT EXISTS (SELECT metadata_field_id,element FROM metadatafieldregistry WHERE element = 'provenance' AND qualifier IS NULL AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'));
-- Insert into dc.rights.license
INSERT INTO metadatafieldregistry (metadata_schema_id, element, qualifier)
SELECT (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'), 'rights', 'license'
WHERE NOT EXISTS (SELECT metadata_field_id,element,qualifier FROM metadatafieldregistry WHERE element = 'rights' AND qualifier='license' AND metadata_schema_id = (SELECT metadata_schema_id FROM metadataschemaregistry WHERE short_id='dc'));

View File

@@ -91,7 +91,6 @@ public class VersioningItemHome implements ItemHomeProcessor {
throw new PluginException(e.getMessage());
}
if (latestVersion != null) {
if (latestVersion != null && latestVersion.getItem() != null
&& !latestVersion.getItem().getID().equals(item.getID())) {
// We have a newer version
@@ -113,7 +112,6 @@ public class VersioningItemHome implements ItemHomeProcessor {
}
}
}
}
request.setAttribute("versioning.enabled", versioningEnabled);
request.setAttribute("versioning.hasversionbutton", hasVersionButton);

View File

@@ -42,7 +42,7 @@ import org.dspace.eperson.service.GroupService;
public class AccessSettingTag extends TagSupport
{
/** log4j category */
private static Logger log = Logger.getLogger(AccessSettingTag.class);
private static final Logger log = Logger.getLogger(AccessSettingTag.class);
/** is advanced form enabled? */
private static final boolean advanced = ConfigurationManager.getBooleanProperty("webui.submission.restrictstep.enableAdvancedForm", false);
@@ -50,7 +50,7 @@ public class AccessSettingTag extends TagSupport
/** Name of the restricted group */
private static final String restrictedGroup = ConfigurationManager.getProperty("webui.submission.restrictstep.groups");
/** the SubmittionInfo */
/** the SubmissionInfo */
private transient SubmissionInfo subInfo = null;
/** the target DSpaceObject */
@@ -68,18 +68,21 @@ public class AccessSettingTag extends TagSupport
/** add the policy button */
private boolean addpolicy = false;
private AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
private final transient AuthorizeService authorizeService
= AuthorizeServiceFactory.getInstance().getAuthorizeService();
private GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
private final transient GroupService groupService
= EPersonServiceFactory.getInstance().getGroupService();
public AccessSettingTag()
{
super();
}
@Override
public int doStartTag() throws JspException
{
String legend = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.legend");
// String legend = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.legend");
String label_name = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.label_name");
String label_group = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.label_group");
String label_embargo = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.label_embargo");
@@ -109,7 +112,7 @@ public class AccessSettingTag extends TagSupport
}
else if (rp != null)
{
policies = new ArrayList<ResourcePolicy>();
policies = new ArrayList<>();
policies.add(rp);
}
@@ -186,7 +189,7 @@ public class AccessSettingTag extends TagSupport
// Embargo Date
if (hidden)
{
sb.append("<input name=\"embargo_until_date\" id=\"embargo_until_date_hidden\" type=\"hidden\" value=\"").append(startDate).append("\" />\n");;
sb.append("<input name=\"embargo_until_date\" id=\"embargo_until_date_hidden\" type=\"hidden\" value=\"").append(startDate).append("\" />\n");
sb.append("<input name=\"reason\" id=\"reason_hidden\" type=\"hidden\" value=\"").append(reason).append("\" />\n");
}
else
@@ -365,6 +368,7 @@ public class AccessSettingTag extends TagSupport
return addpolicy;
}
@Override
public void release()
{
dso = null;

View File

@@ -57,10 +57,10 @@ import org.dspace.sort.SortOption;
public class BrowseListTag extends TagSupport
{
/** log4j category */
private static Logger log = Logger.getLogger(BrowseListTag.class);
private static final Logger log = Logger.getLogger(BrowseListTag.class);
/** Items to display */
private transient List<Item> items;
private List<Item> items;
/** Row to highlight, -1 for no row */
private int highlightRow = -1;
@@ -105,11 +105,14 @@ public class BrowseListTag extends TagSupport
private static final long serialVersionUID = 8091584920304256107L;
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
transient private final ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
private MetadataAuthorityService metadataAuthorityService = ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
transient private final MetadataAuthorityService metadataAuthorityService
= ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
private BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
transient private final BitstreamService bitstreamService
= ContentServiceFactory.getInstance().getBitstreamService();
static
{
@@ -152,6 +155,7 @@ public class BrowseListTag extends TagSupport
super();
}
@Override
public int doStartTag() throws JspException
{
JspWriter out = pageContext.getOut();
@@ -477,7 +481,7 @@ public class BrowseListTag extends TagSupport
// save on a null check which would make the code untidy
if (metadataArray == null)
{
metadataArray = new ArrayList<MetadataValue>();
metadataArray = new ArrayList<>();
}
// now prepare the content of the table division
@@ -758,6 +762,7 @@ public class BrowseListTag extends TagSupport
emphColumn = emphColumnIn;
}
@Override
public void release()
{
highlightRow = -1;
@@ -885,12 +890,12 @@ public class BrowseListTag extends TagSupport
Bitstream original = thumbnail.getOriginal();
String link = hrq.getContextPath() + "/bitstream/" + item.getHandle() + "/" + original.getSequenceID() + "/" +
UIUtil.encodeBitstreamName(original.getName(), Constants.DEFAULT_ENCODING);
thumbFrag.append("<a target=\"_blank\" href=\"" + link + "\" />");
thumbFrag.append("<a target=\"_blank\" href=\"").append(link).append("\" />");
}
else
{
String link = hrq.getContextPath() + "/handle/" + item.getHandle();
thumbFrag.append("<a href=\"" + link + "\" />");
thumbFrag.append("<a href=\"").append(link).append("\" />");
}
Bitstream thumb = thumbnail.getThumb();

View File

@@ -27,7 +27,7 @@ import org.dspace.content.Collection;
public class CollectionListTag extends TagSupport
{
/** Collections to display */
private transient List<Collection> collections;
private List<Collection> collections;
private static final long serialVersionUID = -9040013543196580904L;
@@ -36,6 +36,7 @@ public class CollectionListTag extends TagSupport
super();
}
@Override
public int doStartTag() throws JspException
{
JspWriter out = pageContext.getOut();
@@ -106,6 +107,7 @@ public class CollectionListTag extends TagSupport
collections = collectionsIn;
}
@Override
public void release()
{
collections = null;

View File

@@ -27,7 +27,7 @@ import org.dspace.content.Community;
public class CommunityListTag extends TagSupport
{
/** Communities to display */
private transient List<Community> communities;
private List<Community> communities;
private static final long serialVersionUID = 5788338729470292501L;
@@ -36,6 +36,7 @@ public class CommunityListTag extends TagSupport
super();
}
@Override
public int doStartTag() throws JspException
{
JspWriter out = pageContext.getOut();
@@ -106,6 +107,7 @@ public class CommunityListTag extends TagSupport
communities = communitiesIn;
}
@Override
public void release()
{
communities = null;

View File

@@ -32,10 +32,11 @@ import org.w3c.dom.Document;
public class ControlledVocabularyTag extends TagSupport
{
// path to the jsp that outputs the results of this tag
private static final String CONTROLLEDVOCABULARY_JSPTAG = "/controlledvocabulary/controlledvocabularyTag.jsp";
private static final String CONTROLLEDVOCABULARY_JSPTAG
= "/controlledvocabulary/controlledvocabularyTag.jsp";
// the log
private static Logger log = Logger.getLogger(ControlledVocabularyTag.class);
private static final Logger log = Logger.getLogger(ControlledVocabularyTag.class);
// a tag attribute that contains the words used to trim the vocabulary tree
private String filter;
@@ -46,12 +47,10 @@ public class ControlledVocabularyTag extends TagSupport
// a tag attribute that specifies the vocabulary to be displayed
private String vocabulary;
// an hashtable containing all the loaded vocabularies
public Map<String, Document> controlledVocabularies;
/**
* Process tag
*/
@Override
public int doStartTag() throws JspException
{
HttpServletRequest request = (HttpServletRequest) pageContext
@@ -69,7 +68,9 @@ public class ControlledVocabularyTag extends TagSupport
+ "vocabulary2html.xsl";
// Load vocabularies on startup
controlledVocabularies = (Map<String, Document>) pageContext.getServletContext().getAttribute("controlledvocabulary.controlledVocabularies");
Map<String, Document> controlledVocabularies
= (Map<String, Document>) pageContext.getServletContext()
.getAttribute("controlledvocabulary.controlledVocabularies");
if (controlledVocabularies == null)
{
controlledVocabularies = loadControlledVocabularies(vocabulariesPath);
@@ -112,6 +113,7 @@ public class ControlledVocabularyTag extends TagSupport
/**
* End processing tag
*/
@Override
public int doEndTag()
{
return EVAL_PAGE;
@@ -168,7 +170,7 @@ public class ControlledVocabularyTag extends TagSupport
*/
private Map<String, Document> filterVocabularies(Map<String, Document> vocabularies, String vocabularyPrunningXSLT)
{
Map<String, Document> prunnedVocabularies = new HashMap<String, Document>();
Map<String, Document> prunnedVocabularies = new HashMap<>();
for (Map.Entry<String, Document> entry : vocabularies.entrySet())
{
prunnedVocabularies.put(entry.getKey(), filterVocabulary(entry.getValue(), vocabularyPrunningXSLT, getFilter()));
@@ -203,7 +205,7 @@ public class ControlledVocabularyTag extends TagSupport
try
{
Map<String, String> parameters = new HashMap<String, String>();
Map<String, String> parameters = new HashMap<>();
parameters.put("allowMultipleSelection", allowMultipleSelection ? "yes" : "no");
parameters.put("contextPath", contextPath);
result = XMLUtil.transformDocumentAsString(vocabulary, parameters, controlledVocabulary2HtmlXSLT);
@@ -236,7 +238,7 @@ public class ControlledVocabularyTag extends TagSupport
try
{
Map<String, String> parameters = new HashMap<String, String>();
Map<String, String> parameters = new HashMap<>();
parameters.put("filter", filter);
return XMLUtil.transformDocument(vocabulary, parameters, vocabularyPrunningXSLT);
}
@@ -259,11 +261,12 @@ public class ControlledVocabularyTag extends TagSupport
*/
private static Map<String, Document> loadControlledVocabularies(String directory)
{
Map<String, Document> controlledVocabularies = new HashMap<String, Document>();
Map<String, Document> controlledVocabularies = new HashMap<>();
File dir = new File(directory);
FilenameFilter filter = new FilenameFilter()
{
@Override
public boolean accept(File dir, String name)
{
return name.endsWith(".xml");

View File

@@ -55,10 +55,10 @@ import org.dspace.sort.SortOption;
*/
public class ItemListTag extends TagSupport
{
private static Logger log = Logger.getLogger(ItemListTag.class);
private static final Logger log = Logger.getLogger(ItemListTag.class);
/** Items to display */
private transient List<Item> items;
private List<Item> items;
/** Row to highlight, -1 for no row */
private int highlightRow = -1;
@@ -101,13 +101,16 @@ public class ItemListTag extends TagSupport
private transient SortOption sortOption = null;
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
private static final long serialVersionUID = 348762897199116432L;
private MetadataAuthorityService metadataAuthorityService = ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
private final transient MetadataAuthorityService metadataAuthorityService
= ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
private BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
private final transient BitstreamService bitstreamService
= ContentServiceFactory.getInstance().getBitstreamService();
static
{
@@ -149,6 +152,7 @@ public class ItemListTag extends TagSupport
super();
}
@Override
public int doStartTag() throws JspException
{
JspWriter out = pageContext.getOut();
@@ -430,7 +434,7 @@ public class ItemListTag extends TagSupport
// save on a null check which would make the code untidy
if (metadataArray == null)
{
metadataArray = new ArrayList<MetadataValue>();
metadataArray = new ArrayList<>();
}
// now prepare the content of the table division
@@ -726,6 +730,7 @@ public class ItemListTag extends TagSupport
emphColumn = emphColumnIn;
}
@Override
public void release()
{
highlightRow = -1;

View File

@@ -37,17 +37,19 @@ import org.dspace.core.Constants;
public class ItemPreviewTag extends TagSupport
{
/** Item to display */
private transient Item item;
private Item item;
private static final long serialVersionUID = -5535762797556685631L;
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
public ItemPreviewTag()
{
super();
}
@Override
public int doStartTag() throws JspException
{
if (!ConfigurationManager.getBooleanProperty("webui.preview.enabled"))
@@ -124,6 +126,7 @@ public class ItemPreviewTag extends TagSupport
}
}
@Override
public void release()
{
item = null;

View File

@@ -26,7 +26,6 @@ import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.jstl.fmt.LocaleSupport;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
import org.dspace.app.util.DCInputsReaderException;
import org.dspace.app.util.Util;
@@ -194,10 +193,10 @@ public class ItemTag extends TagSupport
private static final String DOI_DEFAULT_BASEURL = "http://dx.doi.org/";
/** Item to display */
private transient Item item;
private Item item;
/** Collections this item appears in */
private transient List<Collection> collections;
private List<Collection> collections;
/** The style to use - "default" or "full" */
private String style;
@@ -206,38 +205,45 @@ public class ItemTag extends TagSupport
private boolean showThumbs;
/** Default DC fields to display, in absence of configuration */
private static String defaultFields = "dc.title, dc.title.alternative, dc.contributor.*, dc.subject, dc.date.issued(date), dc.publisher, dc.identifier.citation, dc.relation.ispartofseries, dc.description.abstract, dc.description, dc.identifier.govdoc, dc.identifier.uri(link), dc.identifier.isbn, dc.identifier.issn, dc.identifier.ismn, dc.identifier";
private static final String defaultFields
= "dc.title, dc.title.alternative, dc.contributor.*, dc.subject, dc.date.issued(date), dc.publisher, dc.identifier.citation, dc.relation.ispartofseries, dc.description.abstract, dc.description, dc.identifier.govdoc, dc.identifier.uri(link), dc.identifier.isbn, dc.identifier.issn, dc.identifier.ismn, dc.identifier";
/** log4j logger */
private static Logger log = Logger.getLogger(ItemTag.class);
private static final Logger log = Logger.getLogger(ItemTag.class);
private StyleSelection styleSelection = (StyleSelection) PluginManager.getSinglePlugin(StyleSelection.class);
private final transient StyleSelection styleSelection
= (StyleSelection) PluginManager.getSinglePlugin(StyleSelection.class);
/** Hashmap of linked metadata to browse, from dspace.cfg */
private static Map<String,String> linkedMetadata;
private static final Map<String,String> linkedMetadata;
/** Hashmap of urn base url resolver, from dspace.cfg */
private static Map<String,String> urn2baseurl;
private static final Map<String,String> urn2baseurl;
/** regex pattern to capture the style of a field, ie <code>schema.element.qualifier(style)</code> */
private Pattern fieldStylePatter = Pattern.compile(".*\\((.*)\\)");
private final Pattern fieldStylePatter = Pattern.compile(".*\\((.*)\\)");
private static final long serialVersionUID = -3841266490729417240L;
private MetadataExposureService metadataExposureService = UtilServiceFactory.getInstance().getMetadataExposureService();
private final transient MetadataExposureService metadataExposureService
= UtilServiceFactory.getInstance().getMetadataExposureService();
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
private MetadataAuthorityService metadataAuthorityService = ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
private final transient MetadataAuthorityService metadataAuthorityService
= ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
private BundleService bundleService = ContentServiceFactory.getInstance().getBundleService();
private final transient BundleService bundleService
= ContentServiceFactory.getInstance().getBundleService();
private AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
private final transient AuthorizeService authorizeService
= AuthorizeServiceFactory.getInstance().getAuthorizeService();
static {
int i;
linkedMetadata = new HashMap<String, String>();
linkedMetadata = new HashMap<>();
String linkMetadata;
i = 1;
@@ -253,7 +259,7 @@ public class ItemTag extends TagSupport
i++;
} while (linkMetadata != null);
urn2baseurl = new HashMap<String, String>();
urn2baseurl = new HashMap<>();
String urn;
i = 1;
@@ -287,6 +293,7 @@ public class ItemTag extends TagSupport
getThumbSettings();
}
@Override
public int doStartTag() throws JspException
{
try
@@ -385,6 +392,7 @@ public class ItemTag extends TagSupport
style = styleIn;
}
@Override
public void release()
{
style = "default";
@@ -517,7 +525,7 @@ public class ItemTag extends TagSupport
//If the values are in controlled vocabulary and the display value should be shown
if (isDisplay){
List<String> displayValues = new ArrayList<String>();
List<String> displayValues = new ArrayList<>();
displayValues = Util.getControlledVocabulariesDisplayValueLocalized(item, values, schema, element, qualifier, sessionLocale);
@@ -585,7 +593,7 @@ public class ItemTag extends TagSupport
else
{
String foundUrn = null;
if (!style.equals("resolver"))
if (!"resolver".equals(style))
{
foundUrn = style;
}

View File

@@ -30,19 +30,21 @@ import org.dspace.authorize.service.ResourcePolicyService;
public class PoliciesListTag extends TagSupport
{
/** log4j category */
private static Logger log = Logger.getLogger(PoliciesListTag.class);
private static final Logger log = Logger.getLogger(PoliciesListTag.class);
/** Groups to make options list */
private transient List<ResourcePolicy> policies = null;
private transient boolean showButton = true;
private boolean showButton = true;
private ResourcePolicyService policyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService();
private final transient ResourcePolicyService policyService
= AuthorizeServiceFactory.getInstance().getResourcePolicyService();
public PoliciesListTag()
{
super();
}
@Override
public int doStartTag() throws JspException
{
String label_name = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.policies-list.label_name");
@@ -137,6 +139,7 @@ public class PoliciesListTag extends TagSupport
}
@Override
public void release()
{
policies = null;

View File

@@ -30,21 +30,23 @@ public class SFXLinkTag extends TagSupport
{
/** Item to display SFX link for */
private transient Item item;
private Item item;
/** The fully qualified pathname of the SFX XML file */
private String sfxFile = ConfigurationManager.getProperty("dspace.dir") + File.separator
private final String sfxFile = ConfigurationManager.getProperty("dspace.dir") + File.separator
+ "config" + File.separator + "sfx.xml";
private static final long serialVersionUID = 7028793612957710128L;
private SFXFileReaderService sfxFileReaderService = SfxServiceFactory.getInstance().getSfxFileReaderService();
private final transient SFXFileReaderService sfxFileReaderService
= SfxServiceFactory.getInstance().getSfxFileReaderService();
public SFXLinkTag()
{
super();
}
@Override
public int doStartTag() throws JspException
{
try

View File

@@ -84,7 +84,7 @@ public class SelectCollectionTag extends TagSupport
for (Collection coll : collections)
{
sb.append("<option value=\"").append(coll.getID()).append("\"");
if (collection == coll.getID().toString())
if (collection.equals(coll.getID().toString()))
{
sb.append(" selected=\"selected\"");
}

View File

@@ -47,7 +47,7 @@ public class SelectEPersonTag extends TagSupport
private boolean multiple;
/** Which eperson/epeople are initially in the list? */
private transient EPerson[] epeople;
private EPerson[] epeople;
private static final long serialVersionUID = -7323789442034590853L;

View File

@@ -42,7 +42,7 @@ public class SelectGroupTag extends TagSupport
private boolean multiple;
/** Which groups are initially in the list? */
private transient Group[] groups;
private Group[] groups;
private static final long serialVersionUID = -3330389128849427302L;
@@ -89,6 +89,7 @@ public class SelectGroupTag extends TagSupport
}
@Override
public void release()
{
multiple = false;
@@ -96,6 +97,7 @@ public class SelectGroupTag extends TagSupport
}
@Override
public int doStartTag()
throws JspException
{

View File

@@ -29,12 +29,12 @@ import org.dspace.core.PluginManager;
*/
public class AdvancedSearchServlet extends DSpaceServlet
{
private SearchRequestProcessor internalLogic;
private transient SearchRequestProcessor internalLogic;
/** log4j category */
private static Logger log = Logger.getLogger(AdvancedSearchServlet.class);
private static final Logger log = Logger.getLogger(AdvancedSearchServlet.class);
public void init()
public AdvancedSearchServlet()
{
try
{
@@ -44,7 +44,7 @@ public class AdvancedSearchServlet extends DSpaceServlet
catch (PluginConfigurationError e)
{
log.warn(
"AdvancedSearchServlet not properly configurated, please configure the SearchRequestProcessor plugin",
"AdvancedSearchServlet not properly configured -- please configure the SearchRequestProcessor plugin",
e);
}
if (internalLogic == null)
@@ -53,6 +53,7 @@ public class AdvancedSearchServlet extends DSpaceServlet
}
}
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException

View File

@@ -5,9 +5,6 @@
*
* http://www.dspace.org/license/
*/
/*
*
*/
package org.dspace.app.webui.servlet;
@@ -28,7 +25,6 @@ import org.dspace.content.authority.Choices;
import org.dspace.content.authority.ChoicesXMLGenerator;
import org.dspace.content.authority.factory.ContentAuthorityServiceFactory;
import org.dspace.content.authority.service.ChoiceAuthorityService;
import org.dspace.content.authority.service.MetadataAuthorityService;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.core.Context;
@@ -38,23 +34,17 @@ import org.apache.xml.serializer.Serializer;
import org.apache.xml.serializer.OutputPropertiesFactory;
import org.apache.xml.serializer.Method;
/**
*
* @author bollini
*/
public class AuthorityChooseServlet extends DSpaceServlet {
private ChoiceAuthorityService choiceAuthorityService;
private final transient ChoiceAuthorityService choiceAuthorityService
= ContentAuthorityServiceFactory.getInstance().getChoiceAuthorityService();
private CollectionService collectionService;
private final transient CollectionService collectionService
= ContentServiceFactory.getInstance().getCollectionService();
@Override
public void init() throws ServletException {
super.init();
choiceAuthorityService = ContentAuthorityServiceFactory.getInstance().getChoiceAuthorityService();
collectionService = ContentServiceFactory.getInstance().getCollectionService();
}
@Override
protected void doDSGet(Context context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException {
process(context, request, response);

View File

@@ -43,19 +43,14 @@ import org.dspace.utils.DSpace;
public class BatchImportServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(BatchImportServlet.class);
private static final Logger log = Logger.getLogger(BatchImportServlet.class);
private CollectionService collectionService;
private final transient CollectionService collectionService
= ContentServiceFactory.getInstance().getCollectionService();
private ItemImportService itemImportService;
private final transient ItemImportService itemImportService
= ItemImportServiceFactory.getInstance().getItemImportService();
@Override
public void init() throws ServletException {
super.init();
collectionService = ContentServiceFactory.getInstance().getCollectionService();
itemImportService = ItemImportServiceFactory.getInstance().getItemImportService();
}
/**
* Respond to a post request for metadata bulk importing via csv
*
@@ -68,6 +63,7 @@ public class BatchImportServlet extends DSpaceServlet
* @throws SQLException
* @throws AuthorizeException
*/
@Override
protected void doDSPost(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -93,7 +89,7 @@ public class BatchImportServlet extends DSpaceServlet
List<Collection> collections = null;
String colIdS = wrapper.getParameter("colId");
if (colIdS!=null){
collections = new ArrayList<Collection>();
collections = new ArrayList<>();
collections.add(collectionService.findByIdOrLegacyId(context, colIdS));
}
@@ -257,6 +253,7 @@ public class BatchImportServlet extends DSpaceServlet
* @throws SQLException
* @throws AuthorizeException
*/
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -265,7 +262,7 @@ public class BatchImportServlet extends DSpaceServlet
List<Collection> collections = null;
String colIdS = request.getParameter("colId");
if (colIdS!=null){
collections = new ArrayList<Collection>();
collections = new ArrayList<>();
collections.add(collectionService.findByIdOrLegacyId(context, colIdS));
}
@@ -305,7 +302,7 @@ public class BatchImportServlet extends DSpaceServlet
protected List<String> getRepeatedParameter(HttpServletRequest request,
String metadataField, String param)
{
List<String> vals = new LinkedList<String>();
List<String> vals = new LinkedList<>();
int i = 1; //start index at the first of the previously entered values
boolean foundLast = false;

View File

@@ -32,7 +32,6 @@ import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.core.Utils;
import org.dspace.handle.HandleServiceImpl;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.usage.UsageEvent;
@@ -51,7 +50,7 @@ import org.dspace.utils.DSpace;
public class BitstreamServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(BitstreamServlet.class);
private static final Logger log = Logger.getLogger(BitstreamServlet.class);
/**
* Threshold on Bitstream size before content-disposition will be set.
@@ -59,17 +58,17 @@ public class BitstreamServlet extends DSpaceServlet
private int threshold;
// services API
private HandleService handleService;
private final transient HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();
private BitstreamService bitstreamService;
private final transient BitstreamService bitstreamService
= ContentServiceFactory.getInstance().getBitstreamService();
@Override
public void init(ServletConfig arg0) throws ServletException {
super.init(arg0);
threshold = ConfigurationManager
.getIntProperty("webui.content_disposition_threshold");
handleService = HandleServiceFactory.getInstance().getHandleService();
bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
}
@Override

View File

@@ -23,13 +23,9 @@ import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.eperson.service.SubscribeService;
import org.dspace.handle.service.HandleService;
/**
* Servlet for listing communities (and collections within them)
@@ -40,20 +36,13 @@ import org.dspace.handle.service.HandleService;
public class CommunityListServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(CommunityListServlet.class);
private static final Logger log = Logger.getLogger(CommunityListServlet.class);
// services API
private CommunityService communityService;
private CollectionService collectionService;
private final transient CommunityService communityService
= ContentServiceFactory.getInstance().getCommunityService();
@Override
public void init() throws ServletException {
super.init();
communityService = ContentServiceFactory.getInstance().getCommunityService();
collectionService = ContentServiceFactory.getInstance().getCollectionService();
}
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -64,8 +53,8 @@ public class CommunityListServlet extends DSpaceServlet
// This will map communityIDs to arrays of sub-communities
Map<String, List<Community>> commMap;
colMap = new HashMap<String, List<Collection>>();
commMap = new HashMap<String, List<Community>>();
colMap = new HashMap<>();
commMap = new HashMap<>();
log.info(LogManager.getHeader(context, "view_community_list", ""));

View File

@@ -45,7 +45,7 @@ import org.dspace.search.QueryResults;
public class ControlledVocabularySearchServlet extends DSpaceServlet
{
// the log
private static Logger log = Logger
private static final Logger log = Logger
.getLogger(ControlledVocabularySearchServlet.class);
// the jsp that displays the HTML version of controlled-vocabulary
@@ -54,19 +54,16 @@ public class ControlledVocabularySearchServlet extends DSpaceServlet
// the jsp that will show the search results
private static final String RESULTS_JSP = "/controlledvocabulary/results.jsp";
private HandleService handleService;
private final transient HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();
private CommunityService communityService;
private final transient CommunityService communityService
= ContentServiceFactory.getInstance().getCommunityService();
@Override
public void init() throws ServletException {
super.init();
handleService = HandleServiceFactory.getInstance().getHandleService();
communityService = ContentServiceFactory.getInstance().getCommunityService();
}
/**
* Handles requests
*/
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -104,7 +101,7 @@ public class ControlledVocabularySearchServlet extends DSpaceServlet
*/
private List<String> extractKeywords(HttpServletRequest request)
{
List<String> keywords = new ArrayList<String>();
List<String> keywords = new ArrayList<>();
Enumeration enumeration = request.getParameterNames();
while (enumeration.hasMoreElements())
{
@@ -143,9 +140,9 @@ public class ControlledVocabularySearchServlet extends DSpaceServlet
start = 0;
}
List<String> itemHandles = new ArrayList<String>();
List<String> collectionHandles = new ArrayList<String>();
List<String> communityHandles = new ArrayList<String>();
List<String> itemHandles = new ArrayList<>();
List<String> collectionHandles = new ArrayList<>();
List<String> communityHandles = new ArrayList<>();
Item[] resultsItems;
Collection[] resultsCollections;
@@ -219,7 +216,7 @@ public class ControlledVocabularySearchServlet extends DSpaceServlet
Integer myType = qResults.getHitTypes().get(i);
// add the handle to the appropriate lists
switch (myType.intValue())
switch (myType)
{
case Constants.ITEM:
itemHandles.add(myHandle);
@@ -317,10 +314,10 @@ public class ControlledVocabularySearchServlet extends DSpaceServlet
request.setAttribute("communities", resultsCommunities);
request.setAttribute("collections", resultsCollections);
request.setAttribute("pagetotal", Integer.valueOf(pageTotal));
request.setAttribute("pagecurrent", Integer.valueOf(pageCurrent));
request.setAttribute("pagelast", Integer.valueOf(pageLast));
request.setAttribute("pagefirst", Integer.valueOf(pageFirst));
request.setAttribute("pagetotal", pageTotal);
request.setAttribute("pagecurrent", pageCurrent);
request.setAttribute("pagelast", pageLast);
request.setAttribute("pagefirst", pageFirst);
request.setAttribute("queryresults", qResults);
@@ -358,6 +355,7 @@ public class ControlledVocabularySearchServlet extends DSpaceServlet
/**
* Handle posts
*/
@Override
protected void doDSPost(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException

View File

@@ -61,22 +61,19 @@ public class DSpaceServlet extends HttpServlet
*/
/** log4j category */
private static Logger log = Logger.getLogger(DSpaceServlet.class);
private static final Logger log = Logger.getLogger(DSpaceServlet.class);
protected AuthorizeService authorizeService;
protected transient AuthorizeService authorizeService
= AuthorizeServiceFactory.getInstance().getAuthorizeService();
@Override
public void init() throws ServletException {
super.init();
authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{

View File

@@ -43,16 +43,12 @@ import org.dspace.statistics.content.StatisticsTable;
public class DisplayStatisticsServlet extends DSpaceServlet
{
/** log4j logger */
private static Logger log = Logger.getLogger(DisplayStatisticsServlet.class);
private static final Logger log = Logger.getLogger(DisplayStatisticsServlet.class);
private HandleService handleService;
private final transient HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();
@Override
public void init() throws ServletException {
super.init();
handleService = HandleServiceFactory.getInstance().getHandleService();
}
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -157,7 +153,6 @@ public class DisplayStatisticsServlet extends DSpaceServlet
try
{
StatisticsTable statisticsTable = new StatisticsTable(new StatisticsDataVisits(dso));
statisticsTable.setTitle("Total Visits Per Month");

View File

@@ -33,17 +33,12 @@ import org.dspace.eperson.service.EPersonService;
public class EditProfileServlet extends DSpaceServlet
{
/** Logger */
private static Logger log = Logger.getLogger(EditProfileServlet.class);
private static final Logger log = Logger.getLogger(EditProfileServlet.class);
protected EPersonService personService;
protected transient EPersonService personService
= EPersonServiceFactory.getInstance().getEPersonService();
@Override
public void init() throws ServletException {
super.init();
personService = EPersonServiceFactory.getInstance().getEPersonService();
}
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -57,6 +52,7 @@ public class EditProfileServlet extends DSpaceServlet
JSPManager.showJSP(request, response, "/register/edit-profile.jsp");
}
@Override
protected void doDSPost(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -99,7 +95,7 @@ public class EditProfileServlet extends DSpaceServlet
personService.update(context, eperson);
// Show confirmation
request.setAttribute("password.updated", Boolean.valueOf(settingPassword));
request.setAttribute("password.updated", settingPassword);
JSPManager.showJSP(request, response,
"/register/profile-updated.jsp");

View File

@@ -28,8 +28,6 @@ import org.apache.log4j.Logger;
import org.dspace.app.util.SyndicationFeed;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.browse.BrowseEngine;
import org.dspace.browse.BrowseException;
import org.dspace.browse.BrowseIndex;
@@ -43,15 +41,11 @@ import org.dspace.content.Item;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.eperson.service.GroupService;
import org.dspace.eperson.service.SubscribeService;
import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.search.Harvest;
@@ -66,7 +60,6 @@ import com.sun.syndication.io.FeedException;
* Currently supports only RSS feed formats.
*
* @author Ben Bosman, Richard Rodgers
* @version $Revision$
*/
public class FeedServlet extends DSpaceServlet
{
@@ -76,9 +69,9 @@ public class FeedServlet extends DSpaceServlet
// one hour in milliseconds
private static final long HOUR_MSECS = 60 * 60 * 1000;
/** log4j category */
private static Logger log = Logger.getLogger(FeedServlet.class);
private String clazz = "org.dspace.app.webui.servlet.FeedServlet";
private static final Logger log = Logger.getLogger(FeedServlet.class);
private static final String clazz = "org.dspace.app.webui.servlet.FeedServlet";
// are syndication feeds enabled?
private static boolean enabled = false;
@@ -96,17 +89,14 @@ public class FeedServlet extends DSpaceServlet
private static boolean includeAll = true;
// services API
private HandleService handleService;
private final transient HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();
private AuthorizeService authorizeService;
private final transient CommunityService communityService
= ContentServiceFactory.getInstance().getCommunityService();
private SubscribeService subscribeService;
private ItemService itemService;
private CommunityService communityService;
private CollectionService collectionService;
private final transient CollectionService collectionService
= ContentServiceFactory.getInstance().getCollectionService();
static
{
@@ -118,7 +108,7 @@ public class FeedServlet extends DSpaceServlet
String fmtsStr = ConfigurationManager.getProperty("webui.feed.formats");
if ( fmtsStr != null )
{
formats = new ArrayList<String>();
formats = new ArrayList<>();
String[] fmts = fmtsStr.split(",");
for (int i = 0; i < fmts.length; i++)
{
@@ -130,22 +120,13 @@ public class FeedServlet extends DSpaceServlet
cacheSize = ConfigurationManager.getIntProperty("webui.feed.cache.size");
if (cacheSize > 0)
{
feedCache = new HashMap<String, CacheFeed>();
feedCache = new HashMap<>();
cacheAge = ConfigurationManager.getIntProperty("webui.feed.cache.age");
}
}
}
@Override
public void init() throws ServletException {
handleService = HandleServiceFactory.getInstance().getHandleService();
authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
subscribeService = EPersonServiceFactory.getInstance().getSubscribeService();
itemService = ContentServiceFactory.getInstance().getItemService();
communityService = ContentServiceFactory.getInstance().getCommunityService();
collectionService = ContentServiceFactory.getInstance().getCollectionService();
}
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -158,7 +139,7 @@ public class FeedServlet extends DSpaceServlet
// build label map from localized Messages resource bundle
Locale locale = request.getLocale();
ResourceBundle msgs = ResourceBundle.getBundle("Messages", locale);
Map<String, String> labelMap = new HashMap<String, String>();
Map<String, String> labelMap = new HashMap<>();
labelMap.put(SyndicationFeed.MSG_UNTITLED, msgs.getString(clazz + ".notitle"));
labelMap.put(SyndicationFeed.MSG_LOGO_TITLE, msgs.getString(clazz + ".logo.title"));
labelMap.put(SyndicationFeed.MSG_FEED_DESCRIPTION, msgs.getString(clazz + ".general-feed.description"));
@@ -354,7 +335,7 @@ public class FeedServlet extends DSpaceServlet
// Check to see if we can include this item
//Group[] authorizedGroups = AuthorizeManager.getAuthorizedGroups(context, results[i], Constants.READ);
//boolean added = false;
List<Item> items = new ArrayList<Item>();
List<Item> items = new ArrayList<>();
for (Item result : results)
{
checkAccess:

View File

@@ -59,20 +59,20 @@ import org.dspace.utils.DSpace;
public class HTMLServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(HTMLServlet.class);
private static final Logger log = Logger.getLogger(HTMLServlet.class);
/**
* Default maximum number of path elements to strip when testing if a
* bitstream called "foo.html" should be served when "xxx/yyy/zzz/foo.html"
* is requested.
*/
private int maxDepthGuess;
private final int maxDepthGuess;
private ItemService itemService;
private final transient ItemService itemService;
private HandleService handleService;
private final transient HandleService handleService;
private BitstreamService bitstreamService;
private final transient BitstreamService bitstreamService;
/**
* Create an HTML Servlet
@@ -122,6 +122,7 @@ public class HTMLServlet extends DSpaceServlet
// On the surface it doesn't make much sense for this servlet to
// handle POST requests, but in practice some HTML pages which
// are actually JSP get called on with a POST, so it's needed.
@Override
protected void doDSPost(Context context, HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
@@ -129,6 +130,7 @@ public class HTMLServlet extends DSpaceServlet
doDSGet(context, request, response);
}
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException

View File

@@ -27,8 +27,6 @@ import org.dspace.app.webui.util.Authenticate;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
@@ -77,38 +75,30 @@ import org.jdom.output.XMLOutputter;
public class HandleServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(HandleServlet.class);
private static final Logger log = Logger.getLogger(HandleServlet.class);
/** For obtaining &lt;meta&gt; elements to put in the &lt;head&gt; */
private DisseminationCrosswalk xHTMLHeadCrosswalk;
private final transient DisseminationCrosswalk xHTMLHeadCrosswalk
= (DisseminationCrosswalk) PluginManager
.getNamedPlugin(DisseminationCrosswalk.class, "XHTML_HEAD_ITEM");
// services API
private HandleService handleService;
private final transient HandleService handleService
= HandleServiceFactory.getInstance().getHandleService();
private SubscribeService subscribeService;
private final transient SubscribeService subscribeService
= EPersonServiceFactory.getInstance().getSubscribeService();
private ItemService itemService;
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
private CommunityService communityService;
private final transient CommunityService communityService
= ContentServiceFactory.getInstance().getCommunityService();
private CollectionService collectionService;
public HandleServlet()
{
super();
xHTMLHeadCrosswalk = (DisseminationCrosswalk) PluginManager
.getNamedPlugin(DisseminationCrosswalk.class, "XHTML_HEAD_ITEM");
}
public void init() throws ServletException {
super.init();
handleService = HandleServiceFactory.getInstance().getHandleService();
subscribeService = EPersonServiceFactory.getInstance().getSubscribeService();
itemService = ContentServiceFactory.getInstance().getItemService();
communityService = ContentServiceFactory.getInstance().getCommunityService();
collectionService = ContentServiceFactory.getInstance().getCollectionService();
}
private final transient CollectionService collectionService
= ContentServiceFactory.getInstance().getCollectionService();
@Override
protected void doDSGet(Context context, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException,
SQLException, AuthorizeException
@@ -469,7 +459,7 @@ public class HandleServlet extends DSpaceServlet
else
{
// check whether there is a logged in user
suggestEnable = (context.getCurrentUser() == null ? false : true);
suggestEnable = (context.getCurrentUser() != null);
}
}
@@ -482,8 +472,8 @@ public class HandleServlet extends DSpaceServlet
item));
// Set attributes and display
request.setAttribute("suggest.enable", Boolean.valueOf(suggestEnable));
request.setAttribute("display.all", Boolean.valueOf(displayAll));
request.setAttribute("suggest.enable", suggestEnable);
request.setAttribute("display.all", displayAll);
request.setAttribute("item", item);
request.setAttribute("collections", collections);
request.setAttribute("dspace.layout.head", headMetadata);
@@ -716,8 +706,8 @@ public class HandleServlet extends DSpaceServlet
// Forward to collection home page
request.setAttribute("collection", collection);
request.setAttribute("community", community);
request.setAttribute("logged.in", Boolean.valueOf(e != null));
request.setAttribute("subscribed", Boolean.valueOf(subscribed));
request.setAttribute("logged.in", e != null);
request.setAttribute("subscribed", subscribed);
JSPManager.showJSP(request, response, "/collection-home.jsp");
if (updated)
@@ -823,7 +813,7 @@ public class HandleServlet extends DSpaceServlet
List<Community> parents = communityService.getAllParents(context, c);
// put into an array in reverse order
List<Community> reversedParents = new ArrayList<Community>();
List<Community> reversedParents = new ArrayList<>();
int index = parents.size() - 1;
for (int i = 0; i < parents.size(); i++)

View File

@@ -38,15 +38,10 @@ import org.dspace.core.Utils;
*/
public class ItemExportArchiveServlet extends DSpaceServlet {
/** log4j category */
private static Logger log = Logger.getLogger(ItemExportArchiveServlet.class);
private static final Logger log = Logger.getLogger(ItemExportArchiveServlet.class);
private ItemExportService itemExportService;
@Override
public void init() throws ServletException {
super.init();
itemExportService = ItemExportServiceFactory.getInstance().getItemExportService();
}
private final transient ItemExportService itemExportService
= ItemExportServiceFactory.getInstance().getItemExportService();
@Override
protected void doDSGet(Context context, HttpServletRequest request,

View File

@@ -20,6 +20,7 @@ import org.apache.log4j.Logger;
import org.dspace.app.webui.util.Authenticate;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.authenticate.AuthenticationMethod;
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
import org.dspace.authenticate.service.AuthenticationService;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.ConfigurationManager;
@@ -38,16 +39,12 @@ import org.dspace.core.LogManager;
public class LDAPServlet extends DSpaceServlet
{
/** log4j logger */
private static Logger log = Logger.getLogger(LDAPServlet.class);
private static final Logger log = Logger.getLogger(LDAPServlet.class);
private AuthenticationService authenticationService;
private final transient AuthenticationService authenticationService
= AuthenticateServiceFactory.getInstance().getAuthenticationService();
@Override
public void init() throws ServletException {
super.init();
}
protected void doDSGet(Context context,
HttpServletRequest request,
HttpServletResponse response)
@@ -66,6 +63,7 @@ public class LDAPServlet extends DSpaceServlet
}
@Override
protected void doDSPost(Context context,
HttpServletRequest request,
HttpServletResponse response)

Some files were not shown because too many files have changed in this diff Show More