@BeforeClass
  public static void setUpClass() throws Exception {
    _userClassNameId = PortalUtil.getClassNameId(User.class.getName());

    Class<?> clazz = SocialActivitySettingLocalServiceTest.class;

    String xml = new String(FileUtil.getBytes(clazz, "dependencies/liferay-social.xml"));

    SocialConfigurationUtil.read(clazz.getClassLoader(), new String[] {xml});
  }
示例#2
0
  protected void initSocial(PluginPackage pluginPackage) throws Exception {
    ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

    ServletContext servletContext = getServletContext();

    String[] xmls =
        new String[] {
          HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/liferay-social.xml")),
          HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/liferay-social-ext.xml"))
        };

    SocialConfigurationUtil.read(classLoader, xmls);
  }
示例#3
0
  protected Map<String, Boolean> getActivitySettingsMap(ThemeDisplay themeDisplay)
      throws Exception {

    Map<String, Boolean> activitySettingsMap = new LinkedHashMap<>();

    List<SocialActivitySetting> activitySettings =
        SocialActivitySettingServiceUtil.getActivitySettings(
            themeDisplay.getSiteGroupIdOrLiveGroupId());

    String[] modelNames = SocialConfigurationUtil.getActivityModelNames();

    Comparator<String> comparator = new ModelResourceComparator(themeDisplay.getLocale());

    Arrays.sort(modelNames, comparator);

    for (String modelName : modelNames) {
      List<SocialActivityDefinition> activityDefinitions =
          SocialActivitySettingServiceUtil.getActivityDefinitions(
              themeDisplay.getScopeGroupId(), modelName);

      for (SocialActivityDefinition activityDefinition : activityDefinitions) {

        if (activityDefinition.isCountersEnabled()) {
          activitySettingsMap.put(modelName, false);

          break;
        }
      }
    }

    for (SocialActivitySetting activitySetting : activitySettings) {
      String name = activitySetting.getName();

      if (name.equals("enabled")
          && activitySettingsMap.containsKey(activitySetting.getClassName())) {

        activitySettingsMap.put(
            activitySetting.getClassName(), GetterUtil.getBoolean(activitySetting.getValue()));
      }
    }

    return activitySettingsMap;
  }