コード例 #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
  protected void testMigrateDL(long folderId) throws Exception {
    FileEntry fileEntry =
        addFileEntry(
            folderId,
            RandomTestUtil.randomString() + ".txt",
            ContentTypes.TEXT_PLAIN,
            RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE));

    _convertProcess.convert();

    DLFileEntry dlFileEntry = (DLFileEntry) fileEntry.getModel();

    DLContentLocalServiceUtil.getContent(
        dlFileEntry.getCompanyId(),
        DLFolderConstants.getDataRepositoryId(
            dlFileEntry.getRepositoryId(), dlFileEntry.getFolderId()),
        dlFileEntry.getName());
  }
コード例 #3
0
  @Test
  public void testMigrateMB() throws Exception {
    MBMessage mbMessage = addMBMessageAttachment();

    _convertProcess.convert();

    DLFileEntry dlFileEntry = getDLFileEntry(mbMessage);

    String title = dlFileEntry.getTitle();

    Assert.assertTrue(title.endsWith(".docx"));

    DLContentLocalServiceUtil.getContent(
        dlFileEntry.getCompanyId(),
        DLFolderConstants.getDataRepositoryId(
            dlFileEntry.getRepositoryId(), dlFileEntry.getFolderId()),
        dlFileEntry.getName());
  }
コード例 #4
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);
      }
    }
  }
コード例 #5
0
  protected void testMigrateAndCheckOldRepositoryFiles(Boolean delete) throws Exception {

    _convertProcess.setParameterValues(new String[] {_CLASS_NAME_DB_STORE, delete.toString()});

    FileEntry rootFileEntry =
        addFileEntry(
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString() + ".txt",
            ContentTypes.TEXT_PLAIN,
            RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE));

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId());

    Folder folder =
        DLAppServiceUtil.addFolder(
            _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString(),
            serviceContext);

    FileEntry folderFileEntry =
        addFileEntry(
            folder.getFolderId(),
            "liferay.jpg",
            ContentTypes.IMAGE_JPEG,
            FileUtil.getBytes(getClass(), "dependencies/liferay.jpg"));

    ImageProcessorUtil.generateImages(null, folderFileEntry.getFileVersion());

    _convertProcess.convert();

    DLFileEntry rootDLFileEntry = (DLFileEntry) rootFileEntry.getModel();

    Assert.assertNotEquals(
        delete,
        _sourceStore.hasFile(
            rootDLFileEntry.getCompanyId(),
            rootDLFileEntry.getDataRepositoryId(),
            rootDLFileEntry.getName()));

    DLFileEntry folderDLFileEntry = (DLFileEntry) folderFileEntry.getModel();

    Assert.assertNotEquals(
        delete,
        _sourceStore.hasDirectory(
            folderDLFileEntry.getCompanyId(),
            DLPreviewableProcessor.REPOSITORY_ID,
            DLPreviewableProcessor.THUMBNAIL_PATH));
    Assert.assertNotEquals(
        delete,
        _sourceStore.hasFile(
            folderDLFileEntry.getCompanyId(),
            folderDLFileEntry.getDataRepositoryId(),
            folderDLFileEntry.getName()));

    DLContentLocalServiceUtil.getContent(
        folderDLFileEntry.getCompanyId(),
        DLFolderConstants.getDataRepositoryId(
            folderDLFileEntry.getRepositoryId(), folderDLFileEntry.getFolderId()),
        folderDLFileEntry.getName());

    DLContentLocalServiceUtil.getContent(
        rootDLFileEntry.getCompanyId(),
        DLFolderConstants.getDataRepositoryId(
            rootDLFileEntry.getRepositoryId(), rootDLFileEntry.getFolderId()),
        rootDLFileEntry.getName());
  }
