Example usage for org.apache.commons.io IOUtils DIR_SEPARATOR

List of usage examples for org.apache.commons.io IOUtils DIR_SEPARATOR

Introduction

In this page you can find the example usage for org.apache.commons.io IOUtils DIR_SEPARATOR.

Prototype

char DIR_SEPARATOR

To view the source code for org.apache.commons.io IOUtils DIR_SEPARATOR.

Click Source Link

Document

The system directory separator character.

Usage

From source file:com.hpe.application.automation.tools.pc.PcClient.java

public FilePath publishRunReport(int runId, String reportDirectory)
        throws IOException, PcException, InterruptedException {
    PcRunResults runResultsList = restProxy.getRunResults(runId);
    if (runResultsList.getResultsList() != null) {
        for (PcRunResult result : runResultsList.getResultsList()) {
            if (result.getName().equals(PcBuilder.pcReportArchiveName)) {
                File dir = new File(reportDirectory);
                dir.mkdirs();/* w  w w .j  a  v a 2s.c  o  m*/
                String reportArchiveFullPath = dir.getCanonicalPath() + IOUtils.DIR_SEPARATOR
                        + PcBuilder.pcReportArchiveName;
                logger.println("Publishing analysis report");
                restProxy.GetRunResultData(runId, result.getID(), reportArchiveFullPath);
                FilePath fp = new FilePath(new File(reportArchiveFullPath));
                fp.unzip(fp.getParent());
                fp.delete();
                FilePath reportFile = fp.sibling(PcBuilder.pcReportFileName);
                if (reportFile.exists())
                    return reportFile;
            }
        }
    }
    logger.println("Failed to get run report");
    return null;
}

From source file:edu.ur.file.db.TreeFolderInfo.java

/**
 * Gets the full path including the folder name this includes the end
 * separator.//  w  w w  .  j  av a  2  s .c  o m
 * 
 * @return full path including the folder name.
 */
public String getFullPath() {
    String fp = null;

    if (getPath() != null) {
        fp = getPath();
    }

    if (fp != null) {
        fp += name + IOUtils.DIR_SEPARATOR;
    }

    return fp;
}

From source file:edu.ur.ir.web.action.repository.EditRepository.java

private void updateNameIndexFolder(Repository r, String folder) throws IOException {

    String oldFolder = r.getNameIndexFolder();
    boolean change = true;
    if (folder != null) {
        // add the end seperator
        if (folder.charAt(folder.length() - 1) != IOUtils.DIR_SEPARATOR) {
            folder = folder + IOUtils.DIR_SEPARATOR;
        }/*from   w  ww  . ja  v  a  2  s . c  om*/
        File f = new File(folder);
        if (oldFolder != null) {
            File oldFolderFile = new File(oldFolder);

            if (f.getAbsolutePath().equals(oldFolderFile.getAbsolutePath())) {
                change = false;
            }
        }

        if (change) {
            FileUtils.forceMkdir(f);
            r.setNameIndexFolder(folder);
            if (oldFolder != null) {
                FileUtils.deleteQuietly(new File(oldFolder));
            }
        }
    } else {
        if (oldFolder != null) {
            FileUtils.deleteQuietly(new File(oldFolder));
        }
    }
}

From source file:edu.ur.ir.web.action.repository.EditRepository.java

private void updateInstitutionalItemIndexFolder(Repository r, String folder) throws IOException {

    String oldFolder = r.getInstitutionalItemIndexFolder();
    boolean change = true;
    if (folder != null) {
        // add the end seperator
        if (folder.charAt(folder.length() - 1) != IOUtils.DIR_SEPARATOR) {
            folder = folder + IOUtils.DIR_SEPARATOR;
        }/*from w  w w.  j a  va2  s  . c o  m*/
        File f = new File(folder);
        if (oldFolder != null) {
            File oldFolderFile = new File(oldFolder);

            if (f.getAbsolutePath().equals(oldFolderFile.getAbsolutePath())) {
                change = false;
            }
        }

        if (change) {
            FileUtils.forceMkdir(f);
            r.setInstitutionalItemIndexFolder(folder);
            if (oldFolder != null) {
                FileUtils.deleteQuietly(new File(oldFolder));
            }
        }
    } else {
        if (oldFolder != null) {
            FileUtils.deleteQuietly(new File(oldFolder));
        }
    }
}

From source file:com.hpe.application.automation.tools.pc.PcClient.java

public boolean downloadTrendReportAsPdf(String trendReportId, String directory) throws PcException {

    try {/*  w w w.  j  a  v a2s.  com*/
        logger.println("Downloading trend report: " + trendReportId + " in PDF format");
        InputStream in = restProxy.getTrendingPDF(trendReportId);
        File dir = new File(directory);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        String filePath = directory + IOUtils.DIR_SEPARATOR + "trendReport" + trendReportId + ".pdf";
        Path destination = Paths.get(filePath);
        Files.copy(in, destination, StandardCopyOption.REPLACE_EXISTING);
        logger.println("Trend report: " + trendReportId + " was successfully downloaded");
    } catch (Exception e) {

        logger.println("Failed to download trend report: " + e.getMessage());
        throw new PcException(e.getMessage());
    }

    return true;

}

