示例#1
0
 String importTree(RepositoryInstance repository, File file, String toPath) throws Exception {
   DocumentReader reader = null;
   DocumentWriter writer = null;
   String dump = "NO RESULTS";
   try {
     System.out.println(
         "importTree reading file: "
             + file
             + (file != null ? " exists? " + file.exists() : " file param is null"));
     reader = new LoggedXMLDirectoryReader(file); // our overload of XMLDirectoryReader.
     writer = new DocumentModelWriter(repository, toPath, 10);
     DocumentPipe pipe = new DocumentPipeImpl(10);
     // pipe.addTransformer(transformer);
     pipe.setReader(reader);
     pipe.setWriter(writer);
     pipe.run();
   } finally {
     if (reader != null) {
       reader.close();
       dump = ((LoggedXMLDirectoryReader) reader).report();
     }
     if (writer != null) {
       writer.close();
     }
   }
   return dump;
 }
  @Test
  public void testBlobFilenamePresent() throws Exception {
    createDocs();

    ExportedDocument exportedDoc = new ExportedDocumentImpl(docToExport, true);
    assertEquals("File", exportedDoc.getType());

    session.removeDocument(docToExport.getRef());
    session.save();
    assertEquals(0, session.getChildren(workspace.getRef()).size());

    DocumentWriter writer = new DocumentModelWriter(session, rootDocument.getPathAsString());
    writer.write(exportedDoc);

    DocumentModelList children = session.getChildren(workspace.getRef());
    assertEquals(1, children.size());
    DocumentModel importedDocument = children.get(0);
    Blob blob = (Blob) importedDocument.getProperty("file", "content");
    assertEquals("dummyBlob.txt", blob.getFilename());
  }