[DS-707] Style / readability improvements

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5555 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-22 16:49:20 +00:00
parent 41e98d3730
commit bed5b7249f
51 changed files with 510 additions and 88 deletions

View File

@@ -160,12 +160,22 @@ public class CreateAdministrator
System.out.print("First name: "); System.out.print("First name: ");
System.out.flush(); System.out.flush();
firstName = input.readLine().trim(); firstName = input.readLine();
if (firstName != null)
{
firstName = firstName.trim();
}
System.out.print("Last name: "); System.out.print("Last name: ");
System.out.flush(); System.out.flush();
lastName = input.readLine().trim(); lastName = input.readLine();
if (lastName != null)
{
lastName = lastName.trim();
}
if (ConfigurationManager.getProperty("webui.supported.locales") != null) if (ConfigurationManager.getProperty("webui.supported.locales") != null)
{ {
@@ -173,7 +183,13 @@ public class CreateAdministrator
System.out.print("Language: "); System.out.print("Language: ");
System.out.flush(); System.out.flush();
language = input.readLine().trim(); language = input.readLine();
if (language != null)
{
language = language.trim();
}
language = I18nUtil.getSupportedLocale(new Locale(language)).getLanguage(); language = I18nUtil.getSupportedLocale(new Locale(language)).getLanguage();
} }
@@ -181,12 +197,22 @@ public class CreateAdministrator
System.out.print("Password: "); System.out.print("Password: ");
System.out.flush(); System.out.flush();
password1 = input.readLine().trim(); password1 = input.readLine();
if (password1 != null)
{
password1 = password1.trim();
}
System.out.print("Again to confirm: "); System.out.print("Again to confirm: ");
System.out.flush(); System.out.flush();
password2 = input.readLine().trim(); password2 = input.readLine();
if (password2 != null)
{
password2 = password2.trim();
}
if (!password1.equals("") && password1.equals(password2)) if (!password1.equals("") && password1.equals(password2))
{ {
@@ -194,7 +220,12 @@ public class CreateAdministrator
System.out.print("Is the above data correct? (y or n): "); System.out.print("Is the above data correct? (y or n): ");
System.out.flush(); System.out.flush();
String s = input.readLine().trim(); String s = input.readLine();
if (s != null)
{
s = s.trim();
}
if (s.toLowerCase().startsWith("y")) if (s.toLowerCase().startsWith("y"))
{ {

View File

@@ -152,10 +152,14 @@ public class DailyFileAppender extends FileAppender
{ {
this.mstrDatePattern = checkPattern(pstrPattern); this.mstrDatePattern = checkPattern(pstrPattern);
if (mstrDatePattern.contains("dd") || mstrDatePattern.contains("DD")) if (mstrDatePattern.contains("dd") || mstrDatePattern.contains("DD"))
{
mMonthOnly = false; mMonthOnly = false;
}
else else
{
mMonthOnly = true; mMonthOnly = true;
} }
}
public void setFile(String file) public void setFile(String file)
{ {

View File

@@ -320,9 +320,13 @@ public class AuthenticationManager
// request, and most sites will only have 0 or 1 auth methods // request, and most sites will only have 0 or 1 auth methods
// actually returning groups, so it pays.. // actually returning groups, so it pays..
if (totalLen == 0) if (totalLen == 0)
{
return new int[0]; return new int[0];
}
else if (gll.size() == 1) else if (gll.size() == 1)
{
return (int[]) gll.get(0); return (int[]) gll.get(0);
}
else else
{ {
// Have to do it this painful way since list.toArray() doesn't // Have to do it this painful way since list.toArray() doesn't

View File

@@ -532,16 +532,24 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
if (ConfigurationManager.getBooleanProperty("webui.browse.metadata.case-insensitive", false)) if (ConfigurationManager.getBooleanProperty("webui.browse.metadata.case-insensitive", false))
{ {
if (isValueColumnClob()) if (isValueColumnClob())
{
select = select + " WHERE UPPER(TO_CHAR(value))=UPPER(?)"; select = select + " WHERE UPPER(TO_CHAR(value))=UPPER(?)";
}
else else
{
select = select + " WHERE UPPER(value)=UPPER(?)"; select = select + " WHERE UPPER(value)=UPPER(?)";
} }
}
else else
{ {
if (isValueColumnClob()) if (isValueColumnClob())
{
select = select + " WHERE TO_CHAR(value)=?"; select = select + " WHERE TO_CHAR(value)=?";
}
else else
{
select = select + " WHERE value=?"; select = select + " WHERE value=?";
}
} }
if (authority != null) if (authority != null)

View File

@@ -888,10 +888,14 @@ public class BrowseDAOOracle implements BrowseDAO
{ {
queryBuf.append("rec WHERE rownum<=? "); queryBuf.append("rec WHERE rownum<=? ");
if (offset > 0) if (offset > 0)
{
params.add(Integer.valueOf(limit + offset)); params.add(Integer.valueOf(limit + offset));
}
else else
{
params.add(Integer.valueOf(limit)); params.add(Integer.valueOf(limit));
} }
}
if (offset > 0) if (offset > 0)
{ {

View File

@@ -664,10 +664,14 @@ public class BrowseIndex
else else
{ {
if (sortOption != null) if (sortOption != null)
{
focusField = "sort_" + sortOption.getNumber(); focusField = "sort_" + sortOption.getNumber();
}
else else
{
focusField = "sort_1"; // Use the first sort column focusField = "sort_1"; // Use the first sort column
} }
}
return focusField; return focusField;
} }

View File

@@ -311,9 +311,13 @@ public final class BitstreamInfoDAO extends DAOSupport
LOG.debug("updating missing bitstreams"); LOG.debug("updating missing bitstreams");
conn = DatabaseManager.getConnection(); conn = DatabaseManager.getConnection();
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
{
stmt = conn.prepareStatement(INSERT_MISSING_CHECKSUM_BITSTREAMS_ORACLE); stmt = conn.prepareStatement(INSERT_MISSING_CHECKSUM_BITSTREAMS_ORACLE);
}
else else
{
stmt = conn.prepareStatement(INSERT_MISSING_CHECKSUM_BITSTREAMS); stmt = conn.prepareStatement(INSERT_MISSING_CHECKSUM_BITSTREAMS);
}
stmt.setTimestamp(1, new java.sql.Timestamp(new Date().getTime())); stmt.setTimestamp(1, new java.sql.Timestamp(new Date().getTime()));
stmt.setTimestamp(2, new java.sql.Timestamp(new Date().getTime())); stmt.setTimestamp(2, new java.sql.Timestamp(new Date().getTime()));
stmt.executeUpdate(); stmt.executeUpdate();
@@ -425,9 +429,13 @@ public final class BitstreamInfoDAO extends DAOSupport
conn = DatabaseManager.getConnection(); conn = DatabaseManager.getConnection();
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
{
prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM_ORACLE); prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM_ORACLE);
}
else else
{
prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM); prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM);
}
rs = prepStmt.executeQuery(); rs = prepStmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
@@ -469,9 +477,13 @@ public final class BitstreamInfoDAO extends DAOSupport
{ {
conn = DatabaseManager.getConnection(); conn = DatabaseManager.getConnection();
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
{
prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM_DATE_ORACLE); prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM_DATE_ORACLE);
}
else else
{
prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM_DATE); prepStmt = conn.prepareStatement(GET_OLDEST_BITSTREAM_DATE);
}
prepStmt.setTimestamp(1, lessThanDate); prepStmt.setTimestamp(1, lessThanDate);
rs = prepStmt.executeQuery(); rs = prepStmt.executeQuery();
if (rs.next()) if (rs.next())

View File

@@ -137,14 +137,16 @@ public class ChecksumHistoryDAO extends DAOSupport
{ {
conn = DatabaseManager.getConnection(); conn = DatabaseManager.getConnection();
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
{
stmt = conn.prepareStatement(INSERT_HISTORY_ORACLE); stmt = conn.prepareStatement(INSERT_HISTORY_ORACLE);
}
else else
{
stmt = conn.prepareStatement(INSERT_HISTORY); stmt = conn.prepareStatement(INSERT_HISTORY);
}
stmt.setInt(1, info.getBitstreamId()); stmt.setInt(1, info.getBitstreamId());
stmt.setTimestamp(2, new java.sql.Timestamp(info stmt.setTimestamp(2, new java.sql.Timestamp(info.getProcessStartDate().getTime()));
.getProcessStartDate().getTime())); stmt.setTimestamp(3, new java.sql.Timestamp(info.getProcessEndDate().getTime()));
stmt.setTimestamp(3, new java.sql.Timestamp(info
.getProcessEndDate().getTime()));
stmt.setString(4, info.getStoredChecksum()); stmt.setString(4, info.getStoredChecksum());
stmt.setString(5, info.getCalculatedChecksum()); stmt.setString(5, info.getCalculatedChecksum());
stmt.setString(6, info.getChecksumCheckResult()); stmt.setString(6, info.getChecksumCheckResult());
@@ -210,9 +212,13 @@ public class ChecksumHistoryDAO extends DAOSupport
try try
{ {
if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
{
stmt = conn.prepareStatement(INSERT_MISSING_HISTORY_BITSTREAMS_ORACLE); stmt = conn.prepareStatement(INSERT_MISSING_HISTORY_BITSTREAMS_ORACLE);
}
else else
{
stmt = conn.prepareStatement(INSERT_MISSING_HISTORY_BITSTREAMS); stmt = conn.prepareStatement(INSERT_MISSING_HISTORY_BITSTREAMS);
}
stmt.executeUpdate(); stmt.executeUpdate();
} }
catch (SQLException e) catch (SQLException e)

View File

@@ -449,14 +449,22 @@ public class DCDate
private synchronized String toStringInternal() private synchronized String toStringInternal()
{ {
if (granularity == DateGran.YEAR) if (granularity == DateGran.YEAR)
{
return String.format("%4d", getYearUTC()); return String.format("%4d", getYearUTC());
}
else if (granularity == DateGran.MONTH) else if (granularity == DateGran.MONTH)
{
return String.format("%4d-%02d", getYearUTC(), getMonthUTC()); return String.format("%4d-%02d", getYearUTC(), getMonthUTC());
}
else if (granularity == DateGran.DAY) else if (granularity == DateGran.DAY)
{
return String.format("%4d-%02d-%02d", getYearUTC(), getMonthUTC(), getDayUTC()); return String.format("%4d-%02d-%02d", getYearUTC(), getMonthUTC(), getDayUTC());
}
else else
{
return fullIso.format(calendar.getTime()); return fullIso.format(calendar.getTime());
} }
}
/** /**
* Get the date as a Java Date object. * Get the date as a Java Date object.
@@ -466,10 +474,14 @@ public class DCDate
public Date toDate() public Date toDate()
{ {
if (calendar == null) if (calendar == null)
{
return null; return null;
}
else else
{
return calendar.getTime(); return calendar.getTime();
} }
}
/** /**
* Format a human-readable version of the DCDate, with optional time. * Format a human-readable version of the DCDate, with optional time.

View File

@@ -140,10 +140,12 @@ public class ChoiceAuthorityManager
closed.put(fkey, Boolean.valueOf(ConfigurationManager.getBooleanProperty(key))); closed.put(fkey, Boolean.valueOf(ConfigurationManager.getBooleanProperty(key)));
} }
else else
{
log.error("Illegal configuration property: " + key); log.error("Illegal configuration property: " + key);
} }
} }
} }
}
/** Factory method */ /** Factory method */
public static ChoiceAuthorityManager getManager() public static ChoiceAuthorityManager getManager()

View File

@@ -127,9 +127,11 @@ public class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
log.debug("Found pairs for name="+pname); log.debug("Found pairs for name="+pname);
} }
else else
{
log.error("Failed to find any pairs for name=" + pname, new IllegalStateException()); log.error("Failed to find any pairs for name=" + pname, new IllegalStateException());
} }
} }
}
public Choices getMatches(String query, int collection, int start, int limit, String locale) public Choices getMatches(String query, int collection, int start, int limit, String locale)