From source file:edu.ur.ir.web.action.repository.EditRepository.java

private void updateResearcherIndexFolder(Repository r, String folder) throws IOException {

    String oldFolder = r.getResearcherIndexFolder();
    boolean change = true;
    if (folder != null) {
        // add the end seperator
        if (folder.charAt(folder.length() - 1) != IOUtils.DIR_SEPARATOR) {
            folder = folder + IOUtils.DIR_SEPARATOR;
        }/*from  w  ww.  j av  a  2 s  . c o m*/
        File f = new File(folder);
        if (oldFolder != null) {
            File oldFolderFile = new File(oldFolder);

            if (f.getAbsolutePath().equals(oldFolderFile.getAbsolutePath())) {
                change = false;
            }
        }

        if (change) {
            FileUtils.forceMkdir(f);
            r.setResearcherIndexFolder(folder);
            if (oldFolder != null) {
                FileUtils.deleteQuietly(new File(oldFolder));
            }
        }
    } else {
        if (oldFolder != null) {
            FileUtils.deleteQuietly(new File(oldFolder));
        }
    }
}

From source file:edu.ur.ir.web.action.repository.EditRepository.java

private void updateUserIndexFolder(Repository r, String folder) throws IOException, NoIndexFoundException {

    String oldFolder = r.getUserIndexFolder();
    boolean change = true;
    if (folder != null) {
        // add the end seperator
        if (folder.charAt(folder.length() - 1) != IOUtils.DIR_SEPARATOR) {
            folder = folder + IOUtils.DIR_SEPARATOR;
        }//from   w w  w. j a va  2 s . c o  m
        File f = new File(folder);
        if (oldFolder != null) {
            File oldFolderFile = new File(oldFolder);

            if (f.getAbsolutePath().equals(oldFolderFile.getAbsolutePath())) {
                change = false;
            }
        }

        if (change) {
            FileUtils.forceMkdir(f);
            r.setUserIndexFolder(folder);
            if (oldFolder != null) {
                FileUtils.deleteQuietly(new File(oldFolder));
            }
            updateUserIndex();
        }
    } else {
        if (oldFolder != null) {
            FileUtils.deleteQuietly(new File(oldFolder));
        }
    }
}

From source file:edu.ur.ir.web.action.repository.EditRepository.java

private void updateUserWorkspaceIndexFolder(Repository r, String folder) throws IOException {

    log.debug("update user workspace index folder " + folder);
    String oldFolder = r.getUserWorkspaceIndexFolder();
    boolean change = true;
    if (folder != null) {
        // add the end seperator
        if (folder.charAt(folder.length() - 1) != IOUtils.DIR_SEPARATOR) {
            folder = folder + IOUtils.DIR_SEPARATOR;
        }// w  w w.  j a v  a2  s.  c  om
        File f = new File(folder);
        if (oldFolder != null) {
            File oldFolderFile = new File(oldFolder);

            if (f.getAbsolutePath().equals(oldFolderFile.getAbsolutePath())) {
                change = false;
            }
        }

        if (change) {
            FileUtils.forceMkdir(f);
            log.debug("setting user workspace index folder to " + folder);
            r.setUserWorkspaceIndexFolder(folder);
            if (oldFolder != null) {
                FileUtils.deleteQuietly(new File(oldFolder));
            }
        }
    } else {
        if (oldFolder != null) {
            FileUtils.deleteQuietly(new File(oldFolder));
        }
    }
}

From source file:com.microfocus.application.automation.tools.pc.PcClient.java

public FilePath publishRunReport(int runId, String reportDirectory)
        throws IOException, PcException, InterruptedException {
    PcRunResults runResultsList = restProxy.getRunResults(runId);
    if (runResultsList.getResultsList() != null) {
        for (PcRunResult result : runResultsList.getResultsList()) {
            if (result.getName().equals(PcBuilder.pcReportArchiveName)) {
                File dir = new File(reportDirectory);
                dir.mkdirs();//w w  w.  ja  va2 s  . c  om
                String reportArchiveFullPath = dir.getCanonicalPath() + IOUtils.DIR_SEPARATOR
                        + PcBuilder.pcReportArchiveName;
                logger.println(
                        String.format("%s - %s", dateFormatter.getDate(), Messages.PublishingAnalysisReport()));
                restProxy.GetRunResultData(runId, result.getID(), reportArchiveFullPath);
                FilePath fp = new FilePath(new File(reportArchiveFullPath));
                fp.unzip(fp.getParent());
                fp.delete();
                FilePath reportFile = fp.sibling(PcBuilder.pcReportFileName);
                if (reportFile.exists())
                    return reportFile;
            }
        }
    }
    logger.println(String.format("%s - %s", dateFormatter.getDate(), Messages.FailedToGetRunReport()));
    return null;
}

