コード例 #1
0
ファイル: AttachmentDtos.java プロジェクト: Rima-B/mica2
  @NotNull
  Mica.FileDto asFileDto(AttachmentState state, boolean publishedFileSystem, boolean detailed) {
    Mica.FileDto.Builder builder = asFileDto(state).toBuilder();

    if (publishedFileSystem) {
      builder.clearRevisionStatus();
      if (state.isPublished()) {
        builder.setAttachment(asDto(state.getPublishedAttachment()));
      }
    } else {
      builder.setState(asDto(state, detailed));
      builder.setPermissions(permissionsDtos.asDto(state));
    }

    if (builder.getType() == Mica.FileType.FOLDER) {
      // get the number of files in the folder
      builder.setSize(
          fileSystemService.countAttachmentStates(state.getPath(), publishedFileSystem));
    }

    return builder.build();
  }
コード例 #2
0
ファイル: AttachmentDtos.java プロジェクト: Rima-B/mica2
  Mica.AttachmentStateDto asDto(AttachmentState state, boolean detailed) {
    Mica.AttachmentStateDto.Builder builder = Mica.AttachmentStateDto.newBuilder();
    builder
        .setId(state.getId()) //
        .setName(state.getName()) //
        .setPath(state.getPath()) //
        .setTimestamps(TimestampsDtos.asDto(state)) //
        .setAttachment(asDto(state.getAttachment()));
    if (state.isPublished()) {
      builder
          .setPublishedId(state.getPublishedAttachment().getId()) //
          .setPublicationDate(state.getPublicationDate().toString());

      if (state.getPublishedBy() != null) builder.setPublishedBy(state.getPublishedBy());
    }
    if (detailed && !FileUtils.isDirectory(state))
      builder.addAllRevisions(
          fileSystemService
              .getAttachmentRevisions(state)
              .stream()
              .map(this::asDto)
              .collect(Collectors.toList()));
    return builder.build();
  }