[DS-707] Style / readability fixes

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5579 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-24 09:06:59 +00:00
parent 72e9793c81
commit 6f9d4e28ab
155 changed files with 2194 additions and 545 deletions

View File

@@ -322,7 +322,9 @@ public class ItemExport
finally finally
{ {
if (i != null) if (i != null)
{
i.close(); i.close();
}
} }
} }
} }
@@ -882,7 +884,9 @@ public class ItemExport
finally finally
{ {
if (iitems != null) if (iitems != null)
{
iitems.close(); iitems.close();
}
} }
} }
} }
@@ -914,7 +918,9 @@ public class ItemExport
finally finally
{ {
if (iitems != null) if (iitems != null)
{
iitems.close(); iitems.close();
}
} }
} }
else if (dso.getType() == Constants.ITEM) else if (dso.getType() == Constants.ITEM)
@@ -1030,7 +1036,9 @@ public class ItemExport
finally finally
{ {
if (iitems != null) if (iitems != null)
{
iitems.close(); iitems.close();
}
// Make sure the database connection gets closed in all conditions. // Make sure the database connection gets closed in all conditions.
try { try {

View File

@@ -953,7 +953,9 @@ public class ItemImport
String value = getStringValue(n); //n.getNodeValue(); String value = getStringValue(n); //n.getNodeValue();
// compensate for empty value getting read as "null", which won't display // compensate for empty value getting read as "null", which won't display
if (value == null) if (value == null)
{
value = ""; value = "";
}
// //getElementData(n, "element"); // //getElementData(n, "element");
String element = getAttributeValue(n, "element"); String element = getAttributeValue(n, "element");
String qualifier = getAttributeValue(n, "qualifier"); //NodeValue(); String qualifier = getAttributeValue(n, "qualifier"); //NodeValue();

View File

@@ -389,7 +389,9 @@ public class MediaFilterManager
if (updateIndex) if (updateIndex)
{ {
if (!isQuiet) if (!isQuiet)
System.out.println("Updating search index:"); {
System.out.println("Updating search index:");
}
DSIndexer.updateIndex(c); DSIndexer.updateIndex(c);
} }
@@ -437,7 +439,9 @@ public class MediaFilterManager
finally finally
{ {
if (i != null) if (i != null)
{
i.close(); i.close();
}
} }
} }
} }
@@ -478,7 +482,9 @@ public class MediaFilterManager
finally finally
{ {
if (i != null) if (i != null)
{
i.close(); i.close();
}
} }
} }
} }
@@ -708,7 +714,9 @@ public class MediaFilterManager
{ {
//do pre-processing of this bitstream, and if it fails, skip this bitstream! //do pre-processing of this bitstream, and if it fails, skip this bitstream!
if(!formatFilter.preProcessBitstream(c, item, source)) if(!formatFilter.preProcessBitstream(c, item, source))
return false; {
return false;
}
boolean overWrite = MediaFilterManager.isForce; boolean overWrite = MediaFilterManager.isForce;
@@ -743,8 +751,10 @@ public class MediaFilterManager
if (!overWrite && (existingBitstream != null)) if (!overWrite && (existingBitstream != null))
{ {
if (!isQuiet) if (!isQuiet)
System.out.println("SKIPPED: bitstream " + source.getID() {
+ " (item: " + item.getHandle() + ") because '" + newName + "' already exists"); System.out.println("SKIPPED: bitstream " + source.getID()
+ " (item: " + item.getHandle() + ") because '" + newName + "' already exists");
}
return false; return false;
} }
@@ -753,8 +763,10 @@ public class MediaFilterManager
if (destStream == null) if (destStream == null)
{ {
if (!isQuiet) if (!isQuiet)
System.out.println("SKIPPED: bitstream " + source.getID() {
+ " (item: " + item.getHandle() + ") because filtering was unsuccessful"); System.out.println("SKIPPED: bitstream " + source.getID()
+ " (item: " + item.getHandle() + ") because filtering was unsuccessful");
}
return false; return false;
} }
@@ -797,8 +809,10 @@ public class MediaFilterManager
} }
if (!isQuiet) if (!isQuiet)
System.out.println("FILTERED: bitstream " + source.getID() {
+ " (item: " + item.getHandle() + ") and created '" + newName + "'"); System.out.println("FILTERED: bitstream " + source.getID()
+ " (item: " + item.getHandle() + ") and created '" + newName + "'");
}
//do post-processing of the generated bitstream //do post-processing of the generated bitstream
formatFilter.postProcessBitstream(c, item, b); formatFilter.postProcessBitstream(c, item, b);
@@ -835,7 +849,9 @@ public class MediaFilterManager
if(skipList!=null && skipList.contains(identifier)) if(skipList!=null && skipList.contains(identifier))
{ {
if (!isQuiet) if (!isQuiet)
System.out.println("SKIP-LIST: skipped bitstreams within identifier " + identifier); {
System.out.println("SKIP-LIST: skipped bitstreams within identifier " + identifier);
}
return true; return true;
} }
else else

View File

@@ -220,7 +220,9 @@ public class METSExport
finally finally
{ {
if (items != null) if (items != null)
{
items.close(); items.close();
}
} }
context.abort(); context.abort();
@@ -261,7 +263,15 @@ public class METSExport
finally finally
{ {
if (is != null) if (is != null)
try { is.close(); } catch (IOException ioe) { } {
try
{
is.close();
}
catch (IOException ioe)
{
}
}
} }
} }

View File

@@ -213,9 +213,13 @@ public class GenerateSitemaps
String url = handleURLStem + comms[i].getHandle(); String url = handleURLStem + comms[i].getHandle();
if (makeHTMLMap) if (makeHTMLMap)
{
html.addURL(url, null); html.addURL(url, null);
}
if (makeSitemapOrg) if (makeSitemapOrg)
{
sitemapsOrg.addURL(url, null); sitemapsOrg.addURL(url, null);
}
} }
Collection[] colls = Collection.findAll(c); Collection[] colls = Collection.findAll(c);
@@ -225,9 +229,13 @@ public class GenerateSitemaps
String url = handleURLStem + colls[i].getHandle(); String url = handleURLStem + colls[i].getHandle();
if (makeHTMLMap) if (makeHTMLMap)
{
html.addURL(url, null); html.addURL(url, null);
}
if (makeSitemapOrg) if (makeSitemapOrg)
{
sitemapsOrg.addURL(url, null); sitemapsOrg.addURL(url, null);
}
} }
ItemIterator allItems = Item.findAll(c); ItemIterator allItems = Item.findAll(c);
@@ -242,9 +250,13 @@ public class GenerateSitemaps
Date lastMod = i.getLastModified(); Date lastMod = i.getLastModified();
if (makeHTMLMap) if (makeHTMLMap)
{
html.addURL(url, lastMod); html.addURL(url, lastMod);
}
if (makeSitemapOrg) if (makeSitemapOrg)
{
sitemapsOrg.addURL(url, lastMod); sitemapsOrg.addURL(url, lastMod);
}
i.decache(); i.decache();
itemCount++; itemCount++;
@@ -271,7 +283,9 @@ public class GenerateSitemaps
finally finally
{ {
if (allItems != null) if (allItems != null)
{
allItems.close(); allItems.close();
}
} }
c.abort(); c.abort();

View File

@@ -99,7 +99,9 @@ public class MetadataExposure
{ {
// the administrator's override // the administrator's override
if (context != null && AuthorizeManager.isAdmin(context)) if (context != null && AuthorizeManager.isAdmin(context))
{
return false; return false;
}
// for schema.element, just check schema->elementSet // for schema.element, just check schema->elementSet
if (!isInitialized()) if (!isInitialized())
@@ -118,7 +120,9 @@ public class MetadataExposure
{ {
Map<String,Set<String>> elts = hiddenElementMaps.get(schema); Map<String,Set<String>> elts = hiddenElementMaps.get(schema);
if (elts == null) if (elts == null)
{
return false; return false;
}
Set<String> quals = elts.get(element); Set<String> quals = elts.get(element);
return quals == null ? false : quals.contains(qualifier); return quals == null ? false : quals.contains(qualifier);
} }

View File

@@ -308,8 +308,10 @@ public class IPAuthentication implements AuthenticationMethod
for (int i = 0; i < results.length; i++) for (int i = 0; i < results.length; i++)
{ {
if (i > 0) if (i > 0)
{
gsb.append(","); gsb.append(",");
gsb.append(results[i]); }
gsb.append(results[i]);
} }
log.debug(LogManager.getHeader(context, "authenticated", log.debug(LogManager.getHeader(context, "authenticated",

View File

@@ -170,7 +170,9 @@ public class LDAPAuthentication
// Skip out when no netid or password is given. // Skip out when no netid or password is given.
if (netid == null || password == null) if (netid == null || password == null)
return BAD_ARGS; {
return BAD_ARGS;
}
// Locate the eperson // Locate the eperson
EPerson eperson = null; EPerson eperson = null;
@@ -379,25 +381,37 @@ public class LDAPAuthentication
if (attlist[0]!=null) if (attlist[0]!=null)
{ {
att = atts.get(attlist[0]); att = atts.get(attlist[0]);
if (att != null) ldapEmail = (String)att.get(); if (att != null)
{
ldapEmail = (String) att.get();
}
} }
if (attlist[1]!=null) if (attlist[1]!=null)
{ {
att = atts.get(attlist[1]); att = atts.get(attlist[1]);
if (att != null) ldapGivenName = (String)att.get(); if (att != null)
{
ldapGivenName = (String) att.get();
}
} }
if (attlist[2]!=null) if (attlist[2]!=null)
{ {
att = atts.get(attlist[2]); att = atts.get(attlist[2]);
if (att != null) ldapSurname = (String)att.get(); if (att != null)
{
ldapSurname = (String) att.get();
}
} }
if (attlist[3]!=null) if (attlist[3]!=null)
{ {
att = atts.get(attlist[3]); att = atts.get(attlist[3]);
if (att != null) ldapPhone = (String)att.get(); if (att != null)
{
ldapPhone = (String) att.get();
}
} }
} }
} }
@@ -422,7 +436,9 @@ public class LDAPAuthentication
try try
{ {
if (ctx != null) if (ctx != null)
{
ctx.close(); ctx.close();
}
} }
catch (NamingException e) catch (NamingException e)
{ {

View File

@@ -194,7 +194,9 @@ public class LDAPHierarchicalAuthentication
// Skip out when no netid or password is given. // Skip out when no netid or password is given.
if (netid == null || password == null) if (netid == null || password == null)
return BAD_ARGS; {
return BAD_ARGS;
}
// Locate the eperson // Locate the eperson
EPerson eperson = null; EPerson eperson = null;
@@ -451,25 +453,33 @@ public class LDAPHierarchicalAuthentication
if (attlist[0] != null) { if (attlist[0] != null) {
att = atts.get(attlist[0]); att = atts.get(attlist[0]);
if (att != null) if (att != null)
ldapEmail = (String) att.get(); {
ldapEmail = (String) att.get();
}
} }
if (attlist[1] != null) { if (attlist[1] != null) {
att = atts.get(attlist[1]); att = atts.get(attlist[1]);
if (att != null) if (att != null)
ldapGivenName = (String) att.get(); {
ldapGivenName = (String) att.get();
}
} }
if (attlist[2] != null) { if (attlist[2] != null) {
att = atts.get(attlist[2]); att = atts.get(attlist[2]);
if (att != null) if (att != null)
ldapSurname = (String) att.get(); {
ldapSurname = (String) att.get();
}
} }
if (attlist[3] != null) { if (attlist[3] != null) {
att = atts.get(attlist[3]); att = atts.get(attlist[3]);
if (att != null) if (att != null)
ldapPhone = (String) att.get(); {
ldapPhone = (String) att.get();
}
} }
if (answer.hasMoreElements()) { if (answer.hasMoreElements()) {
@@ -502,7 +512,9 @@ public class LDAPHierarchicalAuthentication
try try
{ {
if (ctx != null) if (ctx != null)
ctx.close(); {
ctx.close();
}
} }
catch (NamingException e) catch (NamingException e)
{ {
@@ -544,7 +556,9 @@ public class LDAPHierarchicalAuthentication
// Close the context when we're done // Close the context when we're done
try { try {
if (ctx != null) if (ctx != null)
ctx.close(); {
ctx.close();
}
} catch (NamingException e) { } catch (NamingException e) {
} }
} }

View File

@@ -543,7 +543,9 @@ public class IndexBrowse
DCValue value = null; DCValue value = null;
if (itemMDMap != null) if (itemMDMap != null)
{
value = (DCValue) itemMDMap.get(metadata); value = (DCValue) itemMDMap.get(metadata);
}
// We haven't used this metadata before, so grab it from the item // We haven't used this metadata before, so grab it from the item
if (value == null) if (value == null)
@@ -564,7 +566,9 @@ public class IndexBrowse
value = dcv[0]; value = dcv[0];
if (itemMDMap != null) if (itemMDMap != null)
{
itemMDMap.put(metadata, dcv[0]); itemMDMap.put(metadata, dcv[0]);
}
} }
} }

View File

@@ -120,7 +120,9 @@ public class ItemCountDAOOracle implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -160,7 +162,9 @@ public class ItemCountDAOOracle implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -302,7 +306,9 @@ public class ItemCountDAOOracle implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -344,7 +350,9 @@ public class ItemCountDAOOracle implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
} }

View File

@@ -120,7 +120,9 @@ public class ItemCountDAOPostgres implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -160,7 +162,9 @@ public class ItemCountDAOPostgres implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -302,7 +306,9 @@ public class ItemCountDAOPostgres implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -344,7 +350,9 @@ public class ItemCountDAOPostgres implements ItemCountDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
} }

View File

@@ -124,7 +124,9 @@ public class LocaleOrderingFilter implements TextFilter
RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance(locale); RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance(locale);
if (collator != null) if (collator != null)
{
return collator; return collator;
}
} }
return null; return null;
} }

View File

@@ -230,11 +230,17 @@ public class DCDate
granularity = DateGran.TIME; granularity = DateGran.TIME;
Date date = tryParse(fullIso, fromDC); Date date = tryParse(fullIso, fromDC);
if (date == null) if (date == null)
{
date = tryParse(fullIso2, fromDC); date = tryParse(fullIso2, fromDC);
}
if (date == null) if (date == null)
{
date = tryParse(fullIso3, fromDC); date = tryParse(fullIso3, fromDC);
}
if (date == null) if (date == null)
{
date = tryParse(fullIso4, fromDC); date = tryParse(fullIso4, fromDC);
}
if (date == null) if (date == null)
{ {
// Seems there is no time component to the date. // Seems there is no time component to the date.
@@ -442,7 +448,9 @@ public class DCDate
public String toString() public String toString()
{ {
if (calendar == null) if (calendar == null)
{
return "null"; return "null";
}
return toStringInternal(); return toStringInternal();
} }

View File

@@ -121,7 +121,9 @@ public class FormatIdentifier
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return retFormat; return retFormat;
} }

View File

@@ -194,7 +194,9 @@ public class InstallItem
// add date available if not under embargo, otherwise it will // add date available if not under embargo, otherwise it will
// be set when the embargo is lifted. // be set when the embargo is lifted.
if (embargoLiftDate == null) if (embargoLiftDate == null)
{
item.addDC("date", "available", null, now.toString()); item.addDC("date", "available", null, now.toString());
}
// create issue date if not present // create issue date if not present
DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY);
@@ -249,7 +251,9 @@ public class InstallItem
// set embargo lift date and take away read access if indicated. // set embargo lift date and take away read access if indicated.
if (embargoLiftDate != null) if (embargoLiftDate != null)
{
EmbargoManager.setEmbargo(c, item, embargoLiftDate); EmbargoManager.setEmbargo(c, item, embargoLiftDate);
}
return item; return item;
} }

View File

@@ -704,7 +704,9 @@ public class Item extends DSpaceObject
// authority sanity check: if authority is required, was it supplied? // authority sanity check: if authority is required, was it supplied?
// XXX FIXME? can't throw a "real" exception here without changing all the callers to expect it, so use a runtime exception // XXX FIXME? can't throw a "real" exception here without changing all the callers to expect it, so use a runtime exception
if (authorityRequired && (dcv.authority == null || dcv.authority.length() == 0)) if (authorityRequired && (dcv.authority == null || dcv.authority.length() == 0))
throw new IllegalArgumentException("The metadata field \""+fieldName+"\" requires an authority key but none was provided. Vaue=\""+dcv.value+"\""); {
throw new IllegalArgumentException("The metadata field \"" + fieldName + "\" requires an authority key but none was provided. Vaue=\"" + dcv.value + "\"");
}
} }
if (values[i] != null) if (values[i] != null)
{ {
@@ -1045,7 +1047,9 @@ public class Item extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
Collection[] collectionArray = new Collection[collections.size()]; Collection[] collectionArray = new Collection[collections.size()];
@@ -1099,7 +1103,9 @@ public class Item extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
Community[] communityArray = new Community[communities.size()]; Community[] communityArray = new Community[communities.size()];
@@ -1149,7 +1155,9 @@ public class Item extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -1328,7 +1336,9 @@ public class Item extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -1623,11 +1633,15 @@ public class Item extends DSpaceObject
// Check the metadata field is the same // Check the metadata field is the same
if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id")) if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id"))
{
matched = false; matched = false;
}
// Check the place is the same // Check the place is the same
if (matched && placeNum[dcIdx] != tr.getIntColumn("place")) if (matched && placeNum[dcIdx] != tr.getIntColumn("place"))
{
matched = false; matched = false;
}
// Check the text is the same // Check the text is the same
if (matched) if (matched)
@@ -1673,7 +1687,9 @@ public class Item extends DSpaceObject
if (!((dcv.authority == null && auth == null) || if (!((dcv.authority == null && auth == null) ||
(dcv.authority != null && auth != null && dcv.authority.equals(auth)) (dcv.authority != null && auth != null && dcv.authority.equals(auth))
&& dcv.confidence == conf)) && dcv.confidence == conf))
{
matched = false; matched = false;
}
} }
// If the db record is identical to the in memory values // If the db record is identical to the in memory values
@@ -2022,8 +2038,14 @@ public class Item extends DSpaceObject
return false; return false;
} }
final Item other = (Item) obj; final Item other = (Item) obj;
if (this.getType() != other.getType()) return false; if (this.getType() != other.getType())
if (this.getID() != other.getID()) return false; {
return false;
}
if (this.getID() != other.getID())
{
return false;
}
return true; return true;
} }
@@ -2384,11 +2406,15 @@ public class Item extends DSpaceObject
{ {
MetadataSchema mds = MetadataSchema.find(context, schema); MetadataSchema mds = MetadataSchema.find(context, schema);
if (mds == null) if (mds == null)
throw new IllegalArgumentException("No such metadata schema: "+schema); {
throw new IllegalArgumentException("No such metadata schema: " + schema);
}
MetadataField mdf = MetadataField.findByElement(context, mds.getSchemaID(), element, qualifier); MetadataField mdf = MetadataField.findByElement(context, mds.getSchemaID(), element, qualifier);
if (mdf == null) if (mdf == null)
{
throw new IllegalArgumentException( throw new IllegalArgumentException(
"No such metadata field: schema="+schema+", element="+element+", qualifier="+qualifier); "No such metadata field: schema=" + schema + ", element=" + element + ", qualifier=" + qualifier);
}
String query = "SELECT item.* FROM metadatavalue,item WHERE item.in_archive='1' "+ String query = "SELECT item.* FROM metadatavalue,item WHERE item.in_archive='1' "+
"AND item.item_id = metadatavalue.item_id AND metadata_field_id = ?"; "AND item.item_id = metadatavalue.item_id AND metadata_field_id = ?";
@@ -2558,10 +2584,14 @@ public class Item extends DSpaceObject
{ {
MetadataSchema mds = MetadataSchema.find(context, schema); MetadataSchema mds = MetadataSchema.find(context, schema);
if (mds == null) if (mds == null)
throw new IllegalArgumentException("No such metadata schema: "+schema); {
throw new IllegalArgumentException("No such metadata schema: " + schema);
}
MetadataField mdf = MetadataField.findByElement(context, mds.getSchemaID(), element, qualifier); MetadataField mdf = MetadataField.findByElement(context, mds.getSchemaID(), element, qualifier);
if (mdf == null) if (mdf == null)
throw new IllegalArgumentException("No such metadata field: schema="+schema+", element="+element+", qualifier="+qualifier); {
throw new IllegalArgumentException("No such metadata field: schema=" + schema + ", element=" + element + ", qualifier=" + qualifier);
}
TableRowIterator rows = DatabaseManager.queryTable(context, "item", TableRowIterator rows = DatabaseManager.queryTable(context, "item",
"SELECT item.* FROM metadatavalue,item WHERE item.in_archive='1' "+ "SELECT item.* FROM metadatavalue,item WHERE item.in_archive='1' "+
@@ -2650,7 +2680,9 @@ public class Item extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
} }

View File

@@ -275,6 +275,8 @@ public class ItemIterator
public void close() public void close()
{ {
if (itemRows != null) if (itemRows != null)
{
itemRows.close(); itemRows.close();
}
} }
} }

View File

@@ -332,7 +332,9 @@ public class MetadataField
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
if (row == null) if (row == null)
@@ -372,7 +374,9 @@ public class MetadataField
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// Convert list into an array // Convert list into an array
@@ -410,7 +414,9 @@ public class MetadataField
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// Convert list into an array // Convert list into an array
@@ -629,7 +635,9 @@ public class MetadataField
// 'sanity check' first. // 'sanity check' first.
Integer iid = Integer.valueOf(id); Integer iid = Integer.valueOf(id);
if (!id2field.containsKey(iid)) if (!id2field.containsKey(iid))
{
return null; return null;
}
return (MetadataField) id2field.get(iid); return (MetadataField) id2field.get(iid);
} }
@@ -670,7 +678,9 @@ public class MetadataField
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
id2field = new_id2field; id2field = new_id2field;

View File

@@ -306,7 +306,9 @@ public class MetadataSchema
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
if (row == null) if (row == null)
@@ -411,7 +413,9 @@ public class MetadataSchema
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// Convert list into an array // Convert list into an array
@@ -545,7 +549,9 @@ public class MetadataSchema
// sanity check // sanity check
if (!id2schema.containsKey(iid)) if (!id2schema.containsKey(iid))
{
return null; return null;
}
return (MetadataSchema) id2schema.get(iid); return (MetadataSchema) id2schema.get(iid);
} }
@@ -565,7 +571,9 @@ public class MetadataSchema
{ {
// If we are not passed a valid schema name then return // If we are not passed a valid schema name then return
if (shortName == null) if (shortName == null)
{
return null; return null;
}
if (!isCacheInitialized()) if (!isCacheInitialized())
{ {
@@ -573,7 +581,9 @@ public class MetadataSchema
} }
if (!name2schema.containsKey(shortName)) if (!name2schema.containsKey(shortName))
{
return null; return null;
}
return (MetadataSchema) name2schema.get(shortName); return (MetadataSchema) name2schema.get(shortName);
} }
@@ -617,7 +627,9 @@ public class MetadataSchema
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
id2schema = new_id2schema; id2schema = new_id2schema;

