Examples of DirectoryEntry


Examples of org.apache.poi.poifs.filesystem.DirectoryEntry

        /* Open the POI filesystem. */
        NPOIFSFileSystem poifs = new NPOIFSFileSystem(summaryFile, false);

        /* Read the summary information. */
        DirectoryEntry dir = poifs.getRoot();
        SummaryInformation si;
        try
        {
            si = (SummaryInformation)PropertySetFactory.create(
                    dir, SummaryInformation.DEFAULT_STREAM_NAME);
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.DirectoryEntry

    directory.createDocumentInputStream(STREAM_WORD_DOCUMENT).read(_mainStream);

    // Create our FIB, and check for the doc being encrypted
    _fib = new FileInformationBlock(_mainStream);

    DirectoryEntry objectPoolEntry;
    try {
      objectPoolEntry = (DirectoryEntry) directory
              .getEntry(STREAM_OBJECT_POOL);
    } catch (FileNotFoundException exc) {
      objectPoolEntry = null;
View Full Code Here

Examples of org.apache.poi.poifs.filesystem.DirectoryEntry

     */
    @Test
    public void inPlaceNPOIFSWrite() throws Exception {
        try {
            NPOIFSFileSystem fs = null;
            DirectoryEntry root = null;
            DocumentNode sinfDoc = null;
            DocumentNode dinfDoc = null;
            SummaryInformation sinf = null;
            DocumentSummaryInformation dinf = null;
           
            // We need to work on a File for in-place changes, so create a temp one
            final File copy = TempFile.createTempFile("Test-HPSF", "ole2");
            copy.deleteOnExit();
           
            // Copy a test file over to our temp location
            InputStream inp = _samples.openResourceAsStream("TestShiftJIS.doc");
            FileOutputStream out = new FileOutputStream(copy);
            IOUtils.copy(inp, out);
            inp.close();
            out.close();
           
           
            // Open the copy in read/write mode
            fs = new NPOIFSFileSystem(copy, false);
            root = fs.getRoot();
           
           
            // Read the properties in there
            sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
   
            sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(sinfDoc));
            assertEquals(131077, sinf.getOSVersion());
           
            dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(dinfDoc));
            assertEquals(131077, dinf.getOSVersion());
           
           
            // Check they start as we expect
            assertEquals("Reiichiro Hori", sinf.getAuthor());
            assertEquals("Microsoft Word 9.0", sinf.getApplicationName());
            assertEquals("\u7b2c1\u7ae0", sinf.getTitle());
           
            assertEquals("", dinf.getCompany());
            assertEquals(null, dinf.getManager());
           
           
            // Do an in-place replace via an InputStream
            new NPOIFSDocument(sinfDoc).replaceContents(sinf.toInputStream());
            new NPOIFSDocument(dinfDoc).replaceContents(dinf.toInputStream());
           
           
            // Check it didn't get changed
            sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
           
            sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(sinfDoc));
            assertEquals(131077, sinf.getOSVersion());
           
            dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(dinfDoc));
            assertEquals(131077, dinf.getOSVersion());
   
           
            // Start again!
            fs.close();
            inp = _samples.openResourceAsStream("TestShiftJIS.doc");
            out = new FileOutputStream(copy);
            IOUtils.copy(inp, out);
            inp.close();
            out.close();
           
            fs = new NPOIFSFileSystem(copy, false);
            root = fs.getRoot();
           
            // Read the properties in once more
            sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
   
            sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(sinfDoc));
            assertEquals(131077, sinf.getOSVersion());
           
            dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(dinfDoc));
            assertEquals(131077, dinf.getOSVersion());
           
           
            // Have them write themselves in-place with no changes, as an OutputStream
            sinf.write(new NDocumentOutputStream(sinfDoc));
            dinf.write(new NDocumentOutputStream(dinfDoc));
           
            // And also write to some bytes for checking
            ByteArrayOutputStream sinfBytes = new ByteArrayOutputStream();
            sinf.write(sinfBytes);
            ByteArrayOutputStream dinfBytes = new ByteArrayOutputStream();
            dinf.write(dinfBytes);
           
           
            // Check that the filesystem can give us back the same bytes
            sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
   
            byte[] sinfData = IOUtils.toByteArray(new NDocumentInputStream(sinfDoc));
            byte[] dinfData = IOUtils.toByteArray(new NDocumentInputStream(dinfDoc));
            assertThat(sinfBytes.toByteArray(), equalTo(sinfData));
            assertThat(dinfBytes.toByteArray(), equalTo(dinfData));
   
           
            // Read back in as-is
            sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(sinfDoc));
            assertEquals(131077, sinf.getOSVersion());
           
            dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(dinfDoc));
            assertEquals(131077, dinf.getOSVersion());
           
            assertEquals("Reiichiro Hori", sinf.getAuthor());
            assertEquals("Microsoft Word 9.0", sinf.getApplicationName());
            assertEquals("\u7b2c1\u7ae0", sinf.getTitle());
           
            assertEquals("", dinf.getCompany());
            assertEquals(null, dinf.getManager());
           
   
            // Now alter a few of them
            sinf.setAuthor("Changed Author");
            sinf.setTitle("Le titre \u00e9tait chang\u00e9");
            dinf.setManager("Changed Manager");
           
           
            // Save this into the filesystem
            sinf.write(new NDocumentOutputStream(sinfDoc));
            dinf.write(new NDocumentOutputStream(dinfDoc));
           
           
            // Read them back in again
            sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(sinfDoc));
            assertEquals(131077, sinf.getOSVersion());
           
            dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(dinfDoc));
            assertEquals(131077, dinf.getOSVersion());
   
            assertEquals("Changed Author", sinf.getAuthor());
            assertEquals("Microsoft Word 9.0", sinf.getApplicationName());
            assertEquals("Le titre \u00e9tait chang\u00e9", sinf.getTitle());
           
            assertEquals("", dinf.getCompany());
            assertEquals("Changed Manager", dinf.getManager());
   
           
            // Close the whole filesystem, and open it once more
            fs.writeFilesystem();
            fs.close();
           
            fs = new NPOIFSFileSystem(copy);
            root = fs.getRoot();
           
            // Re-check on load
            sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            sinf = (SummaryInformation)PropertySetFactory.create(new NDocumentInputStream(sinfDoc));
            assertEquals(131077, sinf.getOSVersion());
           
            dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            dinf = (DocumentSummaryInformation)PropertySetFactory.create(new NDocumentInputStream(dinfDoc));
            assertEquals(131077, dinf.getOSVersion());
   
            assertEquals("Changed Author", sinf.getAuthor());
            assertEquals("Microsoft Word 9.0", sinf.getApplicationName());
