예제 #1
0
  protected TemplateResource getErrorTemplateResource(String langType) {
    try {
      long companyId = CompanyThreadLocal.getCompanyId();

      JournalServiceConfiguration journalServiceConfiguration =
          ConfigurationProviderUtil.getCompanyConfiguration(
              JournalServiceConfiguration.class, companyId);

      String template = StringPool.BLANK;

      if (langType.equals(TemplateConstants.LANG_TYPE_FTL)) {
        template = journalServiceConfiguration.errorTemplateFTL();
      } else if (langType.equals(TemplateConstants.LANG_TYPE_VM)) {
        template = journalServiceConfiguration.errorTemplateVM();
      } else if (langType.equals(TemplateConstants.LANG_TYPE_XSL)) {
        template = journalServiceConfiguration.errorTemplateXSL();
      } else {
        return null;
      }

      return new StringTemplateResource(langType, template);
    } catch (Exception e) {
    }

    return null;
  }
  protected boolean isIndexAllArticleVersions() {
    JournalServiceConfiguration journalServiceConfiguration = null;

    try {
      journalServiceConfiguration =
          _configurationProvider.getCompanyConfiguration(
              JournalServiceConfiguration.class, CompanyThreadLocal.getCompanyId());

      return journalServiceConfiguration.indexAllArticleVersionsEnabled();
    } catch (Exception e) {
      _log.error(e, e);
    }

    return false;
  }
  /**
   * Deletes the user group.
   *
   * @param userGroup the user group
   * @return the deleted user group
   */
  @Override
  @SystemEvent(action = SystemEventConstants.ACTION_SKIP, type = SystemEventConstants.TYPE_DELETE)
  public UserGroup deleteUserGroup(UserGroup userGroup) throws PortalException {

    if (!CompanyThreadLocal.isDeleteInProcess()) {
      int count =
          userLocalService.getUserGroupUsersCount(
              userGroup.getUserGroupId(), WorkflowConstants.STATUS_APPROVED);

      if (count > 0) {
        throw new RequiredUserGroupException();
      }
    }

    // Expando

    expandoRowLocalService.deleteRows(userGroup.getUserGroupId());

    // Group

    Group group = userGroup.getGroup();

    groupLocalService.deleteGroup(group);

    // User group roles

    userGroupGroupRoleLocalService.deleteUserGroupGroupRolesByUserGroupId(
        userGroup.getUserGroupId());

    // Resources

    resourceLocalService.deleteResource(
        userGroup.getCompanyId(),
        UserGroup.class.getName(),
        ResourceConstants.SCOPE_INDIVIDUAL,
        userGroup.getUserGroupId());

    // User group

    userGroupPersistence.remove(userGroup);

    // Permission cache

    PermissionCacheUtil.clearCache();

    return userGroup;
  }
  @Override
  public List<Long> filterFindByR_U_T(long groupId, long userId, long[] typePKs) {

    if (ArrayUtil.isEmpty(typePKs)) {
      return Collections.emptyList();
    }

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(getClass(), FIND_BY_TYPE_PKS);

      sql =
          StringUtil.replace(
              sql,
              new String[] {"[$TYPE_PKS$]", "[$ROLE_IDS_OR_OWNER_ID$]"},
              new String[] {getTypePKsSQL(typePKs), getRoleOwnerIdsSQL(groupId, userId)});

      SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);

      sqlQuery.addScalar("primKey", Type.LONG);

      QueryPos qPos = QueryPos.getInstance(sqlQuery);

      qPos.add(CompanyThreadLocal.getCompanyId());
      qPos.add(ResourceConstants.SCOPE_INDIVIDUAL);

      return (List<Long>) sqlQuery.list();
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }