Skip to content

Commit

Permalink
rewrite GetBinaryStore to reach into the Modeshape runningState to pu…
Browse files Browse the repository at this point in the history
…ll out the BinaryStore instance
  • Loading branch information
cbeer committed Apr 30, 2013
1 parent 46bd4de commit 50f2a5b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 44 deletions.
Expand Up @@ -33,7 +33,7 @@

import org.fcrepo.Datastream;
import org.fcrepo.services.functions.GetBinaryKey;
import org.fcrepo.services.functions.GetBinaryStore;
import org.modeshape.jcr.GetBinaryStore;
import org.fcrepo.services.functions.GetCacheStore;
import org.fcrepo.services.functions.GetGoodFixityResults;
import org.fcrepo.utils.FixityResult;
Expand Down Expand Up @@ -161,9 +161,6 @@ protected Set<LowLevelCacheEntry> getLowLevelCacheEntriesFromStore(final Composi

final ImmutableSet.Builder<LowLevelCacheEntry> blobs = builder();

//seems like we have to start it, not sure why.
compositeStore.start();

Iterator<Map.Entry<String,BinaryStore>> it = compositeStore.getNamedStoreIterator();

while(it.hasNext()) {
Expand Down Expand Up @@ -191,9 +188,6 @@ protected Set<LowLevelCacheEntry> getLowLevelCacheEntriesFromStore(final Infinis

final ImmutableSet.Builder<LowLevelCacheEntry> blobs = builder();

//seems like we have to start it, not sure why.
ispnStore.start();

for (final Cache<?, ?> c : ImmutableSet.copyOf(ispnStore.getCaches())) {

final CacheStore cacheStore = getCacheStore.apply(c);
Expand Down
@@ -1,5 +1,5 @@

package org.fcrepo.services.functions;
package org.modeshape.jcr;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Throwables.propagate;
Expand All @@ -21,8 +21,10 @@ public class GetBinaryStore implements Function<Repository, BinaryStore> {
public BinaryStore apply(final Repository input) {
checkArgument(input != null, "null cannot have a BinaryStore!");
try {
return ((JcrRepository) input).getConfiguration()
.getBinaryStorage().getBinaryStore();
assert(input != null);
JcrRepository.RunningState runningState = ((JcrRepository)input).runningState();

return runningState.binaryStore();
} catch (final Exception e) {
throw propagate(e);
}
Expand Down
Expand Up @@ -8,6 +8,7 @@
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
Expand Down
Expand Up @@ -32,7 +32,7 @@
import org.fcrepo.Datastream;
import org.fcrepo.FedoraObject;
import org.fcrepo.services.functions.GetBinaryKey;
import org.fcrepo.services.functions.GetBinaryStore;
import org.modeshape.jcr.GetBinaryStore;
import org.fcrepo.services.functions.GetCacheStore;
import org.fcrepo.services.functions.GetGoodFixityResults;
import org.fcrepo.utils.FixityResult;
Expand Down

This file was deleted.

@@ -0,0 +1,35 @@

package org.modeshape.jcr;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import javax.inject.Inject;
import javax.jcr.RepositoryException;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.modeshape.jcr.GetBinaryStore;
import org.modeshape.jcr.value.binary.BinaryStore;
import org.modeshape.jcr.value.binary.TransientBinaryStore;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


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

@Inject
javax.jcr.Repository repo;

@Test
public void testApply() throws RepositoryException {
final GetBinaryStore testObj = new GetBinaryStore();

final BinaryStore binaryStore = testObj.apply(repo);

assertThat(binaryStore, instanceOf(TransientBinaryStore.class));

}

}

0 comments on commit 50f2a5b

Please sign in to comment.