Exemple #1
0
  public static SyncDLObject toSyncDLObject(
      DLFileEntry dlFileEntry, String event, boolean excludeWorkingCopy)
      throws PortalException, SystemException {

    DLFileVersion dlFileVersion = null;

    Date lockExpirationDate = null;
    long lockUserId = 0;
    String lockUserName = StringPool.BLANK;
    String type = null;

    Lock lock = dlFileEntry.getLock();

    if ((lock == null) || excludeWorkingCopy) {
      dlFileVersion =
          DLFileVersionLocalServiceUtil.getFileVersion(
              dlFileEntry.getFileEntryId(), dlFileEntry.getVersion());

      type = SyncConstants.TYPE_FILE;
    } else {
      dlFileVersion =
          DLFileVersionLocalServiceUtil.getFileVersion(
              dlFileEntry.getFileEntryId(), DLFileEntryConstants.PRIVATE_WORKING_COPY_VERSION);

      lockExpirationDate = lock.getExpirationDate();
      lockUserId = lock.getUserId();
      lockUserName = lock.getUserName();
      type = SyncConstants.TYPE_PRIVATE_WORKING_COPY;
    }

    SyncDLObject syncDLObject = new SyncDLObjectImpl();

    syncDLObject.setCompanyId(dlFileVersion.getCompanyId());
    syncDLObject.setCreateDate(dlFileVersion.getCreateDate());
    syncDLObject.setModifiedDate(dlFileVersion.getModifiedDate());
    syncDLObject.setRepositoryId(dlFileVersion.getRepositoryId());
    syncDLObject.setParentFolderId(dlFileVersion.getFolderId());
    syncDLObject.setName(dlFileVersion.getTitle());
    syncDLObject.setExtension(dlFileVersion.getExtension());
    syncDLObject.setMimeType(dlFileVersion.getMimeType());
    syncDLObject.setDescription(dlFileVersion.getDescription());
    syncDLObject.setChangeLog(dlFileVersion.getChangeLog());
    syncDLObject.setExtraSettings(dlFileVersion.getExtraSettings());
    syncDLObject.setVersion(dlFileVersion.getVersion());
    syncDLObject.setSize(dlFileVersion.getSize());
    syncDLObject.setChecksum(getChecksum(dlFileVersion));
    syncDLObject.setEvent(event);
    syncDLObject.setLockExpirationDate(lockExpirationDate);
    syncDLObject.setLockUserId(lockUserId);
    syncDLObject.setLockUserName(lockUserName);
    syncDLObject.setType(type);
    syncDLObject.setTypePK(dlFileEntry.getFileEntryId());
    syncDLObject.setTypeUuid(dlFileEntry.getUuid());

    return syncDLObject;
  }
  @Override
  public Map<String, DDMFormValues> getDDMFormValuesMap(long fileVersionId) throws PortalException {

    Map<String, DDMFormValues> ddmFormValuesMap = new HashMap<>();

    DLFileVersion dlFileVersion = DLFileVersionLocalServiceUtil.getFileVersion(fileVersionId);

    long fileEntryTypeId = dlFileVersion.getFileEntryTypeId();

    if (fileEntryTypeId <= 0) {
      return ddmFormValuesMap;
    }

    DLFileEntryType dlFileEntryType = getDLFileEntryType();

    List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();

    for (DDMStructure ddmStructure : ddmStructures) {
      DLFileEntryMetadata dlFileEntryMetadata =
          DLFileEntryMetadataLocalServiceUtil.fetchFileEntryMetadata(
              ddmStructure.getStructureId(), fileVersionId);

      if (dlFileEntryMetadata != null) {
        DDMFormValues ddmFormValues =
            StorageEngineUtil.getDDMFormValues(dlFileEntryMetadata.getDDMStorageId());

        ddmFormValuesMap.put(ddmStructure.getStructureKey(), ddmFormValues);
      }
    }

    return ddmFormValuesMap;
  }
 @Override
 public DLFileVersion getFileVersion(String version) throws PortalException {
   return DLFileVersionLocalServiceUtil.getFileVersion(getFileEntryId(), version);
 }