View File

@@ -381,7 +381,9 @@ public class AIPTechMDCrosswalk
// if we get <dim> in a list, recurse. // if we get <dim> in a list, recurse.
if (field.getName().equals("dim") && field.getNamespace().equals(XSLTCrosswalk.DIM_NS)) if (field.getName().equals("dim") && field.getNamespace().equals(XSLTCrosswalk.DIM_NS))
{
ingest(context, dso, field.getChildren()); ingest(context, dso, field.getChildren());
}
else if (field.getName().equals("field") && field.getNamespace().equals(XSLTCrosswalk.DIM_NS)) else if (field.getName().equals("field") && field.getNamespace().equals(XSLTCrosswalk.DIM_NS))
{ {
String schema = field.getAttributeValue("mdschema"); String schema = field.getAttributeValue("mdschema");
@@ -426,17 +428,23 @@ public class AIPTechMDCrosswalk
{ {
int sl = BitstreamFormat.getSupportLevelID(value); int sl = BitstreamFormat.getSupportLevelID(value);
if (sl < 0) if (sl < 0)
{
throw new MetadataValidationException("Got unrecognized value for bitstream support level: " + value); throw new MetadataValidationException("Got unrecognized value for bitstream support level: " + value);
}
else else
{
bsfSupport = sl; bsfSupport = sl;
} }
}
else if (dcField.equals("format.internal")) else if (dcField.equals("format.internal"))
{ {
bsfInternal = (Boolean.valueOf(value)).booleanValue(); bsfInternal = (Boolean.valueOf(value)).booleanValue();
} }
else else
{
log.warn("Got unrecognized DC field for Bitstream: " + dcField); log.warn("Got unrecognized DC field for Bitstream: " + dcField);
} }
}
else if (type == Constants.ITEM) else if (type == Constants.ITEM)
{ {
Item item = (Item)dso; Item item = (Item)dso;
@@ -462,8 +470,10 @@ public class AIPTechMDCrosswalk
sub.update(); sub.update();
} }
else else
{
log.warn("Ignoring unknown Submitter=" + value + " in AIP Tech MD, no matching EPerson and 'mets.dspaceAIP.ingest.createSubmitter' is false in dspace.cfg."); log.warn("Ignoring unknown Submitter=" + value + " in AIP Tech MD, no matching EPerson and 'mets.dspaceAIP.ingest.createSubmitter' is false in dspace.cfg.");
} }
}
if (sub != null) if (sub != null)
{ {
item.setSubmitter(sub); item.setSubmitter(sub);

View File

@@ -335,9 +335,13 @@ public abstract class AbstractMETSDisseminator
//actually add the file to the Zip package //actually add the file to the Zip package
ZipEntry ze = new ZipEntry(fname); ZipEntry ze = new ZipEntry(fname);
if (lmTime != 0) if (lmTime != 0)
{
ze.setTime(lmTime); ze.setTime(lmTime);
}
else //Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged else //Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged
{
ze.setTime(DEFAULT_MODIFIED_DATE); ze.setTime(DEFAULT_MODIFIED_DATE);
}
zip.putNextEntry(ze); zip.putNextEntry(ze);
Utils.copy(is, zip); Utils.copy(is, zip);
zip.closeEntry(); zip.closeEntry();
@@ -350,9 +354,13 @@ public abstract class AbstractMETSDisseminator
// write manifest after metadata. // write manifest after metadata.
ZipEntry me = new ZipEntry(METSManifest.MANIFEST_FILE); ZipEntry me = new ZipEntry(METSManifest.MANIFEST_FILE);
if (lmTime != 0) if (lmTime != 0)
{
me.setTime(lmTime); me.setTime(lmTime);
}
else //Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged else //Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged
{
me.setTime(DEFAULT_MODIFIED_DATE); me.setTime(DEFAULT_MODIFIED_DATE);
}
zip.putNextEntry(me); zip.putNextEntry(me);
@@ -407,8 +415,10 @@ public abstract class AbstractMETSDisseminator
continue; continue;
} }
else else
{
throw new AuthorizeException("Not authorized to read Bundle named \"" + bundles[i].getName() + "\""); throw new AuthorizeException("Not authorized to read Bundle named \"" + bundles[i].getName() + "\"");
} }
}
Bitstream[] bitstreams = bundles[i].getBitstreams(); Bitstream[] bitstreams = bundles[i].getBitstreams();
for (int k = 0; k < bitstreams.length; k++) for (int k = 0; k < bitstreams.length; k++)
{ {
@@ -424,15 +434,23 @@ public abstract class AbstractMETSDisseminator
log.debug(new StringBuilder().append("Writing CONTENT stream of bitstream(").append(bitstreams[k].getID()).append(") to Zip: ").append(zname).append(", size=").append(bitstreams[k].getSize()).toString()); log.debug(new StringBuilder().append("Writing CONTENT stream of bitstream(").append(bitstreams[k].getID()).append(") to Zip: ").append(zname).append(", size=").append(bitstreams[k].getSize()).toString());
} }
if (lmTime != 0) if (lmTime != 0)
{
ze.setTime(lmTime); ze.setTime(lmTime);
}
else //Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged else //Set a default modified date so that checksum of Zip doesn't change if Zip contents are unchanged
{
ze.setTime(DEFAULT_MODIFIED_DATE); ze.setTime(DEFAULT_MODIFIED_DATE);
}
ze.setSize(auth ? bitstreams[k].getSize() : 0); ze.setSize(auth ? bitstreams[k].getSize() : 0);
zip.putNextEntry(ze); zip.putNextEntry(ze);
if (auth) if (auth)
{
Utils.copy(bitstreams[k].retrieve(), zip); Utils.copy(bitstreams[k].retrieve(), zip);
}
else else
{
log.warn("Adding zero-length file for Bitstream, SID=" + String.valueOf(bitstreams[k].getSequenceID()) + ", not authorized for READ."); log.warn("Adding zero-length file for Bitstream, SID=" + String.valueOf(bitstreams[k].getSequenceID()) + ", not authorized for READ.");
}
zip.closeEntry(); zip.closeEntry();
} }
else if (unauth != null && else if (unauth != null &&
@@ -549,7 +567,9 @@ public abstract class AbstractMETSDisseminator
xwalkName = parts[1]; xwalkName = parts[1];
} }
else else
{
xwalkName = metsName = typeSpec; xwalkName = metsName = typeSpec;
}
// First, check to see if the crosswalk we are using is a normal DisseminationCrosswalk // First, check to see if the crosswalk we are using is a normal DisseminationCrosswalk
boolean xwalkFound = PluginManager.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName); boolean xwalkFound = PluginManager.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName);
@@ -583,11 +603,15 @@ public abstract class AbstractMETSDisseminator
return mdSec; return mdSec;
} }
else else
{
return null; return null;
} }
}
else else
{
return null; return null;
} }
}
// If we didn't find the correct crosswalk, we will check to see if this is // If we didn't find the correct crosswalk, we will check to see if this is
// a StreamDisseminationCrosswalk -- a Stream crosswalk disseminates to an OutputStream // a StreamDisseminationCrosswalk -- a Stream crosswalk disseminates to an OutputStream
else else
@@ -649,15 +673,20 @@ public abstract class AbstractMETSDisseminator
mdWrap.getContent().add(binData); mdWrap.getContent().add(binData);
mdSec.getContent().add(mdWrap); mdSec.getContent().add(mdWrap);
} }
return mdSec; return mdSec;
} }
else else
{
return null; return null;
} }
}
else else
{
throw new PackageValidationException("Cannot find " + xwalkName + " crosswalk plugin, either DisseminationCrosswalk or StreamDisseminationCrosswalk"); throw new PackageValidationException("Cannot find " + xwalkName + " crosswalk plugin, either DisseminationCrosswalk or StreamDisseminationCrosswalk");
} }
} }
}
catch (InstantiationException e) catch (InstantiationException e)
{ {
throw new PackageValidationException("Error instantiating Mdsec object: "+ e.toString(), e); throw new PackageValidationException("Error instantiating Mdsec object: "+ e.toString(), e);
@@ -715,8 +744,10 @@ public abstract class AbstractMETSDisseminator
return result; return result;
} }
else else
{
return null; return null;
} }
}
// make the most "persistent" identifier possible, preferably a URN // make the most "persistent" identifier possible, preferably a URN
// based on the Handle. // based on the Handle.
@@ -726,10 +757,14 @@ public abstract class AbstractMETSDisseminator
// If no Handle, punt to much-less-satisfactory database ID and type.. // If no Handle, punt to much-less-satisfactory database ID and type..
if (handle == null) if (handle == null)
{
return "DSpace_DB_" + Constants.typeText[dso.getType()] + "_" + String.valueOf(dso.getID()); return "DSpace_DB_" + Constants.typeText[dso.getType()] + "_" + String.valueOf(dso.getID());
}
else else
{
return getHandleURN(handle); return getHandleURN(handle);
} }
}
/** /**
* Write out a METS manifest. * Write out a METS manifest.
@@ -833,10 +868,14 @@ public abstract class AbstractMETSDisseminator
{ {
if (unauth != null && if (unauth != null &&
(unauth.equalsIgnoreCase("skip"))) (unauth.equalsIgnoreCase("skip")))
{
continue; continue;
}
else else
{
throw new AuthorizeException("Not authorized to read Bundle named \"" + bundles[i].getName() + "\""); throw new AuthorizeException("Not authorized to read Bundle named \"" + bundles[i].getName() + "\"");
} }
}
Bitstream[] bitstreams = bundles[i].getBitstreams(); Bitstream[] bitstreams = bundles[i].getBitstreams();
@@ -1168,10 +1207,14 @@ public abstract class AbstractMETSDisseminator
} }
if(emptyDiv) if(emptyDiv)
{
return null; return null;
}
else else
{
return div; return div;
} }
}
// put handle in canonical URN format -- note that HandleManager's // put handle in canonical URN format -- note that HandleManager's
// canonicalize currently returns HTTP URL format. // canonicalize currently returns HTTP URL format.
@@ -1246,10 +1289,14 @@ public abstract class AbstractMETSDisseminator
{ {
String uri = ns[i].getURI(); String uri = ns[i].getURI();
if (sloc != null && sloc.length > 1 && uri.equals(sloc[0])) if (sloc != null && sloc.length > 1 && uri.equals(sloc[0]))
{
me.setSchema(ns[i].getPrefix(), uri, sloc[1]); me.setSchema(ns[i].getPrefix(), uri, sloc[1]);
}
else else
{
me.setSchema(ns[i].getPrefix(), uri); me.setSchema(ns[i].getPrefix(), uri);
} }
}
// add result of crosswalk // add result of crosswalk
PreformedXML pXML = null; PreformedXML pXML = null;

View File

@@ -505,9 +505,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
// Do nothing -- Crosswalks will handle anything necessary to ingest at Site-level // Do nothing -- Crosswalks will handle anything necessary to ingest at Site-level
} }
else else
{
throw new PackageValidationException( throw new PackageValidationException(
"Unknown DSpace Object type in package, type=" "Unknown DSpace Object type in package, type="
+ String.valueOf(type)); + String.valueOf(type));
}
// -- Step 5 -- // -- Step 5 --
// Run our Descriptive metadata (dublin core, etc) crosswalks! // Run our Descriptive metadata (dublin core, etc) crosswalks!
@@ -757,9 +759,13 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
Bundle bundle; Bundle bundle;
Bundle bns[] = item.getBundles(bundleName); Bundle bns[] = item.getBundles(bundleName);
if (bns != null && bns.length > 0) if (bns != null && bns.length > 0)
{
bundle = bns[0]; bundle = bns[0];
}
else else
{
bundle = item.createBundle(bundleName); bundle = item.createBundle(bundleName);
}
// Create the bitstream in the bundle & initialize its name // Create the bitstream in the bundle & initialize its name
Bitstream bitstream = bundle.createBitstream(fileStream); Bitstream bitstream = bundle.createBitstream(fileStream);
@@ -909,9 +915,13 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
// Add this logo to the Community/Collection // Add this logo to the Community/Collection
if (dso.getType() == Constants.COLLECTION) if (dso.getType() == Constants.COLLECTION)
{
((Collection) dso).setLogo(fileStream); ((Collection) dso).setLogo(fileStream);
}
else else
{
((Community) dso).setLogo(fileStream); ((Community) dso).setLogo(fileStream);
}
break; break;
} }
@@ -1029,8 +1039,10 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
} }
} }
else else
{
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Could not find a parent DSpaceObject where we can ingest this package. A valid parent DSpaceObject must be specified in the METS Manifest itself."); "Could not find a parent DSpaceObject where we can ingest this package. A valid parent DSpaceObject must be specified in the METS Manifest itself.");
}
// As this object doesn't already exist, we will perform an // As this object doesn't already exist, we will perform an
// ingest of a new object in order to restore it // ingest of a new object in order to restore it
@@ -1128,10 +1140,14 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
protected String decodeHandleURN(String value) protected String decodeHandleURN(String value)
{ {
if (value != null && value.startsWith("hdl:")) if (value != null && value.startsWith("hdl:"))
{
return value.substring(4); return value.substring(4);
}
else else
{
return null; return null;
} }
}
/** /**
* Remove an existing DSpace Object (called during a replace) * Remove an existing DSpace Object (called during a replace)
@@ -1244,8 +1260,10 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
} }
} }
else else
{
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Could not find a parent DSpaceObject where we can ingest this package. A parent DSpaceObject must be specified from either the 'packager' command or noted in the METS Manifest itself."); "Could not find a parent DSpaceObject where we can ingest this package. A parent DSpaceObject must be specified from either the 'packager' command or noted in the METS Manifest itself.");
}
return parent; return parent;
} }

View File

@@ -160,8 +160,10 @@ public abstract class AbstractPackageIngester
log.warn(LogManager.getHeader(context, "skip_package_ingest", "Object already exists, package-skipped=" + pkgFile)); log.warn(LogManager.getHeader(context, "skip_package_ingest", "Object already exists, package-skipped=" + pkgFile));
} }
else // Pass this exception on -- which essentially causes a full rollback of all changes (this is the default) else // Pass this exception on -- which essentially causes a full rollback of all changes (this is the default)
{
throw ie; throw ie;
} }
}
//as long as our first object was ingested successfully //as long as our first object was ingested successfully
if(dso!=null) if(dso!=null)

View File

@@ -899,8 +899,10 @@ public class ConfigurationManager
from = end+1; from = end+1;
} }
else else
{
break; break;
} }
}
if (result != null && from < value.length()) if (result != null && from < value.length())
{ {
result.append(value.substring(from)); result.append(value.substring(from));

View File

@@ -88,10 +88,14 @@ public class DefaultEmbargoSetter implements EmbargoSetter
if (terms != null && terms.length() > 0) if (terms != null && terms.length() > 0)
{ {
if (termsOpen.equals(terms)) if (termsOpen.equals(terms))
{
return EmbargoManager.FOREVER; return EmbargoManager.FOREVER;
}
else else
{
return new DCDate(terms); return new DCDate(terms);
} }
}
return null; return null;
} }

View File

@@ -123,12 +123,14 @@ public class ConsumerProfile
{ {
String fpart[] = part[j].split("\\+"); String fpart[] = part[j].split("\\+");
if (fpart.length != 2) if (fpart.length != 2)
{
log log
.error("Bad Filter clause in consumer stanza in Configuration entry for " .error("Bad Filter clause in consumer stanza in Configuration entry for "
+ CONSUMER_PREFIX + CONSUMER_PREFIX
+ name + name
+ ".consumers: " + ".consumers: "
+ part[j]); + part[j]);
}
else else
{ {
int filter[] = new int[2]; int filter[] = new int[2];
@@ -138,27 +140,35 @@ public class ConsumerProfile
{ {
int ot = Event.parseObjectType(objectNames[k]); int ot = Event.parseObjectType(objectNames[k]);
if (ot == 0) if (ot == 0)
{
log log
.error("Bad ObjectType in Consumer Stanza in Configuration entry for " .error("Bad ObjectType in Consumer Stanza in Configuration entry for "
+ CONSUMER_PREFIX + CONSUMER_PREFIX
+ name + name
+ ".consumers: " + objectNames[k]); + ".consumers: " + objectNames[k]);
}
else else
{
filter[Event.SUBJECT_MASK] |= ot; filter[Event.SUBJECT_MASK] |= ot;
} }
}
String eventNames[] = fpart[1].split("\\|"); String eventNames[] = fpart[1].split("\\|");
for (int k = 0; k < eventNames.length; ++k) for (int k = 0; k < eventNames.length; ++k)
{ {
int et = Event.parseEventType(eventNames[k]); int et = Event.parseEventType(eventNames[k]);
if (et == 0) if (et == 0)
{
log log
.error("Bad EventType in Consumer Stanza in Configuration entry for " .error("Bad EventType in Consumer Stanza in Configuration entry for "
+ CONSUMER_PREFIX + CONSUMER_PREFIX
+ name + name
+ ".consumers: " + eventNames[k]); + ".consumers: " + eventNames[k]);
}
else else
{
filter[Event.EVENT_MASK] |= et; filter[Event.EVENT_MASK] |= et;
} }
}
filters.add(filter); filters.add(filter);
} }
} }

View File

@@ -115,11 +115,15 @@ public abstract class AbstractTextFilterOFD implements OrderFormatDelegate
for (int idx = 0; idx < filters.length; idx++) for (int idx = 0; idx < filters.length; idx++)
{ {
if (language != null) if (language != null)
{
value = filters[idx].filter(value, language); value = filters[idx].filter(value, language);
}
else else
{
value = filters[idx].filter(value); value = filters[idx].filter(value);
} }
} }
}
return value; return value;
} }

View File

@@ -1198,10 +1198,14 @@ public class DatabaseManager
// Otherwise, store it as long // Otherwise, store it as long
long longValue = results.getLong(i); long longValue = results.getLong(i);
if (longValue <= (long)Integer.MAX_VALUE) if (longValue <= (long)Integer.MAX_VALUE)
{
row.setColumn(name, (int) longValue); row.setColumn(name, (int) longValue);
}
else else
{
row.setColumn(name, longValue); row.setColumn(name, longValue);
} }
}
else else
{ // Not Oracle { // Not Oracle
if (jdbctype == Types.INTEGER) if (jdbctype == Types.INTEGER)
@@ -1402,7 +1406,9 @@ public class DatabaseManager
{ {
// If we are using Oracle, we can pass in long values, so always do so. // If we are using Oracle, we can pass in long values, so always do so.
if ("oracle".equals(dbName)) if ("oracle".equals(dbName))
{
statement.setLong(count, row.getLongColumn(column)); statement.setLong(count, row.getLongColumn(column));
}
else else
{ // not Oracle { // not Oracle
if (jdbctype == Types.INTEGER) if (jdbctype == Types.INTEGER)

View File

@@ -190,10 +190,14 @@ public abstract class AbstractProcessingStep
private static final void setErrorFields(HttpServletRequest request, List errorFields) private static final void setErrorFields(HttpServletRequest request, List errorFields)
{ {
if(errorFields==null) if(errorFields==null)
{
request.removeAttribute(ERROR_FIELDS_ATTRIBUTE); request.removeAttribute(ERROR_FIELDS_ATTRIBUTE);
}
else else
{
request.setAttribute(ERROR_FIELDS_ATTRIBUTE, errorFields); request.setAttribute(ERROR_FIELDS_ATTRIBUTE, errorFields);
} }
}
/** /**
* Add a single UI field to the list of all error fields (which can * Add a single UI field to the list of all error fields (which can
@@ -260,10 +264,14 @@ public abstract class AbstractProcessingStep
public final String getErrorMessage(int errorFlag) public final String getErrorMessage(int errorFlag)
{ {
if (this.errorMessages == null || this.errorMessages.size() == 0) if (this.errorMessages == null || this.errorMessages.size() == 0)
{
return null; return null;
}
else else
{
return (String) this.errorMessages.get(Integer.valueOf(errorFlag)); return (String) this.errorMessages.get(Integer.valueOf(errorFlag));
} }
}
/** /**
* Add an error message to the internal map for this step. * Add an error message to the internal map for this step.

View File

@@ -126,10 +126,14 @@ public class CompleteStep extends AbstractProcessingStep
{ {
// commit changes to database // commit changes to database
if (success) if (success)
{
context.commit(); context.commit();
}
else else
{
context.getDBConnection().rollback(); context.getDBConnection().rollback();
} }
}
return STATUS_COMPLETE; return STATUS_COMPLETE;
} }

View File

@@ -610,17 +610,21 @@ public class DescribeStep extends AbstractProcessingStep
addErrorField(request, metadataField); addErrorField(request, metadataField);
} }
else else
{
item.addMetadata(schema, element, qualifier, null, item.addMetadata(schema, element, qualifier, null,
new DCPersonName(l, f).toString(), authKey, new DCPersonName(l, f).toString(), authKey,
(sconf != null && sconf.length() > 0) ? (sconf != null && sconf.length() > 0) ?
Choices.getConfidenceValue(sconf) : Choices.CF_ACCEPTED); Choices.getConfidenceValue(sconf) : Choices.CF_ACCEPTED);
} }
}
else else
{
item.addMetadata(schema, element, qualifier, null, item.addMetadata(schema, element, qualifier, null,
new DCPersonName(l, f).toString()); new DCPersonName(l, f).toString());
} }
} }
} }
}
/** /**
* Fill out an item's metadata values from a plain standard text field. If * Fill out an item's metadata values from a plain standard text field. If
@@ -738,15 +742,19 @@ public class DescribeStep extends AbstractProcessingStep
addErrorField(request, metadataField); addErrorField(request, metadataField);
} }
else else
{
item.addMetadata(schema, element, qualifier, lang, s, item.addMetadata(schema, element, qualifier, lang, s,
authKey, (sconf != null && sconf.length() > 0) ? authKey, (sconf != null && sconf.length() > 0) ?
Choices.getConfidenceValue(sconf) : Choices.CF_ACCEPTED); Choices.getConfidenceValue(sconf) : Choices.CF_ACCEPTED);
} }
}
else else
{
item.addMetadata(schema, element, qualifier, lang, s); item.addMetadata(schema, element, qualifier, lang, s);
} }
} }
} }
}
/** /**
* Fill out a metadata date field with the value from a form. The date is * Fill out a metadata date field with the value from a form. The date is

View File

@@ -70,9 +70,13 @@ public abstract class AbstractUsageEventListener implements EventListener {
public void setEventService(EventService service) throws Exception { public void setEventService(EventService service) throws Exception {
if(service != null) if(service != null)
{
service.registerEventListener(this); service.registerEventListener(this);
}
else else
{
throw new RuntimeException("EventService handed to Listener cannot be null"); throw new RuntimeException("EventService handed to Listener cannot be null");
}
} }

View File

@@ -339,10 +339,14 @@ public abstract class AbstractFiltersTransformer extends AbstractDSpaceTransform
//Also make sure we don't go above our newest year //Also make sure we don't go above our newest year
int currentTop = year; int currentTop = year;
if((year == topYear)) if((year == topYear))
{
currentTop = newestYear; currentTop = newestYear;
}
else else
{
//We need to do -1 on this one to get a better result //We need to do -1 on this one to get a better result
currentTop--; currentTop--;
}
facetQueries.add(dateFacet + ":[" + bottomYear + " TO " + currentTop + "]"); facetQueries.add(dateFacet + ":[" + bottomYear + " TO " + currentTop + "]");
} }
for (String facetQuery : facetQueries) { for (String facetQuery : facetQueries) {

View File

@@ -482,9 +482,13 @@ public abstract class AbstractSearch extends AbstractFiltersTransformer {
if (sortBy != null) { if (sortBy != null) {
if (sortOrder == null || sortOrder.equals("DESC")) if (sortOrder == null || sortOrder.equals("DESC"))
{
queryArgs.addSortField(sortBy, SolrQuery.ORDER.desc); queryArgs.addSortField(sortBy, SolrQuery.ORDER.desc);
}
else else
{
queryArgs.addSortField(sortBy, SolrQuery.ORDER.asc); queryArgs.addSortField(sortBy, SolrQuery.ORDER.asc);
}
} else { } else {
queryArgs.addSortField("score", SolrQuery.ORDER.asc); queryArgs.addSortField("score", SolrQuery.ORDER.asc);
} }
@@ -514,9 +518,13 @@ public abstract class AbstractSearch extends AbstractFiltersTransformer {
queryArgs.setQuery(query != null && !query.trim().equals("") ? query : "*:*"); queryArgs.setQuery(query != null && !query.trim().equals("") ? query : "*:*");
if (page > 1) if (page > 1)
{
queryArgs.setStart((page - 1) * queryArgs.getRows()); queryArgs.setStart((page - 1) * queryArgs.getRows());
}
else else
{
queryArgs.setStart(0); queryArgs.setStart(0);
}
@@ -590,11 +598,15 @@ public abstract class AbstractSearch extends AbstractFiltersTransformer {
// Are we in a community or collection? // Are we in a community or collection?
DSpaceObject dso; DSpaceObject dso;
if (scopeString == null || "".equals(scopeString)) if (scopeString == null || "".equals(scopeString))
{
// get the search scope from the url handle // get the search scope from the url handle
dso = HandleUtil.obtainHandle(objectModel); dso = HandleUtil.obtainHandle(objectModel);
}
else else
{
// Get the search scope from the location parameter // Get the search scope from the location parameter
dso = HandleManager.resolveToObject(context, scopeString); dso = HandleManager.resolveToObject(context, scopeString);
}
return dso; return dso;
} }

View File

@@ -193,9 +193,13 @@ public class CollectionSearch extends AbstractDSpaceTransformer implements Cache
// Set the page title // Set the page title
String name = collection.getMetadata("name"); String name = collection.getMetadata("name");
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
{
pageMeta.addMetadata("title").addContent(T_untitled); pageMeta.addMetadata("title").addContent(T_untitled);
}
else else
{
pageMeta.addMetadata("title").addContent(name); pageMeta.addMetadata("title").addContent(name);
}
pageMeta.addTrailLink(contextPath + "/",T_dspace_home); pageMeta.addTrailLink(contextPath + "/",T_dspace_home);
HandleUtil.buildHandleTrail(collection,pageMeta,contextPath); HandleUtil.buildHandleTrail(collection,pageMeta,contextPath);

View File

@@ -223,9 +223,13 @@ public class CommunitySearch extends AbstractDSpaceTransformer implements Cachea
Division home = body.addDivision("community-home", "primary repository community"); Division home = body.addDivision("community-home", "primary repository community");
String name = community.getMetadata("name"); String name = community.getMetadata("name");
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
{
home.setHead(T_untitled); home.setHead(T_untitled);
}
else else
{
home.setHead(name); home.setHead(name);
}
// The search / browse box. // The search / browse box.

View File

@@ -148,10 +148,14 @@ public abstract class AbstractBrowserServlet extends DSpaceServlet
if (bi == null) if (bi == null)
{ {
if (sortBy > 0) if (sortBy > 0)
{
bi = BrowseIndex.getBrowseIndex(SortOption.getSortOption(sortBy)); bi = BrowseIndex.getBrowseIndex(SortOption.getSortOption(sortBy));
}
else else
{
bi = BrowseIndex.getBrowseIndex(SortOption.getDefaultSortOption()); bi = BrowseIndex.getBrowseIndex(SortOption.getDefaultSortOption());
} }
}
// If we don't have a sort column // If we don't have a sort column
if (bi != null && sortBy == -1) if (bi != null && sortBy == -1)

View File

@@ -233,10 +233,14 @@ public class Authenticate
} }
} }
if (count == 1) if (count == 1)
{
response.sendRedirect(url); response.sendRedirect(url);
}
else else
{
JSPManager.showJSP(request, response, "/login/chooser.jsp"); JSPManager.showJSP(request, response, "/login/chooser.jsp");
} }
}
return false; return false;
} }

View File

@@ -77,8 +77,10 @@ public class CollectionStyleSelection extends AKeyBasedStyleSelection
return getFromMap(c.getHandle()); return getFromMap(c.getHandle());
} }
else else
{
return "default"; //no specific style - item is an in progress Submission return "default"; //no specific style - item is an in progress Submission
} }
}
/** /**
* Put collection handle/style name mapping in an in-memory map. * Put collection handle/style name mapping in an in-memory map.

View File

@@ -1332,6 +1332,7 @@ abstract class DAVResource
typeMask = TYPE_ALL; typeMask = TYPE_ALL;
} }
else else
{
for (String element : types) for (String element : types)
{ {
String key = element.trim(); String key = element.trim();
@@ -1362,6 +1363,7 @@ abstract class DAVResource
"Unrecognized type keyword: " + key); "Unrecognized type keyword: " + key);
} }
} }
}
return typeMask; return typeMask;
} }

View File

@@ -99,7 +99,9 @@ public class DatasetTimeGenerator extends DatasetGenerator {
endPos = true; endPos = true;
}else }else
if(0 < difEnd) if(0 < difEnd)
{
endPos = true; endPos = true;
}
else{ else{
difEnd++; difEnd++;
} }
@@ -209,7 +211,9 @@ public class DatasetTimeGenerator extends DatasetGenerator {
cal2 = backup; cal2 = backup;
toAdd = 1; toAdd = 1;
}else }else
{
toAdd = -1; toAdd = -1;
}

View File

@@ -51,13 +51,17 @@ public class ApacheLogRobotsProcessor {
String logFileLoc; String logFileLoc;
String spiderIpPath; String spiderIpPath;
if (line.hasOption("l")) if (line.hasOption("l"))
{
logFileLoc = line.getOptionValue("l"); logFileLoc = line.getOptionValue("l");
}
else { else {
System.out.println("We need our log file"); System.out.println("We need our log file");
return; return;
} }
if (line.hasOption("s")) if (line.hasOption("s"))
{
spiderIpPath = line.getOptionValue("s"); spiderIpPath = line.getOptionValue("s");
}
else { else {
System.out.println("We need a spider IP output file"); System.out.println("We need a spider IP output file");
return; return;

View File

@@ -434,9 +434,13 @@ public class ControlPanel extends AbstractDSpaceTransformer implements Serviceab
message.setLabel(T_alerts_message_label); message.setLabel(T_alerts_message_label);
message.setSize(5, 45); message.setSize(5, 45);
if (SystemwideAlerts.getMessage() == null) if (SystemwideAlerts.getMessage() == null)
{
message.setValue(T_alerts_message_default); message.setValue(T_alerts_message_default);
}
else else
{
message.setValue(SystemwideAlerts.getMessage()); message.setValue(SystemwideAlerts.getMessage());
}
Select countdown = form.addItem().addSelect("countdown"); Select countdown = form.addItem().addSelect("countdown");
countdown.setLabel(T_alerts_countdown_label); countdown.setLabel(T_alerts_countdown_label);
@@ -449,9 +453,13 @@ public class ControlPanel extends AbstractDSpaceTransformer implements Serviceab
// Is there a current count down active? // Is there a current count down active?
if (SystemwideAlerts.isAlertActive() && SystemwideAlerts.getCountDownToo() - System.currentTimeMillis() > 0) if (SystemwideAlerts.isAlertActive() && SystemwideAlerts.getCountDownToo() - System.currentTimeMillis() > 0)
{
countdown.addOption(true, -1, T_alerts_countdown_keep); countdown.addOption(true, -1, T_alerts_countdown_keep);
}
else else
{
countdown.setOptionSelected(0); countdown.setOptionSelected(0);
}
Select restrictsessions = form.addItem().addSelect("restrictsessions"); Select restrictsessions = form.addItem().addSelect("restrictsessions");
restrictsessions.setLabel(T_alerts_session_label); restrictsessions.setLabel(T_alerts_session_label);
@@ -627,11 +635,17 @@ public class ControlPanel extends AbstractDSpaceTransformer implements Serviceab
long ago = System.currentTimeMillis() - event.getTimeStamp(); long ago = System.currentTimeMillis() - event.getTimeStamp();
if (ago > 2*60*60*1000) if (ago > 2*60*60*1000)
{
timeStampMessage = T_hours.parameterize((ago / (60 * 60 * 1000))); timeStampMessage = T_hours.parameterize((ago / (60 * 60 * 1000)));
}
else if (ago > 60*1000) else if (ago > 60*1000)
{
timeStampMessage = T_minutes.parameterize((ago / (60 * 1000))); timeStampMessage = T_minutes.parameterize((ago / (60 * 1000)));
}
else else
{
timeStampMessage = T_seconds.parameterize((ago / (1000))); timeStampMessage = T_seconds.parameterize((ago / (1000)));
}
Row eventRow = activeUsers.addRow(); Row eventRow = activeUsers.addRow();

View File

@@ -125,8 +125,14 @@ public class DeletePoliciesConfirm extends AbstractDSpaceTransformer
Row row = table.addRow(); Row row = table.addRow();
row.addCell().addContent(policy.getID()); row.addCell().addContent(policy.getID());
row.addCell().addContent(policy.getActionText()); row.addCell().addContent(policy.getActionText());
if (policy.getGroup() != null) row.addCell().addContent(policy.getGroup().getName()); if (policy.getGroup() != null)
else row.addCell().addContent("..."); {
row.addCell().addContent(policy.getGroup().getName());
}
else
{
row.addCell().addContent("...");
}
} }
Para buttons = deleted.addPara(); Para buttons = deleted.addPara();
buttons.addButton("submit_confirm").setValue(T_submit_confirm); buttons.addButton("submit_confirm").setValue(T_submit_confirm);

View File

@@ -91,9 +91,13 @@ public class DeleteCollectionRoleConfirm extends AbstractDSpaceTransformer
main.setHead(T_main_head.parameterize(role)); main.setHead(T_main_head.parameterize(role));
// Different help message for the default read group to enforce its non-retroactive nature // Different help message for the default read group to enforce its non-retroactive nature
if (role == "DEFAULT_READ") if (role == "DEFAULT_READ")
{
main.addPara(T_main_para_read.parameterize(toBeDeleted.getName())); main.addPara(T_main_para_read.parameterize(toBeDeleted.getName()));
}
else else
{
main.addPara(T_main_para.parameterize(toBeDeleted.getName())); main.addPara(T_main_para.parameterize(toBeDeleted.getName()));
}
Para buttonList = main.addPara(); Para buttonList = main.addPara();
buttonList.addButton("submit_confirm").setValue(T_submit_confirm); buttonList.addButton("submit_confirm").setValue(T_submit_confirm);

View File

@@ -99,9 +99,13 @@ public class CreateCommunityForm extends AbstractDSpaceTransformer
/* Whether the parent community is null is what determines if /* Whether the parent community is null is what determines if
we are creating a top-level community or a sub-community */ we are creating a top-level community or a sub-community */
if (parentCommunity != null) if (parentCommunity != null)
{
main.setHead(T_main_head_sub.parameterize(parentCommunity.getMetadata("name"))); main.setHead(T_main_head_sub.parameterize(parentCommunity.getMetadata("name")));
}
else else
{
main.setHead(T_main_head_top); main.setHead(T_main_head_top);
}
// The grand list of metadata options // The grand list of metadata options

