diff --git a/build.gradle b/build.gradle index 22ecd80..e1c5501 100644 --- a/build.gradle +++ b/build.gradle @@ -31,18 +31,16 @@ repositories { } configurations { - asciidoclet wagon } dependencies { + testCompile "org.junit.vintage:junit-vintage-engine:${project.property('junit-vintage.version')}" testCompile "org.xbib:bibliographic-character-sets:${project.property('xbib-bibliographic-character-sets.version')}" testCompile "org.xbib:content-core:${project.property('xbib-content.version')}" - testCompile "junit:junit:${project.property('junit.version')}" testCompile "xalan:xalan:${project.property('xalan.version')}" testCompile "org.xmlunit:xmlunit-matchers:${project.property('xmlunit-matchers.version')}" testCompile "com.github.stefanbirkner:system-rules:${project.property('system-rules.version')}" - asciidoclet "org.xbib:asciidoclet:${project.property('asciidoclet.version')}" wagon "org.apache.maven.wagon:wagon-ssh:${project.property('wagon.version')}" } @@ -78,18 +76,6 @@ asciidoctor { 'source-highlighter': 'coderay' } -javadoc { - options.docletpath = configurations.asciidoclet.files.asType(List) - options.doclet = 'org.xbib.asciidoclet.Asciidoclet' - options.overview = "src/docs/asciidoclet/overview.adoc" - options.addStringOption "-base-dir", "${projectDir}" - options.addStringOption "-attribute", - "name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}" - configure(options) { - noTimestamp = true - } -} - clean { delete 'out' } diff --git a/gradle.properties b/gradle.properties index 053c8b9..cb6ceb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,11 @@ group = org.xbib name = marc -version = 1.2.0 +version = 1.2.1 xbib-content.version = 1.3.0 xbib-bibliographic-character-sets.version = 1.0.0 xalan.version = 2.7.2 xmlunit-matchers.version = 2.3.0 system-rules.version = 1.16.0 -asciidoclet.version = 1.6.0.0 -junit.version = 4.12 +junit-vintage.version = 4.12.0 wagon.version = 3.0.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c44b679..f6b961f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 03524e7..dde0a3a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Feb 07 00:10:24 CET 2018 +#Wed Mar 14 10:32:45 CET 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/src/main/java/org/xbib/marc/Marc.java b/src/main/java/org/xbib/marc/Marc.java index e1f73e0..42a3799 100644 --- a/src/main/java/org/xbib/marc/Marc.java +++ b/src/main/java/org/xbib/marc/Marc.java @@ -285,6 +285,7 @@ public final class Marc { /** * Pass a given chunk stream to a MARC generator, chunk by chunk. * Can process any MARC streams, not only separator streams. + * @param type the MARC record type * @param stream a chunk stream * @param withCollection true if stream should be wrapped into a collection element * @return the number of chunks in the stream diff --git a/src/main/java/org/xbib/marc/MarcRecord.java b/src/main/java/org/xbib/marc/MarcRecord.java index ffc148d..d3a00fe 100644 --- a/src/main/java/org/xbib/marc/MarcRecord.java +++ b/src/main/java/org/xbib/marc/MarcRecord.java @@ -115,6 +115,7 @@ public class MarcRecord extends LinkedHashMap { /** * Return the MARC fields of this record with a given tag. * + * @param tag the MARC tag * @return the MARC field list matching the given tag. */ public List getFields(String tag) { diff --git a/src/main/java/org/xbib/marc/MarcWriter.java b/src/main/java/org/xbib/marc/MarcWriter.java index 854239f..d6f0166 100644 --- a/src/main/java/org/xbib/marc/MarcWriter.java +++ b/src/main/java/org/xbib/marc/MarcWriter.java @@ -55,7 +55,6 @@ public class MarcWriter extends MarcContentHandler implements Flushable, Closeab * Create a MarcWriter on an underlying output stream. * @param out the underlying output stream * @param charset the character set - * @throws IOException if writer can not be created */ public MarcWriter(OutputStream out, Charset charset) { this(out, charset, DEFAULT_BUFFER_SIZE); @@ -66,7 +65,6 @@ public class MarcWriter extends MarcContentHandler implements Flushable, Closeab * @param out the underlying output stream * @param charset the character set * @param buffersize the buffer size writing to the underlying output stream - * @throws IOException if writer can not be created */ public MarcWriter(OutputStream out, Charset charset, int buffersize) { this.out = new SeparatorOutputStream(out, buffersize); diff --git a/src/main/java/org/xbib/marc/json/MarcJsonWriter.java b/src/main/java/org/xbib/marc/json/MarcJsonWriter.java index a5ffab8..c9e927e 100644 --- a/src/main/java/org/xbib/marc/json/MarcJsonWriter.java +++ b/src/main/java/org/xbib/marc/json/MarcJsonWriter.java @@ -269,7 +269,7 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo sb.append("]"); } if (style == Style.ELASTICSEARCH_BULK) { - // finish with line-feed + // finish with line-feed "\n", not with System.lineSeparator() sb.append("\n"); } try { @@ -435,6 +435,10 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo return exception; } + public void writeLine() throws IOException { + writer.write(System.lineSeparator()); + } + private void handleException(IOException e) { exception = e; if (fatalErrors) { diff --git a/src/test/java/org/xbib/marc/json/MarcJsonWriterTest.java b/src/test/java/org/xbib/marc/json/MarcJsonWriterTest.java index c369f71..cb1bebd 100644 --- a/src/test/java/org/xbib/marc/json/MarcJsonWriterTest.java +++ b/src/test/java/org/xbib/marc/json/MarcJsonWriterTest.java @@ -312,4 +312,39 @@ public class MarcJsonWriterTest { assertNull(writer.getException()); } } + + @Test + public void testJsonWriterWithMultipleInput() throws Exception { + File file = File.createTempFile("multi.", ".json"); + file.deleteOnExit(); + FileOutputStream out = new FileOutputStream(file); + try (MarcJsonWriter writer = new MarcJsonWriter(out, MarcJsonWriter.Style.ARRAY)) { + writer.beginCollection(); + try (InputStream inputStream = getClass().getResource("/org/xbib/marc/summerland.mrc").openStream()) { + Marc.builder() + .setFormat(MarcXchangeConstants.MARCXCHANGE_FORMAT) + .setType(MarcXchangeConstants.BIBLIOGRAPHIC_TYPE) + .setInputStream(inputStream) + .setCharset(Charset.forName("ANSEL")) + .setMarcRecordListener(writer) + .build() + .writeRecords(); + } + writer.writeLine(); + try (InputStream inputStream = getClass().getResource("/org/xbib/marc/chabon.mrc").openStream()) { + Marc.builder() + .setFormat(MarcXchangeConstants.MARCXCHANGE_FORMAT) + .setType(MarcXchangeConstants.BIBLIOGRAPHIC_TYPE) + .setInputStream(inputStream) + .setCharset(Charset.forName("ANSEL")) + .setMarcRecordListener(writer) + .build() + .writeRecords(); + } + writer.endCollection(); + } + assertStream("multi", getClass().getResource("/org/xbib/marc/json/multi.json").openStream(), + new FileInputStream(file)); + } + } diff --git a/src/test/resources/org/xbib/marc/json/multi.json b/src/test/resources/org/xbib/marc/json/multi.json new file mode 100644 index 0000000..02a1bfd --- /dev/null +++ b/src/test/resources/org/xbib/marc/json/multi.json @@ -0,0 +1,2 @@ +[{"_FORMAT":"MarcXchange","_TYPE":"Bibliographic","_LEADER":"00714cam a2200205 a 4500","001":["12883376"],"005":["20030616111422.0"],"008":["020805s2002 nyu j 000 1 eng "],"020":[{"__":[{"a":"0786808772"}]},{"__":[{"a":"0786816155 (pbk.)"}]}],"040":[{"__":[{"a":"DLC"},{"c":"DLC"},{"d":"DLC"}]}],"100":[{"1_":[{"a":"Chabon, Michael."}]}],"245":[{"10":[{"a":"Summerland /"},{"c":"Michael Chabon."}]}],"250":[{"__":[{"a":"1st ed."}]}],"260":[{"__":[{"a":"New York :"},{"b":"Miramax Books/Hyperion Books for Children,"},{"c":"c2002."}]}],"300":[{"__":[{"a":"500 p. ;"},{"c":"22 cm."}]}],"520":[{"__":[{"a":"Ethan Feld, the worst baseball player in the history of the game, finds himself recruited by a 100-year-old scout to help a band of fairies triumph over an ancient enemy."}]}],"650":[{"_1":[{"a":"Fantasy."}]},{"_1":[{"a":"Baseball"},{"v":"Fiction."}]},{"_1":[{"a":"Magic"},{"v":"Fiction."}]}]} +,{"_FORMAT":"MarcXchange","_TYPE":"Bibliographic","_LEADER":"00759cam a2200229 a 4500","001":["11939876"],"005":["20041229190604.0"],"008":["000313s2000 nyu 000 1 eng "],"020":[{"__":[{"a":"0679450041 (acid-free paper)"}]}],"040":[{"__":[{"a":"DLC"},{"c":"DLC"},{"d":"DLC"}]}],"100":[{"1_":[{"a":"Chabon, Michael."}]}],"245":[{"14":[{"a":"The amazing adventures of Kavalier and Clay :"},{"b":"a novel /"},{"c":"Michael Chabon."}]}],"260":[{"__":[{"a":"New York :"},{"b":"Random House,"},{"c":"c2000."}]}],"300":[{"__":[{"a":"639 p. ;"},{"c":"25 cm."}]}],"650":[{"_0":[{"a":"Comic books, strips, etc."},{"x":"Authorship"},{"v":"Fiction."}]},{"_0":[{"a":"Heroes in mass media"},{"v":"Fiction."}]},{"_0":[{"a":"Czech Americans"},{"v":"Fiction."}]},{"_0":[{"a":"Young men"},{"v":"Fiction."}]},{"_0":[{"a":"Cartoonists"},{"v":"Fiction."}]}],"651":[{"_0":[{"a":"New York (N.Y.)"},{"v":"Fiction."}]}],"655":[{"_7":[{"a":"Humorous stories."},{"2":"gsafd"}]},{"_7":[{"a":"Bildungsromane."},{"2":"gsafd"}]}]},{"_FORMAT":"MarcXchange","_TYPE":"Bibliographic","_LEADER":"00714cam a2200205 a 4500","001":["12883376"],"005":["20030616111422.0"],"008":["020805s2002 nyu j 000 1 eng "],"020":[{"__":[{"a":"0786808772"}]},{"__":[{"a":"0786816155 (pbk.)"}]}],"040":[{"__":[{"a":"DLC"},{"c":"DLC"},{"d":"DLC"}]}],"100":[{"1_":[{"a":"Chabon, Michael."}]}],"245":[{"10":[{"a":"Summerland /"},{"c":"Michael Chabon."}]}],"250":[{"__":[{"a":"1st ed."}]}],"260":[{"__":[{"a":"New York :"},{"b":"Miramax Books/Hyperion Books for Children,"},{"c":"c2002."}]}],"300":[{"__":[{"a":"500 p. ;"},{"c":"22 cm."}]}],"520":[{"__":[{"a":"Ethan Feld, the worst baseball player in the history of the game, finds himself recruited by a 100-year-old scout to help a band of fairies triumph over an ancient enemy."}]}],"650":[{"_1":[{"a":"Fantasy."}]},{"_1":[{"a":"Baseball"},{"v":"Fiction."}]},{"_1":[{"a":"Magic"},{"v":"Fiction."}]}]}] \ No newline at end of file