Example usage for com.liferay.portal.kernel.util PropsKeys LIFERAY_HOME

List of usage examples for com.liferay.portal.kernel.util PropsKeys LIFERAY_HOME

Introduction

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

Prototype

String LIFERAY_HOME

To view the source code for com.liferay.portal.kernel.util PropsKeys LIFERAY_HOME.

Click Source Link

Usage

From source file:com.liferay.alloy.mvc.jsonwebservice.AlloyControllerInvokerManager.java

License:Open Source License

protected Class<? extends AlloyControllerInvoker> createAlloyControllerInvokerClass(
        Class<? extends AlloyController> controllerClass) throws NoClassNecessaryException {

    ClassLoader classLoader = controllerClass.getClassLoader();

    String alloyControllerInvokerClassName = getAlloyControllerInvokerClassName(controllerClass);

    Class<? extends AlloyControllerInvoker> alloyControllerInvokerClass = null;

    synchronized (classLoader) {
        try {//from   w  ww.j  a v  a2 s .c om
            Method defineClassMethod = ReflectionUtil.getDeclaredMethod(ClassLoader.class, "defineClass",
                    String.class, byte[].class, int.class, int.class);

            final byte[] classData = generateAlloyControllerInvokerClassData(controllerClass,
                    alloyControllerInvokerClassName);

            final String fileName = PropsUtil.get(PropsKeys.LIFERAY_HOME) + "/data/alloy/"
                    + getClassBinaryName(alloyControllerInvokerClassName) + ".class";

            ClassLoader customClassLoader = new ClassLoader(classLoader) {

                @Override
                public URL getResource(String name) {
                    if (fileName.contains(name)) {
                        File file = new File(fileName);

                        try {
                            FileUtil.write(file, classData);

                            URI uri = file.toURI();

                            return uri.toURL();
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                    }

                    return super.getResource(name);
                }

            };

            alloyControllerInvokerClass = (Class<? extends AlloyControllerInvoker>) defineClassMethod
                    .invoke(customClassLoader, alloyControllerInvokerClassName, classData, 0, classData.length);

            return alloyControllerInvokerClass;
        } catch (NoClassNecessaryException ncne) {
            throw ncne;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:com.liferay.google.apps.connector.auth.GoogleCredentialUtil.java

License:Open Source License

public static GoogleCredential getGoogleCredential() throws Exception {
    if (_googleCredential != null) {
        return _googleCredential;
    }//from www .j  a  v  a2  s. c o m

    GoogleCredential.Builder builder = new GoogleCredential.Builder();

    builder.setJsonFactory(new JacksonFactory());
    builder.setServiceAccountId(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_ID);

    File file = new File(PropsUtil.get(PropsKeys.LIFERAY_HOME)
            + PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_PRIVATE_KEY_P12_FILE);

    builder.setServiceAccountPrivateKeyFromP12File(file);

    builder.setServiceAccountScopes(Arrays.asList(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_SCOPES));
    builder.setServiceAccountUser(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_USER);
    builder.setTransport(new NetHttpTransport());

    _googleCredential = builder.build();

    return _googleCredential;
}

From source file:com.liferay.google.mail.groups.util.GoogleCredentialUtil.java

License:Open Source License

public static GoogleCredential getGoogleCredential() throws Exception {
    if (_googleCredential != null) {
        return _googleCredential;
    }/*from   www  .j a v a2 s  . c  om*/

    GoogleCredential.Builder builder = new GoogleCredential.Builder();

    builder.setJsonFactory(new JacksonFactory());
    builder.setServiceAccountId(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_ID);

    File file = new File(PropsUtil.get(PropsKeys.LIFERAY_HOME)
            + PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_PRIVATE_KEY_P12_FILE);

    builder.setServiceAccountPrivateKeyFromP12File(file);

    builder.setServiceAccountScopes(_SCOPES);
    builder.setServiceAccountUser(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_USER);
    builder.setTransport(new NetHttpTransport());

    _googleCredential = builder.build();

    return _googleCredential;
}

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   www.  j a v  a 2  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.petra.log4j.Log4JUtil.java

License:Open Source License

private static String _getLiferayHome() {
    if (_liferayHome == null) {
        _liferayHome = PropsUtil.get(PropsKeys.LIFERAY_HOME);
    }/*from  w w  w .  j  a  va 2  s.  c  om*/

    return _liferayHome;
}

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

License:Open Source License

private void _generateAudioXuggler(FileVersion fileVersion, File srcFile, File destFile) throws Exception {

    StopWatch stopWatch = null;/*from   w  w  w  .  j  a  v a 2s  .  c  om*/

    if (_log.isInfoEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();
    }

    try {
        if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) {
            ProcessCallable<String> processCallable = new LiferayAudioProcessCallable(
                    ServerDetector.getServerId(), PropsUtil.get(PropsKeys.LIFERAY_HOME),
                    Log4JUtil.getCustomLogSettings(), srcFile.getCanonicalPath(), destFile.getCanonicalPath());

            ProcessExecutor.execute(processCallable, ClassPathUtil.getPortalClassPath());
        } else {
            LiferayConverter liferayConverter = new LiferayAudioConverter(srcFile.getCanonicalPath(),
                    destFile.getCanonicalPath());

            liferayConverter.convert();
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH, getPreviewFilePath(fileVersion), destFile);

    if (_log.isInfoEnabled()) {
        _log.info("Xuggler generated a preview audio for " + fileVersion.getTitle() + " in " + stopWatch);
    }
}

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

License:Open Source License

private void _generateThumbnailXuggler(FileVersion fileVersion, File file, int height, int width)
        throws Exception {

    StopWatch stopWatch = null;/*from   ww  w .j a  v a2s.c o m*/

    if (_log.isInfoEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();
    }

    String tempFileId = DLUtil.getTempFileId(fileVersion.getFileEntryId(), fileVersion.getVersion());

    File thumbnailTempFile = getThumbnailTempFile(tempFileId);

    try {
        try {
            if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) {
                ProcessCallable<String> processCallable = new LiferayVideoThumbnailProcessCallable(
                        ServerDetector.getServerId(), PropsUtil.get(PropsKeys.LIFERAY_HOME),
                        Log4JUtil.getCustomLogSettings(), file.getCanonicalPath(), thumbnailTempFile,
                        THUMBNAIL_TYPE, height, width,
                        PropsValues.DL_FILE_ENTRY_THUMBNAIL_VIDEO_FRAME_PERCENTAGE);

                ProcessExecutor.execute(processCallable, ClassPathUtil.getPortalClassPath());
            } else {
                LiferayConverter liferayConverter = new LiferayVideoThumbnailConverter(file.getCanonicalPath(),
                        thumbnailTempFile, THUMBNAIL_TYPE, height, width,
                        PropsValues.DL_FILE_ENTRY_THUMBNAIL_VIDEO_FRAME_PERCENTAGE);

                liferayConverter.convert();
            }
        } catch (Exception e) {
            _log.error(e, e);
        }

        storeThumbnailImages(fileVersion, thumbnailTempFile);

        if (_log.isInfoEnabled()) {
            _log.info("Xuggler generated a thumbnail for " + fileVersion.getTitle() + " in " + stopWatch);
        }
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        FileUtil.delete(thumbnailTempFile);
    }
}

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

License:Open Source License

private void _generateVideoXuggler(FileVersion fileVersion, File srcFile, File destFile, String containerType)
        throws Exception {

    if (!_isGeneratePreview(fileVersion, containerType)) {
        return;//  w ww.  java  2  s  . c  o  m
    }

    StopWatch stopWatch = null;

    if (_log.isInfoEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();
    }

    if (PropsValues.DL_FILE_ENTRY_PREVIEW_FORK_PROCESS_ENABLED) {
        ProcessCallable<String> processCallable = new LiferayVideoProcessCallable(ServerDetector.getServerId(),
                PropsUtil.get(PropsKeys.LIFERAY_HOME), Log4JUtil.getCustomLogSettings(),
                srcFile.getCanonicalPath(), destFile.getCanonicalPath(), FileUtil.createTempFileName(),
                PropsUtil.getProperties(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO, false),
                PropsUtil.getProperties(PropsKeys.XUGGLER_FFPRESET, true));

        ProcessExecutor.execute(processCallable, ClassPathUtil.getPortalClassPath());
    } else {
        LiferayConverter liferayConverter = new LiferayVideoConverter(srcFile.getCanonicalPath(),
                destFile.getCanonicalPath(), FileUtil.createTempFileName(),
                PropsUtil.getProperties(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO, false),
                PropsUtil.getProperties(PropsKeys.XUGGLER_FFPRESET, true));

        liferayConverter.convert();
    }

    addFileToStore(fileVersion.getCompanyId(), PREVIEW_PATH, getPreviewFilePath(fileVersion, containerType),
            destFile);

    if (_log.isInfoEnabled()) {
        _log.info("Xuggler generated a " + containerType + " preview video for " + fileVersion.getTitle()
                + " in " + stopWatch);
    }
}

From source file:com.liferay.server.manager.internal.executor.OutputLogExecutor.java

License:Open Source License

protected File getLogFile() {
    File logFile = null;//from ww  w. j av a 2s.c  o m

    if (ServerDetector.isJBoss()) {
        File logDirectory = new File(System.getProperty("jboss.server.log.dir"));

        logFile = new File(logDirectory, "server.log");
    } else {
        logFile = new File(StringBundler.concat(PropsUtil.get(PropsKeys.LIFERAY_HOME), "/logs/liferay.",
                getLiferayDateString(), ".log"));
    }

    return logFile;
}

From source file:com.liferay.servermanager.executor.OutputLogExecutor.java

License:Open Source License

protected File getLogFile() {
    File logFile = null;//  w w  w.j av a  2s  . com

    if (ServerDetector.isJBoss()) {
        File logDirectory = new File(System.getProperty("jboss.server.log.dir"));

        logFile = new File(logDirectory, "server.log");
    } else {
        logFile = new File(
                PropsUtil.get(PropsKeys.LIFERAY_HOME) + "/logs/liferay." + getLiferayDateString() + ".log");
    }

    return logFile;
}