View File

@@ -444,9 +444,13 @@ public abstract class AbstractSearch extends AbstractDSpaceTransformer
queryArgs.setQuery(query); queryArgs.setQuery(query);
if (page > 1) if (page > 1)
{
queryArgs.setStart((Integer.valueOf(page) - 1) * queryArgs.getPageSize()); queryArgs.setStart((Integer.valueOf(page) - 1) * queryArgs.getPageSize());
}
else else
{
queryArgs.setStart(0); queryArgs.setStart(0);
}
QueryResults qResults = null; QueryResults qResults = null;
if (scope instanceof Community) if (scope instanceof Community)
@@ -480,11 +484,15 @@ public abstract class AbstractSearch extends AbstractDSpaceTransformer
// Are we in a community or collection? // Are we in a community or collection?
DSpaceObject dso; DSpaceObject dso;
if (scopeString == null || "".equals(scopeString)) if (scopeString == null || "".equals(scopeString))
{
// get the search scope from the url handle // get the search scope from the url handle
dso = HandleUtil.obtainHandle(objectModel); dso = HandleUtil.obtainHandle(objectModel);
}
else else
{
// Get the search scope from the location parameter // Get the search scope from the location parameter
dso = HandleManager.resolveToObject(context, scopeString); dso = HandleManager.resolveToObject(context, scopeString);
}
return dso; return dso;
} }

