Search in sources :

Example 1 with ContentEntity

use of org.pentaho.reporting.libraries.repository.ContentEntity in project pentaho-kettle by pentaho.

the class FileObjectContentLocation method listContents.

/**
 * 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.
 */
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);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) ContentEntity(org.pentaho.reporting.libraries.repository.ContentEntity) FileObject(org.apache.commons.vfs2.FileObject)

Example 2 with ContentEntity

use of org.pentaho.reporting.libraries.repository.ContentEntity in project pentaho-platform by pentaho.

the class PentahoURLRewriterTest method testRewriteRoot.

@Test
public void testRewriteRoot() throws Exception {
    String pattern = TEST_SRC + "/solution/test/reporting/system/{0}/param";
    PentahoURLRewriter rewriter = new PentahoURLRewriter(pattern);
    File dataDirectory = new File("/");
    FileRepository dataRepository = new FileRepository(dataDirectory);
    File contentEntryBackend = new File(TEST_SRC + "/solution/test/reporting/contentEntryBackend");
    File dataEntityBackend = new File(TEST_SRC + "/solution/test/reporting/dataEntityBackend");
    ContentEntity contentEntry = new FileContentItem(dataRepository.getRoot(), contentEntryBackend);
    ContentEntity dataEntity = new FileContentItem(dataRepository.getRoot(), dataEntityBackend);
    String result = rewriter.rewrite(contentEntry, dataEntity);
    assertEquals(TEST_SRC + "/solution/test/reporting/system/dataEntityBackend/param", result);
}
Also used : FileRepository(org.pentaho.reporting.libraries.repository.file.FileRepository) FileContentItem(org.pentaho.reporting.libraries.repository.file.FileContentItem) ContentEntity(org.pentaho.reporting.libraries.repository.ContentEntity) File(java.io.File) Test(org.junit.Test)

Example 3 with ContentEntity

use of org.pentaho.reporting.libraries.repository.ContentEntity in project pentaho-platform by pentaho.

the class PentahoURLRewriterTest method testRewriteWithSimplePattern.

@Test
public void testRewriteWithSimplePattern() throws Exception {
    String pattern = TEST_SRC + "/solution/test/reporting/system";
    PentahoURLRewriter rewriter = new PentahoURLRewriter(pattern);
    File dataDirectory = new File(TEST_SRC + "/solution/test/reporting/");
    FileRepository dataRepository = new FileRepository(dataDirectory);
    File contentEntryBackend = new File(TEST_SRC + "/solution/test/reporting/contentEntryBackend");
    File dataEntityBackend = new File(TEST_SRC + "/solution/test/reporting/dataEntityBackend");
    ContentEntity contentEntry = new FileContentItem(dataRepository.getRoot(), contentEntryBackend);
    ContentEntity dataEntity = new FileContentItem(dataRepository.getRoot(), dataEntityBackend);
    String result = rewriter.rewrite(contentEntry, dataEntity);
    assertEquals(pattern, result);
}
Also used : FileRepository(org.pentaho.reporting.libraries.repository.file.FileRepository) FileContentItem(org.pentaho.reporting.libraries.repository.file.FileContentItem) ContentEntity(org.pentaho.reporting.libraries.repository.ContentEntity) File(java.io.File) Test(org.junit.Test)

Example 4 with ContentEntity

use of org.pentaho.reporting.libraries.repository.ContentEntity in project pentaho-platform by pentaho.

the class PentahoURLRewriterTest method testRewriteWithPatternParam.

@Test
public void testRewriteWithPatternParam() throws Exception {
    String pattern = TEST_SRC + "/solution/test/reporting/system/{0}/param";
    PentahoURLRewriter rewriter = new PentahoURLRewriter(pattern);
    File dataDirectory = new File(TEST_SRC + "/solution/test/reporting/");
    FileRepository dataRepository = new FileRepository(dataDirectory);
    File contentEntryBackend = new File(TEST_SRC + "/solution/test/reporting/contentEntryBackend");
    File dataEntityBackend = new File(TEST_SRC + "/solution/test/reporting/dataEntityBackend");
    ContentEntity contentEntry = new FileContentItem(dataRepository.getRoot(), contentEntryBackend);
    ContentEntity dataEntity = new FileContentItem(dataRepository.getRoot(), dataEntityBackend);
    String result = rewriter.rewrite(contentEntry, dataEntity);
    assertEquals(TEST_SRC + "/solution/test/reporting/system/dataEntityBackend/param", result);
}
Also used : FileRepository(org.pentaho.reporting.libraries.repository.file.FileRepository) FileContentItem(org.pentaho.reporting.libraries.repository.file.FileContentItem) ContentEntity(org.pentaho.reporting.libraries.repository.ContentEntity) File(java.io.File) Test(org.junit.Test)

Example 5 with ContentEntity

use of org.pentaho.reporting.libraries.repository.ContentEntity in project pentaho-platform by pentaho.

the class PentahoURLRewriterTest method testRewriteWithNullPattern.

@Test
public void testRewriteWithNullPattern() throws Exception {
    String pattern = null;
    PentahoURLRewriter rewriter = new PentahoURLRewriter(pattern);
    File dataDirectory = new File(TEST_SRC + "/solution/test/reporting/");
    FileRepository dataRepository = new FileRepository(dataDirectory);
    File contentEntryBackend = new File(TEST_SRC + "/solution/test/reporting/contentEntryBackend");
    File dataEntityBackend = new File(TEST_SRC + "/solution/test/reporting/dataEntityBackend");
    ContentEntity contentEntry = new FileContentItem(dataRepository.getRoot(), contentEntryBackend);
    ContentEntity dataEntity = new FileContentItem(dataRepository.getRoot(), dataEntityBackend);
    String result = rewriter.rewrite(contentEntry, dataEntity);
    assertEquals("dataEntityBackend", result);
}
Also used : FileRepository(org.pentaho.reporting.libraries.repository.file.FileRepository) FileContentItem(org.pentaho.reporting.libraries.repository.file.FileContentItem) ContentEntity(org.pentaho.reporting.libraries.repository.ContentEntity) File(java.io.File) Test(org.junit.Test)

Aggregations

ContentEntity (org.pentaho.reporting.libraries.repository.ContentEntity)5 File (java.io.File)4 Test (org.junit.Test)4 FileContentItem (org.pentaho.reporting.libraries.repository.file.FileContentItem)4 FileRepository (org.pentaho.reporting.libraries.repository.file.FileRepository)4 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1