コード例 #1
0
    @Override
    protected void doRun() throws Exception {
      try {
        FileEntry fileEntry = DLAppServiceUtil.getFileEntry(_fileEntryIds[_index]);

        InputStream is = fileEntry.getContentStream();

        String content = StringUtil.read(is);

        if (CONTENT.equals(content)) {
          _log.debug("Retrieved file " + _index);

          _success = true;
        }
      } catch (Exception e) {
        _log.error("Unable to add file " + _index, e);
      }
    }
コード例 #2
0
  protected void assertFileEntryTitle(String fileName) throws PortalException {

    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(_fileEntry.getFileEntryId());

    Assert.assertEquals(fileName, fileEntry.getTitle());
  }
コード例 #3
0
  @Test
  public void testFileEntryTypeRestrictions() throws Exception {

    // Configure folder

    DLFolderLocalServiceUtil.updateFolder(
        _folder.getFolderId(),
        _folder.getParentFolderId(),
        _folder.getName(),
        _folder.getDescription(),
        _contractDLFileEntryType.getPrimaryKey(),
        ListUtil.toList(
            new long[] {
              _contractDLFileEntryType.getPrimaryKey(),
              _marketingBannerDLFileEntryType.getPrimaryKey()
            }),
        true,
        ServiceContextTestUtil.getServiceContext(_group.getGroupId()));

    // Add file to folder

    String name = "Test.txt";
    byte[] bytes = _CONTENT.getBytes();

    FileEntry fileEntry =
        DLAppServiceUtil.addFileEntry(
            _group.getGroupId(),
            _folder.getFolderId(),
            name,
            ContentTypes.TEXT_PLAIN,
            name,
            "",
            "",
            bytes,
            ServiceContextTestUtil.getServiceContext(_group.getGroupId()));

    assertFileEntryType(fileEntry, _contractDLFileEntryType);

    // Add file to subfolder

    fileEntry =
        DLAppServiceUtil.addFileEntry(
            _group.getGroupId(),
            _subfolder.getFolderId(),
            name,
            ContentTypes.TEXT_PLAIN,
            name,
            "",
            "",
            bytes,
            ServiceContextTestUtil.getServiceContext(_group.getGroupId()));

    assertFileEntryType(fileEntry, _contractDLFileEntryType);

    // Configure subfolder

    DLFolderLocalServiceUtil.updateFolder(
        _subfolder.getFolderId(),
        _subfolder.getParentFolderId(),
        _subfolder.getName(),
        _subfolder.getDescription(),
        _basicDocumentDLFileEntryType.getPrimaryKey(),
        ListUtil.toList(new long[] {_basicDocumentDLFileEntryType.getPrimaryKey()}),
        true,
        ServiceContextTestUtil.getServiceContext(_group.getGroupId()));

    fileEntry = DLAppServiceUtil.getFileEntry(fileEntry.getFileEntryId());

    assertFileEntryType(fileEntry, _basicDocumentDLFileEntryType);
  }