[DS-707] Style / readability improvements

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5565 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-22 23:19:13 +00:00
parent 56c6ca1f49
commit d032c565e0
79 changed files with 927 additions and 246 deletions

View File

@@ -325,10 +325,14 @@ public class Harvest
// resolved, now make sure it's a collection
if (dso == null || dso.getType() != Constants.COLLECTION)
{
targetCollection = null;
}
else
{
targetCollection = (Collection) dso;
}
}
// not a handle, try and treat it as an integer collection
// database ID
else

View File

@@ -1145,8 +1145,10 @@ public class ItemExport
return new FileInputStream(file);
}
else
{
return null;
}
}
/**
* Get the file size of the export archive represented by the file name

View File

@@ -839,7 +839,9 @@ public class MediaFilterManager
return true;
}
else
{
return false;
}
}
}

View File

@@ -224,9 +224,13 @@ public class OpenSearch
{
// Encode results in requested format
if ("rss".equals(format))
{
format = "rss_2.0";
}
else if ("atom".equals(format))
{
format = "atom_1.0";
}
SyndicationFeed feed = new SyndicationFeed(labels.get(SyndicationFeed.MSG_UITYPE));
feed.populate(null, scope, results, labels);

View File

@@ -188,10 +188,14 @@ public class LDAPAuthentication
{
// e-mail address corresponds to active account
if (eperson.getRequireCertificate())
return CERT_REQUIRED;
else if (!eperson.canLogIn())
return BAD_ARGS;
{
return CERT_REQUIRED;
}
else if (!eperson.canLogIn())
{
return BAD_ARGS;
}
if (ldap.ldapAuthenticate(netid, password, context))
{
context.setCurrentUser(eperson = EPerson.findByNetid(context, netid.toLowerCase()));
@@ -200,6 +204,7 @@ public class LDAPAuthentication
return SUCCESS;
}
else
{
return BAD_CREDENTIALS;
}
}
@@ -240,11 +245,26 @@ public class LDAPAuthentication
{
context.setIgnoreAuthorization(true);
eperson = EPerson.create(context);
if ((ldap.ldapEmail!=null)&&(!ldap.ldapEmail.equals(""))) eperson.setEmail(ldap.ldapEmail);
else eperson.setEmail(netid);
if ((ldap.ldapGivenName!=null)&&(!ldap.ldapGivenName.equals(""))) eperson.setFirstName(ldap.ldapGivenName);
if ((ldap.ldapSurname!=null)&&(!ldap.ldapSurname.equals(""))) eperson.setLastName(ldap.ldapSurname);
if ((ldap.ldapPhone!=null)&&(!ldap.ldapPhone.equals(""))) eperson.setMetadata("phone", ldap.ldapPhone);
if ((ldap.ldapEmail!=null)&&(!ldap.ldapEmail.equals("")))
{
eperson.setEmail(ldap.ldapEmail);
}
else
{
eperson.setEmail(netid);
}
if ((ldap.ldapGivenName!=null)&&(!ldap.ldapGivenName.equals("")))
{
eperson.setFirstName(ldap.ldapGivenName);
}
if ((ldap.ldapSurname!=null)&&(!ldap.ldapSurname.equals("")))
{
eperson.setLastName(ldap.ldapSurname);
}
if ((ldap.ldapPhone!=null)&&(!ldap.ldapPhone.equals("")))
{
eperson.setMetadata("phone", ldap.ldapPhone);
}
eperson.setNetid(netid.toLowerCase());
eperson.setCanLogIn(true);
AuthenticationManager.initEPerson(context, request, eperson);

View File

@@ -225,10 +225,14 @@ public class LDAPHierarchicalAuthentication
{
// e-mail address corresponds to active account
if (eperson.getRequireCertificate())
return CERT_REQUIRED;
else if (!eperson.canLogIn())
return BAD_ARGS;
{
return CERT_REQUIRED;
}
else if (!eperson.canLogIn())
{
return BAD_ARGS;
}
if (ldap.ldapAuthenticate(dn, password, context))
{
context.setCurrentUser(eperson);
@@ -237,6 +241,7 @@ public class LDAPHierarchicalAuthentication
return SUCCESS;
}
else
{
return BAD_CREDENTIALS;
}
}

View File

@@ -80,8 +80,10 @@ public class ShibAuthentication implements AuthenticationMethod
java.util.Enumeration names = request.getHeaderNames();
String name;
while (names.hasMoreElements())
{
log.debug("header:" + (name = names.nextElement().toString()) + "="
+ request.getHeader(name));
}
boolean isUsingTomcatUser = ConfigurationManager
.getBooleanProperty("authentication.shib.email-use-tomcat-remote-user");

View File

@@ -147,9 +147,13 @@ public class LocaleOrderingFilter implements TextFilter
String[] localeArr = locale.split("_");
if (localeArr.length > 1)
{
theLocale = new Locale(localeArr[0], localeArr[1]);
}
else
{
theLocale = new Locale(locale);
}
// Return the configured locale, or English default
if (theLocale == null)
@@ -159,7 +163,9 @@ public class LocaleOrderingFilter implements TextFilter
}
}
else
{
return Locale.ENGLISH;
}
return theLocale;
}

View File

@@ -71,10 +71,14 @@ public abstract class DSpaceObject
protected void addDetails(String d)
{
if (eventDetails == null)
{
eventDetails = new StringBuffer(d);
}
else
{
eventDetails.append(", ").append(d);
}
}
/**
* @return summary of event details, or null if there are none.

View File

@@ -636,8 +636,10 @@ public class Item extends DSpaceObject
addMetadata(schema, element, qualifier, lang, values, authorities, confidences);
}
else
{
addMetadata(schema, element, qualifier, lang, values, null, null);
}
}
/**
* Add metadata fields. These are appended to existing values.
@@ -1632,24 +1634,36 @@ public class Item extends DSpaceObject
{
String text = tr.getStringColumn("text_value");
if (dcv.value == null && text == null)
{
matched = true;
}
else if (dcv.value != null && dcv.value.equals(text))
{
matched = true;
}
else
{
matched = false;
}
}
// Check the language is the same
if (matched)
{
String lang = tr.getStringColumn("text_lang");
if (dcv.language == null && lang == null)
{
matched = true;
}
else if (dcv.language != null && dcv.language.equals(lang))
{
matched = true;
}
else
{
matched = false;
}
}
// check that authority and confidence match
if (matched)

View File

@@ -205,11 +205,17 @@ public class LCNameAuthority implements ChoiceAuthority
int confidence;
if (handler.hits == 0)
{
confidence = Choices.CF_NOTFOUND;
}
else if (handler.hits == 1)
{
confidence = Choices.CF_UNCERTAIN;
}
else
{
confidence = Choices.CF_AMBIGUOUS;
}
return new Choices(handler.result.toArray(new Choice[handler.result.size()]),
start, handler.hits, confidence, more);
}
@@ -271,11 +277,15 @@ public class LCNameAuthority implements ChoiceAuthority
if (newValue.length() > 0)
{
if (textValue == null)
{
textValue = newValue;
}
else
{
textValue += newValue;
}
}
}
public void endElement(String namespaceURI, String localName,
String qName)
@@ -308,7 +318,9 @@ public class LCNameAuthority implements ChoiceAuthority
result.add(new Choice(lccn, name, name));
}
else
{
log.warn("Got anomalous result, at least one of these null: lccn=" + lccn + ", name=" + name);
}
name = null;
lccn = null;
}
@@ -318,13 +330,16 @@ public class LCNameAuthority implements ChoiceAuthority
{
if (lastTag != null && lastCode != null)
{
// 010.a is lccn, "authority code"
if (lastTag.equals("010") && lastCode.equals("a"))
{
// 010.a is lccn, "authority code"
lccn = textValue;
// 100.a is the personal name
}
else if (lastTag.equals("100") && lastCode.equals("a"))
{
// 100.a is the personal name
name = textValue;
}
if (lastTag.equals("100") && lastCode.equals("d") && (name != null))
name = name+" "+textValue;

View File

@@ -159,10 +159,14 @@ public class METSRightsCrosswalk
IOException, SQLException, AuthorizeException
{
if(dso==null)
{
return null;
}
// we don't have a way to provide METSRights for a SITE object
else if(dso.getType() == Constants.SITE)
{
throw new CrosswalkObjectNotSupported("The METSRightsCrosswalk cannot crosswalk a SITE object");
}
//Root element: RightsDeclarationMD
@@ -203,9 +207,13 @@ public class METSRightsCrosswalk
String contextClass=GROUP_CONTEXTCLASS;
if(group.getID()==0) //DSpace Anonymous Group = 'GENERAL PUBLIC' type
{
contextClass = ANONYMOUS_CONTEXTCLASS;
}
else if(group.getID()==1) //DSpace Administrator Group = 'REPOSITORY MGR' type
{
contextClass = ADMIN_CONTEXTCLASS;
}
rightsContext.setAttribute("CONTEXTCLASS", contextClass);
@@ -423,7 +431,9 @@ public class METSRightsCrosswalk
// if we're fed a <RightsDeclarationMD> wrapper object, recurse on its guts:
if (element.getName().equals("RightsDeclarationMD"))
{
ingest(context, dso, element.getChildren());
}
// "Context" section (where permissions are stored)
else if (element.getName().equals("Context"))
{

View File

@@ -288,8 +288,10 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String val = modsConfig.getProperty(qdc);
String pair[] = val.split("\\s+\\|\\s+", 2);
if (pair.length < 2)
{
log.warn("Illegal MODS mapping in " + propsFile.toString() + ", line = " +
qdc + " = " + val);
}
else
{
modsTriple trip = modsTriple.create(qdc, pair[0], pair[1]);
@@ -379,7 +381,9 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
modsTriple trip = (modsTriple)modsMap.get(qdc);
if (trip == null)
{
log.warn("WARNING: " + getPluginInstanceName() + ": No MODS mapping for \"" + qdc + "\"");
}
else
{
try
@@ -397,14 +401,22 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
{
Object what = ni.next();
if (what instanceof Element)
{
((Element) what).setText(checkedString(value));
}
else if (what instanceof Attribute)
{
((Attribute) what).setValue(checkedString(value));
}
else if (what instanceof Text)
{
((Text) what).setText(checkedString(value));
}
else
{
log.warn("Got unknown object from XPath, class=" + what.getClass().getName());
}
}
result.add(me);
}
catch (JDOMException je)
@@ -584,14 +596,20 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
private String checkedString(String value)
{
if (value == null)
{
return null;
}
String reason = Verifier.checkCharacterData(value);
if (reason == null)
{
return value;
}
else
{
if (log.isDebugEnabled())
{
log.debug("Filtering out non-XML characters in string, reason=" + reason);
}
StringBuffer result = new StringBuffer(value.length());
for (int i = 0; i < value.length(); ++i)
{

View File

@@ -248,8 +248,10 @@ public class DSpaceAIPDisseminator
return result;
}
else
{
return dmdTypes.split("\\s*,\\s*");
}
}
/**
* Return the name of all crosswalks to run for the techMD section of
@@ -284,8 +286,10 @@ public class DSpaceAIPDisseminator
}
}
else
{
return techTypes.split("\\s*,\\s*");
}
}
/**
* Return the name of all crosswalks to run for the sourceMD section of
@@ -317,8 +321,10 @@ public class DSpaceAIPDisseminator
return result;
}
else
{
return sourceTypes.split("\\s*,\\s*");
}
}
/**
* Return the name of all crosswalks to run for the digiprovMD section of
@@ -340,10 +346,14 @@ public class DSpaceAIPDisseminator
{
String dpTypes = ConfigurationManager.getProperty("aip.disseminate.digiprovMD");
if (dpTypes == null)
{
return new String[0];
}
else
{
return dpTypes.split("\\s*,\\s*");
}
}
/**
* Return the name of all crosswalks to run for the rightsMD section of
@@ -380,7 +390,9 @@ public class DSpaceAIPDisseminator
result.add(DSPACE_DEPOSIT_LICENSE_MDTYPE);
if (CreativeCommons.getLicenseRdfBitstream((Item)dso) != null)
{
result.add(CREATIVE_COMMONS_RDF_MDTYPE);
}
else if (CreativeCommons.getLicenseTextBitstream((Item)dso) != null)
result.add(CREATIVE_COMMONS_TEXT_MDTYPE);
}
@@ -389,7 +401,9 @@ public class DSpaceAIPDisseminator
result.add("METSRights");
}
else
{
return rTypes.split("\\s*,\\s*");
}
return result.toArray(new String[result.size()]);
}
@@ -504,9 +518,13 @@ public class DSpaceAIPDisseminator
case Constants.COMMUNITY:
Community parent = ((Community)dso).getParentCommunity();
if (parent == null)
{
parentHandle = Site.getSiteHandle();
}
else
{
parentHandle = parent.getHandle();
}
case Constants.SITE:
break;
}

View File

@@ -113,7 +113,9 @@ public class DSpaceAIPIngester
{
String profile = manifest.getProfile();
if (profile == null)
{
throw new MetadataValidationException("Cannot accept METS with no PROFILE attribute!");
}
else if (!profile.equals(DSpaceAIPDisseminator.PROFILE_1_0))
throw new MetadataValidationException("METS has unacceptable PROFILE attribute, profile="+profile);
}
@@ -209,8 +211,10 @@ public class DSpaceAIPIngester
// it's an error if there is nothing to crosswalk:
else
{
throw new MetadataValidationException("DSpaceAIPIngester: Could not find an acceptable object-wide DMD section in manifest.");
}
}
/**

View File

@@ -133,10 +133,14 @@ public class DSpaceMETSDisseminator
public String bundleToFileGrp(String bname)
{
if (bname.equals("ORIGINAL"))
{
return "CONTENT";
}
else
{
return bname;
}
}
/**
* Create metsHdr element - separate so subclasses can override.
@@ -205,8 +209,10 @@ public class DSpaceMETSDisseminator
return result;
}
else
{
return new String[0];
}
}
@Override
public String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params)
@@ -244,13 +250,20 @@ public class DSpaceMETSDisseminator
{
Item item = (Item)dso;
if (PackageUtils.findDepositLicense(context, item) != null)
{
result.add(DSPACE_DEPOSIT_LICENSE_MDTYPE);
}
if (CreativeCommons.getLicenseRdfBitstream(item) != null)
{
result.add(CREATIVE_COMMONS_RDF_MDTYPE);
}
else if (CreativeCommons.getLicenseTextBitstream(item) != null)
{
result.add(CREATIVE_COMMONS_TEXT_MDTYPE);
}
}
return result.toArray(new String[result.size()]);
}

View File

@@ -92,10 +92,14 @@ public class DSpaceMETSIngester
{
String profile = manifest.getProfile();
if (profile == null)
{
throw new MetadataValidationException("Cannot accept METS with no PROFILE attribute!");
}
else if (!profile.startsWith(PROFILE_START))
{
throw new MetadataValidationException("METS has unacceptable PROFILE value, profile=" + profile);
}
}
/**
* Choose DMD section(s) to crosswalk.

View File

@@ -220,9 +220,13 @@ public class METSManifest
{
File xsd = new File(xsdPath1, val[1]);
if (!xsd.exists())
{
xsd = new File(xsdPath2, val[1]);
}
if (!xsd.exists())
{
log.warn("Schema file not found for config entry=\"" + spec + "\"");
}
else
{
try
@@ -239,13 +243,17 @@ public class METSManifest
}
}
else
{
log.warn("Schema config entry has wrong format, entry=\"" + spec + "\"");
}
}
}
localSchemas = result.toString();
if (log.isDebugEnabled())
{
log.debug("Got local schemas = \"" + localSchemas + "\"");
}
}
/**
* Default constructor, only called internally.
@@ -437,9 +445,13 @@ public class METSManifest
private static String normalizeBundleName(String in)
{
if (in.equals("CONTENT"))
{
return Constants.CONTENT_BUNDLE_NAME;
}
else if (in.equals("MANIFESTMD"))
{
return Constants.METADATA_BUNDLE_NAME;
}
return in;
}
@@ -456,7 +468,9 @@ public class METSManifest
Element fg = file.getParentElement();
String fgUse = fg.getAttributeValue("USE");
if (fgUse == null)
{
throw new MetadataValidationException("Invalid METS Manifest: every fileGrp element must have a USE attribute.");
}
return normalizeBundleName(fgUse);
}
@@ -480,21 +494,31 @@ public class METSManifest
{
// check for forbidden FContent child first:
if (file.getChild("FContent", metsNS) == null)
{
throw new MetadataValidationException("Invalid METS Manifest: Every file element must have FLocat child.");
}
else
{
throw new MetadataValidationException("Invalid METS Manifest: file element has forbidden FContent child, only FLocat is allowed.");
}
}
}
else if (file.getName().equals("mdRef"))
{
ref = file;
}
else
{
throw new MetadataValidationException("getFileName() called with recognized element type: " + file.toString());
}
String loctype = ref.getAttributeValue("LOCTYPE");
if (loctype != null && loctype.equals("URL"))
{
String result = ref.getAttributeValue("href", xlinkNS);
if (result == null)
{
throw new MetadataValidationException("Invalid METS Manifest: FLocat/mdRef is missing the required xlink:href attribute.");
}
return result;
}
throw new MetadataValidationException("Invalid METS Manifest: FLocat/mdRef does not have LOCTYPE=\"URL\" attribute.");
@@ -604,7 +628,9 @@ public class METSManifest
{
Element bin = mdWrap.getChild("binData", metsNS);
if (bin == null)
{
throw new MetadataValidationException("Invalid METS Manifest: mdWrap element with neither xmlData nor binData child.");
}
// if binData is actually XML, return it; otherwise ignore.
else
@@ -647,8 +673,10 @@ public class METSManifest
}
}
else
{
throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element with neither mdRef nor mdWrap child.");
}
}
catch (JDOMException je)
{
throw new MetadataValidationException("Error parsing or validating metadata section in mdRef or binData within "+mdSec.toString(), je);
@@ -676,7 +704,9 @@ public class METSManifest
{
Element bin = mdWrap.getChild("binData", metsNS);
if (bin == null)
{
throw new MetadataValidationException("Invalid METS Manifest: mdWrap element with neither xmlData nor binData child.");
}
else
{
@@ -696,8 +726,10 @@ public class METSManifest
return callback.getInputStream(mdRef);
}
else
{
throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element with neither mdRef nor mdWrap child.");
}
}
/**
@@ -853,12 +885,18 @@ public class METSManifest
xpath.addNamespace(xlinkNS);
Object result = xpath.selectSingleNode(mets);
if (result == null && nullOk)
{
return null;
}
else if (result instanceof Element)
{
return (Element) result;
}
else
{
throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\"" + path + "\"");
}
}
catch (JDOMException je)
{
throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\""+path+"\"", je);
@@ -1102,7 +1140,9 @@ public class METSManifest
{
Element bin = mdWrap.getChild("binData", metsNS);
if (bin == null)
{
throw new MetadataValidationException("Invalid METS Manifest: mdWrap element for streaming crosswalk without binData child.");
}
else
{
byte value[] = Base64.decodeBase64(bin.getText().getBytes());
@@ -1112,15 +1152,19 @@ public class METSManifest
}
}
else
{
throw new MetadataValidationException("Cannot process METS Manifest: " +
"Metadata of type=" + type + " requires a reference to a stream (mdRef), which was not found in " + xmd.getName());
}
}
}
else
{
throw new MetadataValidationException("Cannot process METS Manifest: " +
"No crosswalk found for contents of " + xmd.getName() + " element, MDTYPE=" + type);
}
}
}
catch (CrosswalkObjectNotSupported e)
{
log.warn("Skipping metadata section "+xmd.getName()+", type="+type+" inappropriate for this type of object: Object="+dso.toString()+", error="+e.toString());

View File

@@ -690,7 +690,9 @@ public class PluginManager
allInterfaces.addAll(reusableKey.keySet());
Iterator ii = allInterfaces.iterator();
while (ii.hasNext())
{
checkClassname((String) ii.next(), "key interface or class");
}
// Check implementation classes:
// - each class is loadable.

View File

@@ -360,11 +360,17 @@ public class EPerson extends DSpaceObject
// Create the parameter array, including limit and offset if part of the query
Object[] paramArr = new Object[] {int_param,params,params,params};
if (limit > 0 && offset > 0)
{
paramArr = new Object[]{int_param, params, params, params, limit, offset};
}
else if (limit > 0)
{
paramArr = new Object[]{int_param, params, params, params, limit};
}
else if (offset > 0)
{
paramArr = new Object[]{int_param, params, params, params, offset};
}
// Get all the epeople that match the query
TableRowIterator rows = DatabaseManager.queryTable(context, "eperson",

View File

@@ -897,11 +897,17 @@ public class Group extends DSpaceObject
// Create the parameter array, including limit and offset if part of the query
Object[] paramArr = new Object[]{params, int_param};
if (limit > 0 && offset > 0)
{
paramArr = new Object[]{params, int_param, limit, offset};
}
else if (limit > 0)
{
paramArr = new Object[]{params, int_param, limit};
}
else if (offset > 0)
{
paramArr = new Object[]{params, int_param, offset};
}
TableRowIterator rows =
DatabaseManager.query(context, dbquery, paramArr);

View File

@@ -306,20 +306,28 @@ public class Event implements Serializable
{
Integer mask = objTypeToMask.get(core);
if (mask == null)
{
return -1;
}
else
{
return mask.intValue();
}
}
// translate bitmask object-type to "core.Constants" object type.
private static int maskTypeToCore(int mask)
{
Integer core = objMaskToType.get(mask);
if (core == null)
{
return -1;
}
else
{
return core.intValue();
}
}
/**
* Get the DSpace object which is the "object" of an event.
@@ -331,10 +339,14 @@ public class Event implements Serializable
int type = getObjectType();
int id = getObjectID();
if (type < 0 || id < 0)
{
return null;
}
else
{
return DSpaceObject.find(context, type, id);
}
}
/**
* Syntactic sugar to get the DSpace object which is the "subject" of an
@@ -387,10 +399,14 @@ public class Event implements Serializable
{
int i = log2(subjectType);
if (i >= 0 && i < Constants.typeText.length)
{
return Constants.typeText[i];
}
else
{
return "(Unknown)";
}
}
/**
* @return type of object of this event as a String, e.g. for logging.
@@ -399,10 +415,14 @@ public class Event implements Serializable
{
int i = log2(objectType);
if (i >= 0 && i < Constants.typeText.length)
{
return Constants.typeText[i];
}
else
{
return "(Unknown)";
}
}
/**
* Translate a textual DSpace Object type name into an event subject-type
@@ -416,7 +436,9 @@ public class Event implements Serializable
public static int parseObjectType(String s)
{
if ("*".equals(s) || "all".equalsIgnoreCase(s))
{
return ALL_OBJECTS_MASK;
}
else
{
int id = Constants.getTypeID(s.toUpperCase());
@@ -445,10 +467,14 @@ public class Event implements Serializable
{
int i = log2(eventType);
if (i >= 0 && i < eventTypeText.length)
{
return eventTypeText[i];
}
else
{
return "(Unknown)";
}
}
/**
* Interpret named event type.

View File

@@ -279,8 +279,10 @@ public class HandleManager
}
else
{
log.warn("Cannot find Handle entry to unbind for object " + Constants.typeText[dso.getType()] + " id=" + dso.getID());
}
}
/**
* Return the object which handle maps to, or null. This is the object
@@ -384,13 +386,19 @@ public class HandleManager
if (row == null)
{
if (dso.getType() == Constants.SITE)
{
return Site.getSiteHandle();
else
return null;
}
else
{
return null;
}
}
else
{
return row.getStringColumn("handle");
}
}
/**
* Return all the handles which start with prefix.

View File

@@ -96,8 +96,10 @@ public class HarvestConsumer implements Consumer
hi.update();
}
else
{
log.debug("Deleted item '" + id + "' and the associated harvested_item.");
}
}
break;
case Constants.COLLECTION:
if (et == Event.DELETE)
@@ -109,8 +111,10 @@ public class HarvestConsumer implements Consumer
hc.update();
}
else
{
log.debug("Deleted collection '" + id + "' and the associated harvested_collection.");
}
}
default:
log.warn("consume() got unrecognized event: " + event.toString());
}

View File

@@ -274,10 +274,14 @@ public class HarvestedCollection
TableRow row = tri.next();
if (row != null)
{
return row.getIntColumn("collection_id");
}
else
{
return -1;
}
}
/** Find the collection that was harvested most recently.
* @throws SQLException
@@ -293,10 +297,14 @@ public class HarvestedCollection
TableRow row = tri.next();
if (row != null)
{
return row.getIntColumn("collection_id");
}
else
{
return -1;
}
}
/**

View File

@@ -1558,7 +1558,9 @@ public class DatabaseManager
Set pks = new HashSet();
while (pkcolumns.next())
{
pks.add(pkcolumns.getString(4));
}
columns = metadata.getColumns(catalog, schema, tname, null);

View File

@@ -119,11 +119,15 @@ public abstract class InitialArticleWord implements TextFilter
// then it must be followed by whitespace, if not, it can be anything
// Setting endPos signifies that we have found an article word
if (endsLetterOrDigit && isNextWhitespace)
{
initialEnd = curPos + initialArticleWord.length();
}
else if (!endsLetterOrDigit)
{
initialEnd = curPos + initialArticleWord.length();
}
}
}
// Quit the loop, as we have a significant character
break;
@@ -139,7 +143,9 @@ public abstract class InitialArticleWord implements TextFilter
// Find a cut point in the source string, removing any whitespace after the article word
int cutPos = initialEnd;
while (cutPos < str.length() && Character.isWhitespace(str.charAt(cutPos)))
{
cutPos++;
}
// Are we stripping the article word?
if (stripInitialArticle)
@@ -202,7 +208,9 @@ public abstract class InitialArticleWord implements TextFilter
{
int testPos = pos + len;
while (testPos < str.length() && Character.isWhitespace(str.charAt(testPos)))
{
testPos++;
}
if (testPos < str.length())
return str.substring(pos, pos + len);

View File

@@ -45,10 +45,14 @@ public class StripLeadingNonAlphaNum implements TextFilter
int i = 0;
while (i < str.length() && !Character.isLetterOrDigit(str.charAt(i)))
{
i++;
}
if (i > 0)
{
return str.substring(i);
}
return str;
}

View File

@@ -93,11 +93,16 @@ public class LoggerUsageEventListener extends AbstractUsageEventListener{
/* Emulate Item logger */
if(handle != null && object instanceof Item)
{
return "handle=" + object.getHandle();
}
else
{
return objText + "_id=" + object.getID();
}
}catch(Exception e)
}
catch(Exception e)
{
}

