mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
[DS-401] Backed out as it raised more questions than it answered.
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5822 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -150,7 +150,7 @@ public class DCDate
|
||||
* @param ss
|
||||
* the seconds
|
||||
*/
|
||||
public DCDate(int yyyy, int mm, int dd, int hh, int mn, int ss) throws DCDateIllegalArgumentException
|
||||
public DCDate(int yyyy, int mm, int dd, int hh, int mn, int ss)
|
||||
{
|
||||
setUTCForFormatting();
|
||||
|
||||
@@ -194,20 +194,8 @@ public class DCDate
|
||||
}
|
||||
|
||||
// Set the local calendar.
|
||||
localCalendar = new GregorianCalendar();
|
||||
localCalendar.setLenient(false);
|
||||
localCalendar.set(lyear, lmonth - 1, lday, lhours, lminutes, lseconds);
|
||||
try
|
||||
{
|
||||
// Unfortunately GregorianCalendar doesn't throw an exception when you 'set' an invalid value so
|
||||
// we have to call a method that causes all the values to be inspected in order to check that they are valid.
|
||||
localCalendar.get(Calendar.YEAR);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
// Re-throw exception as a checked exception so that the calling classes have to deal with it.
|
||||
throw new DCDateIllegalArgumentException("Invalid parameter", e);
|
||||
}
|
||||
localCalendar = new GregorianCalendar(lyear, lmonth - 1, lday,
|
||||
lhours, lminutes, lseconds);
|
||||
|
||||
if (granularity == DateGran.TIME)
|
||||
{
|
||||
|
@@ -1,27 +0,0 @@
|
||||
package org.dspace.content;
|
||||
|
||||
|
||||
public class DCDateIllegalArgumentException extends Exception
|
||||
{
|
||||
|
||||
public DCDateIllegalArgumentException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DCDateIllegalArgumentException(String arg0, Throwable arg1)
|
||||
{
|
||||
super(arg0, arg1);
|
||||
}
|
||||
|
||||
public DCDateIllegalArgumentException(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public DCDateIllegalArgumentException(Throwable arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
}
|
@@ -203,18 +203,7 @@ public class InstallItem
|
||||
|
||||
if (currentDateIssued.length == 0)
|
||||
{
|
||||
DCDate issued = null;
|
||||
try
|
||||
{
|
||||
issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1);
|
||||
}
|
||||
catch (DCDateIllegalArgumentException e)
|
||||
{
|
||||
// The parameters should never be invalid since they are generated from the current date,
|
||||
// but we still have to deal with the exception anyway.
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1);
|
||||
item.addDC("date", "issued", null, issued.toString());
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,13 @@ import org.dspace.app.util.DCInput;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DCDate;
|
||||
import org.dspace.content.DCPersonName;
|
||||
import org.dspace.content.DCSeriesNumber;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.authority.MetadataAuthorityManager;
|
||||
import org.dspace.content.authority.ChoiceAuthorityManager;
|
||||
import org.dspace.content.authority.Choices;
|
||||
@@ -787,7 +793,9 @@ public class DescribeStep extends AbstractProcessingStep
|
||||
int month = Util.getIntParameter(request, metadataField + "_month");
|
||||
int day = Util.getIntParameter(request, metadataField + "_day");
|
||||
|
||||
|
||||
// FIXME: Probably should be some more validation
|
||||
// Make a standard format date
|
||||
DCDate d = new DCDate(year, month, day, -1, -1, -1);
|
||||
|
||||
// already done in doProcessing see also bug DS-203
|
||||
// item.clearMetadata(schema, element, qualifier, Item.ANY);
|
||||
@@ -795,17 +803,7 @@ public class DescribeStep extends AbstractProcessingStep
|
||||
if (year > 0)
|
||||
{
|
||||
// Only put in date if there is one!
|
||||
|
||||
try
|
||||
{
|
||||
DCDate d = new DCDate(year, month, day, -1, -1, -1);
|
||||
item.addMetadata(schema, element, qualifier, null, d.toString());
|
||||
}
|
||||
catch (DCDateIllegalArgumentException e)
|
||||
{
|
||||
// One or more of the DCDate parameters was invalid so don't add it to the metadata.
|
||||
}
|
||||
|
||||
item.addMetadata(schema, element, qualifier, null, d.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -161,9 +161,8 @@ public class DCDateTest extends AbstractUnitTest
|
||||
* Test of DCDate constructor, of class DCDate.
|
||||
*/
|
||||
@Test
|
||||
public void testDCDateIntBits() throws DCDateIllegalArgumentException
|
||||
public void testDCDateIntBits()
|
||||
{
|
||||
|
||||
dc = new DCDate(2010,1,1,-1,-1,-1);
|
||||
|
||||
assertThat("testDCDateIntBits 1", dc.getYear(), equalTo(2010));
|
||||
@@ -195,17 +194,7 @@ public class DCDateTest extends AbstractUnitTest
|
||||
assertThat("testDCDateIntBits 22", dc.getHourUTC(), equalTo(2));
|
||||
assertThat("testDCDateIntBits 23", dc.getMinuteUTC(), equalTo(30));
|
||||
assertThat("testDCDateIntBits 24", dc.getSecondUTC(), equalTo(5));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional tests of DCDate constructor checking for dodgy parameters.
|
||||
*/
|
||||
@Test (expected=DCDateIllegalArgumentException.class)
|
||||
public void testDCDateIntBits1() throws DCDateIllegalArgumentException
|
||||
{
|
||||
dc = new DCDate(2010,2,29,18,30,5);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -81,7 +81,7 @@
|
||||
<hint>Please give the date of previous publication or public distribution
|
||||
below. You can leave out the day and/or month if they aren't
|
||||
applicable.</hint>
|
||||
<required>You must enter a valid complete or partial date.</required>
|
||||
<required>You must enter at least the year.</required>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
|
Reference in New Issue
Block a user