Example usage for org.apache.commons.vfs2 FileObject getPublicURIString

List of usage examples for org.apache.commons.vfs2 FileObject getPublicURIString

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileObject getPublicURIString.

Prototype

String getPublicURIString();

Source Link

Document

Returns the receiver as a URI String for public display, like, without a password.

Usage

From source file:org.pentaho.di.core.fileinput.FileInputListTest.java

@Test
public void testGetUrlStrings() throws Exception {

    String sFileA = "hdfs://myfolderA/myfileA.txt";
    String sFileB = "file:///myfolderB/myfileB.txt";

    FileObject fileA = mock(FileObject.class);
    FileObject fileB = mock(FileObject.class);

    when(fileA.getPublicURIString()).thenReturn(sFileA);
    when(fileB.getPublicURIString()).thenReturn(sFileB);

    FileInputList fileInputList = new FileInputList();
    fileInputList.addFile(fileA);/* w w  w.j  a  v  a 2  s.  co m*/
    fileInputList.addFile(fileB);
    String[] result = fileInputList.getUrlStrings();
    assertEquals(2, result.length);
    assertEquals(sFileA, result[0]);
    assertEquals(sFileB, result[1]);
}

From source file:org.pentaho.di.trans.steps.pentahoreporting.urlrepository.FileObjectContentLocation.java

/**
 * Lists all content entities stored in this content-location. This method filters out all files that have an invalid
 * name (according to the repository rules).
 *
 * @return the content entities for this location.
 * @throws ContentIOException if an repository error occured.
 *///www  .  ja v a2s . c o m
public ContentEntity[] listContents() throws ContentIOException {
    try {
        final FileObject file = getBackend();
        final FileObject[] files = file.getChildren();
        final ContentEntity[] entities = new ContentEntity[files.length];
        for (int i = 0; i < files.length; i++) {
            final FileObject child = files[i];
            if (RepositoryUtilities.isInvalidPathName(child.getPublicURIString())) {
                continue;
            }

            if (child.isFolder()) {
                entities[i] = new FileObjectContentLocation(this, child);
            } else if (child.isFile()) {
                entities[i] = new FileObjectContentLocation(this, child);
            }
        }
        return entities;
    } catch (FileSystemException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.pentaho.metaverse.api.model.ExternalResourceInfoFactory.java

public static IExternalResourceInfo createFileResource(FileObject fileObject, boolean isInput) {
    BaseResourceInfo resource = null;//from www  . j a  va 2s  .c o m
    if (fileObject != null) {
        resource = new BaseResourceInfo();
        resource.setName(fileObject.getPublicURIString());
        resource.setInput(isInput);
        // default value, different value can be specified by the custom analyzer
        resource.setType(DictionaryConst.NODE_TYPE_FILE);
    }
    return resource;
}

From source file:org.pentaho.metaverse.api.model.ExternalResourceInfoFactoryTest.java

@Test
public void testCreateFileResource() throws Exception {
    assertNull(ExternalResourceInfoFactory.createFileResource(null));
    FileObject mockFile = mock(FileObject.class);
    IExternalResourceInfo resource = ExternalResourceInfoFactory.createFileResource(mockFile, false);
    assertNotNull(resource);//from   ww w  .  j  a  v a  2s.c  o  m
    assertNull(resource.getName());
    assertFalse(resource.isInput());

    when(mockFile.getPublicURIString()).thenReturn("/path/to/file");
    resource = ExternalResourceInfoFactory.createFileResource(mockFile, true);
    assertNotNull(resource);
    assertEquals("/path/to/file", resource.getName());
    assertTrue(resource.isInput());
}

From source file:org.pentaho.repositoryvfs.vfs.RepositoryVfsFileObject.java

@Override
public int compareTo(FileObject o) {
    return getPublicURIString().compareTo(o.getPublicURIString());
}