mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 22:13:08 +00:00
(Scott Phillips) Modified ItemImport so that when testing, i.e. the -t flag, each metadata field that is being added is check to see if it exists. If the field does not exist then an error message is printed, and the test continues.
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2230 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -74,6 +74,7 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.FormatIdentifier;
|
||||
import org.dspace.content.InstallItem;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
@@ -785,7 +786,7 @@ public class ItemImport
|
||||
// Load all metadata schemas into the item.
|
||||
private void loadMetadata(Context c, Item myitem, String path)
|
||||
throws SQLException, IOException, ParserConfigurationException,
|
||||
SAXException, TransformerException
|
||||
SAXException, TransformerException, AuthorizeException
|
||||
{
|
||||
// Load the dublin core metadata
|
||||
loadDublinCore(c, myitem, path + "dublin_core.xml");
|
||||
@@ -801,7 +802,7 @@ public class ItemImport
|
||||
|
||||
private void loadDublinCore(Context c, Item myitem, String filename)
|
||||
throws SQLException, IOException, ParserConfigurationException,
|
||||
SAXException, TransformerException //, AuthorizeException
|
||||
SAXException, TransformerException, AuthorizeException
|
||||
{
|
||||
Document document = loadXML(filename);
|
||||
|
||||
@@ -831,11 +832,11 @@ public class ItemImport
|
||||
for (int i = 0; i < dcNodes.getLength(); i++)
|
||||
{
|
||||
Node n = dcNodes.item(i);
|
||||
addDCValue(myitem, schema, n);
|
||||
addDCValue(c, myitem, schema, n);
|
||||
}
|
||||
}
|
||||
|
||||
private void addDCValue(Item i, String schema, Node n) throws TransformerException
|
||||
private void addDCValue(Context c, Item i, String schema, Node n) throws TransformerException, SQLException, AuthorizeException
|
||||
{
|
||||
String value = getStringValue(n); //n.getNodeValue();
|
||||
// compensate for empty value getting read as "null", which won't display
|
||||
@@ -872,6 +873,26 @@ public class ItemImport
|
||||
{
|
||||
i.addMetadata(schema, element, qualifier, language, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we're just test the import, let's check that the actual metadata field exists.
|
||||
MetadataSchema foundSchema = MetadataSchema.find(c,schema);
|
||||
|
||||
if (foundSchema == null)
|
||||
{
|
||||
System.out.println("ERROR: schema '"+schema+"' was not found in the registry.");
|
||||
return;
|
||||
}
|
||||
|
||||
int schemaID = foundSchema.getSchemaID();
|
||||
MetadataField foundField = MetadataField.findByElement(c, schemaID, element, qualifier);
|
||||
|
||||
if (foundField == null)
|
||||
{
|
||||
System.out.println("ERROR: Metadata field: '"+schema+"."+element+"."+qualifier+"' was not found in the registry.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user