use of v7db.files.spi.OffsetAndLength in project v7files by thiloplanz.
the class MongoContentStorage method getContent.
public Content getContent(ContentPointer pointer) throws IOException {
if (pointer == null)
return null;
if (pointer instanceof InlineContent)
return (Content) pointer;
if (pointer instanceof ContentSHA) {
ContentSHA p = (ContentSHA) pointer;
byte[] sha = p.getSHA();
Content base = getContent(sha);
if (base == null)
throw new IllegalArgumentException("base SHA not found: " + Hex.encodeHexString(sha));
return base;
}
if (pointer instanceof StoredContent) {
StoredContent p = (StoredContent) pointer;
byte[] sha = p.getBaseSHA();
Content base = getContent(sha);
if (base == null)
throw new IllegalArgumentException("base SHA not found: " + Hex.encodeHexString(sha));
if (p.getLength() != base.getLength()) {
return new OffsetAndLength(base, 0, p.getLength());
}
return base;
}
throw new IllegalArgumentException(pointer.getClass().toString());
}
Aggregations