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

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

Introduction

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

Prototype

public static String encodeSafeFileName(String fileName) 

Source Link

Usage

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

License:Open Source License

public byte[] getFileAsBytes(long companyId, long repositoryId, String fileName)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName)) {

        return _store.getFileAsBytes(companyId, repositoryId, fileName);
    }/*from   www . j a v  a  2  s .  co  m*/

    return _store.getFileAsBytes(companyId, repositoryId, safeFileName);
}

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

License:Open Source License

public byte[] getFileAsBytes(long companyId, long repositoryId, String fileName, String versionLabel)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName, versionLabel)) {

        return _store.getFileAsBytes(companyId, repositoryId, fileName, versionLabel);
    }//  www.  j  av  a  2 s  .  com

    return _store.getFileAsBytes(companyId, repositoryId, safeFileName, versionLabel);
}

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

License:Open Source License

public InputStream getFileAsStream(long companyId, long repositoryId, String fileName)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName)) {

        return _store.getFileAsStream(companyId, repositoryId, fileName);
    }//  w ww . j av  a  2 s  . c  om

    return _store.getFileAsStream(companyId, repositoryId, safeFileName);
}

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

License:Open Source License

public InputStream getFileAsStream(long companyId, long repositoryId, String fileName, String versionLabel)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName, versionLabel)) {

        return _store.getFileAsStream(companyId, repositoryId, fileName, versionLabel);
    }/*from  w w w .  ja v  a  2  s.  c om*/

    return _store.getFileAsStream(companyId, repositoryId, safeFileName, versionLabel);
}

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

License:Open Source License

public String[] getFileNames(long companyId, long repositoryId, String dirName)
        throws PortalException, SystemException {

    String safeDirName = FileUtil.encodeSafeFileName(dirName);

    if (!safeDirName.equals(dirName)) {
        try {//  w  ww.  j ava 2  s  .co m
            _store.move(dirName, safeDirName);
        } catch (Exception e) {
        }
    }

    String[] fileNames = _store.getFileNames(companyId, repositoryId, safeDirName);

    String[] decodedFileNames = new String[fileNames.length];

    for (int i = 0; i < fileNames.length; i++) {
        decodedFileNames[i] = FileUtil.decodeSafeFileName(fileNames[i]);
    }

    return decodedFileNames;
}

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

License:Open Source License

public long getFileSize(long companyId, long repositoryId, String fileName)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName)) {

        return _store.getFileSize(companyId, repositoryId, fileName);
    }/*from   w  ww.  ja  v  a  2 s .c o m*/

    return _store.getFileSize(companyId, repositoryId, safeFileName);
}

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

License:Open Source License

public boolean hasDirectory(long companyId, long repositoryId, String dirName)
        throws PortalException, SystemException {

    String safeDirName = FileUtil.encodeSafeFileName(dirName);

    return _store.hasDirectory(companyId, repositoryId, safeDirName);
}

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

License:Open Source License

public boolean hasFile(long companyId, long repositoryId, String fileName)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName)) {

        return true;
    }/*from  w  ww . j a v  a 2  s.com*/

    return _store.hasFile(companyId, repositoryId, safeFileName);
}

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

License:Open Source License

public boolean hasFile(long companyId, long repositoryId, String fileName, String versionLabel)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    if (!safeFileName.equals(fileName) && _store.hasFile(companyId, repositoryId, fileName, versionLabel)) {

        return true;
    }//from  w ww.j a  v a2  s.c o  m

    return _store.hasFile(companyId, repositoryId, safeFileName, versionLabel);
}

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

License:Open Source License

public void updateFile(long companyId, long repositoryId, long newRepositoryId, String fileName)
        throws PortalException, SystemException {

    String safeFileName = FileUtil.encodeSafeFileName(fileName);

    renameUnsafeFile(companyId, repositoryId, fileName, safeFileName);

    _store.updateFile(companyId, repositoryId, newRepositoryId, safeFileName);
}