protected DLFileEntry addDLFileEntry(long folderId, boolean appendExtension) throws Exception {

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

    String sourceFileName = RandomTestUtil.randomString();

    if (appendExtension) {
      sourceFileName = sourceFileName.concat(".pdf");
    }

    String fileEntryTitle = RandomTestUtil.randomString();

    return DLFileEntryLocalServiceUtil.addFileEntry(
        TestPropsValues.getUserId(),
        _group.getGroupId(),
        _group.getGroupId(),
        folderId,
        sourceFileName,
        null,
        fileEntryTitle,
        RandomTestUtil.randomString(),
        StringPool.BLANK,
        DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT,
        null,
        null,
        new ByteArrayInputStream(_CONTENT.getBytes()),
        0,
        serviceContext);
  }
Example #2
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);
  }