コード例 #1
0
  protected void addFileEntryResources(DLFileEntry dlFileEntry, ServiceContext serviceContext)
      throws PortalException {

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

      resourceLocalService.addResources(
          dlFileEntry.getCompanyId(),
          dlFileEntry.getGroupId(),
          dlFileEntry.getUserId(),
          DLFileEntry.class.getName(),
          dlFileEntry.getFileEntryId(),
          false,
          serviceContext.isAddGroupPermissions(),
          serviceContext.isAddGuestPermissions());
    } else {
      if (serviceContext.isDeriveDefaultPermissions()) {
        serviceContext.deriveDefaultPermissions(
            dlFileEntry.getRepositoryId(), DLFileEntryConstants.getClassName());
      }

      resourceLocalService.addModelResources(
          dlFileEntry.getCompanyId(),
          dlFileEntry.getGroupId(),
          dlFileEntry.getUserId(),
          DLFileEntry.class.getName(),
          dlFileEntry.getFileEntryId(),
          serviceContext.getModelPermissions());
    }
  }
コード例 #2
0
  @Override
  public void validate(
      long groupId, String className, long classTypePK, long[] categoryIds, String[] entryNames)
      throws PortalException {

    if (className.equals(DLFileEntryConstants.getClassName())) {
      DLFileEntry dlFileEntry = _dlFileEntryLocalService.fetchDLFileEntry(classTypePK);

      if ((dlFileEntry == null) || (dlFileEntry.getRepositoryId() != groupId)) {

        return;
      }
    }

    List<AssetVocabulary> assetVocabularies =
        _assetVocabularyLocalService.getGroupVocabularies(groupId, false);

    Group group = _groupLocalService.getGroup(groupId);

    if (!group.isCompany()) {
      Group companyGroup = _groupLocalService.fetchCompanyGroup(group.getCompanyId());

      if (companyGroup != null) {
        assetVocabularies = ListUtil.copy(assetVocabularies);

        assetVocabularies.addAll(
            _assetVocabularyLocalService.getGroupVocabularies(companyGroup.getGroupId()));
      }
    }

    long classNameId = _classNameLocalService.getClassNameId(className);

    if (isCategorizable(classNameId)) {
      for (AssetVocabulary assetVocabulary : assetVocabularies) {
        validate(classNameId, classTypePK, categoryIds, assetVocabulary);
      }
    }
  }