@Override public String generateOutput(DocumentRecord documentRecord) { if (Format.XML.equals(documentRecord.getFormat())) { DOMHandle handle = documentRecord.getContent(new DOMHandle()); Document document = handle.get(); OutputFormat format = new OutputFormat(handle.get()); format.setOmitXMLDeclaration(omitXmlDeclaration); StringWriter writer = new StringWriter(); try { new XMLSerializer(writer, format).serialize(document); return writer.toString(); } catch (IOException e) { throw new RuntimeException("Unable to serialize XML document to string: " + e.getMessage(), e); } } else if (logger.isDebugEnabled()) { logger.debug(String.format("Document '%s' has a format of '%s', so will not attempt to remove the XML declaration from it", documentRecord.getUri(), documentRecord.getFormat().name())); } return documentRecord.getContent(new StringHandle()).get(); }
synchronized(writer) { for ( DocumentRecord doc : docs ) { Format format = doc.getFormat(); if ( Format.BINARY.equals(format) ) { throw new IllegalStateException("Document " + doc.getUri() +
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); }
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); }
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); // System.out.println(record.getMimetype()); }
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); } }
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record .getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); } }
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); } }
public void validateRecord(DocumentRecord record, Format type) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be in same format", type, record.getFormat()); // System.out.println(record.getMimetype()); }
@Test public void test_issue_758() throws Exception { BinaryDocumentManager docMgr = Common.client.newBinaryDocumentManager(); DocumentWriteSet writeset =docMgr.newWriteSet(); FileHandle h1 = new FileHandle(new File( "../marklogic-client-api-functionaltests/src/test/java/com/marklogic" + "/client" + "/functionaltest/data" + "/Sega-4MB.jpg")); String uri = "BinaryDocumentTest_" + new Random().nextInt(10000) + "/" + "Sega-4MB.jpg"; writeset.add(uri, h1); docMgr.write(writeset); DocumentPage page = docMgr.read(uri); DocumentRecord rec = page.next(); assertNotNull("DocumentRecord should never be null", rec); assertEquals(rec.getFormat(),Format.BINARY); } }
private void validateRecord(DocumentRecord record) { assertNotNull("DocumentRecord should never be null", record); assertNotNull("Document uri should never be null", record.getUri()); assertTrue("Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY)); assertEquals("All records are expected to be XML format", Format.XML, record.getFormat()); /* assertEquals("All records are expected to be mimetype application/xml", "application/xml", record.getMimetype()); */ if ( record.getUri().equals(DIRECTORY + "1205733.xml") ) { City chittagong = record.getContentAs(City.class); validateChittagong(chittagong); } }
rec.getFormat(); validateRecord(rec, Format.JSON); count++;
rec.getFormat(); validateRecord(rec, Format.JSON); System.out.println(rec.getContent(new StringHandle()).get().toString());
rec.getFormat(); validateRecord(rec, Format.JSON); System.out.println(rec.getContent(new StringHandle()).get().toString());
rec.getFormat(); validateRecord(rec, Format.JSON); System.out.println(rec.getContent(new StringHandle()).get().toString());
rec.getFormat(); validateRecord(rec, Format.TEXT);
rec.getFormat(); validateRecord(rec, Format.XML);
rec.getFormat(); validateRecord(rec, Format.XML);