Package edu.isi.karma.imp.json

Examples of edu.isi.karma.imp.json.JsonImport$FileObject


          TablePager pager = vWorksheet.getTopTablePager();
          generateRowsUsingPager(pager, vWorksheet, vWorksheet.getHeaderViewNodes(), fileWriter,"");
          fileWriter.close();

          if(importAsWorksheet) {
            JsonImport jsonImp = new JsonImport(new File(fileLocalPath), newWorksheetName, finalWorkspace, "utf-8", -1, null);
            jsonImp.generateWorksheet();
            newWSId = jsonImp.getWorksheet().getId();
            new WorksheetListUpdate().applyUpdate(vWorkspace);
          }


        } catch(Exception ie) {
View Full Code Here


    baos.write('\n');
    baos.write(']');
    baos.flush();
    baos.close();
    String json = new String(baos.toByteArray());
    JsonImport jsonImport = new JsonImport(json, this.getFactory(), this.getWorksheet(), workspace, maxNumLines);
    return jsonImport.generateWorksheet();
  }
View Full Code Here

    public void testSmallFS() throws Exception
    {

        // Default FS
        FileObject fo1 = manager.resolveFile("ram:/");
        FileObject fo2 = manager.resolveFile("ram:/");
        assertTrue("Both files should exist in the same fs instance.", fo1
                .getFileSystem() == fo2.getFileSystem());

        // Small FS
        FileObject fo3 = manager.resolveFile("ram:/fo3", smallSized);
        FileObject fo4 = manager.resolveFile("ram:/", smallSized);
        assertTrue("Both files should exist in different fs instances.", fo3
                .getFileSystem() == fo4.getFileSystem());
        assertTrue("These file shouldn't be in the same file system.", fo1
                .getFileSystem() != fo3.getFileSystem());

        fo3.createFile();
        try
View Full Code Here

     * Checks root folder exists
     *
     * @throws FileSystemException
     */
    public void testRootFolderExists() throws FileSystemException {
        FileObject root = manager.resolveFile("ram:///", defaultRamFs);
        assertTrue(root.getType().hasChildren());

        try {
            root.delete();
            fail();
        } catch (FileSystemException e) {

        }

View Full Code Here

    /**
     * Sets up a scratch folder for the test to use.
     */
    protected FileObject createScratchFolder() throws Exception
    {
        FileObject scratchFolder = getWriteFolder();

        // Make sure the test folder is empty
        scratchFolder.delete(Selectors.EXCLUDE_SELF);
        scratchFolder.createFolder();

        return scratchFolder;
    }
View Full Code Here

    /**
     * Tests create-delete-create-a-file sequence on the same file system.
     */
    public void testRenameFile() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        // Create direct child of the test folder
        final FileObject file = scratchFolder.resolveFile("file1.txt");
        assertTrue(!file.exists());

        // Create the source file
        final String content = "Here is some sample content for the file.  Blah Blah Blah.";

        final OutputStream os = file.getContent().getOutputStream();
        try
        {
            os.write(content.getBytes("utf-8"));
        }
        finally
        {
            os.close();
        }
        assertSameContent(content, file);


        // Make sure we can move the new file to another file on the same filesystem

        FileObject fileMove = scratchFolder.resolveFile("file1move.txt");
        assertTrue(!fileMove.exists());

        file.moveTo(fileMove);

        assertTrue(!file.exists());
        assertTrue(fileMove.exists());

        assertSameContent(content, fileMove);

        // Delete the file.
        assertTrue(fileMove.exists());
        assertTrue(fileMove.delete());
    }
View Full Code Here

    /**
     * Tests that folders have no content.
     */
    public void testFolderURL() throws Exception
    {
        final FileObject folder = getReadFolder().resolveFile("dir1");
        if (folder.getFileSystem().hasCapability(Capability.DIRECTORY_READ_CONTENT))
        {
            // test might not fail on e.g. HttpFileSystem as there are no direcotries.
            // A Directory do have a content on http. e.g a generated directory listing or the index.html page.
            return;
        }

        assertTrue(folder.exists());

        // Try getting the content of a folder
        try
        {
            folder.getURL().openConnection().getInputStream();
            fail();
        }
        catch (final IOException e)
        {
            assertSameMessage("vfs.provider/read-not-file.error", folder, e);
View Full Code Here

     * Tests getting the last modified time of a file.
     */
    public void testGetLastModified() throws Exception
    {
        // Try a file.
        final FileObject file = getReadFolder().resolveFile("file1.txt");
        file.getContent().getLastModifiedTime();

        // TODO - switch this on
        // Try a folder
        //final FileObject folder = getReadFolder().resolveFile( "dir1" );
        //folder.getContent().getLastModifiedTime();
View Full Code Here

        final long now = System.currentTimeMillis();

        if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE))
        {
            // Try a file
            final FileObject file = getReadFolder().resolveFile("file1.txt");
            file.getContent().setLastModifiedTime(now);
            try
            {
                assertEquals(now, file.getContent().getLastModifiedTime(), file.getFileSystem().getLastModTimeAccuracy());
            }
            catch (AssertionFailedError e)
            {
                // on linux ext3 the above check is not necessarily true
                if (file.getFileSystem().getLastModTimeAccuracy() < 1000L)
                {
                    assertEquals(now, file.getContent().getLastModifiedTime(), 1000L);
                }
                else
                {
                    throw e;
                }
            }
        }

        if (getReadFolder().getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FOLDER))
        {
            // Try a folder
            final FileObject folder = getReadFolder().resolveFile("dir1");
            folder.getContent().setLastModifiedTime(now);
            try
            {
                assertEquals(now, folder.getContent().getLastModifiedTime(), folder.getFileSystem().getLastModTimeAccuracy());
            }
            catch (AssertionFailedError e)
            {
                // on linux ext3 the above check is not necessarily true
                if (folder.getFileSystem().getLastModTimeAccuracy() < 1000L)
                {
                    assertEquals(now, folder.getContent().getLastModifiedTime(), 1000L);
                }
                else
                {
                    throw e;
                }
View Full Code Here

    /**
     * Tests file/folder creation with mismatched types.
     */
    public void testFileCreateMismatched() throws Exception
    {
        FileObject scratchFolder = createScratchFolder();

        // Create a test file and folder
        FileObject file = scratchFolder.resolveFile("dir1/file1.txt");
        file.createFile();
        assertEquals(FileType.FILE, file.getType());

        FileObject folder = scratchFolder.resolveFile("dir1/dir2");
        folder.createFolder();
        assertEquals(FileType.FOLDER, folder.getType());

        // Attempt to create a file that already exists as a folder
        try
        {
            folder.createFile();
            fail();
        }
        catch (FileSystemException exc)
        {
        }

        // Attempt to create a folder that already exists as a file
        try
        {
            file.createFolder();
            fail();
        }
        catch (FileSystemException exc)
        {
        }

        // Attempt to create a folder as a child of a file
        FileObject folder2 = file.resolveFile("some-child");
        try
        {
            folder2.createFolder();
            fail();
        }
        catch (FileSystemException exc)
        {
        }
View Full Code Here

TOP

Related Classes of edu.isi.karma.imp.json.JsonImport$FileObject

Copyright © 2018 www.massapicom. 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.