Example usage for com.liferay.portal.kernel.deploy DeployManagerUtil isDeployed

List of usage examples for com.liferay.portal.kernel.deploy DeployManagerUtil isDeployed

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.deploy DeployManagerUtil isDeployed.

Prototype

public static boolean isDeployed(String context) 

Source Link

Usage

From source file:com.liferay.google.GoogleOAuth.java

License:Open Source License

protected GoogleAuthorizationCodeFlow getFlow(long companyId) throws IOException, SystemException {

    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();

    GoogleAuthorizationCodeFlow.Builder builder = null;

    String googleClientId = PrefsPropsUtil.getString(companyId, "google.client.id");
    String googleClientSecret = PrefsPropsUtil.getString(companyId, "google.client.secret");

    List<String> scopes = null;

    if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) {
        scopes = _SCOPES_DRIVE;//from   w w w. java 2  s.  com
    } else {
        scopes = _SCOPES_LOGIN;
    }

    if (Validator.isNull(googleClientId) || Validator.isNull(googleClientSecret)) {

        InputStream is = GoogleOAuth.class.getResourceAsStream(_CLIENT_SECRETS_LOCATION);

        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jsonFactory, new InputStreamReader(is));

        builder = new GoogleAuthorizationCodeFlow.Builder(httpTransport, jsonFactory, clientSecrets, scopes);
    } else {
        builder = new GoogleAuthorizationCodeFlow.Builder(httpTransport, jsonFactory, googleClientId,
                googleClientSecret, scopes);
    }

    String accessType = "online";

    if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) {
        accessType = "offline";
    }

    builder.setAccessType(accessType);
    builder.setApprovalPrompt("force");

    return builder.build();
}

From source file:com.liferay.google.GoogleOAuth.java

License:Open Source License

protected User setGoogleCredentials(HttpSession session, long companyId, Credential credential)
        throws Exception {

    Userinfo userinfo = getUserInfo(credential);

    if (userinfo == null) {
        return null;
    }/*from  w  w w . java2  s. c  o  m*/

    User user = null;

    String emailAddress = userinfo.getEmail();

    if ((user == null) && Validator.isNotNull(emailAddress)) {
        user = UserLocalServiceUtil.fetchUserByEmailAddress(companyId, emailAddress);

        if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) {

            session.setAttribute("GOOGLE_USER_EMAIL_ADDRESS", emailAddress);
        }
    }

    if (user != null) {
        if (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
            session.setAttribute("GOOGLE_INCOMPLETE_USER_ID", userinfo.getId());

            user.setEmailAddress(userinfo.getEmail());
            user.setFirstName(userinfo.getGivenName());
            user.setLastName(userinfo.getFamilyName());

            return user;
        }

        user = updateUser(user, userinfo);
    } else {
        user = addUser(session, companyId, userinfo);
    }

    if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) {
        updateCustomFields(user, userinfo, credential.getAccessToken(), credential.getRefreshToken());
    }

    return user;
}

From source file:com.liferay.google.login.hook.action.GoogleLoginAction.java

License:Open Source License

protected GoogleAuthorizationCodeFlow getGoogleAuthorizationCodeFlow(long companyId) throws Exception {

    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();
    String googleClientId = PrefsPropsUtil.getString(companyId, "google-client-id");
    String googleClientSecret = PrefsPropsUtil.getString(companyId, "google-client-secret");

    List<String> scopes = null;

    if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) {
        scopes = _SCOPES_DRIVE;//w w w .  ja  va  2 s.com
    } else {
        scopes = _SCOPES_LOGIN;
    }

    GoogleAuthorizationCodeFlow.Builder builder = new GoogleAuthorizationCodeFlow.Builder(httpTransport,
            jsonFactory, googleClientId, googleClientSecret, scopes);

    String accessType = "online";

    if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) {
        accessType = "offline";
    }

    builder.setAccessType(accessType);

    builder.setApprovalPrompt("force");

    return builder.build();
}

From source file:com.liferay.google.login.hook.action.GoogleLoginAction.java

License:Open Source License

protected User setCredential(HttpSession session, long companyId, Credential credential) throws Exception {

    Userinfo userinfo = getUserinfo(credential);

    if (userinfo == null) {
        return null;
    }//w  w w .  j a va  2  s.  c  o m

    User user = null;

    String emailAddress = userinfo.getEmail();

    if ((user == null) && Validator.isNotNull(emailAddress)) {
        user = UserLocalServiceUtil.fetchUserByEmailAddress(companyId, emailAddress);

        if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) {

            session.setAttribute(WebKeys.GOOGLE_USER_EMAIL_ADDRESS, emailAddress);
        }
    }

    if (user != null) {
        if (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE) {
            session.setAttribute(WebKeys.GOOGLE_INCOMPLETE_USER_ID, userinfo.getId());

            user.setEmailAddress(userinfo.getEmail());
            user.setFirstName(userinfo.getGivenName());
            user.setLastName(userinfo.getFamilyName());

            return user;
        }

        user = updateUser(user, userinfo);
    } else {
        user = addUser(session, companyId, userinfo);
    }

    if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) {
        updateExpandoValues(user, userinfo, credential.getAccessToken(), credential.getRefreshToken());
    }

    return user;
}

From source file:com.liferay.marketplace.model.impl.AppImpl.java

License:Open Source License

@Override
public boolean isInstalled() {
    List<Module> modules = ModuleLocalServiceUtil.getModules(getAppId());

    if (modules.isEmpty()) {
        return false;
    }//from ww  w .ja  va2 s . c o m

    for (Module module : modules) {
        if (Validator.isNotNull(module.getBundleSymbolicName())) {
            if (!BundleUtil.isActive(module.getBundleSymbolicName(), module.getBundleVersion())) {

                return false;
            }
        } else if (Validator.isNotNull(module.getContextName())) {
            if (!DeployManagerUtil.isDeployed(module.getContextName())) {
                return false;
            }
        }
    }

    return true;
}