コード例 #1
0
  protected DLFileVersion addDLFileVersion() throws Exception {
    long pk = RandomTestUtil.nextLong();

    DLFileVersion dlFileVersion = _persistence.create(pk);

    dlFileVersion.setUuid(RandomTestUtil.randomString());

    dlFileVersion.setGroupId(RandomTestUtil.nextLong());

    dlFileVersion.setCompanyId(RandomTestUtil.nextLong());

    dlFileVersion.setUserId(RandomTestUtil.nextLong());

    dlFileVersion.setUserName(RandomTestUtil.randomString());

    dlFileVersion.setCreateDate(RandomTestUtil.nextDate());

    dlFileVersion.setModifiedDate(RandomTestUtil.nextDate());

    dlFileVersion.setRepositoryId(RandomTestUtil.nextLong());

    dlFileVersion.setFolderId(RandomTestUtil.nextLong());

    dlFileVersion.setFileEntryId(RandomTestUtil.nextLong());

    dlFileVersion.setTreePath(RandomTestUtil.randomString());

    dlFileVersion.setExtension(RandomTestUtil.randomString());

    dlFileVersion.setMimeType(RandomTestUtil.randomString());

    dlFileVersion.setTitle(RandomTestUtil.randomString());

    dlFileVersion.setDescription(RandomTestUtil.randomString());

    dlFileVersion.setChangeLog(RandomTestUtil.randomString());

    dlFileVersion.setExtraSettings(RandomTestUtil.randomString());

    dlFileVersion.setFileEntryTypeId(RandomTestUtil.nextLong());

    dlFileVersion.setVersion(RandomTestUtil.randomString());

    dlFileVersion.setSize(RandomTestUtil.nextLong());

    dlFileVersion.setChecksum(RandomTestUtil.randomString());

    dlFileVersion.setStatus(RandomTestUtil.nextInt());

    dlFileVersion.setStatusByUserId(RandomTestUtil.nextLong());

    dlFileVersion.setStatusByUserName(RandomTestUtil.randomString());

    dlFileVersion.setStatusDate(RandomTestUtil.nextDate());

    _persistence.update(dlFileVersion);

    return dlFileVersion;
  }
コード例 #2
0
  protected void updateThumbnails(long fileEntryId) throws Exception {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      con = DataAccess.getUpgradeOptimizedConnection();

      ps =
          con.prepareStatement(
              "select fileVersionId, userId, extension, mimeType, version "
                  + "from DLFileVersion where fileEntryId = "
                  + fileEntryId
                  + " order by version asc");

      rs = ps.executeQuery();

      while (rs.next()) {
        long fileVersionId = rs.getLong("fileVersionId");
        long userId = rs.getLong("userId");
        String extension = rs.getString("extension");
        String mimeType = rs.getString("mimeType");
        String version = rs.getString("version");

        if (_imageMimeTypes.contains(mimeType)) {
          DLFileVersion dlFileVersion = new DLFileVersionImpl();

          dlFileVersion.setFileVersionId(fileVersionId);
          dlFileVersion.setUserId(userId);
          dlFileVersion.setFileEntryId(fileEntryId);
          dlFileVersion.setExtension(extension);
          dlFileVersion.setMimeType(mimeType);
          dlFileVersion.setVersion(version);

          FileVersion fileVersion = new LiferayFileVersion(dlFileVersion);

          try {
            ImageProcessorUtil.generateImages(null, fileVersion);
          } catch (Exception e) {
            if (_log.isWarnEnabled()) {
              _log.warn("Unable to generate thumbnails for " + fileVersion.getFileVersionId(), e);
            }
          }
        }
      }
    } finally {
      DataAccess.cleanUp(con, ps, rs);
    }
  }
コード例 #3
0
  public DLFileVersion updateDLFileVersion(DLFileVersion model) throws SystemException {
    DLFileVersion dlFileVersion = new DLFileVersionImpl();

    dlFileVersion.setNew(false);

    dlFileVersion.setFileVersionId(model.getFileVersionId());
    dlFileVersion.setCompanyId(model.getCompanyId());
    dlFileVersion.setUserId(model.getUserId());
    dlFileVersion.setUserName(model.getUserName());
    dlFileVersion.setCreateDate(model.getCreateDate());
    dlFileVersion.setFolderId(model.getFolderId());
    dlFileVersion.setName(model.getName());
    dlFileVersion.setVersion(model.getVersion());
    dlFileVersion.setSize(model.getSize());

    return dlFileVersionPersistence.update(dlFileVersion);
  }
