Skip to content

Commit

Permalink
Catching up to changes in kernel from the introduction of policy-driv…
Browse files Browse the repository at this point in the history
…en storage
  • Loading branch information
ajs6f committed Apr 26, 2013
1 parent 306c8fb commit 1c872cf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 44 deletions.
59 changes: 25 additions & 34 deletions pom.xml
Expand Up @@ -7,15 +7,12 @@
<version>4.0-SNAPSHOT</version>
</parent>
<artifactId>fcrepo-bagit-modeshape-federation-connector</artifactId>

<name>fcrepo-bagit-modeshape-federation-connector</name>
<description>Connects ModeShape to a filesystem directory containing BagIt directories.</description>

<properties>
<modeshape.version>3.2-SNAPSHOT</modeshape.version>
<modeshape.version>3.3-SNAPSHOT</modeshape.version>
<resteasy.version>2.3.5.Final</resteasy.version>
</properties>

<dependencies>
<dependency>
<groupId>org.fcrepo</groupId>
Expand All @@ -27,34 +24,30 @@
<artifactId>fcrepo-http-api</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Apache Velocity -->
<!-- Apache Velocity -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-kernel</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
</dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>

<!-- test gear -->
<dependency>
<groupId>org.fcrepo</groupId>
Expand All @@ -63,13 +56,13 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-http-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-http-commons</artifactId>
<version>${project.version}</version>
Expand Down Expand Up @@ -97,17 +90,17 @@
<artifactId>mail</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -116,11 +109,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<!-- This dependency is for compile-time: it keeps this module independent
of any given choice of JAX-RS implementation. It must be _after_ the test
gear. Otherwise it will get loaded during test phase, but because this is
Expand All @@ -142,12 +134,11 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/org/fcrepo/federation/bagit/BagItWatchService.java
Expand Up @@ -4,6 +4,7 @@
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import static java.util.regex.Pattern.compile;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;
Expand Down Expand Up @@ -31,17 +32,16 @@ public class BagItWatchService implements WatchService {

private static final Logger logger = getLogger(BagItWatchService.class);

static final Pattern MANIFEST = Pattern.compile("^manifest-([^\\.]+).txt$");
static final Pattern MANIFEST = compile("^manifest-([^\\.]+).txt$");

static final Pattern TAG_MANIFEST = Pattern
.compile("^tagmanifest-([^\\.]+).txt$");
static final Pattern TAG_MANIFEST = compile("^tagmanifest-([^\\.]+).txt$");

static GetFilesFromManifest getFilesFromManifest =
new GetFilesFromManifest();

WatchService delegate;
private WatchService delegate;

Collection<Path> tagFiles = new ArrayList<Path>();
private Collection<Path> tagFiles = new ArrayList<Path>();

Collection<Path> manifests = new ArrayList<Path>();

Expand Down Expand Up @@ -175,16 +175,15 @@ public Collection<File> apply(final File input) {
try (final LineNumberReader lnr =
new LineNumberReader(new FileReader(input))) {
final ArrayList<File> result = new ArrayList<File>();
String line = null;
String line;
while ((line = lnr.readLine()) != null) {
final String fileName = line.split(" ")[0];
final File file = new File(input.getParentFile(), fileName);
result.add(file);
}
return result;
} catch (final IOException e) {
e.printStackTrace();
return null;
throw new RuntimeException(e);
}
}
}
Expand Down
@@ -1,12 +1,13 @@

package org.fcrepo.federation.bagit;

import static java.util.concurrent.TimeUnit.SECONDS;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.WatchEvent;
import java.nio.file.WatchKey;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class ManifestMonitor implements Runnable {

Expand All @@ -28,7 +29,7 @@ public ManifestMonitor(final BagItConnector connector)
public void run() {
while (!this.shutdown) {
try {
final WatchKey key = watchService.poll(1, TimeUnit.SECONDS);
final WatchKey key = watchService.poll(1, SECONDS);
if (key != null) {
final List<WatchEvent<?>> events = key.pollEvents();
boolean manifest = false;
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/spring-test/repo.xml
Expand Up @@ -20,5 +20,6 @@
<bean class="org.fcrepo.services.ObjectService"/>
<bean class="org.fcrepo.services.LowLevelStorageService"/>
<bean class="org.fcrepo.services.DatastreamService"/>
<bean class="org.fcrepo.binary.PolicyDecisionPoint" />

</beans>

0 comments on commit 1c872cf

Please sign in to comment.