コード例 #6
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    DLFileEntry newDLFileEntry = _persistence.create(pk);

    newDLFileEntry.setUuid(RandomTestUtil.randomString());

    newDLFileEntry.setGroupId(RandomTestUtil.nextLong());

    newDLFileEntry.setCompanyId(RandomTestUtil.nextLong());

    newDLFileEntry.setUserId(RandomTestUtil.nextLong());

    newDLFileEntry.setUserName(RandomTestUtil.randomString());

    newDLFileEntry.setCreateDate(RandomTestUtil.nextDate());

    newDLFileEntry.setModifiedDate(RandomTestUtil.nextDate());

    newDLFileEntry.setClassNameId(RandomTestUtil.nextLong());

    newDLFileEntry.setClassPK(RandomTestUtil.nextLong());

    newDLFileEntry.setRepositoryId(RandomTestUtil.nextLong());

    newDLFileEntry.setFolderId(RandomTestUtil.nextLong());

    newDLFileEntry.setTreePath(RandomTestUtil.randomString());

    newDLFileEntry.setName(RandomTestUtil.randomString());

    newDLFileEntry.setFileName(RandomTestUtil.randomString());

    newDLFileEntry.setExtension(RandomTestUtil.randomString());

    newDLFileEntry.setMimeType(RandomTestUtil.randomString());

    newDLFileEntry.setTitle(RandomTestUtil.randomString());

    newDLFileEntry.setDescription(RandomTestUtil.randomString());

    newDLFileEntry.setExtraSettings(RandomTestUtil.randomString());

    newDLFileEntry.setFileEntryTypeId(RandomTestUtil.nextLong());

    newDLFileEntry.setVersion(RandomTestUtil.randomString());

    newDLFileEntry.setSize(RandomTestUtil.nextLong());

    newDLFileEntry.setReadCount(RandomTestUtil.nextInt());

    newDLFileEntry.setSmallImageId(RandomTestUtil.nextLong());

    newDLFileEntry.setLargeImageId(RandomTestUtil.nextLong());

    newDLFileEntry.setCustom1ImageId(RandomTestUtil.nextLong());

    newDLFileEntry.setCustom2ImageId(RandomTestUtil.nextLong());

    newDLFileEntry.setManualCheckInRequired(RandomTestUtil.randomBoolean());

    newDLFileEntry.setLastPublishDate(RandomTestUtil.nextDate());

    _dlFileEntries.add(_persistence.update(newDLFileEntry));

    DLFileEntry existingDLFileEntry = _persistence.findByPrimaryKey(newDLFileEntry.getPrimaryKey());

    Assert.assertEquals(existingDLFileEntry.getUuid(), newDLFileEntry.getUuid());
    Assert.assertEquals(existingDLFileEntry.getFileEntryId(), newDLFileEntry.getFileEntryId());
    Assert.assertEquals(existingDLFileEntry.getGroupId(), newDLFileEntry.getGroupId());
    Assert.assertEquals(existingDLFileEntry.getCompanyId(), newDLFileEntry.getCompanyId());
    Assert.assertEquals(existingDLFileEntry.getUserId(), newDLFileEntry.getUserId());
    Assert.assertEquals(existingDLFileEntry.getUserName(), newDLFileEntry.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileEntry.getCreateDate()),
        Time.getShortTimestamp(newDLFileEntry.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileEntry.getModifiedDate()),
        Time.getShortTimestamp(newDLFileEntry.getModifiedDate()));
    Assert.assertEquals(existingDLFileEntry.getClassNameId(), newDLFileEntry.getClassNameId());
    Assert.assertEquals(existingDLFileEntry.getClassPK(), newDLFileEntry.getClassPK());
    Assert.assertEquals(existingDLFileEntry.getRepositoryId(), newDLFileEntry.getRepositoryId());
    Assert.assertEquals(existingDLFileEntry.getFolderId(), newDLFileEntry.getFolderId());
    Assert.assertEquals(existingDLFileEntry.getTreePath(), newDLFileEntry.getTreePath());
    Assert.assertEquals(existingDLFileEntry.getName(), newDLFileEntry.getName());
    Assert.assertEquals(existingDLFileEntry.getFileName(), newDLFileEntry.getFileName());
    Assert.assertEquals(existingDLFileEntry.getExtension(), newDLFileEntry.getExtension());
    Assert.assertEquals(existingDLFileEntry.getMimeType(), newDLFileEntry.getMimeType());
    Assert.assertEquals(existingDLFileEntry.getTitle(), newDLFileEntry.getTitle());
    Assert.assertEquals(existingDLFileEntry.getDescription(), newDLFileEntry.getDescription());
    Assert.assertEquals(existingDLFileEntry.getExtraSettings(), newDLFileEntry.getExtraSettings());
    Assert.assertEquals(
        existingDLFileEntry.getFileEntryTypeId(), newDLFileEntry.getFileEntryTypeId());
    Assert.assertEquals(existingDLFileEntry.getVersion(), newDLFileEntry.getVersion());
    Assert.assertEquals(existingDLFileEntry.getSize(), newDLFileEntry.getSize());
    Assert.assertEquals(existingDLFileEntry.getReadCount(), newDLFileEntry.getReadCount());
    Assert.assertEquals(existingDLFileEntry.getSmallImageId(), newDLFileEntry.getSmallImageId());
    Assert.assertEquals(existingDLFileEntry.getLargeImageId(), newDLFileEntry.getLargeImageId());
    Assert.assertEquals(
        existingDLFileEntry.getCustom1ImageId(), newDLFileEntry.getCustom1ImageId());
    Assert.assertEquals(
        existingDLFileEntry.getCustom2ImageId(), newDLFileEntry.getCustom2ImageId());
    Assert.assertEquals(
        existingDLFileEntry.getManualCheckInRequired(), newDLFileEntry.getManualCheckInRequired());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileEntry.getLastPublishDate()),
        Time.getShortTimestamp(newDLFileEntry.getLastPublishDate()));
  }