Skip to content

Commit

Permalink
rename some bad class names to LowLevel...
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Mar 12, 2013
1 parent 1801499 commit 64ec7c1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 30 deletions.
@@ -1,50 +1,41 @@
package org.fcrepo.services;

import org.fcrepo.utils.BinaryCacheStore;
import org.fcrepo.utils.LowLevelCacheStore;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.CacheStoreConfiguration;
import org.infinispan.loaders.CacheLoaderManager;
import org.infinispan.loaders.CacheStore;
import org.infinispan.loaders.decorators.ChainingCacheStore;
import org.modeshape.jcr.JcrRepository;
import org.modeshape.jcr.RepositoryConfiguration;
import org.modeshape.jcr.cache.NodeKey;
import org.modeshape.jcr.value.BinaryKey;
import org.modeshape.jcr.value.BinaryValue;
import org.modeshape.jcr.value.binary.AbstractBinaryStore;
import org.modeshape.jcr.value.binary.BinaryStore;
import org.modeshape.jcr.value.binary.BinaryStoreException;
import org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore;

import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.modeshape.jcr.api.JcrConstants.JCR_DATA;

import org.fcrepo.utils.infinispan.StoreChunkInputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;

public class RepositoryService {
public class LowLevelStorageService {


private static final Logger logger = LoggerFactory
.getLogger(RepositoryService.class);
.getLogger(LowLevelStorageService.class);


@Inject
Expand All @@ -55,7 +46,7 @@ public class RepositoryService {
*/
private static Session readOnlySession;

private static List<BinaryCacheStore> cacheStores;
private static List<LowLevelCacheStore> cacheStores;

private static JcrRepository getRepositoryInstance() {
return (JcrRepository)readOnlySession.getRepository();
Expand All @@ -67,7 +58,7 @@ private static JcrRepository getRepositoryInstance() {
* @return a map of binary stores and input streams
* @throws RepositoryException
*/
public static HashMap<BinaryCacheStore, InputStream> getContentBlobs(Node resource) throws RepositoryException {
public static HashMap<LowLevelCacheStore, InputStream> getContentBlobs(Node resource) throws RepositoryException {

BinaryValue v = (BinaryValue) resource.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary();

Expand All @@ -80,11 +71,11 @@ public static HashMap<BinaryCacheStore, InputStream> getContentBlobs(Node resour
* @param key a Modeshape BinaryValue's key.
* @return a map of binary stores and input streams
*/
public static HashMap<BinaryCacheStore, InputStream> getBlobs(BinaryKey key) {
public static HashMap<LowLevelCacheStore, InputStream> getBlobs(BinaryKey key) {

HashMap<BinaryCacheStore, InputStream> blobs = new LinkedHashMap<BinaryCacheStore, InputStream>();
HashMap<LowLevelCacheStore, InputStream> blobs = new LinkedHashMap<LowLevelCacheStore, InputStream>();

for( BinaryCacheStore c : getLowLevelCacheStores()) {
for( LowLevelCacheStore c : getLowLevelCacheStores()) {
try {
blobs.put(c, c.getInputStream(key));
} catch (BinaryStoreException e) {
Expand Down Expand Up @@ -120,13 +111,13 @@ private static BinaryStore getBinaryStore() {
*
* @return a list of "BinaryCacheStore", an abstraction over a plain BinaryStore or a specific Infinispan Cache
*/
private static List<BinaryCacheStore> getLowLevelCacheStores() {
private static List<LowLevelCacheStore> getLowLevelCacheStores() {
// I'm assuming the list of stores doesn't change.. probably not a safe assumption
if(cacheStores != null) {
return cacheStores;
}

List<BinaryCacheStore> stores = new ArrayList<>();
List<LowLevelCacheStore> stores = new ArrayList<>();

BinaryStore store = getBinaryStore();

Expand All @@ -151,17 +142,17 @@ private static List<BinaryCacheStore> getLowLevelCacheStores() {

// the stores are a map of the cache store and the configuration; i'm just throwing the configuration away..
for( CacheStore s : chainingCacheStore.getStores().keySet()) {
stores.add(new BinaryCacheStore(store, s));
stores.add(new LowLevelCacheStore(store, s));
}

} else {
// just a nice, simple infinispan cache.
stores.add(new BinaryCacheStore(store, cacheStore));
stores.add(new LowLevelCacheStore(store, cacheStore));
}

}
} else {
stores.add(new BinaryCacheStore(store));
stores.add(new LowLevelCacheStore(store));
}

cacheStores = stores;
Expand Down
Expand Up @@ -9,18 +9,18 @@

import java.io.InputStream;

public class BinaryCacheStore {
public class LowLevelCacheStore {

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) {
public LowLevelCacheStore(BinaryStore store, CacheStore low_level_store) {
this.store = store;
this.low_level_store = low_level_store;
}

public BinaryCacheStore(BinaryStore store) {
public LowLevelCacheStore(BinaryStore store) {
this.store = store;
this.low_level_store = null;
}
Expand Down
@@ -1,7 +1,6 @@
package org.fcrepo.services;

import org.apache.commons.io.IOUtils;
import org.fcrepo.AbstractTest;
import org.fcrepo.Datastream;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -14,20 +13,19 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;

import static org.fcrepo.services.DatastreamService.createDatastreamNode;
import static org.fcrepo.services.DatastreamService.getDatastream;
import static org.fcrepo.services.ObjectService.createObjectNode;
import static org.fcrepo.services.RepositoryService.getContentBlobs;
import static org.fcrepo.services.LowLevelStorageService.getContentBlobs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;



@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/spring-test/repo.xml"})
public class RepositoryServiceTest {
public class LowLevelStorageServiceTest {

@Inject
Repository repo;
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-kernel/src/test/resources/spring-test/repo.xml
Expand Up @@ -22,6 +22,6 @@

<bean class="org.fcrepo.services.ObjectService"/>
<bean class="org.fcrepo.services.DatastreamService"/>
<bean class="org.fcrepo.services.RepositoryService"/>
<bean class="org.fcrepo.services.LowLevelStorageService"/>

</beans>

0 comments on commit 64ec7c1

Please sign in to comment.