content

adobeAPI의 응답 ..난 단순히 서명참여자의 서명여부만 알고 싶은데…

{
  "ccsInfo": [
    {
      "company": "",
      "email": "",
      "hidden": false,
      "name": "",
      "participantId": "",
      "self": false
    }
  ],
  "nextParticipantSets": [
    {
      "order": 1,
      "providerParticipationInfo": {
        "label": "",
        "participationId": "",
        "participationSetId": ""
      },
      "role": "",
      "electronicSealId": "",
      "id": "",
      "memberInfos": [
        {
          "email": "",
          "securityOption": {
            "authenticationMethod": "",
            "digAuthInfo": {
              "providerId": "",
              "providerDesc": "",
              "providerName": ""
            },
            "nameInfo": {
              "firstName": "",
              "lastName": ""
            },
            "notaryAuthentication": "",
            "password": "",
            "phoneInfo": {
              "countryCode": "",
              "countryIsoCode": "",
              "phone": ""
            }
          },
          "company": "",
          "createdDate": "date",
          "deliverableEmail": false,
          "hidden": false,
          "id": "",
          "name": "",
          "phoneDeliveryInfo": {
            "countryCode": "",
            "countryIsoCode": "",
            "phone": ""
          },
          "privateMessage": "",
          "self": false,
          "status": "",
          "userId": ""
        }
      ],
      "name": "",
      "privateMessage": "",
      "status": ""
    }
  ],
  "participantSets": [
    {
      "order": 1,
      "providerParticipationInfo": {
        "label": "",
        "participationId": "",
        "participationSetId": ""
      },
      "role": "",
      "electronicSealId": "",
      "id": "",
      "memberInfos": [
        {
          "email": "",
          "securityOption": {
            "authenticationMethod": "",
            "digAuthInfo": {
              "providerId": "",
              "providerDesc": "",
              "providerName": ""
            },
            "nameInfo": {
              "firstName": "",
              "lastName": ""
            },
            "notaryAuthentication": "",
            "password": "",
            "phoneInfo": {
              "countryCode": "",
              "countryIsoCode": "",
              "phone": ""
            }
          },
          "company": "",
          "createdDate": "date",
          "deliverableEmail": false,
          "hidden": false,
          "id": "",
          "name": "",
          "phoneDeliveryInfo": {
            "countryCode": "",
            "countryIsoCode": "",
            "phone": ""
          },
          "privateMessage": "",
          "self": false,
          "status": "",
          "userId": ""
        }
      ],
      "name": "",
      "privateMessage": "",
      "status": ""
    }
  ],
  "senderInfo": {
    "company": "",
    "email": "",
    "hidden": false,
    "name": "",
    "participantId": "",
    "self": false,
    "status": "",
    "createdDate": "date",
    "userId": ""
  },
  "sharesInfo": [
    {
      "company": "",
      "email": "",
      "hidden": false,
      "name": "",
      "participantId": "",
      "self": false,
      "sharerParticipantId": ""
    }
  ]
}

이 구조를 원하는 데이터 level관점에서 단순하면 이렇다.

{
  "participantSets": [
    {
      "memberInfos": [
        {
          "email": ""
        }
      ],
      "status": ""
    }
  ]
}

어도비가 이렇게 DTO를 설계한 이유는 복수의 멤버가 들어있는 participantSet을 하나의 서명단위로 정의하기 때문일 것이다. 따라서 같은 Set 안에 존재하는 여러 멤버의 서명상태는 Set에서 명시한 하나의 status 만을 가진다.

이런 개념이 개발하고자하는 기능의 요구사항과 차이가 있을 수 있다. 일반적으로 각자의 서명여부상태를 가지는 것이 직관적으로 이해가 쉽기 때문이다.

내가 개발하고자하는 데이터의 입출력의 기본 포맷은 아래와 같이 하고자 했다. 이 포맷에 맞추도록 응답 json을 가공해보자.

Map<String, String> emailStatus; //키를 email로 , 값을 status로 갖는 맵

여기서 status는 설명에 집중하기 위해 Enum으로 변경하지 않았다. 그러나 해도 좋다.

API응답을 받기위한 ResponseDTO는 다음과 같이설계 했다.

@Getter @Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class AdobeMembersInfo {
    private List<ParticipantSet> participantSets;


    @Getter @Setter
    @JsonIgnoreProperties(ignoreUnknown = true)
    private static class ParticipantSet {
        private List<MemberInfo> memberInfos;
        private String status;
    }
    @Getter @Setter
    @JsonIgnoreProperties(ignoreUnknown = true)
    private static class MemberInfo {
        private String email;
    }

    public Map<String,String> getMemberStatusMap(){
        Map<String, String> emailStatus = this.participantSets.stream().
                flatMap(p -> p.getMemberInfos().stream().collect(Collectors.toMap(MemberInfo::getEmail, mi -> p.status, (email1, email2) -> email1)).entrySet().stream())
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (key1, key2) -> key1));
        return emailStatus;
    }
}

응답으로 받은 모든 email은 상위 level의 status와 매핑되어 모든 EntrySet은 동일한 차원의 Map으로 병합되어야한다.

getMemberStatusMap() 은 그 편의 메소드이다.

success!