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

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

Introduction

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

Prototype

public static boolean exists(String fileName) 

Source Link

Usage

From source file:com.liferay.maven.plugins.compatibility.WSDDBuilder.java

License:Open Source License

public void build() throws Exception {
    if (!FileUtil.exists(_serverConfigFileName)) {
        ClassLoader classLoader = getClass().getClassLoader();

        String serverConfigContent = StringUtil.read(classLoader,
                "com/liferay/portal/tools/dependencies/server-config.wsdd");

        FileUtil.write(_serverConfigFileName, serverConfigContent);
    }/*  w w  w.  j  a v a  2 s  .co m*/

    Document document = SAXReaderUtil.read(new File(_fileName), true);

    Element rootElement = document.getRootElement();

    String packagePath = rootElement.attributeValue("package-path");

    Element portletElement = rootElement.element("portlet");
    Element namespaceElement = rootElement.element("namespace");

    if (portletElement != null) {
        _portletShortName = portletElement.attributeValue("short-name");
    } else {
        _portletShortName = namespaceElement.getText();
    }

    _outputPath += StringUtil.replace(packagePath, ".", "/") + "/service/http";

    _packagePath = packagePath;

    List<Element> entityElements = rootElement.elements("entity");

    for (Element entityElement : entityElements) {
        String entityName = entityElement.attributeValue("name");

        boolean remoteService = GetterUtil.getBoolean(entityElement.attributeValue("remote-service"), true);

        if (remoteService) {
            _createServiceWSDD(entityName);

            WSDDMerger.merge(_outputPath + "/" + entityName + "Service_deploy.wsdd", _serverConfigFileName);
        }
    }
}

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 ww.  jav a2 s .co 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;
}