List<RiakObject> roList = new LinkedList<RiakObject>();
BasicVClock vclock = new BasicVClock(contentVClock.toByteArray());
for (RpbContent content : contentList)
{
RiakObject ro = new RiakObject();
ro.setVClock(vclock);
if (content.hasDeleted())
{
ro.setDeleted(content.getDeleted());
}
if (content.hasContentType())
{
ro.setContentType(content.getContentType().toStringUtf8());
}
if (content.hasCharset())
{
ro.setCharset(content.getCharset().toStringUtf8());
}
if (content.hasLastMod())
{
int lastMod = content.getLastMod();
int lastModUsec = content.getLastModUsecs();
ro.setLastModified((lastMod * 1000L) + (lastModUsec / 1000L));
}
if (content.hasValue() && !content.getValue().isEmpty())
{
ro.setValue(BinaryValue.unsafeCreate(content.getValue().toByteArray()));
}
if (content.hasVtag())
{
ro.setVTag(content.getVtag().toStringUtf8());
}
if (content.getLinksCount() > 0)
{
List<RiakKvPB.RpbLink> pbLinkList = content.getLinksList();
RiakLinks riakLinks = ro.getLinks();
for (RiakKvPB.RpbLink pbLink : pbLinkList)
{
RiakLink link = new RiakLink(pbLink.getBucket().toStringUtf8(),
pbLink.getKey().toStringUtf8(),
pbLink.getTag().toStringUtf8());
riakLinks.addLink(link);
}
}
if (content.getIndexesCount() > 0)
{
RiakIndexes indexes = ro.getIndexes();
for (RiakPB.RpbPair p : content.getIndexesList())
{
String name = p.getKey().toStringUtf8();
try
{
IndexType type = IndexType.typeFromFullname(name);
indexes.getIndex(RawIndex.named(name, type))
.add(BinaryValue.unsafeCreate(p.getValue().toByteArray()));
}
catch (IllegalArgumentException e)
{
logger.error("Unknown index type during conversion: {};{}", name, e);
}
}
}
if (content.getUsermetaCount() > 0)
{
RiakUserMetadata userMeta = ro.getUserMeta();
for (int j = 0; j < content.getUsermetaCount(); j++)
{
RiakPB.RpbPair pair = content.getUsermeta(j);
userMeta.put(BinaryValue.unsafeCreate(pair.getKey().toByteArray()),
BinaryValue.unsafeCreate(pair.getValue().toByteArray()));