protected void updateCustomFields(
      User user, Userinfo userinfo, String accessToken, String refreshToken)
      throws PortalException, SystemException {

    ExpandoValueLocalServiceUtil.addValue(
        user.getCompanyId(),
        User.class.getName(),
        ExpandoTableConstants.DEFAULT_TABLE_NAME,
        GOOGLE_ACCESS_TOKEN,
        user.getUserId(),
        accessToken);

    ExpandoValueLocalServiceUtil.addValue(
        user.getCompanyId(),
        User.class.getName(),
        ExpandoTableConstants.DEFAULT_TABLE_NAME,
        GOOGLE_REFRESH_TOKEN,
        user.getUserId(),
        refreshToken);

    ExpandoValueLocalServiceUtil.addValue(
        user.getCompanyId(),
        User.class.getName(),
        ExpandoTableConstants.DEFAULT_TABLE_NAME,
        GOOGLE_USER_ID,
        user.getUserId(),
        userinfo.getId());
  }
  protected void populateExpandoAttributes(
      ExpandoBridge expandoBridge, Map<String, String[]> expandoAttributes) {

    for (Map.Entry<String, String[]> expandoAttribute : expandoAttributes.entrySet()) {

      String name = expandoAttribute.getKey();

      if (!expandoBridge.hasAttribute(name)) {
        continue;
      }

      int type = expandoBridge.getAttributeType(name);

      Serializable value =
          ExpandoConverterUtil.getAttributeFromStringArray(type, expandoAttribute.getValue());

      try {
        ExpandoValueLocalServiceUtil.addValue(
            expandoBridge.getCompanyId(),
            expandoBridge.getClassName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME,
            name,
            expandoBridge.getClassPK(),
            value);
      } catch (Exception e) {
        _log.error(e, e);
      }
    }
  }
Esempio n. 3
0
  protected void updateMPExpandoColumns(long companyId) throws Exception {
    ExpandoTable expandoTable = null;

    try {
      expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), "MP");
    } catch (NoSuchTableException nste) {
      return;
    }

    ExpandoColumn oldExpandoColumn =
        ExpandoColumnLocalServiceUtil.getColumn(
            companyId, User.class.getName(), expandoTable.getName(), "client-id");

    if (oldExpandoColumn == null) {
      return;
    }

    ExpandoColumn newExpandoColumn =
        ExpandoColumnLocalServiceUtil.getColumn(
            companyId, User.class.getName(), expandoTable.getName(), "clientId");

    if (newExpandoColumn == null) {
      newExpandoColumn =
          ExpandoColumnLocalServiceUtil.updateColumn(
              oldExpandoColumn.getColumnId(), "clientId", ExpandoColumnConstants.STRING);
    }

    List<ExpandoValue> expandoValues =
        ExpandoValueLocalServiceUtil.getColumnValues(
            oldExpandoColumn.getColumnId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    for (ExpandoValue expandoValue : expandoValues) {
      ExpandoValueLocalServiceUtil.addValue(
          expandoValue.getCompanyId(), User.class.getName(),
          expandoTable.getName(), newExpandoColumn.getName(),
          expandoValue.getClassPK(), expandoValue.getString());
    }

    ExpandoColumnLocalServiceUtil.deleteColumn(oldExpandoColumn.getColumnId());
  }