Example usage for org.apache.commons.vfs2 FileSystemException printStackTrace

List of usage examples for org.apache.commons.vfs2 FileSystemException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileSystemException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.mycore.datamodel.ifs2.MCRStore.java

protected void init(final MCRStoreConfig config) {
    setStoreConfig(config);/*from w ww  .  j  ava 2s.c  om*/

    idLength = 0;

    final StringTokenizer st = new StringTokenizer(getStoreConfig().getSlotLayout(), "-");
    slotLength = new int[st.countTokens() - 1];

    int i = 0;
    while (st.countTokens() > 1) {
        slotLength[i] = Integer.parseInt(st.nextToken());
        idLength += slotLength[i++];
    }
    idLength += Integer.parseInt(st.nextToken());

    try {
        baseDirectory = VFS.getManager().resolveFile(getStoreConfig().getBaseDir());

        if (!baseDirectory.exists()) {
            baseDirectory.createFolder();
        } else {
            if (!baseDirectory.isReadable()) {
                final String msg = "Store directory " + getStoreConfig().getBaseDir() + " is not readable";
                throw new MCRConfigurationException(msg);
            }

            if (baseDirectory.getType() != FileType.FOLDER) {
                final String msg = "Store " + getStoreConfig().getBaseDir() + " is a file, not a directory";
                throw new MCRConfigurationException(msg);
            }
        }
    } catch (final FileSystemException e) {
        e.printStackTrace();
    }
}

From source file:org.pentaho.big.data.kettle.plugins.pig.NoArgJobEntryPigScriptExecutor.java

