type = Type.REQUEST_3;
} else {
type = Type.REQUEST_4;
}
final Message message = createMessage(remotePeer, command, type);
if (getBuilder.isSign()) {
message.publicKeyAndSign(getBuilder.keyPair());
}
if (getBuilder.to() != null && getBuilder.from() != null) {
final Collection<Number640> keys = new ArrayList<Number640>(2);
keys.add(getBuilder.from());
keys.add(getBuilder.to());
message.intValue(getBuilder.returnNr());
message.keyCollection(new KeyCollection(keys));
} else if (getBuilder.keys() == null) {
if (getBuilder.locationKey() == null || getBuilder.domainKey() == null) {
throw new IllegalArgumentException("Null not allowed in location or domain");
}
message.key(getBuilder.locationKey());
message.key(getBuilder.domainKey());
if (getBuilder.contentKeys() != null) {
message.keyCollection(new KeyCollection(getBuilder.locationKey(), getBuilder
.domainKey(), getBuilder.versionKey(), getBuilder.contentKeys()));
} else {
message.intValue(getBuilder.returnNr());
if (getBuilder.keyBloomFilter() != null || getBuilder.contentBloomFilter() != null) {
if (getBuilder.keyBloomFilter() != null) {
message.bloomFilter(getBuilder.keyBloomFilter());
}
if (getBuilder.contentBloomFilter() != null) {
message.bloomFilter(getBuilder.contentBloomFilter());
}
}
}
} else {
message.keyCollection(new KeyCollection(getBuilder.keys()));
}
final FutureResponse futureResponse = new FutureResponse(message);
final RequestHandler<FutureResponse> request = new RequestHandler<FutureResponse>(futureResponse,
peerBean(), connectionBean(), getBuilder);