Check that the proposals all have consistent read write sets

@param proposalResponses
@param invalid           proposals that were found to be invalid.
@return A Collection of sets where each set has consistent proposals.
@throws InvalidArgumentException
512283
public static Collection<Set<ProposalResponse>> getProposalConsistencySets(Collection<? extends ProposalResponse> proposalResponses,
                                                                               Set<ProposalResponse> invalid) throws InvalidArgumentException {

        if (proposalResponses == null) {
            throw new InvalidArgumentException("proposalResponses collection is null");
        }

        if (proposalResponses.isEmpty()) {
            throw new InvalidArgumentException("proposalResponses collection is empty");
        }

        if (null == invalid) {
            throw new InvalidArgumentException("invalid set is null.");
        }

        HashMap<ByteString, Set<ProposalResponse>> ret = new HashMap<>();

        for (ProposalResponse proposalResponse : proposalResponses) {

            if (proposalResponse.isInvalid()) {
                invalid.add(proposalResponse);
            } else {
                // payload bytes is what's being signed over so it must be consistent.
                final ByteString payloadBytes = proposalResponse.getPayloadBytes();

                if (payloadBytes == null) {
                    throw new InvalidArgumentException(format("proposalResponse.getPayloadBytes() was null from peer: %s.",
                            proposalResponse.getPeer()));
                } else if (payloadBytes.isEmpty()) {
                    throw new InvalidArgumentException(format("proposalResponse.getPayloadBytes() was empty from peer: %s.",
                            proposalResponse.getPeer()));
                }
                Set<ProposalResponse> set = ret.computeIfAbsent(payloadBytes, k -> new HashSet<>());
                set.add(proposalResponse);
            }
        }

        if (IS_DEBUG_LEVEL && ret.size() > 1) {

            StringBuilder sb = new StringBuilder(1000);

            int i = 0;
            String sep = "";

            for (Map.Entry<ByteString, Set<ProposalResponse>> entry : ret.entrySet()) {
                ByteString bytes = entry.getKey();
                Set<ProposalResponse> presp = entry.getValue();

                sb.append(sep)
                        .append("Consistency set: ").append(i++).append(" bytes size: ").append(bytes.size())
                        .append(" bytes: ")
                        .append(Utils.toHexString(bytes.toByteArray())).append(" [");

                String psep = "";

                for (ProposalResponse proposalResponse : presp) {
                    sb.append(psep).append(proposalResponse.getPeer());
                    psep = ", ";
                }
                sb.append("]");
                sep = ", ";
            }

            logger.debug(sb.toString());

        }

        return ret.values();

    }
386589
@SuppressWarnings("unchecked")
    public static Set<Repository> toRepositoryList(Vector<Object> repositoriesParams)
    {
        Set<Repository> repositories = new TreeSet<Repository>();
        for(Object repositoryParams : repositoriesParams)
        {
            repositories.add(toRepository((Vector<Object>)repositoryParams));
        }
        
        return repositories;
    }
577804
public void setRevisions(java.util.Collection<RevisionInfo> revisions) {
        if (revisions == null) {
            this.revisions = null;
            return;
        }

        this.revisions = new com.amazonaws.internal.SdkInternalList<RevisionInfo>(revisions);
    }
82242
public void setGrants(java.util.Collection<GrantListEntry> grants) {
        if (grants == null) {
            this.grants = null;
            return;
        }

        this.grants = new com.ibm.cloud.objectstorage.internal.SdkInternalList<GrantListEntry>(grants);
    }
1064052
public void setRecommendations(java.util.Collection<ReservationPurchaseRecommendation> recommendations) {
        if (recommendations == null) {
            this.recommendations = null;
            return;
        }

        this.recommendations = new java.util.ArrayList<ReservationPurchaseRecommendation>(recommendations);
    }
943692
public void setFailedEntries(java.util.Collection<PutTargetsResultEntry> failedEntries) {
        if (failedEntries == null) {
            this.failedEntries = null;
            return;
        }

        this.failedEntries = new java.util.ArrayList<PutTargetsResultEntry>(failedEntries);
    }
137373
public ChaincodeCollectionConfiguration getChaincodeCollectionConfiguration() throws ProposalException {
        Collection.CollectionConfigPackage collections = parsePayload().getCollections();

        if (null == collections || !parsePayload().hasCollections()) {
            return null;
        }
        try {
            return ChaincodeCollectionConfiguration.fromCollectionConfigPackage(collections);
        } catch (InvalidArgumentException e) {
            throw new ProposalException(e);
        }
    }
931687
@Override
    public Collection<String> createResources(Request request)
            throws InvalidQueryException, ResourceNotFoundException, ResourceAlreadyExistsException {

        Collection<String> relativeUrls = new ArrayList<>();
        AtlasQuery atlasQuery = queryFactory.createEntityQuery(request);
        Collection<String> guids = new ArrayList<>();
        for (Map<String, Object> entityMap: atlasQuery.execute()) {
            guids.add(String.valueOf(entityMap.get("id")));
        }

        Collection<Map<String, String>> tagMaps = request.getProperty("tags");
        for (Map<String, String> tagMap : tagMaps) {
            Result termResult = getTermQueryResult(tagMap.get("name"));
            relativeUrls.addAll(tagEntities(guids, termResult.getPropertyMaps().iterator().next()));
        }
        return relativeUrls;
    }