View File

@@ -242,9 +242,13 @@ public class CollectionViewer extends AbstractDSpaceTransformer implements Cache
Division home = body.addDivision("collection-home", "primary repository collection"); Division home = body.addDivision("collection-home", "primary repository collection");
String name = collection.getMetadata("name"); String name = collection.getMetadata("name");
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
{
home.setHead(T_untitled); home.setHead(T_untitled);
}
else else
{
home.setHead(name); home.setHead(name);
}
// The search / browse box. // The search / browse box.
{ {

View File

@@ -207,9 +207,13 @@ public class CommunityViewer extends AbstractDSpaceTransformer implements Cachea
// Set the page title // Set the page title
String name = community.getMetadata("name"); String name = community.getMetadata("name");
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
{
pageMeta.addMetadata("title").addContent(T_untitled); pageMeta.addMetadata("title").addContent(T_untitled);
}
else else
{
pageMeta.addMetadata("title").addContent(name); pageMeta.addMetadata("title").addContent(name);
}
// Add the trail back to the repository root. // Add the trail back to the repository root.
pageMeta.addTrailLink(contextPath + "/",T_dspace_home); pageMeta.addTrailLink(contextPath + "/",T_dspace_home);
@@ -259,9 +263,13 @@ public class CommunityViewer extends AbstractDSpaceTransformer implements Cachea
Division home = body.addDivision("community-home", "primary repository community"); Division home = body.addDivision("community-home", "primary repository community");
String name = community.getMetadata("name"); String name = community.getMetadata("name");
if (name == null || name.length() == 0) if (name == null || name.length() == 0)
{
home.setHead(T_untitled); home.setHead(T_untitled);
}
else else
{
home.setHead(name); home.setHead(name);
}
// The search / browse box. // The search / browse box.
{ {

View File

@@ -422,12 +422,18 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
year.addOption(false, String.valueOf(i), String.valueOf(i)); year.addOption(false, String.valueOf(i), String.valueOf(i));
if (i <= fiveYearBreak) if (i <= fiveYearBreak)
{
i -= 10; i -= 10;
}
else if (i <= oneYearBreak) else if (i <= oneYearBreak)
{
i -= 5; i -= 5;
}
else else
{
i--; i--;
} }
}
while (i > tenYearBreak); while (i > tenYearBreak);
// Create a free text entry box for the year // Create a free text entry box for the year
@@ -866,16 +872,22 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
value = "\""+cm.getLabel(fk, info.getValue(), null)+"\""; value = "\""+cm.getLabel(fk, info.getValue(), null)+"\"";
} }
else else
{
value = "\"" + info.getValue() + "\""; value = "\"" + info.getValue() + "\"";
} }
}
// Get the name of any scoping element (collection / community) // Get the name of any scoping element (collection / community)
String scopeName = ""; String scopeName = "";
if (info.getBrowseContainer() != null) if (info.getBrowseContainer() != null)
{
scopeName = info.getBrowseContainer().getName(); scopeName = info.getBrowseContainer().getName();
}
else else
{
scopeName = ""; scopeName = "";
}
if (bix.isMetadataIndex()) if (bix.isMetadataIndex())
{ {
@@ -907,9 +919,13 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
String scopeName = ""; String scopeName = "";
if (info.getBrowseContainer() != null) if (info.getBrowseContainer() != null)
{
scopeName = info.getBrowseContainer().getName(); scopeName = info.getBrowseContainer().getName();
}
else else
{
scopeName = ""; scopeName = "";
}
if (bix.isMetadataIndex()) if (bix.isMetadataIndex())
{ {

View File

@@ -161,9 +161,13 @@ public class ChoiceLookupTransformer extends AbstractDSpaceTransformer
Division idiv = body.addInteractiveDivision("lookup", "", "get", "popup"); Division idiv = body.addInteractiveDivision("lookup", "", "get", "popup");
if (isFieldMessage(field, "title")) if (isFieldMessage(field, "title"))
{
idiv.setHead(getFieldMessage(field, "title")); idiv.setHead(getFieldMessage(field, "title"));
}
else else
{
idiv.setHead(getFieldLabel(field, "title")); idiv.setHead(getFieldLabel(field, "title"));
}
List fl = idiv.addList("choicesList", "form", "choices-lookup"); List fl = idiv.addList("choicesList", "form", "choices-lookup");
fl.setHead(T_results); fl.setHead(T_results);
@@ -204,10 +208,14 @@ public class ChoiceLookupTransformer extends AbstractDSpaceTransformer
{ {
h = selectItem.addHidden("paramNonAuthority"); h = selectItem.addHidden("paramNonAuthority");
if (isFieldMessage(field, "nonauthority")) if (isFieldMessage(field, "nonauthority"))
{
h.setValue(getFieldMessage(field, "nonauthority")); h.setValue(getFieldMessage(field, "nonauthority"));
}
else else
{
h.setValue(getFieldLabel(field, "nonauthority")); h.setValue(getFieldLabel(field, "nonauthority"));
} }
}
h = selectItem.addHidden("contextPath"); h = selectItem.addHidden("contextPath");
h.setValue(contextPath); h.setValue(contextPath);
@@ -315,10 +323,14 @@ public class ChoiceLookupTransformer extends AbstractDSpaceTransformer
{ {
String cv = getFieldLabel(field, name); String cv = getFieldLabel(field, name);
if (cv == null) if (cv == null)
{
return message(MESSAGE_PREFIX + "field." + field + "." + name); return message(MESSAGE_PREFIX + "field." + field + "." + name);
}
else else
{
return message(cv); return message(cv);
} }
}
private int atoi(String s) private int atoi(String s)
{ {

View File

@@ -504,9 +504,13 @@ abstract public class AbstractStep extends AbstractDSpaceTransformer
if (errors!=null && errors.length() > 0) if (errors!=null && errors.length() > 0)
{ {
if(errors.indexOf(',') > 0) if(errors.indexOf(',') > 0)
{
fields = Arrays.asList(errors.split(",")); fields = Arrays.asList(errors.split(","));
}
else//only one error field else//only one error field
{
fields.add(errors); fields.add(errors);
}
} }
return fields; return fields;
@@ -532,12 +536,18 @@ abstract public class AbstractStep extends AbstractDSpaceTransformer
try try
{ {
if (givenStepAndPage.equals(this.stepAndPage)) if (givenStepAndPage.equals(this.stepAndPage))
{
return "current"; return "current";
}
else if (givenStepAndPage.compareTo(getMaxStepAndPageReached())>0) else if (givenStepAndPage.compareTo(getMaxStepAndPageReached())>0)
{
return "disabled"; return "disabled";
}
else else
{
return null; return null;
} }
}
catch(Exception e) catch(Exception e)
{ {
return null; return null;

View File

@@ -409,8 +409,10 @@ public class DescribeStep extends AbstractSubmissionStep
authItem.addContent(displayValue); authItem.addContent(displayValue);
} }
else else
{
describeSection.addItem(displayValue); describeSection.addItem(displayValue);
} }
}
} // For each DCValue } // For each DCValue
} // If values exist } // If values exist
}// For each input }// For each input
@@ -496,12 +498,16 @@ public class DescribeStep extends AbstractSubmissionStep
if (isAuthorityControlled) if (isAuthorityControlled)
{ {
if (dcValue.authority == null || dcValue.authority.equals("")) if (dcValue.authority == null || dcValue.authority.equals(""))
{
fi.setAuthorityValue("", "blank"); fi.setAuthorityValue("", "blank");
}
else else
{
fi.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence)); fi.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence));
} }
} }
} }
}
else if (dcValues.length == 1) else if (dcValues.length == 1)
{ {
DCPersonName dpn = new DCPersonName(dcValues[0].value); DCPersonName dpn = new DCPersonName(dcValues[0].value);
@@ -511,12 +517,16 @@ public class DescribeStep extends AbstractSubmissionStep
if (isAuthorityControlled) if (isAuthorityControlled)
{ {
if (dcValues[0].authority == null || dcValues[0].authority.equals("")) if (dcValues[0].authority == null || dcValues[0].authority.equals(""))
{
lastName.setAuthorityValue("", "blank"); lastName.setAuthorityValue("", "blank");
}
else else
{
lastName.setAuthorityValue(dcValues[0].authority, Choices.getConfidenceText(dcValues[0].confidence)); lastName.setAuthorityValue(dcValues[0].authority, Choices.getConfidenceText(dcValues[0].confidence));
} }
} }
} }
}
/** /**
* Render a date field to the DRI document. The date field consists of * Render a date field to the DRI document. The date field consists of
@@ -604,11 +614,15 @@ public class DescribeStep extends AbstractSubmissionStep
// Check if the day field is not specified, if so then just // Check if the day field is not specified, if so then just
// put a blank value in instead of the wiered looking -1. // put a blank value in instead of the wiered looking -1.
if (dcDate.getDay() == -1) if (dcDate.getDay() == -1)
{
day.setValue(""); day.setValue("");
}
else else
{
day.setValue(String.valueOf(dcDate.getDay())); day.setValue(String.valueOf(dcDate.getDay()));
} }
} }
}
/** /**
* Render a series field to the DRI document. The series field conist of * Render a series field to the DRI document. The series field conist of
@@ -818,24 +832,32 @@ public class DescribeStep extends AbstractSubmissionStep
if (isAuth) if (isAuth)
{ {
if (dcValue.authority == null || dcValue.authority.equals("")) if (dcValue.authority == null || dcValue.authority.equals(""))
{
ti.setAuthorityValue("", "blank"); ti.setAuthorityValue("", "blank");
}
else else
{
ti.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence)); ti.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence));
} }
} }
} }
}
else if (dcValues.length == 1) else if (dcValues.length == 1)
{ {
textArea.setValue(dcValues[0].value); textArea.setValue(dcValues[0].value);
if (isAuth) if (isAuth)
{ {
if (dcValues[0].authority == null || dcValues[0].authority.equals("")) if (dcValues[0].authority == null || dcValues[0].authority.equals(""))
{
textArea.setAuthorityValue("", "blank"); textArea.setAuthorityValue("", "blank");
}
else else
{
textArea.setAuthorityValue(dcValues[0].authority, Choices.getConfidenceText(dcValues[0].confidence)); textArea.setAuthorityValue(dcValues[0].authority, Choices.getConfidenceText(dcValues[0].confidence));
} }
} }
} }
}
/** /**
* Render a dropdown field for a choice-controlled input of the * Render a dropdown field for a choice-controlled input of the
@@ -879,7 +901,9 @@ public class DescribeStep extends AbstractSubmissionStep
select.setSize(6); select.setSize(6);
} }
else else
{
select.setSize(1); select.setSize(1);
}
if (readonly) if (readonly)
{ {
@@ -1108,24 +1132,32 @@ public class DescribeStep extends AbstractSubmissionStep
if (isAuth) if (isAuth)
{ {
if (dcValue.authority == null || dcValue.authority.equals("")) if (dcValue.authority == null || dcValue.authority.equals(""))
{
ti.setAuthorityValue("", "blank"); ti.setAuthorityValue("", "blank");
}
else else
{
ti.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence)); ti.setAuthorityValue(dcValue.authority, Choices.getConfidenceText(dcValue.confidence));
} }
} }
} }
}
else if (dcValues.length == 1) else if (dcValues.length == 1)
{ {
text.setValue(dcValues[0].value); text.setValue(dcValues[0].value);
if (isAuth) if (isAuth)
{ {
if (dcValues[0].authority == null || dcValues[0].authority.equals("")) if (dcValues[0].authority == null || dcValues[0].authority.equals(""))
{
text.setAuthorityValue("", "blank"); text.setAuthorityValue("", "blank");
}
else else
{
text.setAuthorityValue(dcValues[0].authority, Choices.getConfidenceText(dcValues[0].confidence)); text.setAuthorityValue(dcValues[0].authority, Choices.getConfidenceText(dcValues[0].confidence));
} }
} }
} }
}

View File

@@ -100,14 +100,22 @@ public class AdvancedFormTest extends AbstractDSpaceTransformer {
div.addPara("There are two options you can use to control how this page is generated. First is the help parameter, if this is present then help text will be provided for all fields. Next is the error parameter, if it is provided then all fields will be generated in error conditions."); div.addPara("There are two options you can use to control how this page is generated. First is the help parameter, if this is present then help text will be provided for all fields. Next is the error parameter, if it is provided then all fields will be generated in error conditions.");
if (help) if (help)
{
div.addPara().addXref(makeURL(false, error), "Turn help OFF"); div.addPara().addXref(makeURL(false, error), "Turn help OFF");
}
else else
{
div.addPara().addXref(makeURL(true, error), "Turn help ON"); div.addPara().addXref(makeURL(true, error), "Turn help ON");
}
if (error) if (error)
{
div.addPara().addXref(makeURL(help, false), "Turn errors OFF"); div.addPara().addXref(makeURL(help, false), "Turn errors OFF");
}
else else
{
div.addPara().addXref(makeURL(help, true), "Turn errors ON"); div.addPara().addXref(makeURL(help, true), "Turn errors ON");
}
List list = div.addList("fieldTest",List.TYPE_FORM); List list = div.addList("fieldTest",List.TYPE_FORM);

View File

@@ -268,9 +268,13 @@ public class BitstreamReader extends AbstractReader implements Recyclable
//build redirect URL based on whether item has a handle assigned yet //build redirect URL based on whether item has a handle assigned yet
if(item.getHandle()!=null && item.getHandle().length()>0) if(item.getHandle()!=null && item.getHandle().length()>0)
{
redirectURL = request.getContextPath() + "/bitstream/handle/" + item.getHandle(); redirectURL = request.getContextPath() + "/bitstream/handle/" + item.getHandle();
}
else else
{
redirectURL = request.getContextPath() + "/bitstream/item/" + item.getID(); redirectURL = request.getContextPath() + "/bitstream/item/" + item.getID();
}
redirectURL += "/" + name + "?sequence=" + bitstream.getSequenceID(); redirectURL += "/" + name + "?sequence=" + bitstream.getSequenceID();

View File

@@ -474,11 +474,17 @@ public abstract class AbstractAdapter
// with an item (such as a community logo) then reference the bitstreamID directly. // with an item (such as a community logo) then reference the bitstreamID directly.
String identifier = null; String identifier = null;
if (item != null && item.getHandle() != null) if (item != null && item.getHandle() != null)
{
identifier = "handle/" + item.getHandle(); identifier = "handle/" + item.getHandle();
}
else if (item != null) else if (item != null)
{
identifier = "item/" + item.getID(); identifier = "item/" + item.getID();
}
else else
{
identifier = "id/" + bitstream.getID(); identifier = "id/" + bitstream.getID();
}
String url = contextPath + "/bitstream/"+identifier+"/"; String url = contextPath + "/bitstream/"+identifier+"/";
@@ -710,9 +716,13 @@ public abstract class AbstractAdapter
{ {
String prefix = namespaces.getPrefix(namespace.URI); String prefix = namespaces.getPrefix(namespace.URI);
if (prefix == null || prefix.equals("")) if (prefix == null || prefix.equals(""))
{
return localName; return localName;
}
else else
{
return prefix + ":" + localName; return prefix + ":" + localName;
} }
}
} }

View File

@@ -154,13 +154,19 @@ public class ContainerAdapter extends AbstractAdapter
if (dso.getHandle() == null) if (dso.getHandle() == null)
{ {
if (dso instanceof Collection) if (dso instanceof Collection)
{
return "collection:" + dso.getID(); return "collection:" + dso.getID();
else
return "community:"+dso.getID();
} }
else else
{
return "community:" + dso.getID();
}
}
else
{
return "hdl:" + dso.getHandle(); return "hdl:" + dso.getHandle();
} }
}
/** /**
* Return the profile to use for communities and collections. * Return the profile to use for communities and collections.
@@ -178,10 +184,14 @@ public class ContainerAdapter extends AbstractAdapter
protected String getMETSLabel() protected String getMETSLabel()
{ {
if (dso instanceof Community) if (dso instanceof Community)
{
return "DSpace Community"; return "DSpace Community";
}
else else
{
return "DSpace Collection"; return "DSpace Collection";
} }
}
/** /**
* Return a unique id for the given bitstream * Return a unique id for the given bitstream

View File

@@ -433,11 +433,15 @@ public class AuthenticationUtil
Context context = ContextUtil.obtainContext(objectModel); Context context = ContextUtil.obtainContext(objectModel);
if (SystemwideAlerts.canUserStartSession()) if (SystemwideAlerts.canUserStartSession())
{
return AuthenticationManager.canSelfRegister(context, request, email); return AuthenticationManager.canSelfRegister(context, request, email);
}
else else
{
// System wide alerts is preventing new sessions. // System wide alerts is preventing new sessions.
return false; return false;
} }
}
/** /**
* Determine if the EPerson (to be created or already created) has the * Determine if the EPerson (to be created or already created) has the

View File

@@ -433,9 +433,13 @@ public abstract class AbstractWingElement implements WingElement
Namespace namespace = attributeMap.getNamespace(); Namespace namespace = attributeMap.getNamespace();
String URI; String URI;
if (namespace != null) if (namespace != null)
{
URI = namespace.URI; URI = namespace.URI;
}
else else
{
URI = WingConstants.DRI.URI; URI = WingConstants.DRI.URI;
}
String prefix = namespaces.getPrefix(URI); String prefix = namespaces.getPrefix(URI);
@@ -478,10 +482,14 @@ public abstract class AbstractWingElement implements WingElement
private String qName(String prefix, String localName) private String qName(String prefix, String localName)
{ {
if (prefix == null || prefix.equals("")) if (prefix == null || prefix.equals(""))
{
return localName; return localName;
}
else else
{
return prefix + ":" + localName; return prefix + ":" + localName;
} }
}
/** /**
* Dispose * Dispose