Esempio n. 1
0
  public static DLFolder addDLFolder(
      long groupId, long parentFolderId, boolean deleteExisting, ServiceContext serviceContext)
      throws Exception {

    String name = RandomTestUtil.randomString();

    if (deleteExisting) {
      try {
        DLFolder folder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, name);

        DLFolderLocalServiceUtil.deleteFolder(folder.getFolderId());
      } catch (NoSuchFolderException nsfe) {
      }
    }

    return DLFolderLocalServiceUtil.addFolder(
        TestPropsValues.getUserId(),
        groupId,
        groupId,
        false,
        parentFolderId,
        name,
        StringPool.BLANK,
        false,
        serviceContext);
  }
  @Test
  public void testCopyFileEntryWithoutExtensionInRootFolderToFolder() throws Exception {

    DLFileEntry dlFileEntry = addDLFileEntry(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, false);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    DLFolder destFolder =
        DLFolderLocalServiceUtil.addFolder(
            TestPropsValues.getUserId(),
            _group.getGroupId(),
            _group.getGroupId(),
            false,
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString(),
            false,
            serviceContext);

    DLFileEntryServiceUtil.copyFileEntry(
        _group.getGroupId(),
        _group.getGroupId(),
        dlFileEntry.getFileEntryId(),
        destFolder.getFolderId(),
        serviceContext);
  }
Esempio n. 3
0
  public static DLFileEntry addDLFileEntry(long dlFolderId) throws Exception {
    DLFolder dlFolder = DLFolderLocalServiceUtil.fetchDLFolder(dlFolderId);

    byte[] bytes = RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE);

    InputStream is = new ByteArrayInputStream(bytes);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(dlFolder.getGroupId());

    return DLFileEntryLocalServiceUtil.addFileEntry(
        TestPropsValues.getUserId(),
        dlFolder.getGroupId(),
        dlFolder.getRepositoryId(),
        dlFolder.getFolderId(),
        RandomTestUtil.randomString(),
        ContentTypes.TEXT_PLAIN,
        RandomTestUtil.randomString(),
        StringPool.BLANK,
        StringPool.BLANK,
        DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT,
        null,
        null,
        is,
        bytes.length,
        serviceContext);
  }
  @Override
  public DLFolder getFolder() throws PortalException {
    if (getFolderId() <= 0) {
      return new DLFolderImpl();
    }

    return DLFolderLocalServiceUtil.getFolder(getFolderId());
  }