コード例 #4
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    DLFileVersion newDLFileVersion = _persistence.create(pk);

    newDLFileVersion.setUuid(RandomTestUtil.randomString());

    newDLFileVersion.setGroupId(RandomTestUtil.nextLong());

    newDLFileVersion.setCompanyId(RandomTestUtil.nextLong());

    newDLFileVersion.setUserId(RandomTestUtil.nextLong());

    newDLFileVersion.setUserName(RandomTestUtil.randomString());

    newDLFileVersion.setCreateDate(RandomTestUtil.nextDate());

    newDLFileVersion.setModifiedDate(RandomTestUtil.nextDate());

    newDLFileVersion.setRepositoryId(RandomTestUtil.nextLong());

    newDLFileVersion.setFolderId(RandomTestUtil.nextLong());

    newDLFileVersion.setFileEntryId(RandomTestUtil.nextLong());

    newDLFileVersion.setTreePath(RandomTestUtil.randomString());

    newDLFileVersion.setExtension(RandomTestUtil.randomString());

    newDLFileVersion.setMimeType(RandomTestUtil.randomString());

    newDLFileVersion.setTitle(RandomTestUtil.randomString());

    newDLFileVersion.setDescription(RandomTestUtil.randomString());

    newDLFileVersion.setChangeLog(RandomTestUtil.randomString());

    newDLFileVersion.setExtraSettings(RandomTestUtil.randomString());

    newDLFileVersion.setFileEntryTypeId(RandomTestUtil.nextLong());

    newDLFileVersion.setVersion(RandomTestUtil.randomString());

    newDLFileVersion.setSize(RandomTestUtil.nextLong());

    newDLFileVersion.setChecksum(RandomTestUtil.randomString());

    newDLFileVersion.setStatus(RandomTestUtil.nextInt());

    newDLFileVersion.setStatusByUserId(RandomTestUtil.nextLong());

    newDLFileVersion.setStatusByUserName(RandomTestUtil.randomString());

    newDLFileVersion.setStatusDate(RandomTestUtil.nextDate());

    _persistence.update(newDLFileVersion);

    DLFileVersion existingDLFileVersion =
        _persistence.findByPrimaryKey(newDLFileVersion.getPrimaryKey());

    Assert.assertEquals(existingDLFileVersion.getUuid(), newDLFileVersion.getUuid());
    Assert.assertEquals(
        existingDLFileVersion.getFileVersionId(), newDLFileVersion.getFileVersionId());
    Assert.assertEquals(existingDLFileVersion.getGroupId(), newDLFileVersion.getGroupId());
    Assert.assertEquals(existingDLFileVersion.getCompanyId(), newDLFileVersion.getCompanyId());
    Assert.assertEquals(existingDLFileVersion.getUserId(), newDLFileVersion.getUserId());
    Assert.assertEquals(existingDLFileVersion.getUserName(), newDLFileVersion.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileVersion.getCreateDate()),
        Time.getShortTimestamp(newDLFileVersion.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileVersion.getModifiedDate()),
        Time.getShortTimestamp(newDLFileVersion.getModifiedDate()));
    Assert.assertEquals(
        existingDLFileVersion.getRepositoryId(), newDLFileVersion.getRepositoryId());
    Assert.assertEquals(existingDLFileVersion.getFolderId(), newDLFileVersion.getFolderId());
    Assert.assertEquals(existingDLFileVersion.getFileEntryId(), newDLFileVersion.getFileEntryId());
    Assert.assertEquals(existingDLFileVersion.getTreePath(), newDLFileVersion.getTreePath());
    Assert.assertEquals(existingDLFileVersion.getExtension(), newDLFileVersion.getExtension());
    Assert.assertEquals(existingDLFileVersion.getMimeType(), newDLFileVersion.getMimeType());
    Assert.assertEquals(existingDLFileVersion.getTitle(), newDLFileVersion.getTitle());
    Assert.assertEquals(existingDLFileVersion.getDescription(), newDLFileVersion.getDescription());
    Assert.assertEquals(existingDLFileVersion.getChangeLog(), newDLFileVersion.getChangeLog());
    Assert.assertEquals(
        existingDLFileVersion.getExtraSettings(), newDLFileVersion.getExtraSettings());
    Assert.assertEquals(
        existingDLFileVersion.getFileEntryTypeId(), newDLFileVersion.getFileEntryTypeId());
    Assert.assertEquals(existingDLFileVersion.getVersion(), newDLFileVersion.getVersion());
    Assert.assertEquals(existingDLFileVersion.getSize(), newDLFileVersion.getSize());
    Assert.assertEquals(existingDLFileVersion.getChecksum(), newDLFileVersion.getChecksum());
    Assert.assertEquals(existingDLFileVersion.getStatus(), newDLFileVersion.getStatus());
    Assert.assertEquals(
        existingDLFileVersion.getStatusByUserId(), newDLFileVersion.getStatusByUserId());
    Assert.assertEquals(
        existingDLFileVersion.getStatusByUserName(), newDLFileVersion.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileVersion.getStatusDate()),
        Time.getShortTimestamp(newDLFileVersion.getStatusDate()));
  }