Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Apr 3, 2013
0 parents commit 53fc41c
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
target/
.classpath
.settings/
.project
.metadata
ActiveMQ/
FedoraRepository/
indexes/
ObjectStore/
*/.cache
.cache
36 changes: 36 additions & 0 deletions pom.xml
@@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo</artifactId>
<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>

<dependencies>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-kernel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>gov.loc</groupId>
<artifactId>bagit</artifactId>
<version>4.4</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
31 changes: 31 additions & 0 deletions src/main/java/org/fcrepo/federation/bagit/BagInfo.java
@@ -0,0 +1,31 @@

package org.fcrepo.federation.bagit;

import gov.loc.repository.bagit.Bag.BagConstants;
import gov.loc.repository.bagit.impl.BagItTxtImpl;

public class BagInfo extends BagItTxtImpl {

/**
* The ID under which this bag is stored.
*/
public String bagID;

/**
* Stores this bag-info.txt into its bag.
*/
public void save() {

}

public static BagInfo fromId(final String bagId) {
return null;
}

private static final long serialVersionUID = 1L;

public BagInfo(BagConstants bagConstants) {
super(bagConstants);
}

}
94 changes: 94 additions & 0 deletions src/main/java/org/fcrepo/federation/bagit/BagItConnector.java
@@ -0,0 +1,94 @@

package org.fcrepo.federation.bagit;

import java.io.File;
import java.io.IOException;
import java.util.Map;

import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;

import org.infinispan.schematic.document.Document;
import org.modeshape.connector.filesystem.FileSystemConnector;
import org.modeshape.jcr.JcrI18n;
import org.modeshape.jcr.api.nodetype.NodeTypeManager;
import org.modeshape.jcr.federation.spi.DocumentChanges;
import org.modeshape.jcr.federation.spi.ExtraPropertiesStore;
import org.modeshape.jcr.value.Name;
import org.modeshape.jcr.value.Property;

public class BagItConnector extends FileSystemConnector {

private static final String FILE_SEPARATOR = File.separator;
private static final String DELIMITER = File.pathSeparator;

/**
* The string path for a {@link File} object that represents the top-level directory accessed by this connector. This is set
* via reflection and is required for this connector.
*/
private String directoryPath;
private File directory;

/**
* A string that is created in the {@link #initialize(NamespaceRegistry, NodeTypeManager)} method that represents the absolute
* path to the {@link #directory}. This path is removed from an absolute path of a file to obtain the ID of the node.
*/
private String directoryAbsolutePath;
private int directoryAbsolutePathLength;

private NamespaceRegistry registry;

@Override
public void initialize( NamespaceRegistry registry,
NodeTypeManager nodeTypeManager ) throws RepositoryException, IOException {

super.initialize(registry, nodeTypeManager);
this.registry = registry;

// Initialize the directory path field that has been set via reflection when this method is called...
checkFieldNotNull(directoryPath, "directoryPath");
directory = new File(directoryPath);
if (!directory.exists() || !directory.isDirectory()) {
String msg = JcrI18n.fileConnectorTopLevelDirectoryMissingOrCannotBeRead.text(getSourceName(), "directoryPath");
throw new RepositoryException(msg);
}
if (!directory.canRead() && !directory.setReadable(true)) {
String msg = JcrI18n.fileConnectorTopLevelDirectoryMissingOrCannotBeRead.text(getSourceName(), "directoryPath");
throw new RepositoryException(msg);
}
directoryAbsolutePath = directory.getAbsolutePath();
if (!directoryAbsolutePath.endsWith(FILE_SEPARATOR)) directoryAbsolutePath = directoryAbsolutePath + FILE_SEPARATOR;
directoryAbsolutePathLength = directoryAbsolutePath.length() - FILE_SEPARATOR.length(); // does NOT include the separator

setExtraPropertiesStore(new BagItExtraPropertiesStore());
}



@Override
public Document getDocumentById(String id) {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean hasDocument(String id) {
// TODO Auto-generated method stub
return false;
}

@Override
public void storeDocument(Document document) {
// TODO Auto-generated method stub

}

@Override
public void updateDocument(DocumentChanges documentChanges) {
// TODO Auto-generated method stub

}



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

package org.fcrepo.federation.bagit;

import java.util.Map;

import org.modeshape.jcr.federation.spi.ExtraPropertiesStore;
import org.modeshape.jcr.value.Name;
import org.modeshape.jcr.value.Property;

public class BagItExtraPropertiesStore implements ExtraPropertiesStore {

@Override
public void storeProperties(String id, Map<Name, Property> properties) {
// TODO Auto-generated method stub
}

@Override
public void updateProperties(String id, Map<Name, Property> properties) {
// TODO Auto-generated method stub

}

@Override
public Map<Name, Property> getProperties(String id) {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean removeProperties(String id) {
// TODO Auto-generated method stub
return false;
}

}

0 comments on commit 53fc41c

Please sign in to comment.