Example usage for com.liferay.portal.kernel.util PrefsPropsUtil getLong

List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getLong

Introduction

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

Prototype

public static long getLong(PortletPreferences preferences, String name, long defaultValue) 

Source Link

Usage

From source file:com.liferay.sync.service.impl.SyncPreferencesLocalServiceImpl.java

License:Open Source License

@Override
public OAuthApplication enableOAuth(long companyId, ServiceContext serviceContext) throws PortalException {

    long oAuthApplicationId = PrefsPropsUtil.getLong(companyId, PortletPropsKeys.SYNC_OAUTH_APPLICATION_ID, 0);

    OAuthApplication oAuthApplication = OAuthApplicationLocalServiceUtil
            .fetchOAuthApplication(oAuthApplicationId);

    if (oAuthApplication != null) {
        return oAuthApplication;
    }//from  w w w. j a va2s.co m

    oAuthApplication = OAuthApplicationLocalServiceUtil.addOAuthApplication(serviceContext.getUserId(),
            "Liferay Sync", StringPool.BLANK, OAuthApplicationConstants.ACCESS_WRITE, true,
            "http://liferay-sync", "http://liferay-sync", serviceContext);

    ClassLoader classLoader = getClassLoader();

    InputStream inputStream = classLoader.getResourceAsStream("/resources/images/logo.png");

    OAuthApplicationLocalServiceUtil.updateLogo(oAuthApplication.getOAuthApplicationId(), inputStream);

    return oAuthApplication;
}