private static HadoopConfigurationProvider initProvider() {
    try {/*from  w w  w .j  av a 2s  .co  m*/
        return new TestProvider();
    } catch (FileSystemException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTableModelTest.java

@Test
public void testGetRowCount() {
    RepositoryTableModel repoTableModel = new RepositoryTableModel();
    assertNotNull(repoTableModel);/*www  . j  a v a2 s.  c o  m*/
    assertEquals(0, repoTableModel.getRowCount());

    repoTableModel.setSelectedPath(fileObject);
    assertEquals(0, repoTableModel.getRowCount());

    try {
        doReturn(FileType.FOLDER).when(fileObject).getType();
        FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
        doReturn(childFileName1).when(childFile1).getName();
        doReturn(childFileName2).when(childFile2).getName();
        doReturn(childFileName3).when(childFile3).getName();
        doReturn("file1.txt").when(childFileName1).getBaseName();
        doReturn("file2.txt").when(childFileName2).getBaseName();
        doReturn("file3.txt").when(childFileName3).getBaseName();
        doReturn(childFiles).when(fileObject).getChildren();
        assertEquals(3, repoTableModel.getRowCount());
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTableModelTest.java

@Test
public void testGetElementForRow() {
    RepositoryTableModel repoTableModel = new RepositoryTableModel();
    assertNotNull(repoTableModel);//from  ww w .  j av  a  2s . co  m
    repoTableModel.setSelectedPath(fileObject);

    try {
        doReturn(FileType.FOLDER).when(fileObject).getType();
        FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
        doReturn(childFileName1).when(childFile1).getName();
        doReturn(childFileName2).when(childFile2).getName();
        doReturn(childFileName3).when(childFile3).getName();
        doReturn("file1.txt").when(childFileName1).getBaseName();
        doReturn("file2.txt").when(childFileName2).getBaseName();
        doReturn("file3.txt").when(childFileName3).getBaseName();
        doReturn(childFiles).when(fileObject).getChildren();
        assertEquals(childFile2, repoTableModel.getElementForRow(1));
    } catch (FileSystemException e) {
        e.printStackTrace();
    }

}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTableModelTest.java

@Test
public void testGetValueAt() {
    final String localizedName1 = "fileName1";
    final String localizedName2 = "fileName2";
    final String localizedName3 = "fileName3";
    final String description1 = "description1";
    final String description2 = "description2";
    final String description3 = "description3";
    final long modifiedTime = System.currentTimeMillis();

    RepositoryTableModel repoTableModel = new RepositoryTableModel();
    assertNotNull(repoTableModel);//from   w  ww  .j  a v  a 2 s .c  o  m
    repoTableModel.setSelectedPath(fileObject);

    try {
        doReturn(FileType.FOLDER).when(fileObject).getType();
        FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
        doReturn(childFileName1).when(childFile1).getName();
        doReturn(childFileName2).when(childFile2).getName();
        doReturn(childFileName3).when(childFile3).getName();
        doReturn("file1.txt").when(childFileName1).getBaseName();
        doReturn("file2.txt").when(childFileName2).getBaseName();
        doReturn("file3.txt").when(childFileName3).getBaseName();
        doReturn(childFileContent1).when(childFile1).getContent();
        doReturn(childFileContent2).when(childFile2).getContent();
        doReturn(childFileContent3).when(childFile3).getContent();
        doReturn(localizedName1).when(childFileContent1).getAttribute("localized-name");
        doReturn(localizedName2).when(childFileContent2).getAttribute("localized-name");
        doReturn(localizedName3).when(childFileContent3).getAttribute("localized-name");
        doReturn(description1).when(childFileContent1).getAttribute("description");
        doReturn(description2).when(childFileContent2).getAttribute("description");
        doReturn(description3).when(childFileContent3).getAttribute("description");
        doReturn(modifiedTime).when(childFileContent1).getLastModifiedTime();
        doReturn(modifiedTime).when(childFileContent2).getLastModifiedTime();
        doReturn(modifiedTime).when(childFileContent3).getLastModifiedTime();
        doReturn(childFiles).when(fileObject).getChildren();
        assertEquals(localizedName1, repoTableModel.getValueAt(0, 0));
        assertEquals("file1.txt", repoTableModel.getValueAt(0, 1));
        assertEquals(new Date(modifiedTime), repoTableModel.getValueAt(0, 2));
        assertEquals(description1, repoTableModel.getValueAt(0, 3));
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModelTest.java

@Test
public void testGetChild() {
    RepositoryTreeModel treeModel = new RepositoryTreeModel();
    assertNotNull(treeModel);//from   w ww .  ja  v a2  s .c  o m
    assertNull(treeModel.getFileSystemRoot());
    FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
    try {
        doReturn(childFiles).when(repositoryRoot).getChildren();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
    treeModel.setFileSystemRoot(repositoryRoot);
    Object value = treeModel.getChild(repositoryRoot, 1);
    assertEquals(childFile2, value);

    treeModel.setShowFoldersOnly(true);
    try {
        doReturn(FileType.FILE).when(childFile1).getType();
        doReturn(FileType.FILE).when(childFile2).getType();
        doReturn(FileType.FILE).when(childFile3).getType();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
    value = treeModel.getChild(repositoryRoot, 0);
    assertEquals(childFile1, value);

    treeModel.setShowHiddenFiles(false);
    try {
        doReturn(FileType.FOLDER).when(childFile1).getType();
        doReturn(FileType.FOLDER).when(childFile2).getType();
        doReturn(FileType.FOLDER).when(childFile3).getType();
        doReturn(true).when(childFile1).isHidden();
        doReturn(true).when(childFile2).isHidden();
        doReturn(true).when(childFile3).isHidden();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
    value = treeModel.getChild(repositoryRoot, 2);
    assertEquals(childFile3, value);

}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModelTest.java

@Test
public void testGetChildCount() {
    RepositoryTreeModel treeModel = new RepositoryTreeModel();
    assertNotNull(treeModel);// w  w  w.j a v  a  2  s  .  c  o m
    treeModel.setFileSystemRoot(repositoryRoot);
    assertEquals(0, treeModel.getChildCount(repositoryRoot));

    FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
    try {
        doReturn(childFiles).when(repositoryRoot).getChildren();
        doReturn(FileType.FOLDER).when(repositoryRoot).getType();
        doReturn(FileType.FOLDER).when(childFile1).getType();
        doReturn(FileType.FOLDER).when(childFile2).getType();
        doReturn(FileType.FOLDER).when(childFile3).getType();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
    assertEquals(3, treeModel.getChildCount(repositoryRoot));
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModelTest.java

@Test
public void testGetIndexOfChild() {
    RepositoryTreeModel treeModel = new RepositoryTreeModel();
    assertNotNull(treeModel);//from   w  w  w  . j a v  a2 s.com
    treeModel.setFileSystemRoot(repositoryRoot);
    treeModel.setShowFoldersOnly(false);
    FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
    try {
        doReturn(childFiles).when(repositoryRoot).getChildren();
        doReturn(childFileName1).when(childFile1).getName();
        doReturn(childFileName2).when(childFile2).getName();
        doReturn(childFileName3).when(childFile3).getName();
        doReturn("BaseName1").when(childFileName1).getBaseName();
        doReturn("BaseName2").when(childFileName2).getBaseName();
        doReturn("BaseName3").when(childFileName3).getBaseName();
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
    assertEquals(1, treeModel.getIndexOfChild(repositoryRoot, childFile2));
    assertEquals(-1, treeModel.getIndexOfChild(repositoryRoot, childFile4));
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModelTest.java

@Test
public void testGetTreePathForSelection() {
    RepositoryTreeModel treeModel = new RepositoryTreeModel();
    assertNotNull(treeModel);//from w ww .j  av  a  2s .co  m
    treeModel.setFileSystemRoot(repositoryRoot);
    FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
    try {
        doReturn(childFiles).when(repositoryRoot).getChildren();
        doReturn(childFileName1).when(childFile1).getName();
        doReturn(childFileName2).when(childFile2).getName();
        doReturn(childFileName3).when(childFile3).getName();
        doReturn(repositoryRoot).when(childFile1).getParent();
        doReturn(repositoryRoot).when(childFile2).getParent();
        doReturn(repositoryRoot).when(childFile3).getParent();
        TreePath path = treeModel.getTreePathForSelection(childFile2, null);
        assertEquals(2, path.getPath().length);
        assertEquals(childFile2, path.getLastPathComponent());
    } catch (FileSystemException e) {
        e.printStackTrace();
    }

}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.model.RepositoryTreeModelTest.java

@Test
public void testFindNodeByName() {
    FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 };
    try {//from w w  w .ja  v  a 2s  .  c  om
        doReturn(FileType.FOLDER).when(repositoryRoot).getType();
        doReturn(childFiles).when(repositoryRoot).getChildren();
        doReturn(childFileName1).when(childFile1).getName();
        doReturn(childFileName2).when(childFile2).getName();
        doReturn(childFileName3).when(childFile3).getName();
        doReturn("BaseName1").when(childFileName1).getBaseName();
        doReturn("BaseName2").when(childFileName2).getBaseName();
        doReturn("BaseName3").when(childFileName3).getBaseName();
        doReturn(childFile2).when(repositoryRoot).getChild("BaseName2");
        assertEquals(childFile2, RepositoryTreeModel.findNodeByName(repositoryRoot, "BaseName2"));
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}