View File

@@ -338,7 +338,9 @@ public class MetadataValue
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
if (row == null) if (row == null)
@@ -383,7 +385,9 @@ public class MetadataValue
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return ret; return ret;

View File

@@ -89,7 +89,9 @@ public class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
try try
{ {
if (dci == null) if (dci == null)
{
dci = new DCInputsReader(); dci = new DCInputsReader();
}
} }
catch (DCInputsReaderException e) catch (DCInputsReaderException e)
{ {
@@ -144,7 +146,9 @@ public class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
{ {
v[i] = new Choice(values[i], values[i], labels[i]); v[i] = new Choice(values[i], values[i], labels[i]);
if (values[i].equalsIgnoreCase(query)) if (values[i].equalsIgnoreCase(query))
{
dflt = i; dflt = i;
}
} }
return new Choices(v, 0, v.length, Choices.CF_AMBIGUOUS, false, dflt); return new Choices(v, 0, v.length, Choices.CF_AMBIGUOUS, false, dflt);
} }

View File

@@ -106,7 +106,9 @@ public class LCNameAuthority implements ChoiceAuthority
// sanity check // sanity check
if (url == null) if (url == null)
{
throw new IllegalStateException("Missing DSpace configuration keys for LCName Query"); throw new IllegalStateException("Missing DSpace configuration keys for LCName Query");
}
} }
} }
@@ -159,7 +161,9 @@ public class LCNameAuthority implements ChoiceAuthority
// XXX arbitrary default limit - should be configurable? // XXX arbitrary default limit - should be configurable?
if (limit == 0) if (limit == 0)
{
limit = 50; limit = 50;
}
NameValuePair args[] = new NameValuePair[6]; NameValuePair args[] = new NameValuePair[6];
args[0] = new NameValuePair("operation", "searchRetrieve"); args[0] = new NameValuePair("operation", "searchRetrieve");
@@ -194,8 +198,10 @@ public class LCNameAuthority implements ChoiceAuthority
// this probably just means more results available.. // this probably just means more results available..
if (handler.hits != handler.result.size()) if (handler.hits != handler.result.size())
log.warn("Discrepency in results, result.length="+handler.result.size()+ {
", yet expected results="+handler.hits); log.warn("Discrepency in results, result.length=" + handler.result.size() +
", yet expected results=" + handler.hits);
}
boolean more = handler.hits > (start + handler.result.size()); boolean more = handler.hits > (start + handler.result.size());
// XXX add non-auth option; perhaps the UI should do this? // XXX add non-auth option; perhaps the UI should do this?
@@ -311,7 +317,9 @@ public class LCNameAuthority implements ChoiceAuthority
{ {
// HACK: many LC name entries end with ',' ...trim it. // HACK: many LC name entries end with ',' ...trim it.
if (name.endsWith(",")) if (name.endsWith(","))
name = name.substring(0, name.length()-1); {
name = name.substring(0, name.length() - 1);
}
// XXX DEBUG // XXX DEBUG
// log.debug("Got result, name="+name+", lccn="+lccn); // log.debug("Got result, name="+name+", lccn="+lccn);
@@ -341,8 +349,10 @@ public class LCNameAuthority implements ChoiceAuthority
name = textValue; name = textValue;
} }
if (lastTag.equals("100") && lastCode.equals("d") && (name != null)) if (lastTag.equals("100") && lastCode.equals("d") && (name != null))
name = name+" "+textValue; {
name = name + " " + textValue;
}
} }
} }
@@ -360,14 +370,18 @@ public class LCNameAuthority implements ChoiceAuthority
{ {
lastTag = atts.getValue("tag"); lastTag = atts.getValue("tag");
if (lastTag == null) if (lastTag == null)
{
log.warn("MARC datafield without tag attribute!"); log.warn("MARC datafield without tag attribute!");
}
} }
else if (localName.equals("subfield") && else if (localName.equals("subfield") &&
namespaceURI.equals(NS_MX)) namespaceURI.equals(NS_MX))
{ {
lastCode = atts.getValue("code"); lastCode = atts.getValue("code");
if (lastCode == null) if (lastCode == null)
{
log.warn("MARC subfield without code attribute!"); log.warn("MARC subfield without code attribute!");
}
} }
} }

View File

@@ -136,7 +136,9 @@ public class MetadataAuthorityManager
// get minConfidence level for this field if any // get minConfidence level for this field if any
int mci = readConfidence("authority.minconfidence."+field); int mci = readConfidence("authority.minconfidence."+field);
if (mci >= Choices.CF_UNSET) if (mci >= Choices.CF_UNSET)
{
minConfidence.put(fkey, Integer.valueOf(mci)); minConfidence.put(fkey, Integer.valueOf(mci));
}
log.debug("Authority Control: For schema="+schema+", elt="+element+", qual="+qualifier+", controlled="+ctl+", required="+req); log.debug("Authority Control: For schema="+schema+", elt="+element+", qual="+qualifier+", controlled="+ctl+", required="+req);
} }
} }
@@ -144,7 +146,9 @@ public class MetadataAuthorityManager
// get default min confidence if any: // get default min confidence if any:
int dmc = readConfidence("authority.minconfidence"); int dmc = readConfidence("authority.minconfidence");
if (dmc >= Choices.CF_UNSET) if (dmc >= Choices.CF_UNSET)
{
defaultMinConfidence = dmc; defaultMinConfidence = dmc;
}
} }
private int readConfidence(String key) private int readConfidence(String key)

View File

@@ -79,7 +79,9 @@ public class CreativeCommonsRDFStreamIngestionCrosswalk
if (dso.getType() == Constants.ITEM) if (dso.getType() == Constants.ITEM)
{ {
if (log.isDebugEnabled()) if (log.isDebugEnabled())
log.debug("Reading a Creative Commons license, MIMEtype="+MIMEType); {
log.debug("Reading a Creative Commons license, MIMEtype=" + MIMEType);
}
CreativeCommons.setLicense(context, (Item)dso, in, MIMEType); CreativeCommons.setLicense(context, (Item)dso, in, MIMEType);
} }

View File

@@ -99,7 +99,9 @@ public class DIMDisseminationCrosswalk
public Element disseminateElement(DSpaceObject dso) throws CrosswalkException, IOException, SQLException, AuthorizeException public Element disseminateElement(DSpaceObject dso) throws CrosswalkException, IOException, SQLException, AuthorizeException
{ {
if (dso.getType() != Constants.ITEM) if (dso.getType() != Constants.ITEM)
{
throw new CrosswalkObjectNotSupported("DIMDisseminationCrosswalk can only crosswalk an Item."); throw new CrosswalkObjectNotSupported("DIMDisseminationCrosswalk can only crosswalk an Item.");
}
Item item = (Item)dso; Item item = (Item)dso;
DCValue[] dc = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); DCValue[] dc = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
@@ -110,11 +112,17 @@ public class DIMDisseminationCrosswalk
field.setAttribute("mdschema", dc[i].schema); field.setAttribute("mdschema", dc[i].schema);
field.setAttribute("element", dc[i].element); field.setAttribute("element", dc[i].element);
if (dc[i].qualifier != null) if (dc[i].qualifier != null)
{
field.setAttribute("qualifier", dc[i].qualifier); field.setAttribute("qualifier", dc[i].qualifier);
}
if (dc[i].language != null) if (dc[i].language != null)
{
field.setAttribute("lang", dc[i].language); field.setAttribute("lang", dc[i].language);
}
if (dc[i].value != null) if (dc[i].value != null)
{
field.setText(dc[i].value); field.setText(dc[i].value);
}
dim.addContent(field); dim.addContent(field);
} }
return dim; return dim;

View File