View Full Code Here

Examples of org.jclouds.atmos.domain.DirectoryEntry

   public void testApplyInputStreamBase() {
      InputStream is = getClass().getResourceAsStream("/list_basic.xml");
      ParseSax<Set<DirectoryEntry>> parser = createParser();
      Set<DirectoryEntry> expected = Sets.newTreeSet();
      expected.add(new DirectoryEntry("4980cdb2a411106a04a4538c92a1b204ad92077de6e3",
               FileType.DIRECTORY, "adriancole-blobstore-2096685753"));
      expected.add(new DirectoryEntry("4980cdb2a410105404980d99e53a0504ad93939e7dc3",
               FileType.DIRECTORY, "adriancole-blobstore247496608"));
      Set<DirectoryEntry> result = parser.parse(is);
      assertEquals(result, expected);
   }
View Full Code Here

Examples of org.mockftpserver.fake.filesystem.DirectoryEntry

        fakeFtpServer = new FakeFtpServer();
        fakeFtpServer.setServerControlPort(9879);
        fakeFtpServer.addUserAccount(new UserAccount("admin", "123456", "/"));

        FileSystem fileSystem = new UnixFakeFileSystem();
        fileSystem.add(new DirectoryEntry("/data/prancingdonkey/catalog"));
        fakeFtpServer.setFileSystem(fileSystem);
        fakeFtpServer.start();

        DataSource dataSource =  muleContext.getRegistry().lookupObject("dataSource");
        template = new JdbcTemplate(dataSource);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.