-
Notifications
You must be signed in to change notification settings - Fork 129
/
BinaryCacheStore.java
36 lines (28 loc) · 1.13 KB
/
BinaryCacheStore.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.fcrepo.utils;
import org.fcrepo.utils.infinispan.StoreChunkInputStream;
import org.infinispan.loaders.CacheStore;
import org.modeshape.jcr.value.BinaryKey;
import org.modeshape.jcr.value.binary.BinaryStore;
import org.modeshape.jcr.value.binary.BinaryStoreException;
import org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore;
import java.io.InputStream;
public class BinaryCacheStore {
private static final String DATA_SUFFIX = "-data";
private final BinaryStore store;
private final CacheStore low_level_store;
public BinaryCacheStore(BinaryStore store, CacheStore low_level_store) {
this.store = store;
this.low_level_store = low_level_store;
}
public BinaryCacheStore(BinaryStore store) {
this.store = store;
this.low_level_store = null;
}
public InputStream getInputStream(BinaryKey key) throws BinaryStoreException {
if(this.store instanceof InfinispanBinaryStore) {
return new StoreChunkInputStream(low_level_store, key.toString() + DATA_SUFFIX);
} else {
return this.store.getInputStream(key);
}
}
}