@@ -88,7 +88,9 @@ public class DIMIngestionCrosswalk
public void ingest(Context context, DSpaceObject dso, Element root) throws CrosswalkException, IOException, SQLException, AuthorizeException { public void ingest(Context context, DSpaceObject dso, Element root) throws CrosswalkException, IOException, SQLException, AuthorizeException {
if (dso.getType() != Constants.ITEM) if (dso.getType() != Constants.ITEM)
{
throw new CrosswalkObjectNotSupported("DIMIngestionCrosswalk can only crosswalk an Item."); throw new CrosswalkObjectNotSupported("DIMIngestionCrosswalk can only crosswalk an Item.");
}
Item item = (Item)dso; Item item = (Item)dso;
if (root == null) { if (root == null) {

View File

@@ -81,7 +81,9 @@ public class LicenseStreamIngestionCrosswalk
if (dso.getType() == Constants.ITEM) if (dso.getType() == Constants.ITEM)
{ {
if (log.isDebugEnabled()) if (log.isDebugEnabled())
log.debug("Reading a DSpace Deposit license, MIMEtype="+MIMEType); {
log.debug("Reading a DSpace Deposit license, MIMEtype=" + MIMEType);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
Utils.copy(in, baos); Utils.copy(in, baos);

View File

@@ -127,13 +127,17 @@ public class METSDisseminationCrosswalk
IOException, SQLException, AuthorizeException IOException, SQLException, AuthorizeException
{ {
if (dso.getType() != Constants.ITEM) if (dso.getType() != Constants.ITEM)
{
throw new CrosswalkObjectNotSupported("METSDisseminationCrosswalk can only crosswalk an Item."); throw new CrosswalkObjectNotSupported("METSDisseminationCrosswalk can only crosswalk an Item.");
}
Item item = (Item)dso; Item item = (Item)dso;
PackageDisseminator dip = (PackageDisseminator) PackageDisseminator dip = (PackageDisseminator)
PluginManager.getNamedPlugin(PackageDisseminator.class, METS_PACKAGER_PLUGIN); PluginManager.getNamedPlugin(PackageDisseminator.class, METS_PACKAGER_PLUGIN);
if (dip == null) if (dip == null)
throw new CrosswalkInternalException("Cannot find a disseminate plugin for package="+METS_PACKAGER_PLUGIN); {
throw new CrosswalkInternalException("Cannot find a disseminate plugin for package=" + METS_PACKAGER_PLUGIN);
}
try try
{ {

View File

@@ -385,7 +385,9 @@ public class METSRightsCrosswalk
throws CrosswalkException, IOException, SQLException, AuthorizeException throws CrosswalkException, IOException, SQLException, AuthorizeException
{ {
if (!(root.getName().equals("RightsDeclarationMD"))) if (!(root.getName().equals("RightsDeclarationMD")))
throw new MetadataValidationException("Wrong root element for METSRights: "+root.toString()); {
throw new MetadataValidationException("Wrong root element for METSRights: " + root.toString());
}
ingest(context, dso, root.getChildren()); ingest(context, dso, root.getChildren());
} }
@@ -416,12 +418,16 @@ public class METSRightsCrosswalk
{ {
// we cannot crosswalk METSRights to a SITE object // we cannot crosswalk METSRights to a SITE object
if (dso.getType() == Constants.SITE) if (dso.getType() == Constants.SITE)
{
throw new CrosswalkObjectNotSupported("Wrong target object type, METSRightsCrosswalk cannot crosswalk a SITE object."); throw new CrosswalkObjectNotSupported("Wrong target object type, METSRightsCrosswalk cannot crosswalk a SITE object.");
}
//First, clear all existing Policies on this DSpace Object //First, clear all existing Policies on this DSpace Object
// as we don't want them to conflict with policies we will be adding // as we don't want them to conflict with policies we will be adding
if(!ml.isEmpty()) if(!ml.isEmpty())
{
AuthorizeManager.removeAllPolicies(context, dso); AuthorizeManager.removeAllPolicies(context, dso);
}
// Loop through each Element in the List // Loop through each Element in the List
Iterator mi = ml.iterator(); Iterator mi = ml.iterator();
@@ -449,7 +455,9 @@ public class METSRightsCrosswalk
//get DSpace Anonymous group, ID=0 //get DSpace Anonymous group, ID=0
Group anonGroup = Group.find(context, 0); Group anonGroup = Group.find(context, 0);
if(anonGroup==null) if(anonGroup==null)
{
throw new CrosswalkInternalException("The DSpace database has not been properly initialized. The Anonymous Group is missing from the database."); throw new CrosswalkInternalException("The DSpace database has not been properly initialized. The Anonymous Group is missing from the database.");
}
assignPermissions(context, dso, anonGroup, permsElement); assignPermissions(context, dso, anonGroup, permsElement);
} // else if this permission declaration pertains to Administrators } // else if this permission declaration pertains to Administrators
@@ -458,7 +466,9 @@ public class METSRightsCrosswalk
//get DSpace Administrator group, ID=1 //get DSpace Administrator group, ID=1
Group adminGroup = Group.find(context, 1); Group adminGroup = Group.find(context, 1);
if(adminGroup==null) if(adminGroup==null)
{
throw new CrosswalkInternalException("The DSpace database has not been properly initialized. The Administrator Group is missing from the database."); throw new CrosswalkInternalException("The DSpace database has not been properly initialized. The Administrator Group is missing from the database.");
}
assignPermissions(context, dso, adminGroup, permsElement); assignPermissions(context, dso, adminGroup, permsElement);
} // else if this permission pertains to another DSpace group } // else if this permission pertains to another DSpace group
@@ -512,7 +522,9 @@ public class METSRightsCrosswalk
//If cannot find by email, try by netID //If cannot find by email, try by netID
//(though METSRights should contain email if it was exported by DSpace) //(though METSRights should contain email if it was exported by DSpace)
if(person==null) if(person==null)
{
person = EPerson.findByNetid(context, personEmail); person = EPerson.findByNetid(context, personEmail);
}
//if not found, throw an error -- user should restore person from the SITE AIP //if not found, throw an error -- user should restore person from the SITE AIP
if(person==null) if(person==null)
@@ -621,7 +633,9 @@ public class METSRightsCrosswalk
{ {
//if found, this is the Action ID corresponding to this permission //if found, this is the Action ID corresponding to this permission
if(otherTypesMapping.get(actionType).equals(otherPermitType)) if(otherTypesMapping.get(actionType).equals(otherPermitType))
{
return actionType; return actionType;
}
} }
} }
else else

View File

@@ -129,7 +129,9 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
{ {
String key = (String)pe.nextElement(); String key = (String)pe.nextElement();
if (key.startsWith(CONFIG_PREFIX)) if (key.startsWith(CONFIG_PREFIX))
{
aliasList.add(key.substring(CONFIG_PREFIX.length())); aliasList.add(key.substring(CONFIG_PREFIX.length()));
}
} }
aliases = (String[])aliasList.toArray(new String[aliasList.size()]); aliases = (String[])aliasList.toArray(new String[aliasList.size()]);
} }
@@ -240,7 +242,9 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
throws CrosswalkInternalException throws CrosswalkInternalException
{ {
if (modsMap != null) if (modsMap != null)
{
return; return;
}
String myAlias = getPluginInstanceName(); String myAlias = getPluginInstanceName();
if (myAlias == null) if (myAlias == null)
{ {
@@ -277,7 +281,15 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
finally finally
{ {
if (pfs != null) if (pfs != null)
try { pfs.close(); } catch (IOException ioe) { } {
try
{
pfs.close();
}
catch (IOException ioe)
{
}
}
} }
modsMap = new HashMap(); modsMap = new HashMap();
@@ -296,7 +308,9 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
{ {
modsTriple trip = modsTriple.create(qdc, pair[0], pair[1]); modsTriple trip = modsTriple.create(qdc, pair[0], pair[1]);
if (trip != null) if (trip != null)
{
modsMap.put(qdc, trip); modsMap.put(qdc, trip);
}
} }
} }
} }
@@ -390,13 +404,17 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
{ {
Element me = (Element)trip.xml.clone(); Element me = (Element)trip.xml.clone();
if (addSchema) if (addSchema)
{
me.setAttribute("schemaLocation", schemaLocation, XSI_NS); me.setAttribute("schemaLocation", schemaLocation, XSI_NS);
}
Iterator ni = trip.xpath.selectNodes(me).iterator(); Iterator ni = trip.xpath.selectNodes(me).iterator();
if (!ni.hasNext()) if (!ni.hasNext())
log.warn("XPath \""+trip.xpath.getXPath()+ {
"\" found no elements in \""+ log.warn("XPath \"" + trip.xpath.getXPath() +
outputUgly.outputString(me)+ "\" found no elements in \"" +
"\", qdc="+qdc); outputUgly.outputString(me) +
"\", qdc=" + qdc);
}
while (ni.hasNext()) while (ni.hasNext())
{ {
Object what = ni.next(); Object what = ni.next();
@@ -468,14 +486,20 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String url = site.getURL(); String url = site.getURL();
if (identifier_uri != null) if (identifier_uri != null)
{
metadata.add(createDCValue("identifier.uri", null, identifier_uri)); metadata.add(createDCValue("identifier.uri", null, identifier_uri));
}
//FIXME: adding two URIs for now (site handle and URL), in case site isn't using handles //FIXME: adding two URIs for now (site handle and URL), in case site isn't using handles
if (url != null) if (url != null)
{
metadata.add(createDCValue("identifier.uri", null, url)); metadata.add(createDCValue("identifier.uri", null, url));
}
if (title != null) if (title != null)
{
metadata.add(createDCValue("title", null, title)); metadata.add(createDCValue("title", null, title));
}
return (DCValue[]) metadata.toArray(new DCValue[metadata.size()]); return (DCValue[]) metadata.toArray(new DCValue[metadata.size()]);
} }
@@ -500,22 +524,34 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String title = community.getMetadata("name"); String title = community.getMetadata("name");
if (description != null) if (description != null)
{
metadata.add(createDCValue("description", null, description)); metadata.add(createDCValue("description", null, description));
}
if (description_abstract != null) if (description_abstract != null)
{
metadata.add(createDCValue("description", "abstract", description_abstract)); metadata.add(createDCValue("description", "abstract", description_abstract));
}
if (description_table != null) if (description_table != null)
{
metadata.add(createDCValue("description", "tableofcontents", description_table)); metadata.add(createDCValue("description", "tableofcontents", description_table));
}
if (identifier_uri != null) if (identifier_uri != null)
{
metadata.add(createDCValue("identifier.uri", null, identifier_uri)); metadata.add(createDCValue("identifier.uri", null, identifier_uri));
}
if (rights != null) if (rights != null)
{
metadata.add(createDCValue("rights", null, rights)); metadata.add(createDCValue("rights", null, rights));
}
if (title != null) if (title != null)
{
metadata.add(createDCValue("title", null, title)); metadata.add(createDCValue("title", null, title));
}
return (DCValue[]) metadata.toArray(new DCValue[metadata.size()]); return (DCValue[]) metadata.toArray(new DCValue[metadata.size()]);
} }
@@ -543,28 +579,44 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String title = collection.getMetadata("name"); String title = collection.getMetadata("name");
if (description != null) if (description != null)
metadata.add(createDCValue("description",null, description)); {
metadata.add(createDCValue("description", null, description));
}
if (description_abstract != null) if (description_abstract != null)
metadata.add(createDCValue("description","abstract",description_abstract)); {
metadata.add(createDCValue("description", "abstract", description_abstract));
}
if (description_table != null) if (description_table != null)
metadata.add(createDCValue("description","tableofcontents",description_table)); {
metadata.add(createDCValue("description", "tableofcontents", description_table));
}
if (identifier_uri != null) if (identifier_uri != null)
metadata.add(createDCValue("identifier","uri", identifier_uri)); {
metadata.add(createDCValue("identifier", "uri", identifier_uri));
}
if (provenance != null) if (provenance != null)
{
metadata.add(createDCValue("provenance", null, provenance)); metadata.add(createDCValue("provenance", null, provenance));
}
if (rights != null) if (rights != null)
{
metadata.add(createDCValue("rights", null, rights)); metadata.add(createDCValue("rights", null, rights));
}
if (rights_license != null) if (rights_license != null)
{
metadata.add(createDCValue("rights.license", null, rights_license)); metadata.add(createDCValue("rights.license", null, rights_license));
}
if (title != null) if (title != null)
{
metadata.add(createDCValue("title", null, title)); metadata.add(createDCValue("title", null, title));
}
return (DCValue[]) metadata.toArray(new DCValue[metadata.size()]); return (DCValue[]) metadata.toArray(new DCValue[metadata.size()]);
} }
@@ -615,7 +667,9 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
{ {
char c = value.charAt(i); char c = value.charAt(i);
if (Verifier.isXMLCharacter((int)c)) if (Verifier.isXMLCharacter((int)c))
{
result.append(c); result.append(c);
}
} }
return result.toString(); return result.toString();
} }

View File

@@ -80,7 +80,9 @@ public class OAIDCIngestionCrosswalk
public void ingest(Context context, DSpaceObject dso, Element root) throws CrosswalkException, IOException, SQLException, AuthorizeException { public void ingest(Context context, DSpaceObject dso, Element root) throws CrosswalkException, IOException, SQLException, AuthorizeException {
if (dso.getType() != Constants.ITEM) if (dso.getType() != Constants.ITEM)
{
throw new CrosswalkObjectNotSupported("DIMIngestionCrosswalk can only crosswalk an Item."); throw new CrosswalkObjectNotSupported("DIMIngestionCrosswalk can only crosswalk an Item.");
}
Item item = (Item)dso; Item item = (Item)dso;
if (root == null) { if (root == null) {

View File

@@ -100,7 +100,9 @@ public class ItemDAOPostgres extends ItemDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return null; return null;
@@ -123,7 +125,9 @@ public class ItemDAOPostgres extends ItemDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return null; return null;
@@ -146,7 +150,9 @@ public class ItemDAOPostgres extends ItemDAO
finally finally
{ {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return null; return null;

View File

@@ -194,7 +194,9 @@ public class DSpaceAIPDisseminator
// Add a LASTMODDATE for items // Add a LASTMODDATE for items
if (dso.getType() == Constants.ITEM) if (dso.getType() == Constants.ITEM)
metsHdr.setLASTMODDATE(((Item)dso).getLastModified()); {
metsHdr.setLASTMODDATE(((Item) dso).getLastModified());
}
// Agent Custodian - name custodian, the DSpace Archive, by handle. // Agent Custodian - name custodian, the DSpace Archive, by handle.
Agent agent = new Agent(); Agent agent = new Agent();
@@ -387,14 +389,18 @@ public class DSpaceAIPDisseminator
//By default, disseminate Deposit License, and any CC Licenses //By default, disseminate Deposit License, and any CC Licenses
// to an item's rightsMD section // to an item's rightsMD section
if (PackageUtils.findDepositLicense(context, (Item)dso) != null) if (PackageUtils.findDepositLicense(context, (Item)dso) != null)
{
result.add(DSPACE_DEPOSIT_LICENSE_MDTYPE); result.add(DSPACE_DEPOSIT_LICENSE_MDTYPE);
}
if (CreativeCommons.getLicenseRdfBitstream((Item)dso) != null) if (CreativeCommons.getLicenseRdfBitstream((Item)dso) != null)
{ {
result.add(CREATIVE_COMMONS_RDF_MDTYPE); result.add(CREATIVE_COMMONS_RDF_MDTYPE);
} }
else if (CreativeCommons.getLicenseTextBitstream((Item)dso) != null) else if (CreativeCommons.getLicenseTextBitstream((Item)dso) != null)
{
result.add(CREATIVE_COMMONS_TEXT_MDTYPE); result.add(CREATIVE_COMMONS_TEXT_MDTYPE);
}
} }
//By default, also add METSRights info to the rightsMD //By default, also add METSRights info to the rightsMD
@@ -440,7 +446,9 @@ public class DSpaceAIPDisseminator
{ {
Item bi[] = bn[0].getItems(); Item bi[] = bn[0].getItems();
if (bi.length > 0) if (bi.length > 0)
{
handle = bi[0].getHandle(); handle = bi[0].getHandle();
}
} }
if (handle != null) if (handle != null)
{ {

View File

@@ -117,7 +117,9 @@ public class DSpaceAIPIngester
throw new MetadataValidationException("Cannot accept METS with no PROFILE attribute!"); throw new MetadataValidationException("Cannot accept METS with no PROFILE attribute!");
} }
else if (!profile.equals(DSpaceAIPDisseminator.PROFILE_1_0)) else if (!profile.equals(DSpaceAIPDisseminator.PROFILE_1_0))
throw new MetadataValidationException("METS has unacceptable PROFILE attribute, profile="+profile); {
throw new MetadataValidationException("METS has unacceptable PROFILE attribute, profile=" + profile);
}
} }
@@ -144,7 +146,9 @@ public class DSpaceAIPIngester
// Check to see what dmdSec the user specified in the 'dmd' parameter // Check to see what dmdSec the user specified in the 'dmd' parameter
String userDmd = null; String userDmd = null;
if (params != null) if (params != null)
{
userDmd = params.getProperty("dmd"); userDmd = params.getProperty("dmd");
}
if (userDmd != null && userDmd.length() > 0) if (userDmd != null && userDmd.length() > 0)
{ {
for (int i = 0; i < dmds.length; ++i) for (int i = 0; i < dmds.length; ++i)
@@ -197,7 +201,9 @@ public class DSpaceAIPIngester
{ {
String g = dmds[i].getAttributeValue("GROUPID"); String g = dmds[i].getAttributeValue("GROUPID");
if (g != null && !g.equals(groupID)) if (g != null && !g.equals(groupID))
{
manifest.crosswalkItemDmd(context, params, dso, dmds[i], callback); manifest.crosswalkItemDmd(context, params, dso, dmds[i], callback);
}
} }
} }
} }
@@ -248,7 +254,9 @@ public class DSpaceAIPIngester
} }
if(newLicense) if(newLicense)
{
PackageUtils.addDepositLicense(context, license, item, collection); PackageUtils.addDepositLicense(context, license, item, collection);
}
} }
/** /**
@@ -306,12 +314,18 @@ public class DSpaceAIPIngester
Element mets = manifest.getMets(); Element mets = manifest.getMets();
String typeStr = mets.getAttributeValue("TYPE"); String typeStr = mets.getAttributeValue("TYPE");
if (typeStr == null || typeStr.length() == 0) if (typeStr == null || typeStr.length() == 0)
{
throw new PackageValidationException("Manifest is missing the required mets@TYPE attribute."); throw new PackageValidationException("Manifest is missing the required mets@TYPE attribute.");
}
if (typeStr.startsWith("DSpace ")) if (typeStr.startsWith("DSpace "))
{
typeStr = typeStr.substring(7); typeStr = typeStr.substring(7);
}
int type = Constants.getTypeID(typeStr); int type = Constants.getTypeID(typeStr);
if (type < 0) if (type < 0)
throw new PackageValidationException("Manifest has unrecognized value in mets@TYPE attribute: "+typeStr); {
throw new PackageValidationException("Manifest has unrecognized value in mets@TYPE attribute: " + typeStr);
}
return type; return type;
} }

View File

@@ -184,7 +184,9 @@ public class DSpaceMETSDisseminator
String result[] = null; String result[] = null;
if (params != null) if (params != null)
{
result = params.getProperties("dmd"); result = params.getProperties("dmd");
}
if (result == null || result.length == 0) if (result == null || result.length == 0)
{ {
result = new String[1]; result = new String[1];

View File

@@ -124,7 +124,9 @@ public class DSpaceMETSIngester
// Check to see what dmdSec the user specified in the 'dmd' parameter // Check to see what dmdSec the user specified in the 'dmd' parameter
String userDmd = null; String userDmd = null;
if (params != null) if (params != null)
{
userDmd = params.getProperty("dmd"); userDmd = params.getProperty("dmd");
}
if (userDmd != null && userDmd.length() > 0) if (userDmd != null && userDmd.length() > 0)
{ {
for (int i = 0; i < dmds.length; ++i) for (int i = 0; i < dmds.length; ++i)
@@ -176,17 +178,20 @@ public class DSpaceMETSIngester
{ {
String g = dmds[i].getAttributeValue("GROUPID"); String g = dmds[i].getAttributeValue("GROUPID");
if (g != null && !g.equals(groupID)) if (g != null && !g.equals(groupID))
{
manifest.crosswalkItemDmd(context, params, dso, dmds[i], callback); manifest.crosswalkItemDmd(context, params, dso, dmds[i], callback);
}
} }
} }
} }
// otherwise take the first. Don't xwalk more than one because
// each xwalk _adds_ metadata, and could add duplicate fields.
else else
{ {
// otherwise take the first. Don't xwalk more than one because
// each xwalk _adds_ metadata, and could add duplicate fields.
if (dmds.length > 0) if (dmds.length > 0)
{
manifest.crosswalkItemDmd(context, params, dso, dmds[0], callback); manifest.crosswalkItemDmd(context, params, dso, dmds[0], callback);
}
} }
} }
@@ -204,7 +209,9 @@ public class DSpaceMETSIngester
AuthorizeException, SQLException, IOException AuthorizeException, SQLException, IOException
{ {
if (PackageUtils.findDepositLicense(context, item) == null) if (PackageUtils.findDepositLicense(context, item) == null)
PackageUtils.addDepositLicense(context, license, item, collection); {
PackageUtils.addDepositLicense(context, license, item, collection);
}
} }
@Override @Override
@@ -231,13 +238,16 @@ public class DSpaceMETSIngester
String mfNames[] = PluginManager.getAllPluginNames(MediaFilter.class); String mfNames[] = PluginManager.getAllPluginNames(MediaFilter.class);
for (int i = 0; i < mfNames.length; ++i) for (int i = 0; i < mfNames.length; ++i)
{ {
MediaFilter mf = (MediaFilter)PluginManager.getNamedPlugin(MediaFilter.class, mfNames[i]); MediaFilter mf = (MediaFilter)PluginManager.getNamedPlugin(MediaFilter.class, mfNames[i]);
if (bundleName.equals(mf.getBundleName())) if (bundleName.equals(mf.getBundleName()))
{
return mf.getFilteredName(origName); return mf.getFilteredName(origName);
} }
}
return null; return null;
} }
/** /**
* Take a second pass over files to correct names of derived files * Take a second pass over files to correct names of derived files

View File

@@ -233,7 +233,9 @@ public class METSManifest
{ {
String u = xsd.toURL().toString(); String u = xsd.toURL().toString();
if (result.length() > 0) if (result.length() > 0)
{
result.append(" "); result.append(" ");
}
result.append(val[0]).append(" ").append(u); result.append(val[0]).append(" ").append(u);
} }
catch (java.net.MalformedURLException e) catch (java.net.MalformedURLException e)
@@ -288,15 +290,16 @@ public class METSManifest
// Set validation feature // Set validation feature
if (validate) if (validate)
builder.setFeature("http://apache.org/xml/features/validation/schema", {
true); builder.setFeature("http://apache.org/xml/features/validation/schema", true);
}
// Tell the parser where local copies of schemas are, to speed up // Tell the parser where local copies of schemas are, to speed up
// validation. Local XSDs are identified in the configuration file. // validation. Local XSDs are identified in the configuration file.
if (localSchemas.length() > 0) if (localSchemas.length() > 0)
builder.setProperty( {
"http://apache.org/xml/properties/schema/external-schemaLocation", builder.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", localSchemas);
localSchemas); }
// Parse the METS file // Parse the METS file
Document metsDocument; Document metsDocument;
@@ -351,11 +354,15 @@ public class METSManifest
throws MetadataValidationException throws MetadataValidationException
{ {
if (contentFiles != null) if (contentFiles != null)
{
return contentFiles; return contentFiles;
}
Element fileSec = mets.getChild("fileSec", metsNS); Element fileSec = mets.getChild("fileSec", metsNS);
if (fileSec == null) if (fileSec == null)
{
throw new MetadataValidationException("Invalid METS Manifest: DSpace requires a fileSec element, but it is missing."); throw new MetadataValidationException("Invalid METS Manifest: DSpace requires a fileSec element, but it is missing.");
}
contentFiles = new ArrayList(); contentFiles = new ArrayList();
Iterator fgi = fileSec.getChildren("fileGrp", metsNS).iterator(); Iterator fgi = fileSec.getChildren("fileGrp", metsNS).iterator();
@@ -415,7 +422,9 @@ public class METSManifest
{ {
String groupID = file.getAttributeValue("GROUPID"); String groupID = file.getAttributeValue("GROUPID");
if (groupID == null || groupID.equals("")) if (groupID == null || groupID.equals(""))
{
return null; return null;
}
try try
{ {
@@ -426,10 +435,14 @@ public class METSManifest
if (oFiles.size() > 0) if (oFiles.size() > 0)
{ {
if (log.isDebugEnabled()) if (log.isDebugEnabled())
log.debug("Got ORIGINAL file for derived="+file.toString()); {
log.debug("Got ORIGINAL file for derived=" + file.toString());
}
Element flocat = ((Element)oFiles.get(0)).getChild("FLocat", metsNS); Element flocat = ((Element)oFiles.get(0)).getChild("FLocat", metsNS);
if (flocat != null) if (flocat != null)
{
return flocat.getAttributeValue("href", xlinkNS); return flocat.getAttributeValue("href", xlinkNS);
}
} }
return null; return null;
} }
@@ -537,13 +550,19 @@ public class METSManifest
Element objDiv = getObjStructDiv(); Element objDiv = getObjStructDiv();
Element fptr = objDiv.getChild("fptr", metsNS); Element fptr = objDiv.getChild("fptr", metsNS);
if (fptr == null) if (fptr == null)
{
return null; return null;
}
String id = fptr.getAttributeValue("FILEID"); String id = fptr.getAttributeValue("FILEID");
if (id == null) if (id == null)
{
throw new MetadataValidationException("fptr for Primary Bitstream is missing the required FILEID attribute."); throw new MetadataValidationException("fptr for Primary Bitstream is missing the required FILEID attribute.");
}
Element result = getElementByXPath("descendant::mets:file[@ID=\""+id+"\"]", false); Element result = getElementByXPath("descendant::mets:file[@ID=\""+id+"\"]", false);
if (result == null) if (result == null)
throw new MetadataValidationException("Cannot find file element for Primary Bitstream: looking for ID="+id); {
throw new MetadataValidationException("Cannot find file element for Primary Bitstream: looking for ID=" + id);
}
return result; return result;
} }
@@ -556,14 +575,22 @@ public class METSManifest
{ {
Element md = mdSec.getChild("mdRef", metsNS); Element md = mdSec.getChild("mdRef", metsNS);
if (md == null) if (md == null)
{
md = mdSec.getChild("mdWrap", metsNS); md = mdSec.getChild("mdWrap", metsNS);
}
if (md == null) if (md == null)
{
throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element has neither mdRef nor mdWrap child."); throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element has neither mdRef nor mdWrap child.");
}
String result = md.getAttributeValue("MDTYPE"); String result = md.getAttributeValue("MDTYPE");
if (result != null && result.equals("OTHER")) if (result != null && result.equals("OTHER"))
{
result = md.getAttributeValue("OTHERMDTYPE"); result = md.getAttributeValue("OTHERMDTYPE");
}
if (result == null) if (result == null)
throw new MetadataValidationException("Invalid METS Manifest: "+md.getName()+" has no MDTYPE or OTHERMDTYPE attribute."); {
throw new MetadataValidationException("Invalid METS Manifest: " + md.getName() + " has no MDTYPE or OTHERMDTYPE attribute.");
}
return result; return result;
} }
@@ -579,12 +606,16 @@ public class METSManifest
{ {
String mimeType = mdWrap.getAttributeValue("MIMETYPE"); String mimeType = mdWrap.getAttributeValue("MIMETYPE");
if (mimeType == null && mdWrap.getChild("xmlData", metsNS) != null) if (mimeType == null && mdWrap.getChild("xmlData", metsNS) != null)
mimeType = "text/xml"; {
mimeType = "text/xml";
}
return mimeType; return mimeType;
} }
Element mdRef = mdSec.getChild("mdRef", metsNS); Element mdRef = mdSec.getChild("mdRef", metsNS);
if (mdRef != null) if (mdRef != null)
{
return mdRef.getAttributeValue("MIMETYPE"); return mdRef.getAttributeValue("MIMETYPE");
}
return null; return null;
} }
@@ -746,15 +777,21 @@ public class METSManifest
//get first <structMap> //get first <structMap>
Element sm = mets.getChild("structMap", metsNS); Element sm = mets.getChild("structMap", metsNS);
if (sm == null) if (sm == null)
{
throw new MetadataValidationException("METS document is missing the required structMap element."); throw new MetadataValidationException("METS document is missing the required structMap element.");
}
//get first <div> //get first <div>
Element result = sm.getChild("div", metsNS); Element result = sm.getChild("div", metsNS);
if (result == null) if (result == null)
{
throw new MetadataValidationException("METS document is missing the required first div element in first structMap."); throw new MetadataValidationException("METS document is missing the required first div element in first structMap.");
}
if (log.isDebugEnabled()) if (log.isDebugEnabled())
log.debug("Got getObjStructDiv result="+result.toString()); {
log.debug("Got getObjStructDiv result=" + result.toString());
}
return (Element)result; return (Element)result;
} }
@@ -814,7 +851,9 @@ public class METSManifest
{ {
String filePath = mptr.getAttributeValue("href", xlinkNS); String filePath = mptr.getAttributeValue("href", xlinkNS);
if(filePath!=null && filePath.length()>0) if(filePath!=null && filePath.length()>0)
{
childPathList.add(filePath); childPathList.add(filePath);
}
} }
}//end <mptr> loop }//end <mptr> loop
}//end if <mptr>'s exist }//end if <mptr>'s exist
@@ -856,17 +895,23 @@ public class METSManifest
} }
if (parentStructMap == null) if (parentStructMap == null)
{
throw new MetadataValidationException("METS document is missing the required structMap[@LABEL='Parent'] element."); throw new MetadataValidationException("METS document is missing the required structMap[@LABEL='Parent'] element.");
}
//get first <div> //get first <div>
Element linkDiv = parentStructMap.getChild("div", metsNS); Element linkDiv = parentStructMap.getChild("div", metsNS);
if (linkDiv == null) if (linkDiv == null)
{
throw new MetadataValidationException("METS document is missing the required first div element in structMap[@LABEL='Parent']."); throw new MetadataValidationException("METS document is missing the required first div element in structMap[@LABEL='Parent'].");
}
//the link is in the <mptr> in the @xlink:href attribute //the link is in the <mptr> in the @xlink:href attribute
Element mptr = linkDiv.getChild("mptr", metsNS); Element mptr = linkDiv.getChild("mptr", metsNS);
if (mptr != null) if (mptr != null)
{
return mptr.getAttributeValue("href", xlinkNS); return mptr.getAttributeValue("href", xlinkNS);
}
//return null if we couldn't find the link //return null if we couldn't find the link
return null; return null;
@@ -921,7 +966,9 @@ public class METSManifest
xwalkName = ConfigurationManager.getProperty( xwalkName = ConfigurationManager.getProperty(
CONFIG_METS_PREFIX+"default.ingest.crosswalk."+type); CONFIG_METS_PREFIX+"default.ingest.crosswalk."+type);
if (xwalkName == null) if (xwalkName == null)
xwalkName = type; {
xwalkName = type;
}
} }
return PluginManager.getNamedPlugin(clazz, xwalkName); return PluginManager.getNamedPlugin(clazz, xwalkName);
} }
@@ -940,7 +987,9 @@ public class METSManifest
Element objDiv = getObjStructDiv(); Element objDiv = getObjStructDiv();
String dmds = objDiv.getAttributeValue("DMDID"); String dmds = objDiv.getAttributeValue("DMDID");
if (dmds == null) if (dmds == null)
{
throw new MetadataValidationException("Invalid METS: Missing reference to Item descriptive metadata, first div on first structmap must have a DMDID attribute."); throw new MetadataValidationException("Invalid METS: Missing reference to Item descriptive metadata, first div on first structmap must have a DMDID attribute.");
}
String dmdID[] = dmds.split("\\s+"); String dmdID[] = dmds.split("\\s+");
Element result[] = new Element[dmdID.length]; Element result[] = new Element[dmdID.length];
@@ -965,7 +1014,9 @@ public class METSManifest
if (amds == null) if (amds == null)
{ {
if (log.isDebugEnabled()) if (log.isDebugEnabled())
log.debug("getItemRightsMD: No ADMID references found."); {
log.debug("getItemRightsMD: No ADMID references found.");
}
return new Element[0]; return new Element[0];
} }
String amdID[] = amds.split("\\s+"); String amdID[] = amds.split("\\s+");
@@ -975,7 +1026,9 @@ public class METSManifest
List rmds = getElementByXPath("mets:amdSec[@ID=\""+amdID[i]+"\"]", false). List rmds = getElementByXPath("mets:amdSec[@ID=\""+amdID[i]+"\"]", false).
getChildren("rightsMD", metsNS); getChildren("rightsMD", metsNS);
if (rmds.size() > 0) if (rmds.size() > 0)
{
resultList.addAll(rmds); resultList.addAll(rmds);
}
} }
return (Element[])resultList.toArray(new Element[resultList.size()]); return (Element[])resultList.toArray(new Element[resultList.size()]);
} }
@@ -1058,7 +1111,9 @@ public class METSManifest
if (amds == null) if (amds == null)
{ {
if (log.isDebugEnabled()) if (log.isDebugEnabled())
{
log.debug("crosswalkObjectTechMD: No ADMID references found."); log.debug("crosswalkObjectTechMD: No ADMID references found.");
}
return new String[0]; return new String[0];
} }
return amds.split("\\s+"); return amds.split("\\s+");
@@ -1128,7 +1183,9 @@ public class METSManifest
finally finally
{ {
if (in != null) if (in != null)
{
in.close(); in.close();
}
} }
} // If we couldn't find an <mdRef>, then we'll try an <mdWrap> } // If we couldn't find an <mdRef>, then we'll try an <mdWrap>
// with a <binData> element instead. // with a <binData> element instead.
@@ -1189,7 +1246,9 @@ public class METSManifest
{ {
Element file = getElementByXPath("descendant::mets:file[@ID=\""+fileId+"\"]", false); Element file = getElementByXPath("descendant::mets:file[@ID=\""+fileId+"\"]", false);
if (file == null) if (file == null)
throw new MetadataValidationException("Failed in Bitstream crosswalk, Could not find file element with ID="+fileId); {
throw new MetadataValidationException("Failed in Bitstream crosswalk, Could not find file element with ID=" + fileId);
}
// In DSpace METS SIP spec, admin metadata is only "highly // In DSpace METS SIP spec, admin metadata is only "highly
// recommended", not "required", so it is OK if there is no ADMID. // recommended", not "required", so it is OK if there is no ADMID.

View File

@@ -57,20 +57,26 @@ public class ItemService
if (primaryBitstream != null) if (primaryBitstream != null)
{ {
if (primaryBitstream.getFormat().getMIMEType().equals("text/html")) if (primaryBitstream.getFormat().getMIMEType().equals("text/html"))
{
return null; return null;
}
thumbBitstream = dao.getNamedBitstream(itemId, "THUMBNAIL", primaryBitstream.getName() + ".jpg"); thumbBitstream = dao.getNamedBitstream(itemId, "THUMBNAIL", primaryBitstream.getName() + ".jpg");
} }
else else
{ {
if (requireOriginal) if (requireOriginal)
{
primaryBitstream = dao.getFirstBitstream(itemId, "ORIGINAL"); primaryBitstream = dao.getFirstBitstream(itemId, "ORIGINAL");
}
thumbBitstream = dao.getFirstBitstream(itemId, "THUMBNAIL"); thumbBitstream = dao.getFirstBitstream(itemId, "THUMBNAIL");
} }
if (thumbBitstream != null) if (thumbBitstream != null)
{
return new Thumbnail(thumbBitstream, primaryBitstream); return new Thumbnail(thumbBitstream, primaryBitstream);
}
return null; return null;
} }

View File

@@ -466,7 +466,9 @@ public class I18nUtil
{ {
Locale lc = makeLocale(ls); Locale lc = makeLocale(ls);
if (lc != null) if (lc != null)
{
resultList.add(lc); resultList.add(lc);
}
} }
return resultList.toArray(new Locale[resultList.size()]); return resultList.toArray(new Locale[resultList.size()]);
} }

View File

@@ -285,7 +285,9 @@ public class EmbargoManager
else else
{ {
if (processOneItem(context, (Item)dso, line, now)) if (processOneItem(context, (Item)dso, line, now))
{
status = 1; status = 1;
}
} }
} }
} }
@@ -295,7 +297,9 @@ public class EmbargoManager
while (ii.hasNext()) while (ii.hasNext())
{ {
if (processOneItem(context, ii.next(), line, now)) if (processOneItem(context, ii.next(), line, now))
{
status = 1; status = 1;
}
} }
} }
log.debug("Cache size at end = "+context.getCacheSize()); log.debug("Cache size at end = "+context.getCacheSize());
@@ -342,19 +346,27 @@ public class EmbargoManager
if (liftDate.toDate().before(now)) if (liftDate.toDate().before(now))
{ {
if (line.hasOption('v')) if (line.hasOption('v'))
System.err.println("Lifting embargo from Item handle="+item.getHandle()+", lift date="+lift[0].value); {
System.err.println("Lifting embargo from Item handle=" + item.getHandle() + ", lift date=" + lift[0].value);
}
if (line.hasOption('n')) if (line.hasOption('n'))
{ {
if (!line.hasOption('q')) if (!line.hasOption('q'))
System.err.println("DRY RUN: would have lifted embargo from Item handle="+item.getHandle()+", lift date="+lift[0].value); {
System.err.println("DRY RUN: would have lifted embargo from Item handle=" + item.getHandle() + ", lift date=" + lift[0].value);
}
} }
else if (!line.hasOption('c')) else if (!line.hasOption('c'))
{
liftEmbargo(context, item); liftEmbargo(context, item);
}
} }
else if (!line.hasOption('l')) else if (!line.hasOption('l'))
{ {
if (line.hasOption('v')) if (line.hasOption('v'))
System.err.println("Checking current embargo on Item handle="+item.getHandle()+", lift date="+lift[0].value); {
System.err.println("Checking current embargo on Item handle=" + item.getHandle() + ", lift date=" + lift[0].value);
}
setter.checkEmbargo(context, item); setter.checkEmbargo(context, item);
} }
} }
@@ -377,7 +389,9 @@ public class EmbargoManager
String terms = ConfigurationManager.getProperty("embargo.field.terms"); String terms = ConfigurationManager.getProperty("embargo.field.terms");
String lift = ConfigurationManager.getProperty("embargo.field.lift"); String lift = ConfigurationManager.getProperty("embargo.field.lift");
if (terms == null || lift == null) if (terms == null || lift == null)
{
throw new IllegalStateException("Missing one or more of the required DSpace configuration properties for EmbargoManager, check your configuration file."); throw new IllegalStateException("Missing one or more of the required DSpace configuration properties for EmbargoManager, check your configuration file.");
}
terms_schema = getSchemaOf(terms); terms_schema = getSchemaOf(terms);
terms_element = getElementOf(terms); terms_element = getElementOf(terms);
terms_qualifier = getQualifierOf(terms); terms_qualifier = getQualifierOf(terms);
@@ -387,11 +401,14 @@ public class EmbargoManager
setter = (EmbargoSetter)PluginManager.getSinglePlugin(EmbargoSetter.class); setter = (EmbargoSetter)PluginManager.getSinglePlugin(EmbargoSetter.class);
if (setter == null) if (setter == null)
{
throw new IllegalStateException("The EmbargoSetter plugin was not defined in DSpace configuration."); throw new IllegalStateException("The EmbargoSetter plugin was not defined in DSpace configuration.");
}
lifter = (EmbargoLifter)PluginManager.getSinglePlugin(EmbargoLifter.class); lifter = (EmbargoLifter)PluginManager.getSinglePlugin(EmbargoLifter.class);
if (lifter == null) if (lifter == null)
{
throw new IllegalStateException("The EmbargoLifter plugin was not defined in DSpace configuration."); throw new IllegalStateException("The EmbargoLifter plugin was not defined in DSpace configuration.");
}
} }
} }

View File

@@ -246,10 +246,11 @@ public class EPerson extends DSpaceObject
throws SQLException throws SQLException
{ {
if (netid == null) if (netid == null)
{
return null; return null;
}
TableRow row = DatabaseManager.findByUnique(context, "eperson", TableRow row = DatabaseManager.findByUnique(context, "eperson", "netid", netid);
"netid", netid);
if (row == null) if (row == null)
{ {
@@ -327,7 +328,9 @@ public class EPerson extends DSpaceObject
queryBuf.append("rec WHERE rownum<=? "); queryBuf.append("rec WHERE rownum<=? ");
// If we also have an offset, then convert the limit into the maximum row number // If we also have an offset, then convert the limit into the maximum row number
if (offset > 0) if (offset > 0)
{
limit += offset; limit += offset;
}
} }
// Return only the records after the specified offset (row number) // Return only the records after the specified offset (row number)
@@ -340,10 +343,14 @@ public class EPerson extends DSpaceObject
else else
{ {
if (limit > 0) if (limit > 0)
{
queryBuf.append(" LIMIT ? "); queryBuf.append(" LIMIT ? ");
}
if (offset > 0) if (offset > 0)
{
queryBuf.append(" OFFSET ? "); queryBuf.append(" OFFSET ? ");
}
} }
String dbquery = queryBuf.toString(); String dbquery = queryBuf.toString();
@@ -403,7 +410,9 @@ public class EPerson extends DSpaceObject
finally finally
{ {
if (rows != null) if (rows != null)
{
rows.close(); rows.close();
}
} }
} }
@@ -525,7 +534,9 @@ public class EPerson extends DSpaceObject
finally finally
{ {
if (rows != null) if (rows != null)
{
rows.close(); rows.close();
}
} }
} }
@@ -1008,7 +1019,9 @@ public class EPerson extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// check for eperson in workflowitem table // check for eperson in workflowitem table
@@ -1027,7 +1040,9 @@ public class EPerson extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// check for eperson in tasklistitem table // check for eperson in tasklistitem table
@@ -1046,7 +1061,9 @@ public class EPerson extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// the list of tables can be used to construct an error message // the list of tables can be used to construct an error message

View File

@@ -164,7 +164,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// now get Group objects // now get Group objects
@@ -198,7 +200,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
@@ -469,7 +473,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
} }
// Also need to get all "Special Groups" user is a member of! // Also need to get all "Special Groups" user is a member of!
@@ -509,7 +515,9 @@ public class Group extends DSpaceObject
groupQuery.append("child_id= ? "); groupQuery.append("child_id= ? ");
if (i.hasNext()) if (i.hasNext())
{
groupQuery.append(" OR "); groupQuery.append(" OR ");
}
} }
// was member of at least one group // was member of at least one group
@@ -534,7 +542,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return groupIDs; return groupIDs;
@@ -610,7 +620,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// now we have all the groups (including this one) // now we have all the groups (including this one)
@@ -629,7 +641,9 @@ public class Group extends DSpaceObject
epersonQuery.append("eperson_group_id= ? "); epersonQuery.append("eperson_group_id= ? ");
if (i.hasNext()) if (i.hasNext())
{
epersonQuery.append(" OR "); epersonQuery.append(" OR ");
}
while (i.hasNext()) while (i.hasNext())
{ {
@@ -638,7 +652,9 @@ public class Group extends DSpaceObject
epersonQuery.append("eperson_group_id= ? "); epersonQuery.append("eperson_group_id= ? ");
if (i.hasNext()) if (i.hasNext())
{
epersonQuery.append(" OR "); epersonQuery.append(" OR ");
}
} }
//get all the EPerson IDs //get all the EPerson IDs
@@ -663,7 +679,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return epeopleIDs; return epeopleIDs;
@@ -806,7 +824,9 @@ public class Group extends DSpaceObject
finally finally
{ {
if (rows != null) if (rows != null)
{
rows.close(); rows.close();
}
} }
} }
@@ -864,7 +884,9 @@ public class Group extends DSpaceObject
queryBuf.append("rec WHERE rownum<=? "); queryBuf.append("rec WHERE rownum<=? ");
// If we also have an offset, then convert the limit into the maximum row number // If we also have an offset, then convert the limit into the maximum row number
if (offset > 0) if (offset > 0)
{
limit += offset; limit += offset;
}
} }
// Return only the records after the specified offset (row number) // Return only the records after the specified offset (row number)
@@ -877,10 +899,14 @@ public class Group extends DSpaceObject
else else
{ {
if (limit > 0) if (limit > 0)
{
queryBuf.append(" LIMIT ? "); queryBuf.append(" LIMIT ? ");
}
if (offset > 0) if (offset > 0)
{
queryBuf.append(" OFFSET ? "); queryBuf.append(" OFFSET ? ");
}
} }
String dbquery = queryBuf.toString(); String dbquery = queryBuf.toString();
@@ -939,7 +965,9 @@ public class Group extends DSpaceObject
finally finally
{ {
if (rows != null) if (rows != null)
{
rows.close(); rows.close();
}
} }
} }
@@ -1189,7 +1217,10 @@ public class Group extends DSpaceObject
return false; return false;
} }
final Group other = (Group) obj; final Group other = (Group) obj;
if(this.getID() != other.getID()) return false; if(this.getID() != other.getID())
{
return false;
}
return true; return true;
} }
@@ -1257,7 +1288,9 @@ public class Group extends DSpaceObject
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
// now parents is a hash of all of the IDs of groups that are parents // now parents is a hash of all of the IDs of groups that are parents
@@ -1311,7 +1344,9 @@ public class Group extends DSpaceObject
// degenerate case, this parent has no children // degenerate case, this parent has no children
if (!parents.containsKey(parent)) if (!parents.containsKey(parent))
{
return myChildren; return myChildren;
}
// got this far, so we must have children // got this far, so we must have children
Set<Integer> children = parents.get(parent); Set<Integer> children = parents.get(parent);

View File

@@ -449,7 +449,9 @@ public class Event implements Serializable
{ {
int id = Constants.getTypeID(s.toUpperCase()); int id = Constants.getTypeID(s.toUpperCase());
if (id >= 0) if (id >= 0)
{
return 1 << id; return 1 << id;
}
} }
return 0; return 0;
} }
@@ -591,16 +593,19 @@ public class Event implements Serializable
for (Iterator fi = filters.iterator(); fi.hasNext();) for (Iterator fi = filters.iterator(); fi.hasNext();)
{ {
int filter[] = (int[]) fi.next(); int filter[] = (int[]) fi.next();
if ((subjectType & filter[SUBJECT_MASK]) != 0 if ((subjectType & filter[SUBJECT_MASK]) != 0 && (eventType & filter[EVENT_MASK]) != 0)
&& (eventType & filter[EVENT_MASK]) != 0) {
result = true; result = true;
}
} }
if (log.isDebugEnabled()) if (log.isDebugEnabled())
{
log.debug("Filtering event: " + "eventType=" log.debug("Filtering event: " + "eventType="
+ String.valueOf(eventType) + ", subjectType=" + String.valueOf(eventType) + ", subjectType="
+ String.valueOf(subjectType) + ", result=" + String.valueOf(subjectType) + ", result="
+ String.valueOf(result)); + String.valueOf(result));
}
return result; return result;
} }

View File

@@ -132,7 +132,9 @@ public class EventManager
} }
if (name == null) if (name == null)
{
name = DEFAULT_DISPATCHER; name = DEFAULT_DISPATCHER;
}
try try
{ {
@@ -318,7 +320,9 @@ public class EventManager
{ {
ConsumerProfile cp = (ConsumerProfile) ci.next(); ConsumerProfile cp = (ConsumerProfile) ci.next();
if (cp != null) if (cp != null)
{
cp.getConsumer().finish(ctx); cp.getConsumer().finish(ctx);
}
} }
return; return;

View File

@@ -275,7 +275,9 @@ public class HandleManager
DatabaseManager.update(context, row); DatabaseManager.update(context, row);
if(log.isDebugEnabled()) if(log.isDebugEnabled())
{
log.debug("Unbound Handle " + row.getStringColumn("handle") + " from object " + Constants.typeText[dso.getType()] + " id=" + dso.getID()); log.debug("Unbound Handle " + row.getStringColumn("handle") + " from object " + Constants.typeText[dso.getType()] + " id=" + dso.getID());
}
} }
else else
@@ -308,7 +310,9 @@ public class HandleManager
{ {
//If this is the Site-wide Handle, return Site object //If this is the Site-wide Handle, return Site object
if (handle.equals(Site.getSiteHandle())) if (handle.equals(Site.getSiteHandle()))
{
return Site.find(context, 0); return Site.find(context, 0);
}
//Otherwise, return null (i.e. handle not found in DB) //Otherwise, return null (i.e. handle not found in DB)
return null; return null;
} }
@@ -431,7 +435,9 @@ public class HandleManager
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (iterator != null) if (iterator != null)
{
iterator.close(); iterator.close();
}
} }
return results; return results;

View File

@@ -171,7 +171,9 @@ public class HarvestedCollection
public boolean isReady() throws SQLException public boolean isReady() throws SQLException
{ {
if (this.isHarvestable() && (this.getHarvestStatus() == HarvestedCollection.STATUS_READY || this.getHarvestStatus() == HarvestedCollection.STATUS_OAI_ERROR)) if (this.isHarvestable() && (this.getHarvestStatus() == HarvestedCollection.STATUS_READY || this.getHarvestStatus() == HarvestedCollection.STATUS_OAI_ERROR))
return true; {
return true;
}
return false; return false;
} }
@@ -205,10 +207,16 @@ public class HarvestedCollection
public static List<Integer> findReady(Context c) throws SQLException public static List<Integer> findReady(Context c) throws SQLException
{ {
int harvestInterval = ConfigurationManager.getIntProperty("harvester.harvestFrequency"); int harvestInterval = ConfigurationManager.getIntProperty("harvester.harvestFrequency");
if (harvestInterval == 0) harvestInterval = 720; if (harvestInterval == 0)
{
harvestInterval = 720;
}
int expirationInterval = ConfigurationManager.getIntProperty("harvester.threadTimeout"); int expirationInterval = ConfigurationManager.getIntProperty("harvester.threadTimeout");
if (expirationInterval == 0) expirationInterval = 24; if (expirationInterval == 0)
{
expirationInterval = 24;
}
Date startTime; Date startTime;
Date expirationTime; Date expirationTime;
@@ -267,7 +275,9 @@ public class HarvestedCollection
String query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? order by last_harvested asc limit 1"; String query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? order by last_harvested asc limit 1";
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? and rownum <= 1 order by last_harvested asc"; {
query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? and rownum <= 1 order by last_harvested asc";
}
TableRowIterator tri = DatabaseManager.queryTable(c, "harvested_collection", TableRowIterator tri = DatabaseManager.queryTable(c, "harvested_collection",
query, 0, 0); query, 0, 0);
@@ -290,7 +300,9 @@ public class HarvestedCollection
String query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? order by last_harvested desc limit 1"; String query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? order by last_harvested desc limit 1";
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
{
query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? and rownum <= 1 order by last_harvested desc"; query = "select collection_id from harvested_collection where harvest_type > ? and harvest_status = ? and rownum <= 1 order by last_harvested desc";
}
TableRowIterator tri = DatabaseManager.queryTable(c, "harvested_collection", TableRowIterator tri = DatabaseManager.queryTable(c, "harvested_collection",
query , 0, 0); query , 0, 0);

View File

@@ -129,7 +129,9 @@ public class HarvestedItem
} }
finally { finally {
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return resolvedItem; return resolvedItem;

View File

@@ -156,14 +156,18 @@ public class OAIHarvester {
public OAIHarvester(Context c, DSpaceObject dso, HarvestedCollection hc) throws HarvestingException, SQLException public OAIHarvester(Context c, DSpaceObject dso, HarvestedCollection hc) throws HarvestingException, SQLException
{ {
if (dso.getType() != Constants.COLLECTION) if (dso.getType() != Constants.COLLECTION)
{
throw new HarvestingException("OAIHarvester can only harvest collections"); throw new HarvestingException("OAIHarvester can only harvest collections");
}
ourContext = c; ourContext = c;
targetCollection = (Collection)dso; targetCollection = (Collection)dso;
harvestRow = hc; harvestRow = hc;
if (harvestRow == null || !harvestRow.isHarvestable()) if (harvestRow == null || !harvestRow.isHarvestable())
throw new HarvestingException("Provided collection is not set up for harvesting"); {
throw new HarvestingException("Provided collection is not set up for harvesting");
}
// Set the ORE options // Set the ORE options
Namespace ORESerializationNamespace = OAIHarvester.getORENamespace(); Namespace ORESerializationNamespace = OAIHarvester.getORENamespace();
@@ -262,12 +266,16 @@ public class OAIHarvester {
String oaiSetId = harvestRow.getOaiSetId(); String oaiSetId = harvestRow.getOaiSetId();
//If we have all selected then make sure that we do not include a set filter //If we have all selected then make sure that we do not include a set filter
if("all".equals(oaiSetId)) if("all".equals(oaiSetId))
{
oaiSetId = null; oaiSetId = null;
}
Date lastHarvestDate = harvestRow.getHarvestDate(); Date lastHarvestDate = harvestRow.getHarvestDate();
String fromDate = null; String fromDate = null;
if (lastHarvestDate != null) if (lastHarvestDate != null)
fromDate = processDate(harvestRow.getHarvestDate()); {
fromDate = processDate(harvestRow.getHarvestDate());
}
Date startTime = new Date(); Date startTime = new Date();
String toDate = processDate(startTime,0); String toDate = processDate(startTime,0);
@@ -283,7 +291,9 @@ public class OAIHarvester {
try { try {
dateGranularity = OAIGetDateGranularity(oaiSource); dateGranularity = OAIGetDateGranularity(oaiSource);
if (fromDate != null) if (fromDate != null)
fromDate = fromDate.substring(0, dateGranularity.length()); {
fromDate = fromDate.substring(0, dateGranularity.length());
}
toDate = toDate.substring(0, dateGranularity.length()); toDate = toDate.substring(0, dateGranularity.length());
descMDPrefix = OAIResolveNamespaceToPrefix(oaiSource, metadataNS.getURI()); descMDPrefix = OAIResolveNamespaceToPrefix(oaiSource, metadataNS.getURI());
@@ -318,7 +328,10 @@ public class OAIHarvester {
// expiration timer starts // expiration timer starts
int expirationInterval = ConfigurationManager.getIntProperty("harvester.threadTimeout"); int expirationInterval = ConfigurationManager.getIntProperty("harvester.threadTimeout");
if (expirationInterval == 0) expirationInterval = 24; if (expirationInterval == 0)
{
expirationInterval = 24;
}
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(startTime); calendar.setTime(startTime);
@@ -331,8 +344,10 @@ public class OAIHarvester {
ListRecords listRecords = new ListRecords(oaiSource, fromDate, toDate, oaiSetId, descMDPrefix); ListRecords listRecords = new ListRecords(oaiSource, fromDate, toDate, oaiSetId, descMDPrefix);
log.debug("Harvesting request parameters: listRecords " + oaiSource + " " + fromDate + " " + toDate + " " + oaiSetId + " " + descMDPrefix); log.debug("Harvesting request parameters: listRecords " + oaiSource + " " + fromDate + " " + toDate + " " + oaiSetId + " " + descMDPrefix);
if (listRecords != null) if (listRecords != null)
log.info("HTTP Request: " + listRecords.getRequestURL()); {
log.info("HTTP Request: " + listRecords.getRequestURL());
}
while (listRecords != null) while (listRecords != null)
{ {
records = new ArrayList<Element>(); records = new ArrayList<Element>();
@@ -369,10 +384,14 @@ public class OAIHarvester {
for (Element record : records) { for (Element record : records) {
// check for STOP interrupt from the scheduler // check for STOP interrupt from the scheduler
if (HarvestScheduler.interrupt == HarvestScheduler.HARVESTER_INTERRUPT_STOP) if (HarvestScheduler.interrupt == HarvestScheduler.HARVESTER_INTERRUPT_STOP)
throw new HarvestingException("Harvest process for " + targetCollection.getID() + " interrupted by stopping the scheduler."); {
throw new HarvestingException("Harvest process for " + targetCollection.getID() + " interrupted by stopping the scheduler.");
}
// check for timeout // check for timeout
if (expirationTime.before(new Date())) if (expirationTime.before(new Date()))
throw new HarvestingException("runHarvest method timed out for collection " + targetCollection.getID()); {
throw new HarvestingException("runHarvest method timed out for collection " + targetCollection.getID());
}
processRecord(record,OREPrefix); processRecord(record,OREPrefix);
ourContext.commit(); ourContext.commit();
@@ -448,7 +467,9 @@ public class OAIHarvester {
if (header.getAttribute("status") != null && header.getAttribute("status").getValue().equals("deleted")) { if (header.getAttribute("status") != null && header.getAttribute("status").getValue().equals("deleted")) {
log.info("Item " + itemOaiID + " has been marked as deleted on the OAI server."); log.info("Item " + itemOaiID + " has been marked as deleted on the OAI server.");
if (item != null) if (item != null)
targetCollection.removeItem(item); {
targetCollection.removeItem(item);
}
ourContext.restoreAuthSystemState(); ourContext.restoreAuthSystemState();
return; return;
@@ -544,7 +565,9 @@ public class OAIHarvester {
{ {
DSpaceObject dso = HandleManager.resolveToObject(ourContext, handle); DSpaceObject dso = HandleManager.resolveToObject(ourContext, handle);
if (dso != null) if (dso != null)
throw new HarvestingException("Handle collision: attempted to re-assign handle '" + handle + "' to an incoming harvested item '" + hi.getOaiID() + "'."); {
throw new HarvestingException("Handle collision: attempted to re-assign handle '" + handle + "' to an incoming harvested item '" + hi.getOaiID() + "'.");
}
} }
try { try {
@@ -616,10 +639,16 @@ public class OAIHarvester {
private String extractHandle(Item item) private String extractHandle(Item item)
{ {
String acceptedHandleServersString = ConfigurationManager.getProperty("harvester.acceptedHandleServer"); String acceptedHandleServersString = ConfigurationManager.getProperty("harvester.acceptedHandleServer");
if (acceptedHandleServersString == null) acceptedHandleServersString = "hdl.handle.net"; if (acceptedHandleServersString == null)
{
acceptedHandleServersString = "hdl.handle.net";
}
String rejectedHandlePrefixString = ConfigurationManager.getProperty("harvester.rejectedHandlePrefix"); String rejectedHandlePrefixString = ConfigurationManager.getProperty("harvester.rejectedHandlePrefix");
if (rejectedHandlePrefixString == null) rejectedHandlePrefixString = "123456789"; if (rejectedHandlePrefixString == null)
{
rejectedHandlePrefixString = "123456789";
}
DCValue[] values = item.getMetadata("dc", "identifier", Item.ANY, Item.ANY); DCValue[] values = item.getMetadata("dc", "identifier", Item.ANY, Item.ANY);
@@ -634,13 +663,17 @@ public class OAIHarvester {
// http://hdl.handle.net/1234/12 // http://hdl.handle.net/1234/12
String[] urlPieces = value.value.split("/"); String[] urlPieces = value.value.split("/");
if (urlPieces.length != 5) if (urlPieces.length != 5)
continue; {
continue;
}
for (String server : acceptedHandleServers) { for (String server : acceptedHandleServers) {
if (urlPieces[2].equals(server)) { if (urlPieces[2].equals(server)) {
for (String prefix : rejectedHandlePrefixes) { for (String prefix : rejectedHandlePrefixes) {
if (!urlPieces[3].equals(prefix)) if (!urlPieces[3].equals(prefix))
return urlPieces[3] + "/" + urlPieces[4]; {
return urlPieces[3] + "/" + urlPieces[4];
}
} }
} }
@@ -661,10 +694,16 @@ public class OAIHarvester {
{ {
// The two options, with three possibilities each: add, ignore, fail // The two options, with three possibilities each: add, ignore, fail
String schemaChoice = ConfigurationManager.getProperty("harvester.unknownSchema"); String schemaChoice = ConfigurationManager.getProperty("harvester.unknownSchema");
if (schemaChoice == null) schemaChoice = "fail"; if (schemaChoice == null)
{
schemaChoice = "fail";
}
String fieldChoice = ConfigurationManager.getProperty("harvester.unknownField"); String fieldChoice = ConfigurationManager.getProperty("harvester.unknownField");
if (fieldChoice == null) fieldChoice = "fail"; if (fieldChoice == null)
{
fieldChoice = "fail";
}
List<String> clearList = new ArrayList<String>(); List<String> clearList = new ArrayList<String>();
@@ -927,9 +966,13 @@ public class OAIHarvester {
} }
if (testORE && OREOAIPrefix == null) if (testORE && OREOAIPrefix == null)
errorSet.add(OAI_ORE_ERROR + ": The OAI server does not support ORE dissemination"); {
errorSet.add(OAI_ORE_ERROR + ": The OAI server does not support ORE dissemination");
}
if (DMDOAIPrefix == null) if (DMDOAIPrefix == null)
errorSet.add(OAI_DMD_ERROR + ": The OAI server does not support dissemination in this format"); {
errorSet.add(OAI_DMD_ERROR + ": The OAI server does not support dissemination in this format");
}
// Now scan the sets and make sure the one supplied is in the list // Now scan the sets and make sure the one supplied is in the list
boolean foundSet = false; boolean foundSet = false;
@@ -1112,16 +1155,27 @@ public class OAIHarvester {
String harvestAdminParam = ConfigurationManager.getProperty("harvester.eperson"); String harvestAdminParam = ConfigurationManager.getProperty("harvester.eperson");
harvestAdmin = null; harvestAdmin = null;
if (harvestAdminParam != null && harvestAdminParam.length() > 0) if (harvestAdminParam != null && harvestAdminParam.length() > 0)
harvestAdmin = EPerson.findByEmail(mainContext, harvestAdminParam); {
harvestAdmin = EPerson.findByEmail(mainContext, harvestAdminParam);
}
harvestThreads = new Stack<HarvestThread>(); harvestThreads = new Stack<HarvestThread>();
maxActiveThreads = ConfigurationManager.getIntProperty("harvester.maxThreads"); maxActiveThreads = ConfigurationManager.getIntProperty("harvester.maxThreads");
if (maxActiveThreads == 0) maxActiveThreads = 3; if (maxActiveThreads == 0)
{
maxActiveThreads = 3;
}
minHeartbeat = ConfigurationManager.getIntProperty("harvester.minHeartbeat") * 1000; minHeartbeat = ConfigurationManager.getIntProperty("harvester.minHeartbeat") * 1000;
if (minHeartbeat == 0) minHeartbeat = 30000; if (minHeartbeat == 0)
{
minHeartbeat = 30000;
}
maxHeartbeat = ConfigurationManager.getIntProperty("harvester.maxHeartbeat") * 1000; maxHeartbeat = ConfigurationManager.getIntProperty("harvester.maxHeartbeat") * 1000;
if (maxHeartbeat == 0) maxHeartbeat = 3600000; if (maxHeartbeat == 0)
{
maxHeartbeat = 3600000;
}
} }
public void run() { public void run() {
@@ -1153,7 +1207,9 @@ public class OAIHarvester {
Thread.sleep(1000); Thread.sleep(1000);
} }
if (interrupt != HARVESTER_INTERRUPT_STOP) if (interrupt != HARVESTER_INTERRUPT_STOP)
break; {
break;
}
case HARVESTER_INTERRUPT_STOP: case HARVESTER_INTERRUPT_STOP:
interrupt = HARVESTER_INTERRUPT_NONE; interrupt = HARVESTER_INTERRUPT_NONE;
status = HARVESTER_STATUS_STOPPED; status = HARVESTER_STATUS_STOPPED;
@@ -1221,7 +1277,10 @@ public class OAIHarvester {
HarvestedCollection hc = HarvestedCollection.find(tempContext, nextCollectionId); HarvestedCollection hc = HarvestedCollection.find(tempContext, nextCollectionId);
int harvestInterval = ConfigurationManager.getIntProperty("harvester.harvestFrequency"); int harvestInterval = ConfigurationManager.getIntProperty("harvester.harvestFrequency");
if (harvestInterval == 0) harvestInterval = 720; if (harvestInterval == 0)
{
harvestInterval = 720;
}
Date nextTime; Date nextTime;
long nextHarvest = 0; long nextHarvest = 0;

View File

@@ -110,7 +110,9 @@ public class LicenseCleanup
File processed = new File("license.processed"); File processed = new File("license.processed");
if (processed.exists()) if (processed.exists())
{
props.load(new FileInputStream(processed)); props.load(new FileInputStream(processed));
}
int i = 0; int i = 0;
@@ -162,7 +164,9 @@ public class LicenseCleanup
Bundle[] bundles = item.getBundles("CC-LICENSE"); Bundle[] bundles = item.getBundles("CC-LICENSE");
if (bundles == null || bundles.length == 0) if (bundles == null || bundles.length == 0)
{
return; return;
}
Bundle bundle = bundles[0]; Bundle bundle = bundles[0];

View File

@@ -100,7 +100,9 @@ public class DSAnalyzer extends Analyzer
{ {
// If it is the default field, or bounded fields is turned off in the config, return the default value // If it is the default field, or bounded fields is turned off in the config, return the default value
if ("default".equalsIgnoreCase(fieldName) || !ConfigurationManager.getBooleanProperty("search.boundedfields", false)) if ("default".equalsIgnoreCase(fieldName) || !ConfigurationManager.getBooleanProperty("search.boundedfields", false))
{
return super.getPositionIncrementGap(fieldName); return super.getPositionIncrementGap(fieldName);
}
// Not the default field, and we want bounded fields, so return an large gap increment // Not the default field, and we want bounded fields, so return an large gap increment
return 10; return 10;

View File

@@ -586,7 +586,9 @@ public class DSIndexer
finally finally
{ {
if (items != null) if (items != null)
{
items.close(); items.close();
}
} }
Collection[] collections = Collection.findAll(context); Collection[] collections = Collection.findAll(context);

View File

@@ -316,7 +316,9 @@ public class Harvest
{ {
// close the TableRowIterator to free up resources // close the TableRowIterator to free up resources
if (tri != null) if (tri != null)
{
tri.close(); tri.close();
}
} }
return infoObjects; return infoObjects;
@@ -401,7 +403,9 @@ public class Harvest
finally finally
{ {
if (colRows != null) if (colRows != null)
{
colRows.close(); colRows.close();
}
} }
} }

View File

@@ -243,7 +243,15 @@ public class DatabaseManager
catch (SQLException sqle) catch (SQLException sqle)
{ {
if (statement != null) if (statement != null)
try { statement.close(); } catch (SQLException s) { } {
try
{
statement.close();
}
catch (SQLException s)
{
}
}
throw sqle; throw sqle;
} }
@@ -294,7 +302,15 @@ public class DatabaseManager
catch (SQLException sqle) catch (SQLException sqle)
{ {
if (statement != null) if (statement != null)
try { statement.close(); } catch (SQLException s) { } {
try
{
statement.close();
}
catch (SQLException s)
{
}
}
throw sqle; throw sqle;
} }
@@ -373,7 +389,9 @@ public class DatabaseManager
finally finally
{ {
if (iterator != null) if (iterator != null)
{
iterator.close(); iterator.close();
}
} }
return (retRow); return (retRow);
@@ -410,7 +428,9 @@ public class DatabaseManager
finally finally
{ {
if (iterator != null) if (iterator != null)
{
iterator.close(); iterator.close();
}
} }
return (retRow); return (retRow);
} }
@@ -538,10 +558,14 @@ public class DatabaseManager
String ctable = canonicalize(table); String ctable = canonicalize(table);
if ( ! DB_SAFE_NAME.matcher(ctable).matches()) if ( ! DB_SAFE_NAME.matcher(ctable).matches())
throw new SQLException("Unable to execute select query because table name ("+ctable+") contains non alphanumeric characters."); {
throw new SQLException("Unable to execute select query because table name (" + ctable + ") contains non alphanumeric characters.");
}
if ( ! DB_SAFE_NAME.matcher(column).matches()) if ( ! DB_SAFE_NAME.matcher(column).matches())
throw new SQLException("Unable to execute select query because column name ("+column+") contains non alphanumeric characters."); {
throw new SQLException("Unable to execute select query because column name (" + column + ") contains non alphanumeric characters.");
}
String sql = "select * from " + ctable + " where "+ column +" = ? "; String sql = "select * from " + ctable + " where "+ column +" = ? ";
@@ -593,10 +617,14 @@ public class DatabaseManager
String ctable = canonicalize(table); String ctable = canonicalize(table);
if ( ! DB_SAFE_NAME.matcher(ctable).matches()) if ( ! DB_SAFE_NAME.matcher(ctable).matches())
throw new SQLException("Unable to execute delete query because table name ("+ctable+") contains non alphanumeric characters."); {
throw new SQLException("Unable to execute delete query because table name (" + ctable + ") contains non alphanumeric characters.");
}
if ( ! DB_SAFE_NAME.matcher(column).matches()) if ( ! DB_SAFE_NAME.matcher(column).matches())
throw new SQLException("Unable to execute delete query because column name ("+column+") contains non alphanumeric characters."); {
throw new SQLException("Unable to execute delete query because column name (" + column + ") contains non alphanumeric characters.");
}
String sql = "delete from "+ctable+" where "+column+" = ? "; String sql = "delete from "+ctable+" where "+column+" = ? ";
@@ -627,7 +655,9 @@ public class DatabaseManager
finally finally
{ {
if (pstmt != null) if (pstmt != null)
pstmt.close(); {
pstmt.close();
}
} }
} }
@@ -726,7 +756,9 @@ public class DatabaseManager
} }
if (newID < 0) if (newID < 0)
{
throw new SQLException("Unable to retrieve sequence ID"); throw new SQLException("Unable to retrieve sequence ID");
}
// Set the ID in the table row object // Set the ID in the table row object
row.setColumn(getPrimaryKeyColumn(table), newID); row.setColumn(getPrimaryKeyColumn(table), newID);
@@ -817,7 +849,9 @@ public class DatabaseManager
public static int delete(Context context, TableRow row) throws SQLException public static int delete(Context context, TableRow row) throws SQLException
{ {
if (null == row.getTable()) if (null == row.getTable())
{
throw new IllegalArgumentException("Row not associated with a table"); throw new IllegalArgumentException("Row not associated with a table");
}
String pk = getPrimaryKeyColumn(row); String pk = getPrimaryKeyColumn(row);

View File

@@ -137,12 +137,16 @@ public class InitializeDatabase
{ {
myFile = new File("etc/" + dbName + "/" + name); myFile = new File("etc/" + dbName + "/" + name);
if (myFile.exists()) if (myFile.exists())
{
return new FileReader(myFile.getCanonicalPath()); return new FileReader(myFile.getCanonicalPath());
}
} }
myFile = new File("etc/" + name); myFile = new File("etc/" + name);
if (myFile.exists()) if (myFile.exists())
{
return new FileReader(myFile.getCanonicalPath()); return new FileReader(myFile.getCanonicalPath());
}
return new FileReader(name); return new FileReader(name);
} }

View File

@@ -556,9 +556,13 @@ public class DescribeStep extends AbstractProcessingStep
String confidence = request.getParameter(metadataField + "_confidence"); String confidence = request.getParameter(metadataField + "_confidence");
if (lastName != null) if (lastName != null)
{
lasts.add(lastName); lasts.add(lastName);
}
if (firstNames != null) if (firstNames != null)
{
firsts.add(firstNames); firsts.add(firstNames);
}
auths.add(authority == null ? "" : authority); auths.add(authority == null ? "" : authority);
confs.add(confidence == null ? "" : confidence); confs.add(confidence == null ? "" : confidence);
} }
@@ -709,7 +713,9 @@ public class DescribeStep extends AbstractProcessingStep
vals = new LinkedList(); vals = new LinkedList();
String value = request.getParameter(metadataField); String value = request.getParameter(metadataField);
if (value != null) if (value != null)
{
vals.add(value.trim()); vals.add(value.trim());
}
if (isAuthorityControlled) if (isAuthorityControlled)
{ {
auths = new LinkedList(); auths = new LinkedList();
@@ -876,7 +882,9 @@ public class DescribeStep extends AbstractProcessingStep
{ {
// if number is null, just set to a nullstring // if number is null, just set to a nullstring
if (n == null) if (n == null)
{
n = ""; n = "";
}
series.add(s); series.add(s);
numbers.add(n); numbers.add(n);
@@ -969,7 +977,9 @@ public class DescribeStep extends AbstractProcessingStep
} }
if (addValue) if (addValue)
vals.add(s.trim()); {
vals.add(s.trim());
}
} }
i++; i++;

View File

@@ -96,7 +96,9 @@ public abstract class InitialArticleWord implements TextFilter
// Only need to do so if we haven't already got one // Only need to do so if we haven't already got one
// of the right length // of the right length
if (initialArticleWord.length() != articleWordArr[idx].length()) if (initialArticleWord.length() != articleWordArr[idx].length())
{
initialArticleWord = extractText(str, curPos, articleWordArr[idx].length()); initialArticleWord = extractText(str, curPos, articleWordArr[idx].length());
}
} }
else else
{ {
@@ -213,7 +215,9 @@ public abstract class InitialArticleWord implements TextFilter
} }
if (testPos < str.length()) if (testPos < str.length())
{
return str.substring(pos, pos + len); return str.substring(pos, pos + len);
}
return null; return null;
} }

View File

@@ -124,43 +124,51 @@ public class Language
private static class LanguageMaps private static class LanguageMaps
{ {
private static final Map langMapIANA = new HashMap(); private static final Map<String, Language> langMapIANA = new HashMap<String, Language>();
private static final Map langMapISO639_1 = new HashMap(); private static final Map<String, Language> langMapISO639_1 = new HashMap<String, Language>();
private static final Map langMapISO639_2 = new HashMap(); private static final Map<String, Language> langMapISO639_2 = new HashMap<String, Language>();
static void add(Language l) static void add(Language l)
{ {
if (l.IANA != null && l.IANA.length() > 0 && !langMapIANA.containsKey(l.IANA)) if (l.IANA != null && l.IANA.length() > 0 && !langMapIANA.containsKey(l.IANA))
{
langMapIANA.put(l.IANA, l); langMapIANA.put(l.IANA, l);
}
if (l.ISO639_1 != null && l.ISO639_1.length() > 0 && !langMapISO639_1.containsKey(l.ISO639_1)) if (l.ISO639_1 != null && l.ISO639_1.length() > 0 && !langMapISO639_1.containsKey(l.ISO639_1))
{
langMapISO639_1.put(l.ISO639_1, l); langMapISO639_1.put(l.ISO639_1, l);
}
if (l.ISO639_2 != null && l.ISO639_2.length() > 0 && !langMapISO639_2.containsKey(l.ISO639_2)) if (l.ISO639_2 != null && l.ISO639_2.length() > 0 && !langMapISO639_2.containsKey(l.ISO639_2))
{
langMapISO639_2.put(l.ISO639_2, l); langMapISO639_2.put(l.ISO639_2, l);
}
} }
public static Language getLanguage(String lang) public static Language getLanguage(String lang)
{ {
if (langMapIANA.containsKey(lang)) if (langMapIANA.containsKey(lang))
return (Language)langMapIANA.get(lang); {
return langMapIANA.get(lang);
}
return (Language)langMapISO639_2.get(lang); return langMapISO639_2.get(lang);
} }
public static Language getLanguageForIANA(String iana) public static Language getLanguageForIANA(String iana)
{ {
return (Language)langMapIANA.get(iana); return langMapIANA.get(iana);
} }
public static Language getLanguageForISO639_1(String iso) public static Language getLanguageForISO639_1(String iso)
{ {
return (Language)langMapISO639_1.get(iso); return langMapISO639_1.get(iso);
} }
public static Language getLanguageForISO639_2(String iso) public static Language getLanguageForISO639_2(String iso)
{ {
return (Language)langMapISO639_2.get(iso); return langMapISO639_2.get(iso);
} }
} }

View File

@@ -73,7 +73,9 @@ public class MARC21InitialArticleWord extends InitialArticleWord
{ {
// No language - no words // No language - no words
if (StringUtils.isEmpty(lang)) if (StringUtils.isEmpty(lang))
{
return defaultWords; return defaultWords;
}
Language l = Language.getLanguage(lang); Language l = Language.getLanguage(lang);
@@ -81,17 +83,19 @@ public class MARC21InitialArticleWord extends InitialArticleWord
if (l != null && ianaArticleMap.containsKey(l.IANA)) if (l != null && ianaArticleMap.containsKey(l.IANA))
{ {
// Get the list of words for this language // Get the list of words for this language
ArticlesForLang articles = (ArticlesForLang)ianaArticleMap.get(l.IANA); ArticlesForLang articles = ianaArticleMap.get(l.IANA);
if (articles != null) if (articles != null)
{
return articles.words; return articles.words;
}
} }
return null; return null;
} }
// Mapping of IANA codes to article word lists // Mapping of IANA codes to article word lists
private static Map ianaArticleMap = new HashMap(); private static Map<String, ArticlesForLang> ianaArticleMap = new HashMap<String, ArticlesForLang>();
private static String[] defaultWords = null; private static String[] defaultWords = null;
@@ -247,7 +251,7 @@ public class MARC21InitialArticleWord extends InitialArticleWord
}; };
// Initialize the lang -> article map // Initialize the lang -> article map
ianaArticleMap = new HashMap(); ianaArticleMap = new HashMap<String, ArticlesForLang>();
int wordIdx = 0; int wordIdx = 0;
int langIdx = 0; int langIdx = 0;
@@ -273,7 +277,9 @@ public class MARC21InitialArticleWord extends InitialArticleWord
// Add language to list if we haven't done so already // Add language to list if we haven't done so already
if (!words.contains(articleWordArray[wordIdx][0])) if (!words.contains(articleWordArray[wordIdx][0]))
{
words.add(articleWordArray[wordIdx][0]); words.add(articleWordArray[wordIdx][0]);
}
} }
} }
} }
@@ -315,7 +321,7 @@ public class MARC21InitialArticleWord extends InitialArticleWord
Language l = Language.getLanguage(langArr[idx]); Language l = Language.getLanguage(langArr[idx]);
if (l != null && ianaArticleMap.containsKey(l.IANA)) if (l != null && ianaArticleMap.containsKey(l.IANA))
{ {
afl[idx] = (ArticlesForLang)ianaArticleMap.get(l.IANA); afl[idx] = ianaArticleMap.get(l.IANA);
if (afl[idx] != null) if (afl[idx] != null)
{ {
wordCount += afl[idx].words.length; wordCount += afl[idx].words.length;

View File

@@ -118,8 +118,10 @@ public class IndexEventConsumer implements Consumer {
et = Event.MODIFY; et = Event.MODIFY;
subject = ((Bundle) subject).getItems()[0]; subject = ((Bundle) subject).getItems()[0];
if (log.isDebugEnabled()) if (log.isDebugEnabled())
{
log.debug("Transforming Bundle event into MODIFY of Item " log.debug("Transforming Bundle event into MODIFY of Item "
+ subject.getHandle()); + subject.getHandle());
}
} else } else
{ {
return; return;
@@ -213,7 +215,9 @@ public class IndexEventConsumer implements Consumer {
try { try {
indexer.unIndexContent(ctx, hdl, true); indexer.unIndexContent(ctx, hdl, true);
if (log.isDebugEnabled()) if (log.isDebugEnabled())
{
log.debug("UN-Indexed Item, handle=" + hdl); log.debug("UN-Indexed Item, handle=" + hdl);
}
} }
catch (Exception e) { catch (Exception e) {
log.error("Failed while UN-indexing object: " + hdl, e); log.error("Failed while UN-indexing object: " + hdl, e);

View File

@@ -60,7 +60,9 @@ public class ItemFacets extends org.dspace.app.xmlui.aspect.discovery.AbstractFi
org.dspace.content.DSpaceObject dso = org.dspace.app.xmlui.utils.HandleUtil.obtainHandle(objectModel); org.dspace.content.DSpaceObject dso = org.dspace.app.xmlui.utils.HandleUtil.obtainHandle(objectModel);
if (!(dso instanceof org.dspace.content.Item)) if (!(dso instanceof org.dspace.content.Item))
{
return; return;
}
org.dspace.content.Item item = (org.dspace.content.Item) dso; org.dspace.content.Item item = (org.dspace.content.Item) dso;
try { try {
@@ -76,7 +78,9 @@ public class ItemFacets extends org.dspace.app.xmlui.aspect.discovery.AbstractFi
public void performSearch(org.dspace.content.DSpaceObject dso) throws org.dspace.discovery.SearchServiceException { public void performSearch(org.dspace.content.DSpaceObject dso) throws org.dspace.discovery.SearchServiceException {
if(queryResults != null) if(queryResults != null)
{
return; return;
}
this.queryArgs = prepareDefaultFilters("item"); this.queryArgs = prepareDefaultFilters("item");

View File

@@ -79,7 +79,9 @@ public class Navigation extends AbstractDSpaceTransformer implements CacheablePr
DSpaceObject dso = HandleUtil.obtainHandle(objectModel); DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
if (dso != null) if (dso != null)
{
key += "-" + dso.getHandle(); key += "-" + dso.getHandle();
}
return HashUtil.hash(key); return HashUtil.hash(key);
} }

View File

@@ -100,7 +100,9 @@ public class JSONSolrSearcher extends AbstractReader implements Recyclable {
query = request.getParameter(CommonParams.Q); query = request.getParameter(CommonParams.Q);
if(query == null) if(query == null)
{
query = "*:*"; query = "*:*";
}
//Retrieve all our filter queries //Retrieve all our filter queries
filterQueries = request.getParameterValues(CommonParams.FQ); filterQueries = request.getParameterValues(CommonParams.FQ);
@@ -126,7 +128,9 @@ public class JSONSolrSearcher extends AbstractReader implements Recyclable {
facetSort = request.getParameter(FacetParams.FACET_SORT); facetSort = request.getParameter(FacetParams.FACET_SORT);
//Make sure we have a valid sorting value //Make sure we have a valid sorting value
if(!FacetParams.FACET_SORT_INDEX.equals(facetSort) && !FacetParams.FACET_SORT_COUNT.equals(facetSort)) if(!FacetParams.FACET_SORT_INDEX.equals(facetSort) && !FacetParams.FACET_SORT_COUNT.equals(facetSort))
{
facetSort = null; facetSort = null;
}
//Retrieve our facet min count //Retrieve our facet min count
facetMinCount = 1; facetMinCount = 1;
@@ -163,13 +167,17 @@ public class JSONSolrSearcher extends AbstractReader implements Recyclable {
} }
if(props.getProperty("solr.search.server") != null) if(props.getProperty("solr.search.server") != null)
{
this.solrServerUrl = props.getProperty("solr.search.server").toString(); this.solrServerUrl = props.getProperty("solr.search.server").toString();
}
} }
public void generate() throws IOException, SAXException, ProcessingException { public void generate() throws IOException, SAXException, ProcessingException {
if(solrServerUrl == null) if(solrServerUrl == null)
{
return; return;
}
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
@@ -196,7 +204,9 @@ public class JSONSolrSearcher extends AbstractReader implements Recyclable {
params.put(FacetParams.FACET_LIMIT, String.valueOf(facetLimit)); params.put(FacetParams.FACET_LIMIT, String.valueOf(facetLimit));
if(facetSort != null) if(facetSort != null)
{
params.put(FacetParams.FACET_SORT, facetSort); params.put(FacetParams.FACET_SORT, facetSort);
}
params.put(FacetParams.FACET_MINCOUNT, String.valueOf(facetMinCount)); params.put(FacetParams.FACET_MINCOUNT, String.valueOf(facetMinCount));
solrRequestUrl = AbstractDSpaceTransformer.generateURL(solrRequestUrl, params); solrRequestUrl = AbstractDSpaceTransformer.generateURL(solrRequestUrl, params);
@@ -205,7 +215,9 @@ public class JSONSolrSearcher extends AbstractReader implements Recyclable {
for (String facetField : facetFields) { for (String facetField : facetFields) {
//This class can only be used for autocomplete facet fields //This class can only be used for autocomplete facet fields
if(!facetField.endsWith(".year") && !facetField.endsWith("_ac")) if(!facetField.endsWith(".year") && !facetField.endsWith("_ac"))
{
facetField += "_ac"; facetField += "_ac";
}
solrRequestUrl += "&" + FacetParams.FACET_FIELD + "=" + URLEncoder.encode(facetField, Constants.DEFAULT_ENCODING); solrRequestUrl += "&" + FacetParams.FACET_FIELD + "=" + URLEncoder.encode(facetField, Constants.DEFAULT_ENCODING);
} }
} }

View File

@@ -219,7 +219,9 @@ public class ItemListTag extends TagSupport
if (listTok != null) if (listTok != null)
{ {
if (newLLine.length() > 0) if (newLLine.length() > 0)
{
newLLine.append(","); newLLine.append(",");
}
newLLine.append(listTok); newLLine.append(listTok);
} }
@@ -227,7 +229,9 @@ public class ItemListTag extends TagSupport
if (widthTok != null) if (widthTok != null)
{ {
if (newWLine.length() > 0) if (newWLine.length() > 0)
{
newWLine.append(","); newWLine.append(",");
}
newWLine.append(widthTok); newWLine.append(widthTok);
} }

View File

@@ -389,7 +389,9 @@ public class ItemTag extends TagSupport
String configLine = styleSelection.getConfigurationForStyle(style); String configLine = styleSelection.getConfigurationForStyle(style);
if (configLine == null) if (configLine == null)
{
configLine = defaultFields; configLine = defaultFields;
}
out.println("<center><table class=\"itemDisplayTable\">"); out.println("<center><table class=\"itemDisplayTable\">");
@@ -453,7 +455,9 @@ public class ItemTag extends TagSupport
// check for hidden field, even if it's configured.. // check for hidden field, even if it's configured..
if (MetadataExposure.isHidden(context, schema, element, qualifier)) if (MetadataExposure.isHidden(context, schema, element, qualifier))
{
continue; continue;
}
// FIXME: Still need to fix for metadata language? // FIXME: Still need to fix for metadata language?
DCValue[] values = item.getMetadata(schema, element, qualifier, Item.ANY); DCValue[] values = item.getMetadata(schema, element, qualifier, Item.ANY);

View File

@@ -331,12 +331,16 @@ public class FeedServlet extends DSpaceServlet
BrowserScope scope = new BrowserScope(context); BrowserScope scope = new BrowserScope(context);
scope.setBrowseIndex(bix); scope.setBrowseIndex(bix);
if (dso != null) if (dso != null)
{
scope.setBrowseContainer(dso); scope.setBrowseContainer(dso);
}
for (SortOption so : SortOption.getSortOptions()) for (SortOption so : SortOption.getSortOptions())
{ {
if (so.getName().equals(idx)) if (so.getName().equals(idx))
{
scope.setSortBy(so.getNumber()); scope.setSortBy(so.getNumber());
}
} }
scope.setOrder(SortOption.DESCENDING); scope.setOrder(SortOption.DESCENDING);
scope.setResultsPerPage(itemCount); scope.setResultsPerPage(itemCount);

View File

@@ -128,7 +128,9 @@ public class HTMLServlet extends DSpaceServlet
for (int k = 0; k < bitstreams.length; k++) for (int k = 0; k < bitstreams.length; k++)
{ {
if (bsName.equals(bitstreams[k].getName())) if (bsName.equals(bitstreams[k].getName()))
{
return bitstreams[k]; return bitstreams[k];
}
} }
} }
return null; return null;

View File

@@ -72,7 +72,9 @@ public class LoadDSpaceConfig extends HttpServlet
{ {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
if (osName != null) if (osName != null)
{
osName = osName.toLowerCase(); osName = osName.toLowerCase();
}
if (osName != null && osName.contains("windows")) if (osName != null && osName.contains("windows"))
{ {

View File

@@ -808,7 +808,9 @@ public class MyDSpaceServlet extends DSpaceServlet
finally finally
{ {
if (subs != null) if (subs != null)
{
subs.close(); subs.close();
}
} }
Item[] items = new Item[subList.size()]; Item[] items = new Item[subList.size()];

View File

@@ -716,8 +716,10 @@ public class EditCommunitiesServlet extends DSpaceServlet
// First, if this is not a harvested collection (anymore), set the harvest type to 0; wipe harvest settings // First, if this is not a harvested collection (anymore), set the harvest type to 0; wipe harvest settings
if (contentSource.equals("source_normal")) if (contentSource.equals("source_normal"))
{ {
if (hc != null) if (hc != null)
hc.delete(); {
hc.delete();
}
} }
else else
{ {

View File

@@ -80,7 +80,10 @@ public class GroupListServlet extends DSpaceServlet
// What's the index of the first group to show? Default is 0 // What's the index of the first group to show? Default is 0
int first = UIUtil.getIntParameter(request, "first"); int first = UIUtil.getIntParameter(request, "first");
if (first == -1) first = 0; if (first == -1)
{
first = 0;
}
// Retrieve the e-people in the specified order // Retrieve the e-people in the specified order
Group[] groups = Group.findAll(context, sortBy); Group[] groups = Group.findAll(context, sortBy);

View File

@@ -173,7 +173,9 @@ public class ItemMapServlet extends DSpaceServlet
finally finally
{ {
if (i != null) if (i != null)
{
i.close(); i.close();
}
} }
// remove this collection's entry because we already have a native // remove this collection's entry because we already have a native
@@ -353,7 +355,9 @@ public class ItemMapServlet extends DSpaceServlet
finally finally
{ {
if (itr != null) if (itr != null)
{
itr.close(); itr.close();
}
} }
} }
catch (BrowseException e) catch (BrowseException e)
@@ -397,7 +401,9 @@ public class ItemMapServlet extends DSpaceServlet
finally finally
{ {
if (i != null) if (i != null)
{
i.close(); i.close();
}
} }
request.setAttribute("collection", myCollection); request.setAttribute("collection", myCollection);

View File

@@ -312,7 +312,9 @@ public class JSPStepManager
// first, do any pre-processing and get the JSP to display // first, do any pre-processing and get the JSP to display
// (assuming that this step has an interface) // (assuming that this step has an interface)
if(stepJSPUI!=null) if(stepJSPUI!=null)
stepJSPUI.doPreProcessing(context, request, response, subInfo); {
stepJSPUI.doPreProcessing(context, request, response, subInfo);
}
// Complete this step, if this response has not already // Complete this step, if this response has not already
// been committed. // been committed.

View File

@@ -384,7 +384,9 @@ public class JSPUploadStep extends JSPStep
// if multipart form, then we just finished a file upload // if multipart form, then we just finished a file upload
if ((contentType != null) if ((contentType != null)
&& (contentType.indexOf("multipart/form-data") != -1)) && (contentType.indexOf("multipart/form-data") != -1))
{
fileUpload = true; fileUpload = true;
}
// show the appropriate upload page // show the appropriate upload page
// (based on if a file has just been uploaded or not) // (based on if a file has just been uploaded or not)

View File

@@ -64,9 +64,15 @@ public class LNIRemoteException extends org.apache.axis.AxisFault implements j
private java.lang.Object __equalsCalc = null; private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) { public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof LNIRemoteException)) return false; if (!(obj instanceof LNIRemoteException))
{
return false;
}
LNIRemoteException other = (LNIRemoteException) obj; LNIRemoteException other = (LNIRemoteException) obj;
if (this == obj) return true; if (this == obj)
{
return true;
}
if (__equalsCalc != null) { if (__equalsCalc != null) {
return (__equalsCalc.equals(obj)); return (__equalsCalc.equals(obj));
} }

View File

@@ -180,7 +180,9 @@ class DAVCollection extends DAVDSpaceObject
finally finally
{ {
if (ii != null) if (ii != null)
{
ii.close(); ii.close();
}
} }
return (DAVResource[]) result.toArray(new DAVResource[result.size()]); return (DAVResource[]) result.toArray(new DAVResource[result.size()]);
@@ -625,10 +627,12 @@ class DAVCollection extends DAVDSpaceObject
{ {
Community[] ca = this.collection.getCommunities(); Community[] ca = this.collection.getCommunities();
if (ca != null) if (ca != null)
{
for (Community element : ca) for (Community element : ca)
{ {
element.removeCollection(this.collection); element.removeCollection(this.collection);
} }
}
// collection.delete(); // collection.delete();
return HttpServletResponse.SC_OK; // HTTP OK return HttpServletResponse.SC_OK; // HTTP OK
} }

View File

@@ -142,6 +142,7 @@ public class DAVServlet extends HttpServlet
{ {
Cookie cookies[] = request.getCookies(); Cookie cookies[] = request.getCookies();
if (cookies != null) if (cookies != null)
{
for (Cookie element : cookies) for (Cookie element : cookies)
{ {
if (element.getName().equals(COOKIE_NAME)) if (element.getName().equals(COOKIE_NAME))
@@ -149,6 +150,7 @@ public class DAVServlet extends HttpServlet
return element; return element;
} }
} }
}
return null; return null;
} }

View File

@@ -199,10 +199,26 @@ public class DIDLCrosswalk extends Crosswalk
finally finally
{ {
if (bis != null) if (bis != null)
try { bis.close(); } catch (IOException ioe) { } {
try
{
bis.close();
}
catch (IOException ioe)
{
}
}
if (is != null) if (is != null)
try { is.close(); } catch (IOException ioe) { } {
try
{
is.close();
}
catch (IOException ioe)
{
}
}
} }
contextl.complete(); contextl.complete();

View File

@@ -62,7 +62,9 @@ public class Dataset {
this.matrix = (float[][]) ArrayUtils.clone(matrix); this.matrix = (float[][]) ArrayUtils.clone(matrix);
nbRows = matrix.length; nbRows = matrix.length;
if(0 < matrix.length && 0 < matrix[0].length) if(0 < matrix.length && 0 < matrix[0].length)
{
nbCols = matrix[0].length; nbCols = matrix[0].length;
}
initColumnLabels(nbCols); initColumnLabels(nbCols);
initRowLabels(nbRows); initRowLabels(nbRows);
} }
@@ -201,7 +203,9 @@ public class Dataset {
for (float[] vector : matrix) { for (float[] vector : matrix) {
for (float v : vector) { for (float v : vector) {
if (v != 0) if (v != 0)
{
return true; return true;
}
} }
} }
} }

View File

@@ -69,7 +69,9 @@ public class DatasetTimeGenerator extends DatasetGenerator {
Calendar endCal1 = Calendar.getInstance(); Calendar endCal1 = Calendar.getInstance();
endCal1.setTime(end); endCal1.setTime(end);
if(endCal1.before(startCal1)) if(endCal1.before(startCal1))
{
throw new IllegalArgumentException(); throw new IllegalArgumentException();
}
// TODO: ensure future dates are tested. Although we normally do not // TODO: ensure future dates are tested. Although we normally do not
// have visits from the future. // have visits from the future.

View File

@@ -46,7 +46,9 @@ public class IPTable {
end = range[1].trim().split("/")[0].split("\\."); end = range[1].trim().split("/")[0].split("\\.");
if (start.length != 4 || end.length != 4) if (start.length != 4 || end.length != 4)
{
throw new IPFormatException(ip + " - Ranges need to be full IPv4 Addresses"); throw new IPFormatException(ip + " - Ranges need to be full IPv4 Addresses");
}
if (!(start[0].equals(end[0]) && start[1].equals(end[1]) && start[2].equals(end[2]))) { if (!(start[0].equals(end[0]) && start[1].equals(end[1]) && start[2].equals(end[2]))) {
throw new IPFormatException(ip + " - Ranges can only be across the last subnet x.y.z.0 - x.y.z.254"); throw new IPFormatException(ip + " - Ranges can only be across the last subnet x.y.z.0 - x.y.z.254");
@@ -123,19 +125,30 @@ public class IPTable {
String[] subnets = ip.split("\\."); String[] subnets = ip.split("\\.");
if (subnets.length != 4) if (subnets.length != 4)
{
throw new IPFormatException("needs to be single IP Address"); throw new IPFormatException("needs to be single IP Address");
}
Map<String, Map<String, Set<String>>> first = map.get(subnets[0]); Map<String, Map<String, Set<String>>> first = map.get(subnets[0]);
if (first == null) return false; if (first == null)
{
return false;
}
Map<String, Set<String>> second = first.get(subnets[1]); Map<String, Set<String>> second = first.get(subnets[1]);
if (second == null) return false; if (second == null)
{
return false;
}
Set<String> third = second.get(subnets[2]); Set<String> third = second.get(subnets[2]);
if (third == null) return false; if (third == null)
{
return false;
}
return third.contains(subnets[3]) || third.contains("*"); return third.contains(subnets[3]) || third.contains("*");

View File

@@ -779,12 +779,18 @@ public class LocationUtils {
static static
{ {
if(countryCodeList == null) if(countryCodeList == null)
countryCodeList = Arrays.asList(countryCodes); {
countryCodeList = Arrays.asList(countryCodes);
}
if(continentCodeList == null) if(continentCodeList == null)
{
continentCodeList = Arrays.asList(continentCodes); continentCodeList = Arrays.asList(continentCodes);
}
if(countryNameList == null) if(countryNameList == null)
{
countryNameList = Arrays.asList(countryNames); countryNameList = Arrays.asList(countryNames);
}
} }
private static String[][] continentCodeToName = new String[][]{ private static String[][] continentCodeToName = new String[][]{
@@ -818,7 +824,9 @@ public class LocationUtils {
// String continentCode = getContinentCode(countryCode); // String continentCode = getContinentCode(countryCode);
for (String[] contCodeName : continentCodeToName) { for (String[] contCodeName : continentCodeToName) {
if (contCodeName[0].equals(continentCode)) if (contCodeName[0].equals(continentCode))
{
return contCodeName[1]; return contCodeName[1];
}
} }
return continentCode; return continentCode;
} }

View File

@@ -87,7 +87,9 @@ public class ControlPanelAction extends AbstractAction
// Update the message // Update the message
if (message != null) if (message != null)
SystemwideAlerts.setMessage(message); {
SystemwideAlerts.setMessage(message);
}
if (countdown >= 0) if (countdown >= 0)
{ {

View File

@@ -214,7 +214,9 @@ public class CurrentActivityAction extends AbstractAction
{ {
EPerson eperson = context.getCurrentUser(); EPerson eperson = context.getCurrentUser();
if (eperson != null) if (eperson != null)
epersonID = eperson.getID(); {
epersonID = eperson.getID();
}
} }
if (request != null) if (request != null)
@@ -222,13 +224,17 @@ public class CurrentActivityAction extends AbstractAction
url = request.getSitemapURI(); url = request.getSitemapURI();
HttpSession session = request.getSession(true); HttpSession session = request.getSession(true);
if (session != null) if (session != null)
sessionID = session.getId(); {
sessionID = session.getId();
}
userAgent = request.getHeader("User-Agent"); userAgent = request.getHeader("User-Agent");
ip = request.getHeader(IP_HEADER); ip = request.getHeader(IP_HEADER);
if (ip == null) if (ip == null)
ip = request.getRemoteAddr(); {
ip = request.getRemoteAddr();
}
} }
// The current time // The current time
@@ -282,7 +288,9 @@ public class CurrentActivityAction extends AbstractAction
public boolean isBot() public boolean isBot()
{ {
if (userAgent == null) if (userAgent == null)
return false; {
return false;
}
String ua = userAgent.toLowerCase(); String ua = userAgent.toLowerCase();
return (ua.contains("google/") || return (ua.contains("google/") ||
@@ -302,61 +310,97 @@ public class CurrentActivityAction extends AbstractAction
public String getDectectedBrowser() public String getDectectedBrowser()
{ {
if (userAgent == null) if (userAgent == null)
return "No browser provided"; {
return "No browser provided";
}
String userAgentLower = userAgent.toLowerCase();
// BOTS // BOTS
if (userAgent.toLowerCase().contains("google/")) if (userAgentLower.contains("google/"))
return "Google (bot)"; {
return "Google (bot)";
}
if (userAgent.toLowerCase().contains("msnbot/")) if (userAgentLower.contains("msnbot/"))
return "MSN (bot)"; {
return "MSN (bot)";
}
if (userAgent.toLowerCase().contains("googlebot/")) if (userAgentLower.contains("googlebot/"))
return "Google (bot)"; {
return "Google (bot)";
}
if (userAgent.toLowerCase().contains("webcrawler/")) if (userAgentLower.contains("webcrawler/"))
return "WebCrawler (bot)"; {
return "WebCrawler (bot)";
}
if (userAgent.toLowerCase().contains("inktomi")) if (userAgentLower.contains("inktomi"))
return "Inktomi (bot)"; {
return "Inktomi (bot)";
}
if (userAgent.toLowerCase().contains("teoma")) if (userAgentLower.contains("teoma"))
return "Teoma (bot)"; {
return "Teoma (bot)";
}
if (userAgent.toLowerCase().contains("bot")) if (userAgentLower.contains("bot"))
return "Unknown (bot)"; {
return "Unknown (bot)";
}
// Normal Browsers // Normal Browsers
if (userAgent.contains("Lotus-Notes/")) if (userAgent.contains("Lotus-Notes/"))
return "Lotus-Notes"; {
return "Lotus-Notes";
}
if (userAgent.contains("Opera")) if (userAgent.contains("Opera"))
return "Opera"; {
return "Opera";
}
if (userAgent.contains("Safari/")) if (userAgent.contains("Safari/"))
{ {
if (userAgent.contains("Chrome")) if (userAgent.contains("Chrome"))
return "Chrome"; {
return "Chrome";
}
return "Safari"; return "Safari";
} }
if (userAgent.contains("Konqueror/")) if (userAgent.contains("Konqueror/"))
return "Konqueror"; {
return "Konqueror";
}
// Internet explorer browsers // Internet explorer browsers
if (userAgent.contains("MSIE")) if (userAgent.contains("MSIE"))
{ {
if (userAgent.contains("MSIE 9")) if (userAgent.contains("MSIE 9"))
return "MSIE 9"; {
return "MSIE 9";
}
if (userAgent.contains("MSIE 8")) if (userAgent.contains("MSIE 8"))
return "MSIE 8"; {
return "MSIE 8";
}
if (userAgent.contains("MSIE 7")) if (userAgent.contains("MSIE 7"))
return "MSIE 7"; {
return "MSIE 7";
}
if (userAgent.contains("MSIE 6")) if (userAgent.contains("MSIE 6"))
return "MSIE 6"; {
return "MSIE 6";
}
if (userAgent.contains("MSIE 5")) if (userAgent.contains("MSIE 5"))
return "MSIE 5"; {
return "MSIE 5";
}
// Can't fine the version number // Can't fine the version number
return "MSIE"; return "MSIE";
@@ -366,37 +410,59 @@ public class CurrentActivityAction extends AbstractAction
if (userAgent.contains("Gecko/")) if (userAgent.contains("Gecko/"))
{ {
if (userAgent.contains("Camio/")) if (userAgent.contains("Camio/"))
return "Gecko/Camino"; {
return "Gecko/Camino";
}
if (userAgent.contains("Chimera/")) if (userAgent.contains("Chimera/"))
return "Gecko/Chimera"; {
return "Gecko/Chimera";
}
if (userAgent.contains("Firebird/")) if (userAgent.contains("Firebird/"))
return "Gecko/Firebird"; {
return "Gecko/Firebird";
}
if (userAgent.contains("Phoenix/")) if (userAgent.contains("Phoenix/"))
return "Gecko/Phoenix"; {
return "Gecko/Phoenix";
}
if (userAgent.contains("Galeon")) if (userAgent.contains("Galeon"))
return "Gecko/Galeon"; {
return "Gecko/Galeon";
}
if (userAgent.contains("Firefox/1")) if (userAgent.contains("Firefox/1"))
return "Firefox 1.x"; {
return "Firefox 1.x";
}
if (userAgent.contains("Firefox/2")) if (userAgent.contains("Firefox/2"))
return "Firefox 2.x"; {
return "Firefox 2.x";
}
if (userAgent.contains("Firefox/3")) if (userAgent.contains("Firefox/3"))
return "Firefox 3.x"; {
return "Firefox 3.x";
}
if (userAgent.contains("Firefox/4")) if (userAgent.contains("Firefox/4"))
return "Firefox 4.x"; {
return "Firefox 4.x";
}
if (userAgent.contains("Firefox/")) if (userAgent.contains("Firefox/"))
return "Firefox"; // can't find the exact version {
return "Firefox"; // can't find the exact version
}
if (userAgent.contains("Netscape/")) if (userAgent.contains("Netscape/"))
return "Netscape"; {
return "Netscape";
}
// Can't find the exact distribution // Can't find the exact distribution
return "Gecko"; return "Gecko";
@@ -408,10 +474,14 @@ public class CurrentActivityAction extends AbstractAction
return "KHTML"; return "KHTML";
if (userAgent.contains("Netscape/")) if (userAgent.contains("Netscape/"))
return "Netscape"; {
return "Netscape";
}
if (userAgent.contains("Mozilla/")) if (userAgent.contains("Mozilla/"))
return "Mozilla"; // Almost everything says they are mozilla. {
return "Mozilla"; // Almost everything says they are mozilla.
}
// if you get all the way to the end and still nothing, return unknown. // if you get all the way to the end and still nothing, return unknown.
return "Unknown"; return "Unknown";

View File

@@ -117,21 +117,35 @@ public class FlowContainerUtils
// If they don't have a name then make it untitled. // If they don't have a name then make it untitled.
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
name = "Untitled"; {
name = "Untitled";
}
// If empty, make it null. // If empty, make it null.
if (shortDescription != null && shortDescription.length() == 0) if (shortDescription != null && shortDescription.length() == 0)
shortDescription = null; {
shortDescription = null;
}
if (introductoryText != null && introductoryText.length() == 0) if (introductoryText != null && introductoryText.length() == 0)
introductoryText = null; {
introductoryText = null;
}
if (copyrightText != null && copyrightText.length() == 0) if (copyrightText != null && copyrightText.length() == 0)
copyrightText = null; {
copyrightText = null;
}
if (sideBarText != null && sideBarText.length() == 0) if (sideBarText != null && sideBarText.length() == 0)
sideBarText = null; {
sideBarText = null;
}
if (license != null && license.length() == 0) if (license != null && license.length() == 0)
license = null; {
license = null;
}
if (provenanceDescription != null && provenanceDescription.length() == 0) if (provenanceDescription != null && provenanceDescription.length() == 0)
provenanceDescription = null; {
provenanceDescription = null;
}
// Save the metadata // Save the metadata
collection.setMetadata("name", name); collection.setMetadata("name", name);
@@ -155,7 +169,9 @@ public class FlowContainerUtils
Object object = request.get("logo"); Object object = request.get("logo");
Part filePart = null; Part filePart = null;
if (object instanceof Part) if (object instanceof Part)
filePart = (Part) object; {
filePart = (Part) object;
}
if (filePart != null && filePart.getSize() > 0) if (filePart != null && filePart.getSize() > 0)
{ {
@@ -194,8 +210,10 @@ public class FlowContainerUtils
// First, if this is not a harvested collection (anymore), set the harvest type to 0; possibly also wipe harvest settings // First, if this is not a harvested collection (anymore), set the harvest type to 0; possibly also wipe harvest settings
if (contentSource.equals("source_normal")) if (contentSource.equals("source_normal"))
{ {
if (hc != null) if (hc != null)
hc.delete(); {
hc.delete();
}
result.setContinue(true); result.setContinue(true);
} }
@@ -350,7 +368,9 @@ public class FlowContainerUtils
String oaiSetId = request.getParameter("oai_setid"); String oaiSetId = request.getParameter("oai_setid");
oaiSetId = request.getParameter("oai-set-setting"); oaiSetId = request.getParameter("oai-set-setting");
if(!"all".equals(oaiSetId)) if(!"all".equals(oaiSetId))
{
oaiSetId = request.getParameter("oai_setid"); oaiSetId = request.getParameter("oai_setid");
}
String metadataKey = request.getParameter("metadata_format"); String metadataKey = request.getParameter("metadata_format");
String harvestType = request.getParameter("harvest_level"); String harvestType = request.getParameter("harvest_level");
int harvestTypeInt = 0; int harvestTypeInt = 0;
@@ -446,32 +466,42 @@ public class FlowContainerUtils
{ {
role = collection.getAdministrators(); role = collection.getAdministrators();
if (role == null) if (role == null)
role = collection.createAdministrators(); {
role = collection.createAdministrators();
}
} }
else if (ROLE_SUBMIT.equals(roleName)) else if (ROLE_SUBMIT.equals(roleName))
{ {
role = collection.getSubmitters(); role = collection.getSubmitters();
if (role == null) if (role == null)
role = collection.createSubmitters(); {
role = collection.createSubmitters();
}
} }
else if (ROLE_WF_STEP1.equals(roleName)) else if (ROLE_WF_STEP1.equals(roleName))
{ {
role = collection.getWorkflowGroup(1); role = collection.getWorkflowGroup(1);
if (role == null) if (role == null)
role = collection.createWorkflowGroup(1); {
role = collection.createWorkflowGroup(1);
}
} }
else if (ROLE_WF_STEP2.equals(roleName)) else if (ROLE_WF_STEP2.equals(roleName))
{ {
role = collection.getWorkflowGroup(2); role = collection.getWorkflowGroup(2);
if (role == null) if (role == null)
role = collection.createWorkflowGroup(2); {
role = collection.createWorkflowGroup(2);
}
} }
else if (ROLE_WF_STEP3.equals(roleName)) else if (ROLE_WF_STEP3.equals(roleName))
{ {
role = collection.getWorkflowGroup(3); role = collection.getWorkflowGroup(3);
if (role == null) if (role == null)
role = collection.createWorkflowGroup(3); {
role = collection.createWorkflowGroup(3);
}
} }
@@ -481,7 +511,9 @@ public class FlowContainerUtils
// If the role name was valid then role should be non null, // If the role name was valid then role should be non null,
if (role != null) if (role != null)
return role.getID(); {
return role.getID();
}
return -1; return -1;
} }
@@ -534,7 +566,9 @@ public class FlowContainerUtils
for (ResourcePolicy policy : policies) for (ResourcePolicy policy : policies)
{ {
if (policy.getGroupID() == groupID) if (policy.getGroupID() == groupID)
policy.delete(); {
policy.delete();
}
} }
// Finally, Delete the role's actual group. // Finally, Delete the role's actual group.
@@ -605,7 +639,9 @@ public class FlowContainerUtils
int roleID = getCollectionDefaultRead(context, collectionID); int roleID = getCollectionDefaultRead(context, collectionID);
if (roleID != 0) if (roleID != 0)
throw new UIException("Unable to create a new default read group because either the group allready exists or multiple groups are assigned the default privleges."); {
throw new UIException("Unable to create a new default read group because either the group allready exists or multiple groups are assigned the default privleges.");
}
Collection collection = Collection.find(context,collectionID); Collection collection = Collection.find(context,collectionID);
Group role = Group.create(context); Group role = Group.create(context);
@@ -723,21 +759,35 @@ public class FlowContainerUtils
// If they don't have a name then make it untitled. // If they don't have a name then make it untitled.
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
name = "Untitled"; {
name = "Untitled";
}
// If empty, make it null. // If empty, make it null.
if (shortDescription != null && shortDescription.length() == 0) if (shortDescription != null && shortDescription.length() == 0)
shortDescription = null; {
shortDescription = null;
}
if (introductoryText != null && introductoryText.length() == 0) if (introductoryText != null && introductoryText.length() == 0)
introductoryText = null; {
introductoryText = null;
}
if (copyrightText != null && copyrightText.length() == 0) if (copyrightText != null && copyrightText.length() == 0)
copyrightText = null; {
copyrightText = null;
}
if (sideBarText != null && sideBarText.length() == 0) if (sideBarText != null && sideBarText.length() == 0)
sideBarText = null; {
sideBarText = null;
}
if (license != null && license.length() == 0) if (license != null && license.length() == 0)
license = null; {
license = null;
}
if (provenanceDescription != null && provenanceDescription.length() == 0) if (provenanceDescription != null && provenanceDescription.length() == 0)
provenanceDescription = null; {
provenanceDescription = null;
}
// Save the metadata // Save the metadata
newCollection.setMetadata("name", name); newCollection.setMetadata("name", name);
@@ -753,7 +803,9 @@ public class FlowContainerUtils
Object object = request.get("logo"); Object object = request.get("logo");
Part filePart = null; Part filePart = null;
if (object instanceof Part) if (object instanceof Part)
filePart = (Part) object; {
filePart = (Part) object;
}
if (filePart != null && filePart.getSize() > 0) if (filePart != null && filePart.getSize() > 0)
{ {
@@ -811,17 +863,27 @@ public class FlowContainerUtils
// If they don't have a name then make it untitled. // If they don't have a name then make it untitled.
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
name = "Untitled"; {
name = "Untitled";
}
// If empty, make it null. // If empty, make it null.
if (shortDescription != null && shortDescription.length() == 0) if (shortDescription != null && shortDescription.length() == 0)
shortDescription = null; {
shortDescription = null;
}
if (introductoryText != null && introductoryText.length() == 0) if (introductoryText != null && introductoryText.length() == 0)
introductoryText = null; {
introductoryText = null;
}
if (copyrightText != null && copyrightText.length() == 0) if (copyrightText != null && copyrightText.length() == 0)
copyrightText = null; {
copyrightText = null;
}
if (sideBarText != null && sideBarText.length() == 0) if (sideBarText != null && sideBarText.length() == 0)
sideBarText = null; {
sideBarText = null;
}
newCommunity.setMetadata("name", name); newCommunity.setMetadata("name", name);
newCommunity.setMetadata("short_description", shortDescription); newCommunity.setMetadata("short_description", shortDescription);
@@ -833,7 +895,9 @@ public class FlowContainerUtils
Object object = request.get("logo"); Object object = request.get("logo");
Part filePart = null; Part filePart = null;
if (object instanceof Part) if (object instanceof Part)
filePart = (Part) object; {
filePart = (Part) object;
}
if (filePart != null && filePart.getSize() > 0) if (filePart != null && filePart.getSize() > 0)
{ {
@@ -878,17 +942,27 @@ public class FlowContainerUtils
// If they don't have a name then make it untitled. // If they don't have a name then make it untitled.
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
name = "Untitled"; {
name = "Untitled";
}
// If empty, make it null. // If empty, make it null.
if (shortDescription != null && shortDescription.length() == 0) if (shortDescription != null && shortDescription.length() == 0)
shortDescription = null; {
shortDescription = null;
}
if (introductoryText != null && introductoryText.length() == 0) if (introductoryText != null && introductoryText.length() == 0)
introductoryText = null; {
introductoryText = null;
}
if (copyrightText != null && copyrightText.length() == 0) if (copyrightText != null && copyrightText.length() == 0)
copyrightText = null; {
copyrightText = null;
}
if (sideBarText != null && sideBarText.length() == 0) if (sideBarText != null && sideBarText.length() == 0)
sideBarText = null; {
sideBarText = null;
}
// Save the data // Save the data
community.setMetadata("name", name); community.setMetadata("name", name);
@@ -908,7 +982,9 @@ public class FlowContainerUtils
Object object = request.get("logo"); Object object = request.get("logo");
Part filePart = null; Part filePart = null;
if (object instanceof Part) if (object instanceof Part)
filePart = (Part) object; {
filePart = (Part) object;
}
if (filePart != null && filePart.getSize() > 0) if (filePart != null && filePart.getSize() > 0)
{ {
@@ -971,7 +1047,9 @@ public class FlowContainerUtils
{ {
role = community.getAdministrators(); role = community.getAdministrators();
if (role == null) if (role == null)
{
role = community.createAdministrators(); role = community.createAdministrators();
}
} }
// In case we needed to create a group, save our changes // In case we needed to create a group, save our changes
@@ -980,7 +1058,9 @@ public class FlowContainerUtils
// If the role name was valid then role should be non null, // If the role name was valid then role should be non null,
if (role != null) if (role != null)
{
return role.getID(); return role.getID();
}
return -1; return -1;
} }
@@ -1015,7 +1095,9 @@ public class FlowContainerUtils
for (ResourcePolicy policy : policies) for (ResourcePolicy policy : policies)
{ {
if (policy.getGroupID() == groupID) if (policy.getGroupID() == groupID)
{
policy.delete(); policy.delete();
}
} }
// Finally, delete the role's actual group. // Finally, delete the role's actual group.
@@ -1111,7 +1193,9 @@ public class FlowContainerUtils
public static String escapeXMLEntities(String value) public static String escapeXMLEntities(String value)
{ {
if (value == null) if (value == null)
return null; {
return null;
}
// Escape any XML entities // Escape any XML entities
int amp = -1; int amp = -1;
@@ -1119,27 +1203,39 @@ public class FlowContainerUtils
{ {
// Is it an xml entity named by number? // Is it an xml entity named by number?
if (substringCompare(value,amp+1,'#')) if (substringCompare(value,amp+1,'#'))
continue; {
continue;
}
// &amp; // &amp;
if (substringCompare(value,amp+1,'a','m','p',';')) if (substringCompare(value,amp+1,'a','m','p',';'))
continue; {
continue;
}
// &apos; // &apos;
if (substringCompare(value,amp+1,'a','p','o','s',';')) if (substringCompare(value,amp+1,'a','p','o','s',';'))
continue; {
continue;
}
// &quot; // &quot;
if (substringCompare(value,amp+1,'q','u','o','t',';')) if (substringCompare(value,amp+1,'q','u','o','t',';'))
continue; {
continue;
}
// &lt; // &lt;
if (substringCompare(value,amp+1,'l','t',';')) if (substringCompare(value,amp+1,'l','t',';'))
continue; {
continue;
}
// &gt; // &gt;
if (substringCompare(value,amp+1,'g','t',';')) if (substringCompare(value,amp+1,'g','t',';'))
continue; {
continue;
}
// Replace the ampersand with an XML entity. // Replace the ampersand with an XML entity.
value = value.substring(0,amp) + "&amp;" + value.substring(amp+1); value = value.substring(0,amp) + "&amp;" + value.substring(amp+1);
@@ -1161,13 +1257,17 @@ public class FlowContainerUtils
{ {
// Is the string long enough? // Is the string long enough?
if (string.length() <= index + characters.length) if (string.length() <= index + characters.length)
return false; {
return false;
}
// Do all the characters match? // Do all the characters match?
for (char character : characters) for (char character : characters)
{ {
if (string.charAt(index) != character) if (string.charAt(index) != character)
return false; {
return false;
}
index++; index++;
} }

View File

@@ -51,6 +51,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.http.HttpEnvironment; import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.commons.lang.StringUtils;
import org.dspace.app.xmlui.utils.AuthenticationUtil; import org.dspace.app.xmlui.utils.AuthenticationUtil;
import org.dspace.app.xmlui.wing.Message; import org.dspace.app.xmlui.wing.Message;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
@@ -108,12 +109,18 @@ public class FlowEPersonUtils {
boolean certificate = (request.getParameter("certificate") != null) ? true : false; boolean certificate = (request.getParameter("certificate") != null) ? true : false;
// If we have errors, the form needs to be resubmitted to fix those problems // If we have errors, the form needs to be resubmitted to fix those problems
if (email.length() == 0) if (StringUtils.isEmpty(email))
result.addError("email_address"); {
if (first.length() == 0) result.addError("email_address");
result.addError("first_name"); }
if (last.length() == 0) if (StringUtils.isEmpty(first))
result.addError("last_name"); {
result.addError("first_name");
}
if (StringUtils.isEmpty(last))
{
result.addError("last_name");
}
// Check if the email address is all ready being used. // Check if the email address is all ready being used.
@@ -178,12 +185,18 @@ public class FlowEPersonUtils {
// If we have errors, the form needs to be resubmitted to fix those problems // If we have errors, the form needs to be resubmitted to fix those problems
if (email.length() == 0) if (StringUtils.isEmpty(email))
result.addError("email_address"); {
if (first.length() == 0) result.addError("email_address");
result.addError("first_name"); }
if (last.length() == 0) if (StringUtils.isEmpty(first))
result.addError("last_name"); {
result.addError("first_name");
}
if (StringUtils.isEmpty(last))
{
result.addError("last_name");
}
// No errors, so we edit the EPerson with the data provided // No errors, so we edit the EPerson with the data provided

View File

@@ -80,12 +80,16 @@ public class FlowGroupUtils {
public static String getName(Context context, int groupID) throws SQLException public static String getName(Context context, int groupID) throws SQLException
{ {
if (groupID < 0) if (groupID < 0)
return "New Group"; {
return "New Group";
}
Group group = Group.find(context,groupID); Group group = Group.find(context,groupID);
if (group == null) if (group == null)
return "New Group"; {
return "New Group";
}
return group.getName(); return group.getName();
} }
@@ -101,12 +105,16 @@ public class FlowGroupUtils {
{ {
// New group, just return an empty list // New group, just return an empty list
if (groupID < 0) if (groupID < 0)
return new String[0]; {
return new String[0];
}
Group group = Group.find(context,groupID); Group group = Group.find(context,groupID);
if (group == null) if (group == null)
return new String[0]; {
return new String[0];
}
EPerson[] epeople = group.getMembers(); EPerson[] epeople = group.getMembers();
@@ -129,12 +137,16 @@ public class FlowGroupUtils {
public static String[] getGroupMembers(Context context, int groupID) throws SQLException public static String[] getGroupMembers(Context context, int groupID) throws SQLException
{ {
if (groupID < 0) if (groupID < 0)
return new String[0]; {
return new String[0];
}
Group group = Group.find(context,groupID); Group group = Group.find(context,groupID);
if (group == null) if (group == null)
return new String[0]; {
return new String[0];
}
Group[] groups = group.getMemberGroups(); Group[] groups = group.getMemberGroups();

View File

@@ -220,7 +220,9 @@ public class FlowItemUtils
// the user selected the remove checkbox. // the user selected the remove checkbox.
if (remove != null) if (remove != null)
continue; {
continue;
}
// get the field's name broken up // get the field's name broken up
String[] parts = parseName(name); String[] parts = parseName(name);
@@ -228,10 +230,14 @@ public class FlowItemUtils
// probe for a confidence value // probe for a confidence value
int iconf = Choices.CF_UNSET; int iconf = Choices.CF_UNSET;
if (confidence != null && confidence.length() > 0) if (confidence != null && confidence.length() > 0)
{
iconf = Choices.getConfidenceValue(confidence); iconf = Choices.getConfidenceValue(confidence);
}
// upgrade to a minimum of NOVALUE if there IS an authority key // upgrade to a minimum of NOVALUE if there IS an authority key
if (authority != null && authority.length() > 0 && iconf == Choices.CF_UNSET) if (authority != null && authority.length() > 0 && iconf == Choices.CF_UNSET)
{
iconf = Choices.CF_NOVALUE; iconf = Choices.CF_NOVALUE;
}
item.addMetadata(parts[0], parts[1], parts[2], lang, item.addMetadata(parts[0], parts[1], parts[2], lang,
value, authority, iconf); value, authority, iconf);
} }
@@ -390,10 +396,14 @@ public class FlowItemUtils
// Remove item from its owning collection and add to the destination // Remove item from its owning collection and add to the destination
if (!alreadyInCollection) if (!alreadyInCollection)
{
destination.addItem(item); destination.addItem(item);
}
if (owningCollection != null) if (owningCollection != null)
{
owningCollection.removeItem(item); owningCollection.removeItem(item);
}
item.setOwningCollection(destination); item.setOwningCollection(destination);
item.update(); item.update();
@@ -465,7 +475,9 @@ public class FlowItemUtils
Object object = request.get("file"); Object object = request.get("file");
Part filePart = null; Part filePart = null;
if (object instanceof Part) if (object instanceof Part)
filePart = (Part) object; {
filePart = (Part) object;
}
if (filePart != null && filePart.getSize() > 0) if (filePart != null && filePart.getSize() > 0)
{ {
@@ -645,7 +657,9 @@ public class FlowItemUtils
String[] parts = id.split("/"); String[] parts = id.split("/");
if (parts.length != 2) if (parts.length != 2)
throw new UIException("Unable to parse id into bundle and bitstream id: "+id); {
throw new UIException("Unable to parse id into bundle and bitstream id: " + id);
}
int bundleID = Integer.valueOf(parts[0]); int bundleID = Integer.valueOf(parts[0]);
int bitstreamID = Integer.valueOf(parts[1]); int bitstreamID = Integer.valueOf(parts[1]);

View File

@@ -110,16 +110,19 @@ public class FlowRegistryUtils
throw new UIException(uee); throw new UIException(uee);
} }
if (namespace == null || if (namespace == null || namespace.length() <= 0)
namespace.length() <= 0) {
result.addError("namespace"); result.addError("namespace");
}
if (name == null || if (name == null ||
name.length() <= 0 || name.length() <= 0 ||
name.indexOf('.') != -1 || name.indexOf('.') != -1 ||
name.indexOf('_') != -1 || name.indexOf('_') != -1 ||
name.indexOf(' ') != -1) name.indexOf(' ') != -1)
// The name must not be empty nor contain dot, underscore or spaces. {
result.addError("name"); // The name must not be empty nor contain dot, underscore or spaces.
result.addError("name");
}
if (result.getErrors() == null) if (result.getErrors() == null)
@@ -213,7 +216,9 @@ public class FlowRegistryUtils
// Make sure qualifier is null if blank. // Make sure qualifier is null if blank.
if ("".equals(qualifier)) if ("".equals(qualifier))
qualifier = null; {
qualifier = null;
}
if (result.getErrors() == null) if (result.getErrors() == null)
{ {
@@ -277,12 +282,16 @@ public class FlowRegistryUtils
// Make sure qualifier is null if blank. // Make sure qualifier is null if blank.
if ("".equals(qualifier)) if ("".equals(qualifier))
qualifier = null; {
qualifier = null;
}
// Check to make sure the field is unique, sometimes the NonUniqueMetadataException is not thrown. // Check to make sure the field is unique, sometimes the NonUniqueMetadataException is not thrown.
MetadataField possibleDuplicate = MetadataField.findByElement(context, schemaID, element, qualifier); MetadataField possibleDuplicate = MetadataField.findByElement(context, schemaID, element, qualifier);
if (possibleDuplicate != null && possibleDuplicate.getFieldID() != fieldID) if (possibleDuplicate != null && possibleDuplicate.getFieldID() != fieldID)
result.addError("duplicate_field"); {
result.addError("duplicate_field");
}
if (result.getErrors() == null) if (result.getErrors() == null)
{ {
@@ -334,28 +343,38 @@ public class FlowRegistryUtils
if (element.indexOf('.') != -1 || if (element.indexOf('.') != -1 ||
element.indexOf('_') != -1 || element.indexOf('_') != -1 ||
element.indexOf(' ') != -1) element.indexOf(' ') != -1)
errors.add("element_badchar"); {
errors.add("element_badchar");
}
// Is the element too long? // Is the element too long?
if (element.length() > 64) if (element.length() > 64)
errors.add("element_tolong"); {
errors.add("element_tolong");
}
// The qualifier can be empty. // The qualifier can be empty.
if (qualifier != null && qualifier.length() > 0) if (qualifier != null && qualifier.length() > 0)
{ {
if (qualifier.length() > 64) if (qualifier.length() > 64)
errors.add("qualifier_tolong"); {
errors.add("qualifier_tolong");
}
if (qualifier.indexOf('.') != -1 || if (qualifier.indexOf('.') != -1 ||
qualifier.indexOf('_') != -1 || qualifier.indexOf('_') != -1 ||
qualifier.indexOf(' ') != -1) qualifier.indexOf(' ') != -1)
errors.add("qualifier_badchar"); {
errors.add("qualifier_badchar");
}
} }
// If there were no errors then just return null. // If there were no errors then just return null.
if (errors.size() == 0) if (errors.size() == 0)
return null; {
return null;
}
return errors; return errors;
} }

View File

@@ -186,7 +186,9 @@ public class FlowResult {
public String getHeader() public String getHeader()
{ {
if (this.header != null) if (this.header != null)
return this.header.getKey(); {
return this.header.getKey();
}
return null; return null;
} }
@@ -206,7 +208,9 @@ public class FlowResult {
public String getMessage() public String getMessage()
{ {
if (this.message != null) if (this.message != null)
return this.message.getKey(); {
return this.message.getKey();
}
return null; return null;
} }
@@ -244,7 +248,9 @@ public class FlowResult {
public void addError(String newError) public void addError(String newError)
{ {
if (this.errors == null) if (this.errors == null)
this.errors = new ArrayList<String>(); {
this.errors = new ArrayList<String>();
}
this.errors.add(newError); this.errors.add(newError);
} }
@@ -294,7 +300,9 @@ public class FlowResult {
public void setParameter(String name, Object value) public void setParameter(String name, Object value)
{ {
if (this.parameters == null) if (this.parameters == null)
this.parameters = new HashMap<String,Object>(); {
this.parameters = new HashMap<String, Object>();
}
this.parameters.put(name, value); this.parameters.put(name, value);
} }
@@ -309,7 +317,9 @@ public class FlowResult {
public Object getParameter(String name) public Object getParameter(String name)
{ {
if (this.parameters == null) if (this.parameters == null)
return null; {
return null;
}
return this.parameters.get(name); return this.parameters.get(name);
} }

View File

@@ -148,7 +148,9 @@ public class ItemExport extends AbstractDSpaceTransformer implements
} }
} }
if (errors.size() <= 0) if (errors.size() <= 0)
message = T_item_export_success; {
message = T_item_export_success;
}
} else if (request.getParameter("collectionID") != null) { } else if (request.getParameter("collectionID") != null) {
Collection col = null; Collection col = null;
try { try {
@@ -169,7 +171,9 @@ public class ItemExport extends AbstractDSpaceTransformer implements
} }
} }
if (errors.size() <= 0) if (errors.size() <= 0)
message = T_col_export_success; {
message = T_col_export_success;
}
} else if (request.getParameter("communityID") != null) { } else if (request.getParameter("communityID") != null) {
Community com = null; Community com = null;
try { try {
@@ -190,7 +194,9 @@ public class ItemExport extends AbstractDSpaceTransformer implements
} }
} }
if (errors.size() <= 0) if (errors.size() <= 0)
message = T_community_export_success; {
message = T_community_export_success;
}
} }
try { try {

View File

@@ -276,8 +276,10 @@ public class Navigation extends AbstractDSpaceTransformer implements CacheablePr
context.setHead(T_context_head); context.setHead(T_context_head);
context.addItemXref(contextPath+"/admin/community?communityID=" + community.getID(), T_context_edit_community); context.addItemXref(contextPath+"/admin/community?communityID=" + community.getID(), T_context_edit_community);
if (AuthorizeManager.isAdmin(this.context, dso)) if (AuthorizeManager.isAdmin(this.context, dso))
context.addItem().addXref(contextPath+"/admin/export?communityID="+community.getID(), T_context_export_community ); {
context.addItem().addXref(contextPath+ "/csv/handle/"+dso.getHandle(),T_context_export_metadata ); context.addItem().addXref(contextPath + "/admin/export?communityID=" + community.getID(), T_context_export_community);
}
context.addItem().addXref(contextPath+ "/csv/handle/"+dso.getHandle(),T_context_export_metadata );
} }
// can they add to this community? // can they add to this community?

View File

@@ -170,7 +170,9 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
// Same for the current action; it can either blank (-1), manually set, or inherited from the current policy // Same for the current action; it can either blank (-1), manually set, or inherited from the current policy
if (policy != null && actionID == -1) if (policy != null && actionID == -1)
actionID = policy.getAction(); {
actionID = policy.getAction();
}
String errorString = parameters.getParameter("errors",null); String errorString = parameters.getParameter("errors",null);
ArrayList<String> errors = new ArrayList<String>(); ArrayList<String> errors = new ArrayList<String>();
@@ -241,7 +243,9 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
} }
} }
if (errors.contains("action_id")) if (errors.contains("action_id"))
actionSelect.addError(T_error_no_action); {
actionSelect.addError(T_error_no_action);
}
// currently set group // currently set group
@@ -268,7 +272,9 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
Item searchItem = actionsList.addItem(); Item searchItem = actionsList.addItem();
Text searchText = searchItem.addText("query"); Text searchText = searchItem.addText("query");
if (!query.equals("-1")) if (!query.equals("-1"))
searchText.setValue(query); {
searchText.setValue(query);
}
searchItem.addButton("submit_search_groups").setValue(T_submit_search_groups); searchItem.addButton("submit_search_groups").setValue(T_submit_search_groups);
@@ -307,9 +313,13 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
String nextURL = null, prevURL = null; String nextURL = null, prevURL = null;
if (page < ((totalResults - 1) / RESULTS_PER_PAGE)) if (page < ((totalResults - 1) / RESULTS_PER_PAGE))
nextURL = baseURL+"&page="+(page+1); {
nextURL = baseURL + "&page=" + (page + 1);
}
if (page > 0) if (page > 0)
prevURL = baseURL+"&page="+(page-1); {
prevURL = baseURL + "&page=" + (page - 1);
}
div.setSimplePagination(totalResults,firstIndex,lastIndex,prevURL, nextURL); div.setSimplePagination(totalResults,firstIndex,lastIndex,prevURL, nextURL);
} }

View File

@@ -150,32 +150,40 @@ public class EditCollectionMetadataForm extends AbstractDSpaceTransformer
Text short_description = metadataList.addItem().addText("short_description"); Text short_description = metadataList.addItem().addText("short_description");
short_description.setValue(thisCollection.getMetadata("short_description")); short_description.setValue(thisCollection.getMetadata("short_description"));
short_description.setSize(40); short_description.setSize(40);
if (short_description_error != null) if (short_description_error != null)
short_description.addError(short_description_error); {
short_description.addError(short_description_error);
}
// introductory text // introductory text
metadataList.addLabel(T_label_introductory_text); metadataList.addLabel(T_label_introductory_text);
TextArea introductory_text = metadataList.addItem().addTextArea("introductory_text"); TextArea introductory_text = metadataList.addItem().addTextArea("introductory_text");
introductory_text.setValue(thisCollection.getMetadata("introductory_text")); introductory_text.setValue(thisCollection.getMetadata("introductory_text"));
introductory_text.setSize(6, 40); introductory_text.setSize(6, 40);
if (introductory_text_error != null) if (introductory_text_error != null)
introductory_text.addError(introductory_text_error); {
introductory_text.addError(introductory_text_error);
}
// copyright text // copyright text
metadataList.addLabel(T_label_copyright_text); metadataList.addLabel(T_label_copyright_text);
TextArea copyright_text = metadataList.addItem().addTextArea("copyright_text"); TextArea copyright_text = metadataList.addItem().addTextArea("copyright_text");
copyright_text.setValue(thisCollection.getMetadata("copyright_text")); copyright_text.setValue(thisCollection.getMetadata("copyright_text"));
copyright_text.setSize(6, 40); copyright_text.setSize(6, 40);
if (copyright_text_error != null) if (copyright_text_error != null)
copyright_text.addError(copyright_text_error); {
copyright_text.addError(copyright_text_error);
}
// legacy sidebar text; may or may not be used for news // legacy sidebar text; may or may not be used for news
metadataList.addLabel(T_label_side_bar_text); metadataList.addLabel(T_label_side_bar_text);
TextArea side_bar_text = metadataList.addItem().addTextArea("side_bar_text"); TextArea side_bar_text = metadataList.addItem().addTextArea("side_bar_text");
side_bar_text.setValue(thisCollection.getMetadata("side_bar_text")); side_bar_text.setValue(thisCollection.getMetadata("side_bar_text"));
side_bar_text.setSize(6, 40); side_bar_text.setSize(6, 40);
if (side_bar_text_error != null) if (side_bar_text_error != null)
side_bar_text.addError(side_bar_text_error); {
side_bar_text.addError(side_bar_text_error);
}
// license text // license text
metadataList.addLabel(T_label_license); metadataList.addLabel(T_label_license);

View File

@@ -134,32 +134,40 @@ public class EditCommunityMetadataForm extends AbstractDSpaceTransformer
Text short_description = metadataList.addItem().addText("short_description"); Text short_description = metadataList.addItem().addText("short_description");
short_description.setValue(thisCommunity.getMetadata("short_description")); short_description.setValue(thisCommunity.getMetadata("short_description"));
short_description.setSize(40); short_description.setSize(40);
if (short_description_error != null) if (short_description_error != null)
short_description.addError(short_description_error); {
short_description.addError(short_description_error);
}
// introductory text // introductory text
metadataList.addLabel(T_label_introductory_text); metadataList.addLabel(T_label_introductory_text);
TextArea introductory_text = metadataList.addItem().addTextArea("introductory_text"); TextArea introductory_text = metadataList.addItem().addTextArea("introductory_text");
introductory_text.setValue(thisCommunity.getMetadata("introductory_text")); introductory_text.setValue(thisCommunity.getMetadata("introductory_text"));
introductory_text.setSize(6, 40); introductory_text.setSize(6, 40);
if (introductory_text_error != null) if (introductory_text_error != null)
introductory_text.addError(introductory_text_error); {
introductory_text.addError(introductory_text_error);
}
// copyright text // copyright text
metadataList.addLabel(T_label_copyright_text); metadataList.addLabel(T_label_copyright_text);
TextArea copyright_text = metadataList.addItem().addTextArea("copyright_text"); TextArea copyright_text = metadataList.addItem().addTextArea("copyright_text");
copyright_text.setValue(thisCommunity.getMetadata("copyright_text")); copyright_text.setValue(thisCommunity.getMetadata("copyright_text"));
copyright_text.setSize(6, 40); copyright_text.setSize(6, 40);
if (copyright_text_error != null) if (copyright_text_error != null)
copyright_text.addError(copyright_text_error); {
copyright_text.addError(copyright_text_error);
}
// legacy sidebar text; may or may not be used for news // legacy sidebar text; may or may not be used for news
metadataList.addLabel(T_label_side_bar_text); metadataList.addLabel(T_label_side_bar_text);
TextArea side_bar_text = metadataList.addItem().addTextArea("side_bar_text"); TextArea side_bar_text = metadataList.addItem().addTextArea("side_bar_text");
side_bar_text.setValue(thisCommunity.getMetadata("side_bar_text")); side_bar_text.setValue(thisCommunity.getMetadata("side_bar_text"));
side_bar_text.setSize(6, 40); side_bar_text.setSize(6, 40);
if (side_bar_text_error != null) if (side_bar_text_error != null)
side_bar_text.addError(side_bar_text_error); {
side_bar_text.addError(side_bar_text_error);
}
// the row to upload a new logo // the row to upload a new logo
metadataList.addLabel(T_label_logo); metadataList.addLabel(T_label_logo);

View File

@@ -208,7 +208,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
EPerson eperson = EPerson.find(context, epersonID); EPerson eperson = EPerson.find(context, epersonID);
if (eperson == null) if (eperson == null)
throw new UIException("Unable to find eperson for id:"+epersonID); {
throw new UIException("Unable to find eperson for id:" + epersonID);
}
String emailValue = eperson.getEmail(); String emailValue = eperson.getEmail();
String firstValue = eperson.getFirstName(); String firstValue = eperson.getFirstName();
@@ -219,13 +221,21 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
java.util.List<String> deleteConstraints = eperson.getDeleteConstraints(); java.util.List<String> deleteConstraints = eperson.getDeleteConstraints();
if (request.getParameter("email_address") != null) if (request.getParameter("email_address") != null)
emailValue = request.getParameter("email_address"); {
emailValue = request.getParameter("email_address");
}
if (request.getParameter("first_name") != null) if (request.getParameter("first_name") != null)
firstValue = request.getParameter("first_name"); {
firstValue = request.getParameter("first_name");
}
if (request.getParameter("last_name") != null) if (request.getParameter("last_name") != null)
lastValue = request.getParameter("last_name"); {
lastValue = request.getParameter("last_name");
}
if (request.getParameter("phone") != null) if (request.getParameter("phone") != null)
phoneValue = request.getParameter("phone"); {
phoneValue = request.getParameter("phone");
}
@@ -271,7 +281,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
firstName.setLabel(T_first_name); firstName.setLabel(T_first_name);
firstName.setValue(firstValue); firstName.setValue(firstValue);
if (errors.contains("first_name")) if (errors.contains("first_name"))
firstName.addError(T_error_fname); {
firstName.addError(T_error_fname);
}
} }
else else
{ {
@@ -286,7 +298,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
lastName.setLabel(T_last_name); lastName.setLabel(T_last_name);
lastName.setValue(lastValue); lastName.setValue(lastValue);
if (errors.contains("last_name")) if (errors.contains("last_name"))
lastName.addError(T_error_lname); {
lastName.addError(T_error_lname);
}
} }
else else
{ {
@@ -329,7 +343,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
Button submitLoginAs = special.addButton("submit_login_as"); Button submitLoginAs = special.addButton("submit_login_as");
submitLoginAs.setValue(T_submit_login_as); submitLoginAs.setValue(T_submit_login_as);
if (!ConfigurationManager.getBooleanProperty("xmlui.user.assumelogin", false)) if (!ConfigurationManager.getBooleanProperty("xmlui.user.assumelogin", false))
submitLoginAs.setDisabled(); {
submitLoginAs.setDisabled();
}
if (deleteConstraints != null && deleteConstraints.size() > 0) if (deleteConstraints != null && deleteConstraints.size() > 0)
{ {
@@ -349,7 +365,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
hi.addContent(" "); hi.addContent(" ");
} }
else if (idx > 0) else if (idx > 0)
hi.addContent(", "); {
hi.addContent(", ");
}
if ("item".equals(constraint)) if ("item".equals(constraint))
{ {
@@ -376,7 +394,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
Item buttons = identity.addItem(); Item buttons = identity.addItem();
if (admin) if (admin)
buttons.addButton("submit_save").setValue(T_submit_save); {
buttons.addButton("submit_save").setValue(T_submit_save);
}
buttons.addButton("submit_cancel").setValue(T_submit_cancel); buttons.addButton("submit_cancel").setValue(T_submit_cancel);
@@ -397,13 +417,15 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
// Check if this membership is via another group or not, if so then add a note. // Check if this membership is via another group or not, if so then add a note.
Group via = findViaGroup(eperson, group); Group via = findViaGroup(eperson, group);
if (via != null) if (via != null)
item.addHighlight("fade").addContent(T_indirect_member.parameterize(via.getName())); {
item.addHighlight("fade").addContent(T_indirect_member.parameterize(via.getName()));
}
} }
if (groups.length <= 0) if (groups.length <= 0)
member.addItem().addHighlight("italic").addContent(T_member_none); {
member.addItem().addHighlight("italic").addContent(T_member_none);
}
} }
edit.addHidden("administrative-continue").setValue(knot.getId()); edit.addHidden("administrative-continue").setValue(knot.getId());
@@ -427,8 +449,10 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
for (EPerson direct : group.getMembers()) for (EPerson direct : group.getMembers())
{ {
if (direct.getID() == eperson.getID()) if (direct.getID() == eperson.getID())
// Direct membership {
return null; // Direct membership
return null;
}
} }
// Otherwise check what group this eperson is a member through // Otherwise check what group this eperson is a member through
@@ -440,7 +464,9 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
for (Group target : targets) for (Group target : targets)
{ {
if (member.getID() == target.getID()) if (member.getID() == target.getID())
return member; {
return member;
}
} }
} }

View File

@@ -175,7 +175,9 @@ public class ManageEPeopleMain extends AbstractDSpaceTransformer
org.dspace.app.xmlui.wing.element.Item actionItem = actionsList.addItem(); org.dspace.app.xmlui.wing.element.Item actionItem = actionsList.addItem();
Text queryField = actionItem.addText("query"); Text queryField = actionItem.addText("query");
if (query != null) if (query != null)
queryField.setValue(query); {
queryField.setValue(query);
}
queryField.setHelp(T_search_help); queryField.setHelp(T_search_help);
actionItem.addButton("submit_search").setValue(T_go); actionItem.addButton("submit_search").setValue(T_go);
@@ -194,9 +196,13 @@ public class ManageEPeopleMain extends AbstractDSpaceTransformer
String nextURL = null, prevURL = null; String nextURL = null, prevURL = null;
if (page < (resultCount / PAGE_SIZE)) if (page < (resultCount / PAGE_SIZE))
nextURL = baseURL+"&page="+(page+1); {
nextURL = baseURL + "&page=" + (page + 1);
}
if (page > 0) if (page > 0)
prevURL = baseURL+"&page="+(page-1); {
prevURL = baseURL + "&page=" + (page - 1);
}
search.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL); search.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL);
} }

View File

@@ -225,13 +225,16 @@ public class EditGroupForm extends AbstractDSpaceTransformer
int groupID = parameters.getParameterAsInteger("groupID",-1); int groupID = parameters.getParameterAsInteger("groupID",-1);
String currentName = URLDecode(parameters.getParameter("groupName",null)); String currentName = URLDecode(parameters.getParameter("groupName",null));
if (currentName == null || currentName.length() == 0) if (currentName == null || currentName.length() == 0)
currentName = FlowGroupUtils.getName(context, groupID); {
currentName = FlowGroupUtils.getName(context, groupID);
}
Group group = null; Group group = null;
if (groupID >= 0) if (groupID >= 0)
group = Group.find(context,groupID); {
group = Group.find(context, groupID);
}
// Find the collection or community if applicable // Find the collection or community if applicable
Collection collection = null; Collection collection = null;
Community community = null; Community community = null;
@@ -260,7 +263,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
for (String id : memberGroupIDsString.split(",")) for (String id : memberGroupIDsString.split(","))
{ {
if (id.length() > 0) if (id.length() > 0)
memberGroupIDs.add(Integer.valueOf(id)); {
memberGroupIDs.add(Integer.valueOf(id));
}
} }
} }
@@ -337,7 +342,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
groupText.setHelp(T_label_instructions); groupText.setHelp(T_label_instructions);
} }
else if (errors.contains("group_name") || errors.contains("group_name_duplicate")) else if (errors.contains("group_name") || errors.contains("group_name_duplicate"))
groupText.addError(""); {
groupText.addError("");
}
Para searchBoxes = actions.addPara(); Para searchBoxes = actions.addPara();
@@ -365,7 +372,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
boolean changes = false; boolean changes = false;
if (group != null) if (group != null)
changes = addMemberList(main,group,memberGroupIDs,memberEPeopleIDs,highlightEPersonID,highlightGroupID); {
changes = addMemberList(main, group, memberGroupIDs, memberEPeopleIDs, highlightEPersonID, highlightGroupID);
}
Para buttons = main.addPara(); Para buttons = main.addPara();
@@ -373,7 +382,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
buttons.addButton("submit_cancel").setValue(T_submit_cancel); buttons.addButton("submit_cancel").setValue(T_submit_cancel);
if (changes) if (changes)
main.addPara().addHighlight("warn").addContent(T_pending_warn); {
main.addPara().addHighlight("warn").addContent(T_pending_warn);
}
main.addHidden("administrative-continue").setValue(knot.getId()); main.addHidden("administrative-continue").setValue(knot.getId());
@@ -400,9 +411,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
String nextURL = null, prevURL = null; String nextURL = null, prevURL = null;
if (page < (resultCount / RESULTS_PER_PAGE)) if (page < (resultCount / RESULTS_PER_PAGE))
nextURL = baseURL+"&page="+(page+1); {
nextURL = baseURL + "&page=" + (page + 1);
}
if (page > 0) if (page > 0)
prevURL = baseURL+"&page="+(page-1); {
prevURL = baseURL + "&page=" + (page - 1);
}
results.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL); results.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL);
} }
@@ -477,9 +492,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
String nextURL = null, prevURL = null; String nextURL = null, prevURL = null;
if (page < (resultCount / RESULTS_PER_PAGE)) if (page < (resultCount / RESULTS_PER_PAGE))
nextURL = baseURL+"&page="+(page+1); {
nextURL = baseURL + "&page=" + (page + 1);
}
if (page > 0) if (page > 0)
prevURL = baseURL+"&page="+(page-1); {
prevURL = baseURL + "&page=" + (page - 1);
}
results.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL); results.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL);
} }
@@ -643,7 +662,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
for (Group group : parent.getMemberGroups()) for (Group group : parent.getMemberGroups())
{ {
if (!allMemberGroupIDs.contains(group.getID())) if (!allMemberGroupIDs.contains(group.getID()))
allMemberGroupIDs.add(group.getID()); {
allMemberGroupIDs.add(group.getID());
}
} }
// Sort them to a consistent ordering // Sort them to a consistent ordering
Collections.sort(allMemberGroupIDs); Collections.sort(allMemberGroupIDs);
@@ -658,7 +679,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
addMemberRow(table, group, highlight,pendingAddition,pendingRemoval); addMemberRow(table, group, highlight,pendingAddition,pendingRemoval);
if (pendingAddition || pendingRemoval) if (pendingAddition || pendingRemoval)
changes = true; {
changes = true;
}
} }
@@ -668,7 +691,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
for (EPerson eperson : parent.getMembers()) for (EPerson eperson : parent.getMembers())
{ {
if (!allMemberEPeopleIDs.contains(eperson.getID())) if (!allMemberEPeopleIDs.contains(eperson.getID()))
allMemberEPeopleIDs.add(eperson.getID()); {
allMemberEPeopleIDs.add(eperson.getID());
}
} }
// Sort them to a consistent ordering // Sort them to a consistent ordering
Collections.sort(allMemberEPeopleIDs); Collections.sort(allMemberEPeopleIDs);
@@ -682,7 +707,9 @@ public class EditGroupForm extends AbstractDSpaceTransformer
addMemberRow(table,eperson,highlight,pendingAddition,pendingRemoval); addMemberRow(table,eperson,highlight,pendingAddition,pendingRemoval);
if (pendingAddition || pendingRemoval) if (pendingAddition || pendingRemoval)
changes = true; {
changes = true;
}
} }
if (allMemberGroupIDs.size() <= 0 && allMemberEPeopleIDs.size() <= 0) if (allMemberGroupIDs.size() <= 0 && allMemberEPeopleIDs.size() <= 0)

View File

@@ -181,7 +181,9 @@ public class ManageGroupsMain extends AbstractDSpaceTransformer
org.dspace.app.xmlui.wing.element.Item actionItem = actionsList.addItem(); org.dspace.app.xmlui.wing.element.Item actionItem = actionsList.addItem();
Text queryField = actionItem.addText("query"); Text queryField = actionItem.addText("query");
if (query != null) if (query != null)
queryField.setValue(query); {
queryField.setValue(query);
}
queryField.setHelp(T_search_help); queryField.setHelp(T_search_help);
actionItem.addButton("submit_search").setValue(T_go); actionItem.addButton("submit_search").setValue(T_go);
@@ -204,9 +206,13 @@ public class ManageGroupsMain extends AbstractDSpaceTransformer
String nextURL = null, prevURL = null; String nextURL = null, prevURL = null;
if (page < (resultCount / PAGE_SIZE)) if (page < (resultCount / PAGE_SIZE))
nextURL = baseURL+"&page="+(page+1); {
nextURL = baseURL + "&page=" + (page + 1);
}
if (page > 0) if (page > 0)
prevURL = baseURL+"&page="+(page-1); {
prevURL = baseURL + "&page=" + (page - 1);
}
search.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL); search.setSimplePagination(resultCount,firstIndex,lastIndex,prevURL, nextURL);
} }

View File

@@ -99,7 +99,9 @@ public class DeleteBitstreamsConfirm extends AbstractDSpaceTransformer
String[] parts = id.split("/"); String[] parts = id.split("/");
if (parts.length != 2) if (parts.length != 2)
throw new UIException("Unable to parse id into bundle and bitstream id: "+id); {
throw new UIException("Unable to parse id into bundle and bitstream id: " + id);
}
int bitstreamID = Integer.valueOf(parts[1]); int bitstreamID = Integer.valueOf(parts[1]);
@@ -125,7 +127,9 @@ public class DeleteBitstreamsConfirm extends AbstractDSpaceTransformer
String format = null; String format = null;
BitstreamFormat bitstreamFormat = bitstream.getFormat(); BitstreamFormat bitstreamFormat = bitstream.getFormat();
if (bitstreamFormat != null) if (bitstreamFormat != null)
format = bitstreamFormat.getShortDescription(); {
format = bitstreamFormat.getShortDescription();
}
Row row = table.addRow(); Row row = table.addRow();
row.addCell().addContent(bitstream.getName()); row.addCell().addContent(bitstream.getName());

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