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

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

Introduction

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

Prototype

public static void mkdirs(String pathName) 

Source Link

Usage

From source file:com.liferay.opensocial.shindig.oauth.LiferayOAuthStoreProvider.java

License:Open Source License

private OAuthConsumer _getOAuthConsumer(String keyFileName, String keyName) {

    OAuthConsumer oAuthConsumer = new OAuthConsumerImpl();

    oAuthConsumer.setConsumerKey(_DEFAULT_CONSUMER_KEY);
    oAuthConsumer.setServiceName(_DEFAULT_SERVICE_NAME);

    String consumerSecret = null;

    String path = PropsUtil.get(PropsKeys.LIFERAY_HOME).concat(_KEY_DIR);

    path = path.replaceAll(StringPool.QUOTE, StringPool.BLANK);

    keyFileName = path.concat(keyFileName);

    try {/*from   w  w  w  .  ja v a2 s  . c o  m*/
        consumerSecret = FileUtil.read(keyFileName);
    } catch (Exception e) {
    } finally {
        if (consumerSecret == null) {
            if (!FileUtil.exists(path)) {
                FileUtil.mkdirs(path);
            }

            if (_log.isWarnEnabled()) {
                _log.warn("Unable to load OAuth key from " + keyFileName);
            }

            return null;
        }
    }

    consumerSecret = _convertFromOpenSsl(consumerSecret);

    oAuthConsumer.setConsumerSecret(consumerSecret);
    oAuthConsumer.setKeyType(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE);
    oAuthConsumer.setKeyName(keyName);

    return oAuthConsumer;
}

From source file:com.liferay.portlet.documentlibrary.util.AudioProcessorImpl.java

License:Open Source License

private AudioProcessorImpl() {
    FileUtil.mkdirs(PREVIEW_TMP_PATH);
}

From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java

License:Open Source License

protected void initialize() {
    try {/*from w  w  w .  j  ava 2  s  .  c o  m*/
        FileUtil.mkdirs(PREVIEW_TMP_PATH);
        FileUtil.mkdirs(THUMBNAIL_TMP_PATH);

        reset();
    } catch (Exception e) {
        _log.warn(e, e);
    }
}

From source file:com.liferay.portlet.documentlibrary.util.VideoProcessorImpl.java

License:Open Source License

private VideoProcessorImpl() {
    boolean valid = true;

    if ((_PREVIEW_TYPES.length == 0) || (_PREVIEW_TYPES.length > 2)) {
        valid = false;// w ww  . j  a  v  a  2 s  . c  om
    } else {
        for (String previewType : _PREVIEW_TYPES) {
            if (!previewType.equals("mp4") && !previewType.equals("ogv")) {
                valid = false;

                break;
            }
        }
    }

    if (!valid && _log.isWarnEnabled()) {
        StringBundler sb = new StringBundler(5);

        sb.append("Liferay is incorrectly configured to generate video ");
        sb.append("previews using video containers other than MP4 or ");
        sb.append("OGV. Please change the property ");
        sb.append(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_CONTAINERS);
        sb.append(" in portal-ext.properties.");

        _log.warn(sb.toString());
    }

    FileUtil.mkdirs(PREVIEW_TMP_PATH);
    FileUtil.mkdirs(THUMBNAIL_TMP_PATH);
}

From source file:com.liferay.web.extender.internal.webbundle.WebBundleProcessor.java

License:Open Source License

public void process() throws IOException {
    String webContextpath = MapUtil.getString(_parameterMap, OSGiConstants.WEB_CONTEXTPATH);

    if (!webContextpath.startsWith(StringPool.SLASH)) {
        webContextpath = StringPool.SLASH.concat(webContextpath);
    }/*from w w  w .  j  a  va  2  s .c  o  m*/

    List<AutoDeployListener> autoDeployListeners = GlobalStartupAction.getAutoDeployListeners();

    for (AutoDeployListener autoDeployListener : autoDeployListeners) {
        if (autoDeployListener instanceof OSGiAutoDeployListener) {
            continue;
        }

        try {
            autoDeployListener.deploy(_file, webContextpath);
        } catch (AutoDeployException e) {
            e.printStackTrace();
        }
    }

    String deployDir = null;

    try {
        deployDir = DeployUtil.getAutoDeployDestDir();
    } catch (Exception e) {
        throw new IOException(e);
    }

    _deployedAppFolder = new File(deployDir, webContextpath);

    if (!_deployedAppFolder.exists() || !_deployedAppFolder.isDirectory()) {
        return;
    }

    File manifestFile = new File(_deployedAppFolder, "META-INF/MANIFEST.MF");

    if (!manifestFile.exists()) {
        FileUtil.mkdirs(manifestFile.getParent());

        manifestFile.createNewFile();
    }

    Manifest manifest = new Manifest();

    FileInputStream fis = new FileInputStream(manifestFile);

    try {
        manifest.read(fis);
    } finally {
        fis.close();
    }

    _resourcePaths = new ArrayList<String>();

    processPaths(_deployedAppFolder, _deployedAppFolder.toURI());

    Attributes attributes = manifest.getMainAttributes();

    attributes.putValue(OSGiConstants.WEB_CONTEXTPATH, webContextpath);

    // If it's not a bundle, then we need to manipulate it into one. The
    // spec states that this is only true when the Manifest does not contain
    // a Bundle_SymbolicName header.

    if (!attributes.containsKey(Constants.BUNDLE_SYMBOLICNAME)) {
        processBundleSymbolicName(attributes, webContextpath);
        processBundleVersion(attributes);
        processBundleManifestVersion(attributes);
        processPortletXML(webContextpath);
        processLiferayPortletXML(webContextpath);

        // The order of these operations is important

        processBundleClassPath(attributes);
        processDeclarativeReferences(attributes);

        processExportImportPackage(attributes);
    }

    if (!attributes.containsKey(Attributes.Name.MANIFEST_VERSION.toString())) {

        attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
    }

    FileOutputStream fos = new FileOutputStream(manifestFile);

    try {
        manifest.write(fos);
    } finally {
        fos.close();
    }
}

From source file:com.sohlman.liferay.bffss.service.impl.FileDataLocalServiceImpl.java

License:Open Source License

protected synchronized File getRootDirFromConfiguration(long companyId) {
    if (_rootDir != null) {
        return _rootDir;
    }//from w  w w .  j  av a  2  s  .com
    try {
        BackupFriendlyFileSystemStoreConfiguration backupFriendlyFileSystemStoreConfiguration = getBackupFriendlyFileSystemStoreConfiguration(
                companyId);

        String rootDir = backupFriendlyFileSystemStoreConfiguration.rootDir();

        if ("".equals(rootDir)) {
            rootDir = "data/document_library";
        }

        _rootDir = new File(rootDir);

        if (!_rootDir.isAbsolute()) {
            _rootDir = new File(PropsUtil.get(PropsKeys.LIFERAY_HOME), rootDir);
        }

        FileUtil.mkdirs(_rootDir);

        return _rootDir;
    } catch (ConfigurationException e) {
        throw new SystemException(e.getMessage());
    } catch (IOException ioe) {
        throw new SystemException(ioe);
    }
}