Example usage for com.liferay.portal.kernel.util FileUtil listFiles

List of usage examples for com.liferay.portal.kernel.util FileUtil listFiles

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util FileUtil listFiles.

Prototype

public static String[] listFiles(String fileName) 

Source Link

Usage

From source file:com.liferay.portlet.documentlibrary.store.AdvancedFileSystemStore.java

License:Open Source License

@Override
public void updateFile(long companyId, long repositoryId, String fileName, String newFileName)
        throws PortalException {

    super.updateFile(companyId, repositoryId, fileName, newFileName);

    File newFileNameDir = getFileNameDir(companyId, repositoryId, newFileName);

    String[] fileNameVersions = FileUtil.listFiles(newFileNameDir);

    for (String fileNameVersion : fileNameVersions) {
        String ext = FileUtil.getExtension(fileNameVersion);

        if (ext.equals(_HOOK_EXTENSION)) {
            continue;
        }//from  w w w.  j a v  a2 s  .  co m

        File fileNameVersionFile = new File(newFileNameDir + StringPool.SLASH + fileNameVersion);
        File newFileNameVersionFile = new File(newFileNameDir + StringPool.SLASH
                + FileUtil.stripExtension(fileNameVersion) + StringPool.PERIOD + _HOOK_EXTENSION);

        fileNameVersionFile.renameTo(newFileNameVersionFile);
    }
}

From source file:com.liferay.portlet.documentlibrary.store.AdvancedFileSystemStore.java

License:Open Source License

@Override
protected String getHeadVersionLabel(long companyId, long repositoryId, String fileName) {

    File fileNameDir = getFileNameDir(companyId, repositoryId, fileName);

    if (!fileNameDir.exists()) {
        return VERSION_DEFAULT;
    }// w w  w . jav  a  2 s. c  om

    String[] versionLabels = FileUtil.listFiles(fileNameDir);

    String headVersionLabel = VERSION_DEFAULT;

    for (int i = 0; i < versionLabels.length; i++) {
        String versionLabelFragment = versionLabels[i];

        int x = versionLabelFragment.lastIndexOf(CharPool.UNDERLINE);
        int y = versionLabelFragment.lastIndexOf(CharPool.PERIOD);

        if (x > -1) {
            versionLabelFragment = versionLabelFragment.substring(x + 1, y);
        }

        String versionLabel = versionLabelFragment;

        if (DLUtil.compareVersions(versionLabel, headVersionLabel) > 0) {
            headVersionLabel = versionLabel;
        }
    }

    return headVersionLabel;
}

From source file:com.liferay.portlet.documentlibrary.store.FileSystemStore.java

License:Open Source License

protected String getHeadVersionLabel(long companyId, long repositoryId, String fileName) {

    File fileNameDir = getFileNameDir(companyId, repositoryId, fileName);

    if (!fileNameDir.exists()) {
        return VERSION_DEFAULT;
    }//www  .  j a  va 2 s . c o m

    String[] versionLabels = FileUtil.listFiles(fileNameDir);

    String headVersionLabel = VERSION_DEFAULT;

    for (String versionLabel : versionLabels) {
        if (DLUtil.compareVersions(versionLabel, headVersionLabel) > 0) {
            headVersionLabel = versionLabel;
        }
    }

    return headVersionLabel;
}