View File

@@ -121,18 +121,22 @@ public class IndexEventConsumer implements Consumer {
log.debug("Transforming Bundle event into MODIFY of Item "
+ subject.getHandle());
} else
{
return;
}
}
switch (et) {
case Event.CREATE:
case Event.MODIFY:
case Event.MODIFY_METADATA:
if (subject == null)
{
log.warn(event.getEventTypeAsString() + " event, could not get object for "
+ event.getSubjectTypeAsString() + " id="
+ String.valueOf(event.getSubjectID())
+ ", perhaps it has been deleted.");
}
else {
log.debug("consume() adding event to update queue: " + event.toString());
objectsToUpdate.add(subject);
@@ -142,10 +146,12 @@ public class IndexEventConsumer implements Consumer {
case Event.REMOVE:
case Event.ADD:
if (object == null)
{
log.warn(event.getEventTypeAsString() + " event, could not get object for "
+ event.getObjectTypeAsString() + " id="
+ String.valueOf(event.getObjectID())
+ ", perhaps it has been deleted.");
}
else {
log.debug("consume() adding event to update queue: " + event.toString());
objectsToUpdate.add(object);
@@ -155,7 +161,9 @@ public class IndexEventConsumer implements Consumer {
case Event.DELETE:
String detail = event.getDetail();
if (detail == null)
{
log.warn("got null detail on DELETE event, skipping it.");
}
else {
log.debug("consume() adding event to delete queue: " + event.toString());
handlesToDelete.add(detail);

View File

@@ -116,8 +116,11 @@ public class JSONSolrSearcher extends AbstractReader implements Recyclable {
//Should an invalid value be supplied use -1
facetLimit = -1;
}
}else
}
else
{
facetLimit = -1;
}
//Retrieve our sorting value
facetSort = request.getParameter(FacetParams.FACET_SORT);

View File

@@ -96,7 +96,10 @@ public class ShibbolethFilter implements Filter
{
java.util.Enumeration names = ((HttpServletRequest) request).getHeaderNames();
String name;
while(names.hasMoreElements()) log.debug("header:"+(name = names.nextElement().toString())+"="+((HttpServletRequest)request).getHeader(name));
while(names.hasMoreElements())
{
log.debug("header:" + (name = names.nextElement().toString()) + "=" + ((HttpServletRequest) request).getHeader(name));
}
// No current user, prompt authentication
Authenticate.startAuthentication(context, hrequest, hresponse);

View File

@@ -86,7 +86,9 @@ public class FeedbackServlet extends DSpaceServlet
String basicHost = "";
if (host.equals("localhost") || host.equals("127.0.0.1")
|| host.equals(InetAddress.getLocalHost().getHostAddress()))
{
basicHost = host;
}
else
{
// cut off all but the hostname, to cover cases where more than one URL

View File

@@ -541,7 +541,9 @@ public class HandleServlet extends DSpaceServlet
!Authenticate
.startAuthentication(context, request, response))
{
return;
}
else
{
Subscribe.subscribe(context, context.getCurrentUser(),

View File

@@ -81,10 +81,14 @@ public class LDAPServlet extends DSpaceServlet
// check if ldap is enables and forward to the correct login form
boolean ldap_enabled = ConfigurationManager.getBooleanProperty("ldap.enable");
if (ldap_enabled)
{
JSPManager.showJSP(request, response, "/login/ldap.jsp");
}
else
{
JSPManager.showJSP(request, response, "/login/password.jsp");
}
}
protected void doDSPost(Context context,

View File

@@ -82,7 +82,10 @@ public class ShibbolethServlet extends DSpaceServlet {
//debugging, show all headers
java.util.Enumeration names = request.getHeaderNames();
String name;
while(names.hasMoreElements()) log.info("header:"+(name=names.nextElement().toString())+"="+request.getHeader(name));
while(names.hasMoreElements())
{
log.info("header:" + (name = names.nextElement().toString()) + "=" + request.getHeader(name));
}
String jsp = null;

View File

@@ -353,8 +353,10 @@ public class JSPStepManager
return completeStep(context, request, response, subInfo);
}
else
{
return false; // step not completed
}
}
/**
* This method actually displays a JSP page for this "step". This method can
@@ -519,9 +521,11 @@ public class JSPStepManager
return true;
}
else
{
return false; // couldn't return to controller since response is
// committed
}
}
/**
* Checks to see if there are more pages in the current step after the

View File

@@ -256,17 +256,25 @@ public class OAIDCCrosswalk extends Crosswalk
// test the contents and replace appropriately
if (group.equals("&"))
{
xmlMatcher.appendReplacement(valueBuf,
"&amp;");
}
else if (group.equals("<"))
{
xmlMatcher.appendReplacement(valueBuf,
"&lt;");
}
else if (group.equals(">"))
{
xmlMatcher.appendReplacement(valueBuf,
"&gt;");
}
else
{
xmlMatcher.appendReplacement(valueBuf, " ");
}
}
// add bit of the string after the final match
xmlMatcher.appendTail(valueBuf);

View File

@@ -39,8 +39,12 @@ public class DnsLookup {
Record[] answers = response.getSectionArray(Section.ANSWER);
if (answers.length == 0)
{
return hostIp;
}
else
{
return answers[0].rdataToString();
}
}
}

View File

@@ -247,8 +247,14 @@ public class FlowAuthorizationUtils {
result.setContinue(true);
result.setOutcome(true);
if (added) result.setMessage(new Message("default","A new policy was created successfully"));
else result.setMessage(new Message("default","The policy was edited successfully"));
if (added)
{
result.setMessage(new Message("default", "A new policy was created successfully"));
}
else
{
result.setMessage(new Message("default", "The policy was edited successfully"));
}
result.setParameter("policyID", policy.getID());

View File

@@ -214,9 +214,13 @@ public class FlowContainerUtils
boolean oaiAllSets = "all".equals(request.getParameter("oai-set-setting"));
String oaiSetId;
if(oaiAllSets)
{
oaiSetId = "all";
}
else
{
oaiSetId = request.getParameter("oai_setid");
}
String metadataKey = request.getParameter("metadata_format");
@@ -352,15 +356,25 @@ public class FlowContainerUtils
int harvestTypeInt = 0;
if (oaiProvider == null || oaiProvider.length() == 0)
{
result.addError("oai_provider");
}
if (oaiSetId == null || oaiSetId.length() == 0)
{
result.addError("oai_setid");
}
if (metadataKey == null || metadataKey.length() == 0)
{
result.addError("metadata_format");
}
if (harvestType == null || harvestType.length() == 0)
{
result.addError("harvest_level");
}
else
{
harvestTypeInt = Integer.parseInt(harvestType);
}
if (result.getErrors() == null) {
@@ -781,9 +795,13 @@ public class FlowContainerUtils
Community newCommunity;
if (parent != null)
{
newCommunity = parent.createSubcommunity();
}
else
{
newCommunity = Community.create(null, context);
}
String name = request.getParameter("name");
String shortDescription = request.getParameter("short_description");

View File

@@ -331,10 +331,14 @@ public class FlowEPersonUtils {
for(String unable : unableList )
{
if (characters == null)
{
characters = unable;
}
else
{
characters += ", " + unable;
}
}
result.setCharacters(characters);
}

View File

@@ -473,23 +473,41 @@ public class FlowGroupUtils {
if (groupName.endsWith(suffix))
{
if (COLLECTION_SUFFIXES[0].equals(suffix))
{
return Role.Submitters;
}
else if (COLLECTION_SUFFIXES[1].equals(suffix))
{
return Role.Administrators;
}
else if (COLLECTION_SUFFIXES[2].equals(suffix))
{
return Role.WorkflowStep1;
}
else if (COLLECTION_SUFFIXES[3].equals(suffix))
{
return Role.WorkflowStep1;
}
else if (COLLECTION_SUFFIXES[4].equals(suffix))
{
return Role.WorkflowStep2;
}
else if (COLLECTION_SUFFIXES[5].equals(suffix))
{
return Role.WorkflowStep2;
}
else if (COLLECTION_SUFFIXES[6].equals(suffix))
{
return Role.WorkflowStep3;
}
else if (COLLECTION_SUFFIXES[7].equals(suffix))
{
return Role.WorkflowStep3;
}
else if (COLLECTION_SUFFIXES[8].equals(suffix))
{
return Role.DefaultRead;
}
} // if it ends with a proper suffix.
} // for each possible suffix
@@ -557,23 +575,41 @@ public class FlowGroupUtils {
if (groupName.endsWith(suffix))
{
if (COLLECTION_SUFFIXES[0].equals(suffix))
{
return Role.Submitters;
}
else if (COLLECTION_SUFFIXES[1].equals(suffix))
{
return Role.Administrators;
}
else if (COLLECTION_SUFFIXES[2].equals(suffix))
{
return Role.WorkflowStep1;
}
else if (COLLECTION_SUFFIXES[3].equals(suffix))
{
return Role.WorkflowStep1;
}
else if (COLLECTION_SUFFIXES[4].equals(suffix))
{
return Role.WorkflowStep2;
}
else if (COLLECTION_SUFFIXES[5].equals(suffix))
{
return Role.WorkflowStep2;
}
else if (COLLECTION_SUFFIXES[6].equals(suffix))
{
return Role.WorkflowStep3;
}
else if (COLLECTION_SUFFIXES[7].equals(suffix))
{
return Role.WorkflowStep3;
}
else if (COLLECTION_SUFFIXES[8].equals(suffix))
{
return Role.DefaultRead;
}
} // if it ends with a proper suffix.
} // for each possible suffix

View File

@@ -472,20 +472,30 @@ public class FlowRegistryUtils
// Get or create the format
BitstreamFormat format;
if (formatID >= 0)
{
format = BitstreamFormat.find(context, formatID);
}
else
{
format = BitstreamFormat.create(context);
}
// Update values
format.setMIMEType(mimeType);
if (formatID != 1) // don't change the unknow format.
{
format.setShortDescription(shortDescription);
}
format.setDescription(description);
format.setSupportLevel(Integer.valueOf(supportLevel));
if (internal == null)
{
format.setInternal(false);
}
else
{
format.setInternal(true);
}
format.setExtensions(extensions);

View File

@@ -144,10 +144,14 @@ public class FlowResult {
public void setOutcome(boolean success)
{
if (success)
{
outcome = Outcome.SUCCESS;
}
else
{
outcome = Outcome.FAILURE;
}
}
/**
* Get the notice outcome in string form, either success
@@ -260,15 +264,21 @@ public class FlowResult {
public String getErrorString()
{
if (errors == null || errors.size() == 0)
{
return null;
}
String errorString = null;
for (String error : errors)
{
if (errorString == null)
{
errorString = error;
}
else
{
errorString += "," + error;
}
}
return errorString;
}

View File

@@ -232,8 +232,11 @@ public class ItemExport extends AbstractDSpaceTransformer implements
if (request.getQueryString() != null) {
key.append(request.getQueryString());
}
} else
}
else
{
key.append("anonymous");
}
return HashUtil.hash(key.toString());
}

View File

@@ -153,7 +153,9 @@ public class Navigation extends AbstractDSpaceTransformer implements CacheablePr
}
}
else
{
key = "anonymous";
}
return HashUtil.hash(key);
}

View File

@@ -149,9 +149,13 @@ public class EditContainerPolicies extends AbstractDSpaceTransformer
{
Row row;
if (policy.getID() == highlightID)
{
row = table.addRow(null, null, "highlight");
}
else
{
row = table.addRow();
}
CheckBox select = row.addCell().addCheckBox("select_policy");
select.setLabel(String.valueOf(policy.getID()));

View File

@@ -208,17 +208,27 @@ public class EditItemPolicies extends AbstractDSpaceTransformer
{
Row row;
if (policy.getID() == highlightID)
{
row = table.addRow(null, null, "highlight");
}
else
{
row = table.addRow();
}
Cell cell;
if (objectType == Constants.BUNDLE)
{
cell = row.addCell(null, null, "indent");
}
else if (objectType == Constants.BITSTREAM)
{
cell = row.addCell(null, null, "doubleIndent");
}
else
{
cell = row.addCell();
}
CheckBox select = cell.addCheckBox("select_policy");

View File

@@ -163,7 +163,10 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
else if (policy != null) {
currentGroup = policy.getGroup();
}
else currentGroup = null;
else
{
currentGroup = null;
}
// Same for the current action; it can either blank (-1), manually set, or inherited from the current policy
if (policy != null && actionID == -1)
@@ -201,7 +204,9 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
main.setHead(T_main_head_edit.parameterize(policyID,Constants.typeText[objectType],objectID));
}
else
{
main.setHead(T_main_head_new.parameterize(Constants.typeText[objectType], objectID));
}
int resourceRelevance = 1 << objectType;
@@ -226,11 +231,15 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
if( (Constants.actionTypeRelevance[i] & resourceRelevance) > 0)
{
if (actionID == i)
{
actionSelect.addOption(true, i, Constants.actionText[i]);
}
else
{
actionSelect.addOption(i, Constants.actionText[i]);
}
}
}
if (errors.contains("action_id"))
actionSelect.addError(T_error_no_action);
@@ -242,10 +251,14 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
for (Group group : Group.findAll(context, Group.NAME))
{
if (group == currentGroup)
{
groupSelect.addOption(true, group.getID(), group.getName());
}
else
{
groupSelect.addOption(group.getID(), group.getName());
}
}
if (errors.contains("group_id"))
groupSelect.addError(T_error_no_group);
@@ -338,12 +351,18 @@ public class EditPolicyForm extends AbstractDSpaceTransformer
row.addCell().addContent(otherAuthorizations.substring(0,otherAuthorizations.lastIndexOf(", ")));
}
else
{
row.addCell().addContent("-");
}
if (group != sourceGroup)
{
row.addCell().addButton("submit_group_id_" + groupID).setValue(T_set_group);
}
else
{
row.addCell().addContent(T_current_group);
}
}
if (groups.length <= 0) {

View File

@@ -166,9 +166,13 @@ public class EditCollectionHarvestingForm extends AbstractDSpaceTransformer
String displayName;
if (metadataString.indexOf(',') != -1)
{
displayName = metadataString.substring(metadataString.indexOf(',') + 1);
}
else
{
displayName = metadataFormatValue + "(" + metadataString + ")";
}
settings.addItem(displayName);

View File

@@ -207,7 +207,9 @@ public class EditCollectionMetadataForm extends AbstractDSpaceTransformer
item = metadataList.addItem();
if (thisCollection.getTemplateItem() == null)
{
item.addButton("submit_create_template").setValue(T_submit_create_template);
}
else
{
item.addButton("submit_edit_template").setValue(T_submit_edit_template);

View File

@@ -250,10 +250,14 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
email.setLabel(T_email_address);
email.setValue(emailValue);
if (errors.contains("eperson_email_key"))
{
email.addError(T_error_email_unique);
}
else if (errors.contains("email_address"))
{
email.addError(T_error_email);
}
}
else
{
identity.addLabel(T_email_address);
@@ -348,13 +352,21 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
hi.addContent(", ");
if ("item".equals(constraint))
{
hi.addContent(T_constraint_item);
}
else if ("workflowitem".equals(constraint))
{
hi.addContent(T_constraint_workflowitem);
}
else if ("tasklistitem".equals(constraint))
{
hi.addContent(T_constraint_tasklistitem);
}
else
{
hi.addContent(T_constraint_unknown);
}
}
hi.addContent(".");

View File

@@ -222,16 +222,22 @@ public class ManageEPeopleMain extends AbstractDSpaceTransformer
Row row;
if (person.getID() == highlightID)
{
// This is a highlighted eperson
row = table.addRow(null, null, "highlight");
}
else
{
row = table.addRow();
}
selectEPerson = row.addCell().addCheckBox("select_eperson");
selectEPerson.setLabel(epersonID);
selectEPerson.addOption(epersonID);
if (deleteConstraints != null && deleteConstraints.size() > 0)
{
selectEPerson.setDisabled();
}
row.addCellContent(epersonID);

View File

@@ -239,14 +239,18 @@ public class EditGroupForm extends AbstractDSpaceTransformer
{
int collectionID = FlowGroupUtils.getCollectionId(group.getName());
if (collectionID > -1)
{
collection = Collection.find(context, collectionID);
}
else
{
int communityID = FlowGroupUtils.getCommunityId(group.getName());
if (communityID > -1)
{
community = Community.find(context, communityID);
}
}
}
// Get list of member groups
String memberGroupIDsString = parameters.getParameter("memberGroupIDs",null);
@@ -297,9 +301,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
//DIVISION: group-edit
Division main = body.addInteractiveDivision("group-edit",contextPath+"/admin/groups",Division.METHOD_POST,"primary administrative groups");
if (group == null)
{
main.setHead(T_main_head_new);
}
else
{
main.setHead(T_main_head.parameterize(group.getName(), groupID));
}
if(collection != null)
@@ -427,9 +435,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
{
// Check if they really members or just pending members
if (group != null && group.isMember(person))
{
personData.addCellContent(T_member);
}
else
{
personData.addCell().addHighlight("warn").addContent(T_pending);
}
}
else
{
@@ -492,9 +504,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
row.addCell().addContent(groupID);
if (AuthorizeManager.isAdmin(context))
// Only administrators can edit other groups.
{
row.addCell().addXref(url, name);
}
else
{
row.addCell().addContent(name);
}
@@ -509,9 +525,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
String collectionName = collection.getMetadata("name");
if (collectionName == null)
{
collectionName = "";
}
else if (collectionName.length() > MAX_COLLECTION_NAME)
{
collectionName = collectionName.substring(0, MAX_COLLECTION_NAME - 3) + "...";
}
cell.addContent(collectionName+" ");
@@ -528,10 +548,14 @@ public class EditGroupForm extends AbstractDSpaceTransformer
{
// Check if they really members or just pending members
if (parent != null && parent.isMember(group))
{
row.addCellContent(T_member);
}
else
{
row.addCell().addHighlight("warn").addContent(T_pending);
}
}
else if (isDescendant(sourceGroup, group, memberGroupIDs))
{
row.addCellContent(T_cycle);
@@ -691,9 +715,13 @@ public class EditGroupForm extends AbstractDSpaceTransformer
// Mark if this member is pending or not.
Cell nameCell = groupData.addCell();
if (AuthorizeManager.isAdmin(context))
{
nameCell.addHighlight("bold").addXref(url, T_members_group_name.parameterize(name));
}
else
{
nameCell.addHighlight("bold").addContent(T_members_group_name.parameterize(name));
}
if (pendingAddition)
{
@@ -704,10 +732,14 @@ public class EditGroupForm extends AbstractDSpaceTransformer
groupData.addCell().addContent("-");
if (pendingRemoval)
{
groupData.addCell().addHighlight("warn").addContent(T_pending);
}
else
{
groupData.addCell().addButton("submit_remove_group_" + group.getID()).setValue(T_submit_remove);
}
}
/**
* Add a single member row for epeople.
@@ -740,8 +772,12 @@ public class EditGroupForm extends AbstractDSpaceTransformer
personData.addCell().addXref(url, email);
if (pendingRemoval)
{
personData.addCell().addHighlight("warn").addContent(T_pending);
}
else
{
personData.addCell().addButton("submit_remove_eperson_" + eperson.getID()).setValue(T_submit_remove);
}
}
}

View File

@@ -224,9 +224,13 @@ public class ManageGroupsMain extends AbstractDSpaceTransformer
{
Row row;
if (group.getID() == highlightID)
{
row = table.addRow(null, null, "highlight");
}
else
{
row = table.addRow();
}
if (group.getID() > 1)
{
@@ -278,9 +282,13 @@ public class ManageGroupsMain extends AbstractDSpaceTransformer
if (collectionOrCommunity != null)
{
if (collectionOrCommunityName == null)
{
collectionOrCommunityName = "";
}
else if (collectionOrCommunityName.length() > MAX_COLLECTION_OR_COMMUNITY_NAME)
{
collectionOrCommunityName = collectionOrCommunityName.substring(0, MAX_COLLECTION_OR_COMMUNITY_NAME - 3) + "...";
}
cell.addContent(collectionOrCommunityName + " ");

View File

@@ -169,9 +169,13 @@ public class EditBitstreamForm extends AbstractDSpaceTransformer
continue;
String supportLevel = "Unknown";
if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN)
{
supportLevel = "known";
}
else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED)
{
supportLevel = "Supported";
}
String name = bitstreamFormat.getShortDescription()+" ("+supportLevel+")";
if (bitstreamFormat.isInternal())
name += " (Internal)";

View File

@@ -235,7 +235,9 @@ public class EditItemBitstreamsForm extends AbstractDSpaceTransformer {
Para actions = main.addPara("editItemActionsP","editItemActionsP" );
// Only System Administrators can delete bitstreams
if (AuthorizeManager.authorizeActionBoolean(context, item, Constants.REMOVE))
{
actions.addButton("submit_delete").setValue(T_submit_delete);
}
else
{
Button button = actions.addButton("submit_delete");

View File

@@ -167,11 +167,15 @@ public class MapperMain extends AbstractDSpaceTransformer {
Item item = iterator.next();
if (item.isOwningCollection(collection))
{
count_native++;
}
else
{
count_import++;
}
}
}
finally
{
if (iterator != null)

View File

@@ -186,9 +186,13 @@ public class EditBitstreamFormat extends AbstractDSpaceTransformer
// DIVISION: edit-bitstream-format
Division main = body.addInteractiveDivision("edit-bitstream-format",contextPath+"/admin/format-registry",Division.METHOD_POST,"primary administrative format-registry");
if (formatID == -1)
{
main.setHead(T_head1);
}
else
{
main.setHead(T_head2.parameterize(nameValue));
}
main.addPara(T_para1);
List form = main.addList("edit-bitstream-format",List.TYPE_FORM);
@@ -200,7 +204,9 @@ public class EditBitstreamFormat extends AbstractDSpaceTransformer
name.setValue(nameValue);
name.setSize(35);
if (errors.contains("short_description"))
{
name.addError(T_name_error);
}
Text mimeType = form.addItem().addText("mimetype");
mimeType.setLabel(T_mimetype);
@@ -210,7 +216,9 @@ public class EditBitstreamFormat extends AbstractDSpaceTransformer
// Do not allow anyone to change the name of the unknown format.
if (format != null && format.getID() == 1)
{
name.setDisabled();
}
TextArea description = form.addItem().addTextArea("description");
description.setLabel(T_description);

View File

@@ -175,11 +175,15 @@ public class EditMetadataSchema extends AbstractDSpaceTransformer
// DIVISION: add or updating a metadata field
if (updateID >= 0)
{
// Updating an existing field
addUpdateFieldForm(main, schemaName, updateID, errors);
}
else
{
// Add a new field
addNewFieldForm(main, schemaName, errors);
}
@@ -215,9 +219,13 @@ public class EditMetadataSchema extends AbstractDSpaceTransformer
Row row;
if (highlight)
{
row = table.addRow(null, null, "highlight");
}
else
{
row = table.addRow();
}
CheckBox select = row.addCell().addCheckBox("select_field");
select.setLabel(id);

View File

@@ -146,9 +146,13 @@ public class FormatRegistryMain extends AbstractDSpaceTransformer
Row row;
if (highlight)
{
row = table.addRow(null, null, "highlight");
}
else
{
row = table.addRow();
}
// Select checkbox
Cell cell = row.addCell();

View File

@@ -180,9 +180,13 @@ public class ItemViewer extends AbstractDSpaceTransformer implements CacheablePr
String title = getItemTitle(item);
if (title != null)
{
pageMeta.addMetadata("title").addContent(title);
}
else
{
pageMeta.addMetadata("title").addContent(item.getHandle());
}
pageMeta.addTrailLink(contextPath + "/",T_dspace_home);
HandleUtil.buildHandleTrail(item,pageMeta,contextPath);
@@ -256,9 +260,13 @@ public class ItemViewer extends AbstractDSpaceTransformer implements CacheablePr
Division division = body.addDivision("item-view","primary");
String title = getItemTitle(item);
if (title != null)
{
division.setHead(title);
}
else
{
division.setHead(item.getHandle());
}
Para showfullPara = division.addPara(null, "item-view-toggle item-view-toggle-top");
@@ -333,9 +341,13 @@ public class ItemViewer extends AbstractDSpaceTransformer implements CacheablePr
String title;
if (titles != null && titles.length > 0)
{
title = titles[0].value;
}
else
{
title = null;
}
return title;
}

View File

@@ -104,8 +104,12 @@ public class EPersonUtils
private static String render(int givenStep, int step)
{
if (givenStep == step)
{
return "current";
}
else
{
return null;
}
}
}

View File

@@ -217,29 +217,43 @@ public class EditProfile extends AbstractDSpaceTransformer
String errors = parameters.getParameter("errors","");
if (errors.length() > 0)
{
this.errors = Arrays.asList(errors.split(","));
}
else
{
this.errors = new ArrayList<String>();
}
// Ensure that the email variable is set.
if (eperson != null)
{
this.email = eperson.getEmail();
}
}
public void addPageMeta(PageMeta pageMeta) throws WingException
{
// Set the page title
if (registering)
{
pageMeta.addMetadata("title").addContent(T_title_create);
}
else
{
pageMeta.addMetadata("title").addContent(T_title_update);
}
pageMeta.addTrailLink(contextPath + "/",T_dspace_home);
if (registering)
{
pageMeta.addTrail().addContent(T_trail_new_registration);
}
else
{
pageMeta.addTrail().addContent(T_trail_update);
}
}
public void addBody(Body body) throws WingException, SQLException
@@ -268,9 +282,13 @@ public class EditProfile extends AbstractDSpaceTransformer
String action = contextPath;
if (registering)
{
action += "/register";
}
else
{
action += "/profile";
}
@@ -279,13 +297,19 @@ public class EditProfile extends AbstractDSpaceTransformer
action,Division.METHOD_POST,"primary");
if (registering)
{
profile.setHead(T_head_create);
}
else
{
profile.setHead(T_head_update);
}
// Add the progress list if we are registering a new user
if (registering)
{
EPersonUtils.registrationProgressList(profile, 2);
}
@@ -425,9 +449,13 @@ public class EditProfile extends AbstractDSpaceTransformer
Button submit = form.addItem().addButton("submit");
if (registering)
{
submit.setValue(T_submit_update);
}
else
{
submit.setValue(T_submit_create);
}
profile.addHidden("eperson-continue").setValue(knot.getId());
@@ -441,7 +469,9 @@ public class EditProfile extends AbstractDSpaceTransformer
// Not a member of any groups then don't do anything.
if (!(memberships.length > 0))
{
return;
}
List list = profile.addList("memberships");
list.setHead(T_head_auth);

View File

@@ -111,12 +111,16 @@ public class LDAPLogin extends AbstractDSpaceTransformer implements
// cachable
if (header == null && message == null && characters == null
&& previous_username == null)
{
// cacheable
return "1";
}
else
{
// Uncachable
return "0";
}
}
/**
* Generate the cache validity object.
@@ -138,12 +142,16 @@ public class LDAPLogin extends AbstractDSpaceTransformer implements
// cachable
if (header == null && message == null && characters == null
&& previous_username == null)
{
// Always valid
return NOPValidity.SHARED_INSTANCE;
}
else
{
// invalid
return null;
}
}
/**
* Set the page title and trail.
@@ -177,10 +185,14 @@ public class LDAPLogin extends AbstractDSpaceTransformer implements
Division reason = body.addDivision("login-reason");
if (header != null)
{
reason.setHead(message(header));
}
else
// Allways have a head.
{
// Always have a head.
reason.setHead("Authentication Required");
}
if (message != null)
reason.addPara(message(message));

View File

@@ -108,12 +108,16 @@ public class LoginChooser extends AbstractDSpaceTransformer implements
// cachable
if (header == null && message == null && characters == null
&& previous_email == null)
{
// cacheable
return "1";
}
else
{
// Uncachable
return "0";
}
}
/**
* Generate the cache validity object.
@@ -135,12 +139,16 @@ public class LoginChooser extends AbstractDSpaceTransformer implements
// cachable
if (header == null && message == null && characters == null
&& previous_email == null)
{
// Always valid
return NOPValidity.SHARED_INSTANCE;
}
else
{
// invalid
return null;
}
}
/**
* Set the page title and trail.
@@ -174,10 +182,14 @@ public class LoginChooser extends AbstractDSpaceTransformer implements
Division reason = body.addDivision("login-reason");
if (header != null)
{
reason.setHead(message(header));
}
else
{
// Allways have a head.
reason.setHead("Authentication Required");
}
if (message != null)
reason.addPara(message(message));

View File

@@ -136,9 +136,13 @@ public class Navigation extends AbstractDSpaceTransformer implements CacheablePr
String key;
if (context.getCurrentUser() != null)
{
key = context.getCurrentUser().getEmail();
}
else
{
key = "anonymous";
}
// Add the user's language
Enumeration locales = request.getLocales();

View File

@@ -106,22 +106,36 @@ public class NoticeTransformer extends AbstractDSpaceTransformer
String rend = "notice";
if ("netural".equals(outcome))
{
rend += " netural";
}
else if ("success".equals(outcome))
{
rend += " success";
}
else if ("failure".equals(outcome))
{
rend += " failure";
}
Division div = body.addDivision("general-message",rend);
if ((header != null) && (!"".equals(header)))
{
div.setHead(message(header));
}
else
{
div.setHead(T_head);
}
if (message != null && message.length() > 0)
{
div.addPara(message(message));
}
if (characters != null && characters.length() > 0)
{
div.addPara(characters);
}
}
}

View File

@@ -182,9 +182,13 @@ public class EditFileStep extends AbstractStep
{
String supportLevel = "Unknown";
if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN)
{
supportLevel = "known";
}
else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED)
{
supportLevel = "Supported";
}
String name = bitstreamFormat.getShortDescription()+" ("+supportLevel+")";
int id = bitstreamFormat.getID();

View File

@@ -131,7 +131,9 @@ public class LicenseStep extends AbstractSubmissionStep
ccLicenseStep.setup(resolver, objectModel, src, parameters);
}
else
{
ccLicenseStep = null;
}
}

View File

@@ -101,14 +101,22 @@ public class InlineFormTest 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.");
if (help)
{
div.addPara().addXref(makeURL(false, error), "Turn help OFF");
}
else
{
div.addPara().addXref(makeURL(true, error), "Turn help ON");
}
if (error)
{
div.addPara().addXref(makeURL(help, false), "Turn errors OFF");
}
else
{
div.addPara().addXref(makeURL(help, true), "Turn errors ON");
}
Division suited = body.addDivision("suited");

View File

@@ -294,7 +294,9 @@ public class DSpaceFeedGenerator extends AbstractGenerator
String source = ConfigurationManager.getProperty("recent.submissions.sort-option");
BrowserScope scope = new BrowserScope(context);
if (dso instanceof Collection)
{
scope.setCollection((Collection) dso);
}
else if (dso instanceof Community)
scope.setCommunity((Community) dso);
scope.setResultsPerPage(itemCount);

View File

@@ -171,10 +171,14 @@ public class DSpaceMETSGenerator extends AbstractGenerator
// Handles can be either items or containers.
if (dso instanceof Item)
{
adapter = new ItemAdapter(context, (Item) dso, contextPath);
}
else if (dso instanceof Collection || dso instanceof Community)
{
adapter = new ContainerAdapter(context, dso, contextPath);
}
}
else if (internal != null)
{
// Internal identifier, format: "type:id".

View File

@@ -122,10 +122,14 @@ public class DSpaceOREGenerator extends AbstractGenerator
// Handles can be either items or containers.
if (dso instanceof Item)
{
return (Item) dso;
}
else
{
throw new CrosswalkException("ORE dissemination only available for DSpace Items.");
}
}
else if (internal != null)
{
// Internal identifier, format: "type:id".
@@ -141,7 +145,9 @@ public class DSpaceOREGenerator extends AbstractGenerator
return Item.find(context,id);
}
else
{
throw new CrosswalkException("ORE dissemination only available for DSpace Items.");
}
}
}

View File

@@ -82,10 +82,14 @@ public class NamespaceFilterTransformer extends AbstractTransformer implements C
*/
public Serializable getKey() {
if (filterNamespace != null)
{
return filterNamespace;
}
else
{
return "1";
}
}
/**

View File

@@ -169,10 +169,14 @@ public class ItemAdapter extends AbstractAdapter
protected String getMETSID()
{
if (item.getHandle() == null)
{
return "item:" + item.getID();
}
else
{
return "hdl:" + item.getHandle();
}
}
/**
* Return the official METS SIP Profile.
@@ -212,10 +216,14 @@ public class ItemAdapter extends AbstractAdapter
protected String getAmdSecID(String admSecName, String mdType, DSpaceObject dso)
{
if (dso.getType() == Constants.BITSTREAM)
{
return admSecName + "_" + getFileID((Bitstream) dso) + "_" + mdType;
}
else
{
return admSecName + "_" + dso.getID() + "_" + mdType;
}
}
/**
* Render the METS descriptive section. This will create a new metadata
@@ -581,18 +589,26 @@ public class ItemAdapter extends AbstractAdapter
// Add this to our list of each file's administrative section IDs
String fileID = getFileID((Bitstream) dso);
if(fileAmdSecIDs.containsKey(fileID))
{
fileAmdSecIDs.get(fileID).append(" " + amdSecID);
}
else
{
fileAmdSecIDs.put(fileID, new StringBuffer(amdSecID));
}
}//else if an Item
else if (dso.getType() == Constants.ITEM)
{
//Add this to our list of item's administrative section IDs
if(amdSecIDS==null)
{
amdSecIDS = new StringBuffer(amdSecID);
}
else
{
amdSecIDS.append(" " + amdSecID);
}
}
////////////////////////////////
// Start a metadata wrapper
@@ -889,7 +905,9 @@ public class ItemAdapter extends AbstractAdapter
// the all bundles.
List<Bundle> bundles;
if (fileGrpTypes.size() == 0)
{
bundles = Arrays.asList(item.getBundles());
}
else
{
bundles = new ArrayList<Bundle>();

View File

@@ -227,19 +227,27 @@ public class HandleUtil
Collection collection = (Collection) pop;
String name = collection.getMetadata("name");
if (name == null || name.length() == 0)
{
pageMeta.addTrailLink(contextPath + "/handle/" + pop.getHandle(), new Message("default", "xmlui.general.untitled"));
}
else
{
pageMeta.addTrailLink(contextPath + "/handle/" + pop.getHandle(), name);
}
}
else if (pop instanceof Community)
{
Community community = (Community) pop;
String name = community.getMetadata("name");
if (name == null || name.length() == 0)
{
pageMeta.addTrailLink(contextPath + "/handle/" + pop.getHandle(), new Message("default", "xmlui.general.untitled"));
}
else
{
pageMeta.addTrailLink(contextPath + "/handle/" + pop.getHandle(), name);
}
}
}
}

View File

@@ -177,8 +177,11 @@ public class Include extends AbstractTransformer implements CacheableProcessingC
{
if (source.exists())
// The file exists so return it's validity.
{
return source.getValidity();
}
else
{
// The file does not exist so we will just return always valid. This
// will have an nastly side effect that if a file is removed from a
// running system the cache will remain valid. However if the other
@@ -186,9 +189,12 @@ public class Include extends AbstractTransformer implements CacheableProcessingC
// which is not desirable either.
return NOPValidity.SHARED_INSTANCE;
}
}
else
{
return null;
}
}
/**
@@ -253,7 +259,9 @@ public class Include extends AbstractTransformer implements CacheableProcessingC
// or not found in startDocument()
}
else if (stack.size() == 0)
{
stack.push(w3cDocument.getDocumentElement());
}
else
{
Element peek = stack.peek();