From source file:edu.ur.file.db.FileSystemManagerTest.java

/**
 * Test moving a folder from somewhere inside the folder to a root folder.
 * @throws LocationAlreadyExistsException 
 *///from  www.  j  a v  a2s  .c  om
public void moveFolderToRootTest() throws LocationAlreadyExistsException {
    String folderPath = properties.getProperty("FileSystemManagerTest.file.move.root");
    DefaultFileServer server = new DefaultFileServer("fileServer");
    DefaultFileDatabase fd = server.createFileDatabase("displayName18", "fileDB_18", folderPath, "description");

    TreeFolderInfo folder1 = FileSystemManager.createFolder("folder1", fd);

    TreeFolderInfo child1 = folder1.createChild("display_1", "name_1");
    TreeFolderInfo subChild1 = child1.createChild("sub_display_1", "sub_name_1");
    TreeFolderInfo subSubChild1 = subChild1.createChild("sus_sub_display_1", "sub_sub_name_1");
    TreeFolderInfo subSubChild2 = subChild1.createChild("sus_sub_display_2", "sub_sub_name_2");

    // check left and right values
    assert folder1.getLeftValue() == 1L : " Should equal 1 but equals " + folder1.getLeftValue();
    assert folder1.getRightValue() == 10L : " Should equal 10 but equals " + folder1.getRightValue();

    assert child1.getLeftValue() == 2L : " Should equal 2 but equals " + child1.getLeftValue();
    assert child1.getRightValue() == 9L : " Should equal 9 but equals " + child1.getRightValue();

    assert subChild1.getLeftValue() == 3L : " Should equal 3 but equals " + subChild1.getLeftValue();
    assert subChild1.getRightValue() == 8L : " Should equal 8 but equals " + subChild1.getRightValue();

    assert subSubChild1.getLeftValue() == 4L : " Should equal 4 but equals " + subSubChild1.getLeftValue();
    assert subSubChild1.getRightValue() == 5L : " Should equal 5 but equals " + subSubChild1.getRightValue();

    assert subSubChild2.getLeftValue() == 6L : " Should equal 6 but equals " + subSubChild2.getLeftValue();
    assert subSubChild2.getRightValue() == 7L : " Should equal 7 but equals " + subSubChild2.getRightValue();

    //move sub child 1 to root location in file database
    FileSystemManager.moveFolder(subChild1, fd);

    // check left and right values of un-moved children
    assert folder1.getLeftValue() == 1L : " Should equal 1 but equals " + folder1.getLeftValue();
    assert folder1.getRightValue() == 4L : " Should equal 4 but equals " + folder1.getRightValue();

    assert child1.getLeftValue() == 2L : " Should equal 2 but equals " + child1.getLeftValue();
    assert child1.getRightValue() == 3L : " Should equal 3 but equals " + child1.getRightValue();

    // check the moved child
    assert subChild1.getTreeRoot().equals(subChild1) : "Should be it's own root but root is "
            + subChild1.getTreeRoot().toString();
    assert subChild1.isRoot() : "Should be a root folder";

    assert subChild1.getLeftValue() == 1L : " Should equal 1 but equals " + subChild1.getLeftValue();
    assert subChild1.getRightValue() == 6L : " Should equal 6 but equals " + subChild1.getRightValue();

    assert subSubChild1.getLeftValue() == 2L : " Should equal 2 but equals " + subSubChild1.getLeftValue();
    assert subSubChild1.getRightValue() == 3L : " Should equal 3 but equals " + subSubChild1.getRightValue();

    assert subSubChild2.getLeftValue() == 4L : " Should equal 4 but equals " + subSubChild2.getLeftValue();
    assert subSubChild2.getRightValue() == 5L : " Should equal 5 but equals " + subSubChild2.getRightValue();

    assert subChild1.getPath().equals(fd.getFullPath()) : "Full path should be equal to db path : "
            + fd.getFullPath() + " but equals " + subChild1.getPath();

    String childPath = fd.getFullPath() + subChild1.getName() + IOUtils.DIR_SEPARATOR;

    assert subChild1.getFullPath().equals(childPath) : "Sub ehcild full path should equal " + childPath
            + " but equals " + subChild1.getFullPath();

    String subSubChildPath1 = subChild1.getFullPath() + subSubChild1.getName() + IOUtils.DIR_SEPARATOR;
    String subSubChildPath2 = subChild1.getFullPath() + subSubChild2.getName() + IOUtils.DIR_SEPARATOR;

    assert subSubChild1.getFullPath().equals(subSubChildPath1) : "Sub sub hcild full path should equal "
            + subSubChildPath1 + " but equals " + subSubChild1.getFullPath();

    assert subSubChild2.getFullPath().equals(subSubChildPath2) : "Sub sub hcild full path should equal "
            + subSubChildPath2 + " but equals " + subSubChild2.getFullPath();

    assert FileSystemManager.deleteDirectory(fd.getFullPath());
}