コード例 #1
0
  protected Map<String, ServiceLink> populateNewServiceLinks(ApiRequest request) {
    Map<String, ServiceLink> newServiceLinks = new HashMap<>();
    List<? extends ServiceLink> serviceLinks =
        DataAccessor.fromMap(request.getRequestObject())
            .withKey(ServiceConstants.FIELD_SERVICE_LINKS)
            .withDefault(Collections.EMPTY_LIST)
            .asList(jsonMapper, ServiceLink.class);

    if (serviceLinks != null) {
      for (ServiceLink serviceLink : serviceLinks) {
        newServiceLinks.put(serviceLink.getUuid(), serviceLink);
      }
    }

    return newServiceLinks;
  }
コード例 #2
0
  private void removeOldServiceMaps(Service service, Map<String, ServiceLink> newServiceLinks) {
    List<? extends ServiceConsumeMap> existingMaps =
        consumeMapDao.findConsumedMapsToRemove(service.getId());
    List<ServiceLink> linksToRemove = new ArrayList<>();

    for (ServiceConsumeMap existingMap : existingMaps) {
      ServiceLink existingLink =
          new ServiceLink(existingMap.getConsumedServiceId(), existingMap.getName());
      if (!newServiceLinks.containsKey(existingLink.getUuid())) {
        linksToRemove.add(existingLink);
      }
    }

    for (ServiceLink linkToRemove : linksToRemove) {
      sdService.removeServiceLink(service, linkToRemove);
    }
  }