, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/licenses/marc4j-2.4.normalizer.LICENSE.txt b/licenses/marc4j-2.4.normalizer.LICENSE.txt
new file mode 100644
index 000000000..f57f6eaa4
--- /dev/null
+++ b/licenses/marc4j-2.4.normalizer.LICENSE.txt
@@ -0,0 +1,34 @@
+
+
+
+ICU4J license - ICU4J 1.3.1 and later
+
+
+
+ICU4J license - ICU4J 1.3.1 and later
+
+COPYRIGHT AND PERMISSION NOTICE
+
+
+Copyright (c) 1995-2001 International Business Machines Corporation and others
+
+
+All rights reserved.
+
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
+
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+
+Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
+
+
+
+
+All trademarks and registered trademarks mentioned herein are the property of their respective owners.
+
+
+
diff --git a/src/main/java/com/metaweb/gridworks/commands/edit/CreateProjectCommand.java b/src/main/java/com/metaweb/gridworks/commands/edit/CreateProjectCommand.java
index fedf7ceb1..121886873 100644
--- a/src/main/java/com/metaweb/gridworks/commands/edit/CreateProjectCommand.java
+++ b/src/main/java/com/metaweb/gridworks/commands/edit/CreateProjectCommand.java
@@ -46,6 +46,7 @@ import com.metaweb.gridworks.ProjectMetadata;
import com.metaweb.gridworks.commands.Command;
import com.metaweb.gridworks.importers.ExcelImporter;
import com.metaweb.gridworks.importers.Importer;
+import com.metaweb.gridworks.importers.MarcImporter;
import com.metaweb.gridworks.importers.TsvCsvImporter;
import com.metaweb.gridworks.importers.XmlImporter;
import com.metaweb.gridworks.model.Project;
@@ -473,6 +474,8 @@ public class CreateProjectCommand extends Command {
"application/atom+xml".equals(contentType) ||
"application/rdf+xml".equals(contentType)) {
return new XmlImporter();
+ } else if ("application/marc".equals(contentType)) {
+ return new MarcImporter();
}
} else if (fileName != null) {
fileName = fileName.toLowerCase();
@@ -487,6 +490,13 @@ public class CreateProjectCommand extends Command {
fileName.endsWith(".rss")
) {
return new XmlImporter();
+ } else if (
+ fileName.endsWith(".mrc") ||
+ fileName.endsWith(".marc") ||
+ fileName.contains(".mrc.") ||
+ fileName.contains(".marc.")
+ ) {
+ return new MarcImporter();
}
}
diff --git a/src/main/java/com/metaweb/gridworks/importers/MarcImporter.java b/src/main/java/com/metaweb/gridworks/importers/MarcImporter.java
new file mode 100644
index 000000000..b4732a909
--- /dev/null
+++ b/src/main/java/com/metaweb/gridworks/importers/MarcImporter.java
@@ -0,0 +1,80 @@
+package com.metaweb.gridworks.importers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.util.Properties;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.marc4j.MarcPermissiveStreamReader;
+import org.marc4j.MarcWriter;
+import org.marc4j.MarcXmlWriter;
+import org.marc4j.marc.Record;
+
+import com.metaweb.gridworks.Gridworks;
+import com.metaweb.gridworks.model.Project;
+
+public class MarcImporter implements Importer {
+
+ public boolean takesReader() {
+ return false;
+ }
+
+ public void read(Reader reader, Project project, Properties options)
+ throws Exception {
+
+ throw new NotImplementedException();
+ }
+
+ public void read(
+ InputStream inputStream,
+ Project project,
+ Properties options
+ ) throws Exception {
+ int limit = ImporterUtilities.getIntegerOption("limit",options,-1);
+ int skip = ImporterUtilities.getIntegerOption("skip",options,0);
+
+ File tempFile = File.createTempFile("gridworks-import-", ".marc.xml");
+ try {
+ OutputStream os = new FileOutputStream(tempFile);
+ try {
+ MarcPermissiveStreamReader reader = new MarcPermissiveStreamReader(
+ inputStream,
+ true,
+ true
+ );
+ MarcWriter writer = new MarcXmlWriter(os, true);
+
+ int count = 0;
+ while (reader.hasNext()) {
+ Record record = reader.next();
+ if (skip <= 0) {
+ if (limit == -1 || count < limit) {
+ writer.write(record);
+ count++;
+ } else {
+ break;
+ }
+ } else {
+ skip--;
+ }
+ }
+ writer.close();
+ } finally {
+ os.close();
+ }
+
+ InputStream is = new FileInputStream(tempFile);
+ try {
+ new XmlImporter().read(is, project, options);
+ } finally {
+ is.close();
+ }
+ } finally {
+ tempFile.delete();
+ }
+ }
+}