Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ckstyle rule.
  • Loading branch information
nianma authored and mikedurbin committed Apr 30, 2015
1 parent 1986787 commit f110262
Show file tree
Hide file tree
Showing 44 changed files with 716 additions and 429 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
target/
.idea
*~
49 changes: 48 additions & 1 deletion pom.xml
Expand Up @@ -15,6 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.1.1.RELEASE</spring.version>
<jena.version>2.12.1</jena.version>
<checkstyle.plugin.version>2.14</checkstyle.plugin.version>
</properties>

<scm>
Expand Down Expand Up @@ -88,7 +89,6 @@
<artifactId>fcrepo-client</artifactId>
<version>4.1.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -118,17 +118,64 @@
</repository>

</repositories>

<pluginRepositories>
<pluginRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-build-tools</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<consoleOutput>true</consoleOutput>
<logViolationsToConsole>true</logViolationsToConsole>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<configLocation>fcrepo-checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>fcrepo-checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions src/main/java/org/fcrepo/migration/ContentDigest.java
Expand Up @@ -3,6 +3,7 @@
/**
* An interface defining access to information about a fedora datastream's
* content digest.
* @author mdurbin
*/
public interface ContentDigest {

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/fcrepo/migration/DatastreamInfo.java
Expand Up @@ -2,6 +2,7 @@

/**
* An interface defining access to information about a fedora datastream.
* @author mdurbin
*/
public interface DatastreamInfo {

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/fcrepo/migration/DatastreamVersion.java
Expand Up @@ -6,6 +6,7 @@
/**
* An interface defining access to information about a version of a
* fedora datastream.
* @author mdurbin
*/
public interface DatastreamVersion {

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/fcrepo/migration/DefaultContentDigest.java
Expand Up @@ -3,14 +3,20 @@
/**
* A default implementation of ContentDigest that accepts
* values at construction time.
* @author mdurbin
*/
public class DefaultContentDigest implements ContentDigest {

private String type;

private String digest;

public DefaultContentDigest(String type, String digest) {
/**
* default content digest.
* @param type the type
* @param digest the digest
*/
public DefaultContentDigest(final String type, final String digest) {
this.type = type;
this.digest = digest;
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/fcrepo/migration/DefaultObjectInfo.java
@@ -1,18 +1,22 @@
package org.fcrepo.migration;

import java.io.InputStream;

/**
* A default implementation of ObjectInfo that accepts
* values at construction time.
* @author mdurbin
*/
public class DefaultObjectInfo implements ObjectInfo {

private String pid;

private String uri;

public DefaultObjectInfo(String pid, String uri) {
/**
* the default object info
* @param pid the pid
* @param uri the uri
*/
public DefaultObjectInfo(final String pid, final String uri) {
this.pid = pid;
this.uri = uri;
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/fcrepo/migration/FedoraObjectHandler.java
@@ -1,18 +1,19 @@
package org.fcrepo.migration;

/**
* An interface for a class that processes Fedora 3 objects.
* An interface for a class that processes Fedora 3 objects.
* The single method {@link #processObject} would be invoked
* for each object to be processed.
* for each object to be processed.
* @author mdurbin
*/
public interface FedoraObjectHandler {

/**
* Invoked to process an object. All the metadata and content
* are accessible during this invocation.
* are accessible during this invocation.
* @param object an object encapsulating everything about a single
* Fedora 3 object.
*/
public void processObject(ObjectReference object);

}
10 changes: 10 additions & 0 deletions src/main/java/org/fcrepo/migration/FedoraObjectProcessor.java
Expand Up @@ -6,10 +6,20 @@
* A class that encapsulates an object for processing. This class represents a single object and
* exposes methods to query basic information about it and then to process it with an arbitrary
* StreamingFedoraObjectHandler.
* @author mdurbin
*/
public interface FedoraObjectProcessor {

/**
* get object information.
* @return the object info
*/
public ObjectInfo getObjectInfo();

/**
* process the object.
* @param handler the handler
* @throws XMLStreamException xml stream exception
*/
public void processObject(StreamingFedoraObjectHandler handler) throws XMLStreamException;
}
@@ -1,20 +1,21 @@
package org.fcrepo.migration;

/**
* An interface for a class that processes Fedora 3 objects
* as an iteration of versions. The single method
* An interface for a class that processes Fedora 3 objects
* as an iteration of versions. The single method
* {@link #processObjectVersions} would be invoked once for
* an object providing the entire version history (ie. times
* with identifiable changes) in the Fedora 3 object
* starting from the creation and proceeding chronologically
* @author mdurbin
*/
public interface FedoraObjectVersionHandler {

/**
* Invoked to process a version of a Fedora 3 object. All the metadata
* and content that changed from the previous version to the one
* represented by the current call is conventiently made available.
* @param versions an iterable of Objects each encapsulating everything
* @param versions an iterable of Objects each encapsulating everything
* about a single version of a Fedora 3 object.
*/
public void processObjectVersions(Iterable<ObjectVersionReference> versions);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/fcrepo/migration/MigrationIDMapper.java
@@ -1,13 +1,14 @@
package org.fcrepo.migration;

/**
* An interface whose implementations represent methods to
* convert Fedora 3 PIDs into fedora 4 paths.
* An interface whose implementations represent methods to
* convert Fedora 3 PIDs into fedora 4 paths.
* @author mdurbin
*/
public interface MigrationIDMapper {

/**
* Takes a Fedora 3 Object reference and returns the path
* Takes a Fedora 3 Object reference and returns the path
* that object would have in Fedora 4.
* @param object an ObjectReference for a Fedora 3 object.
* @return a path suitable for use in Fedora 4.
Expand All @@ -21,5 +22,5 @@ public interface MigrationIDMapper {
* @return a path suitable for use in Fedora 4.
*/
public String mapDatastreamPath(DatastreamInfo dsInfo);

}
46 changes: 39 additions & 7 deletions src/main/java/org/fcrepo/migration/Migrator.java
@@ -1,13 +1,14 @@
package org.fcrepo.migration;

import org.slf4j.Logger;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.slf4j.LoggerFactory.getLogger;

import javax.xml.stream.XMLStreamException;
import java.io.IOException;

import static org.slf4j.LoggerFactory.getLogger;
import javax.xml.stream.XMLStreamException;

import org.slf4j.Logger;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* A class that represents a command-line program to migrate a fedora 3
Expand All @@ -17,11 +18,18 @@
*
* The source is responsible for exposing objects from a fedora repository,
* while the handler is responsible for processing each one.
* @author mdurbin
*/
public class Migrator {

private static final Logger LOGGER = getLogger(Migrator.class);


/**
* the main method.
* @param args the arguments
* @throws IOException IO exception
* @throws XMLStreamException xml stream exception
*/
public static void main(final String [] args) throws IOException, XMLStreamException {

final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("spring/migration-bean.xml");
Expand All @@ -36,29 +44,53 @@ public static void main(final String [] args) throws IOException, XMLStreamExcep

private int limit;

/**
* the migrator. set limit to -1.
*/
public Migrator() {
limit = -1;
}

public void setLimit(int limit) {
/**
* set the limit.
* @param limit the limit
*/
public void setLimit(final int limit) {
this.limit = limit;
}

/**
* set the source.
* @param source the object source
*/
public void setSource(final ObjectSource source) {
this.source = source;
}


/**
* set the handler.
* @param handler the handler
*/
public void setHandler(final StreamingFedoraObjectHandler handler) {
this.handler = handler;
}

/**
* The constructor for migrator.
* @param source the source
* @param handler the handler
*/
public Migrator(final ObjectSource source, final StreamingFedoraObjectHandler handler) {
this();
this.source = source;
this.handler = handler;
}

/**
* the run method for migrator.
* @throws XMLStreamException xml stream exception
*/
public void run() throws XMLStreamException {
int index = 0;
for (final FedoraObjectProcessor o : source) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/fcrepo/migration/ObjectInfo.java
@@ -1,10 +1,9 @@
package org.fcrepo.migration;

import java.io.InputStream;

/**
* An interface defining access to the high level identifying information
* about a fedora 3 object.
* @author mdurbin
*/
public interface ObjectInfo {

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/fcrepo/migration/ObjectProperties.java
Expand Up @@ -5,6 +5,7 @@
/**
* An interface defining access to the object-level properties for
* a fedora 3 object.
* @author mdurbin
*/
public interface ObjectProperties {

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/fcrepo/migration/ObjectProperty.java
Expand Up @@ -3,6 +3,7 @@
/**
* An interface defining access to a specific object level property
* for a fedora 3 object.
* @author mdurbin
*/
public interface ObjectProperty {

Expand Down

0 comments on commit f110262

Please sign in to comment.