214234
public Set<String> queryChannels(Peer peer) throws InvalidArgumentException, ProposalException {

        clientCheck();

        if (null == peer) {

            throw new InvalidArgumentException("peer set to null");

        }

        //Run this on a system channel.

        try {
            Channel systemChannel = Channel.newSystemChannel(this);

            return systemChannel.queryChannels(peer);
        } catch (InvalidArgumentException e) {
            throw e; //dont log
        } catch (ProposalException e) {
            logger.error(format("queryChannels for peer %s failed." + e.getMessage(), peer.getName()), e);
            throw e;
        }

    }
969955
public static InvalidKBException validationErrors(List<String> errors){
        StringBuilder message = new StringBuilder();
        message.append(ErrorMessage.VALIDATION.getMessage(errors.size()));
        for (String s : errors) {
            message.append(s);
        }
        return create(message.toString());
    }
922404
public TxReadWriteSetInfo getChaincodeActionResponseReadWriteSetInfo() throws InvalidArgumentException {

        if (isInvalid()) {
            throw new InvalidArgumentException("Proposal response is invalid.");
        }

        try {

            final ProposalResponsePayloadDeserializer proposalResponsePayloadDeserializer = getProposalResponsePayloadDeserializer();

            TxReadWriteSet txReadWriteSet = proposalResponsePayloadDeserializer.getExtension().getResults();

            if (txReadWriteSet == null) {
                return null;
            }

            return new TxReadWriteSetInfo(txReadWriteSet);

        } catch (Exception e) {
            throw new InvalidArgumentException(e);
        }

    }
959971
public void setReadReplicaIdentifiers(java.util.Collection<String> readReplicaIdentifiers) {
        if (readReplicaIdentifiers == null) {
            this.readReplicaIdentifiers = null;
            return;
        }

        this.readReplicaIdentifiers = new com.amazonaws.internal.SdkInternalList<String>(readReplicaIdentifiers);
    }
1194243
Collection<ProposalResponse> sendInstallProposal(InstallProposalRequest installProposalRequest, Collection<Peer> peers)
            throws ProposalException, InvalidArgumentException {

        checkChannelState();
        checkPeers(peers);
        if (null == installProposalRequest) {
            throw new InvalidArgumentException("InstallProposalRequest is null");
        }

        try {
            TransactionContext transactionContext = getTransactionContext(installProposalRequest.getUserContext());
            transactionContext.verify(false);  // Install will have no signing cause it's not really targeted to a channel.
            transactionContext.setProposalWaitTime(installProposalRequest.getProposalWaitTime());
            InstallProposalBuilder installProposalbuilder = InstallProposalBuilder.newBuilder();
            installProposalbuilder.context(transactionContext);
            installProposalbuilder.setChaincodeLanguage(installProposalRequest.getChaincodeLanguage());
            installProposalbuilder.chaincodeName(installProposalRequest.getChaincodeName());
            installProposalbuilder.chaincodePath(installProposalRequest.getChaincodePath());
            installProposalbuilder.chaincodeVersion(installProposalRequest.getChaincodeVersion());
            installProposalbuilder.setChaincodeSource(installProposalRequest.getChaincodeSourceLocation());
            installProposalbuilder.setChaincodeInputStream(installProposalRequest.getChaincodeInputStream());
            installProposalbuilder.setChaincodeMetaInfLocation(installProposalRequest.getChaincodeMetaInfLocation());

            FabricProposal.Proposal deploymentProposal = installProposalbuilder.build();
            SignedProposal signedProposal = getSignedProposal(transactionContext, deploymentProposal);

            return sendProposalToPeers(peers, signedProposal, transactionContext);
        } catch (Exception e) {
            throw new ProposalException(e);
        }

    }
1354622
@Override
	public void revalidate() {
		// Override this function to be sure that
		// the invalid and valid collections
		// has no impact of the iteration on
		// the elements in this itinerary
		final BusItineraryHalt[] tabV = new BusItineraryHalt[this.validHalts.size()];
		this.validHalts.toArray(tabV);
		final BusItineraryHalt[] tabI = new BusItineraryHalt[this.invalidHalts.size()];
		this.invalidHalts.toArray(tabI);

		// Revalidate valid halts
		for (final BusItineraryHalt halt : tabV) {
			assert halt != null;
			halt.revalidate();
		}

		// Revalidate invalid halts
		for (final BusItineraryHalt halt : tabI) {
			assert halt != null;
			halt.revalidate();
		}

		checkPrimitiveValidity();
	}
679281
private void respondToListSets(Map<String, String> args,
                                   String baseURL,
                                   List<?> sets,
                                   ResumptionToken resumptionToken,
                                   PrintWriter out) {
        appendTop(out);
        appendRequest(args, baseURL, out);
        out.println("  <ListSets>");
        for (int i = 0; i < sets.size(); i++) {
            SetInfo s = (SetInfo) sets.get(i);
            out.println("    <set>");
            out.println("      <setSpec>" + s.getSpec() + "</setSpec>");
            out.println("      <setName>" + s.getName() + "</setName>");
            Iterator<String> iter = s.getDescriptions().iterator();
            while (iter.hasNext()) {
                out.println("      <setDescription>\n");
                out.println(iter.next());
                out.println("      </setDescription>\n");
            }
            out.println("    </set>");
        }
        appendResumptionToken(resumptionToken, out);
        out.println("  </ListSets>");
        appendBottom(out);
    }
682989
public List<String> format(final Collection<ObjectError> errors) {
        ArgUtils.notNull(errors, "errors");
        
        final List<String> messageList = new ArrayList<>();
        for(ObjectError error : errors) {
            messageList.add(format(error));
        }
        
        return messageList;
    }
54554
public Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest) throws InvalidArgumentException, ProposalException {
        return queryByChaincode(queryByChaincodeRequest, getChaincodeQueryPeers());
    }