All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.fedora.server.storage.DirectoryBasedRepositoryReader Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/*
 * -----------------------------------------------------------------------------
 *
 * 

License and Copyright: The contents of this file are subject to the * Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of * the License at * http://www.fedora-commons.org/licenses.

* *

Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License.

* *

The entire file consists of original code.

*

Copyright © 2008 Fedora Commons, Inc.
*

Copyright © 2002-2007 The Rector and Visitors of the University of * Virginia and Cornell University
* All rights reserved.

* * ----------------------------------------------------------------------------- */ package fedora.server.storage; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.HashMap; import java.util.Iterator; import org.apache.log4j.Logger; import fedora.server.Context; import fedora.server.errors.ObjectNotFoundException; import fedora.server.errors.ObjectIntegrityException; import fedora.server.errors.ServerException; import fedora.server.errors.StorageDeviceException; import fedora.server.errors.StreamIOException; import fedora.server.errors.UnsupportedTranslationException; import fedora.server.storage.translation.DOTranslator; /** * A RepositoryReader that uses a directory of serialized * objects as its working repository. * *

All files in the directory must be digital object serializations, * and none may have the same PID. This is verified upon construction.

* *

Note: This implementation does not recognize when files are added * to the directory. What is in the directory at construction-time * is what is assumed to be the extent of the repository for the life * of the object.

* * @author [email protected] * @version $Id: DirectoryBasedRepositoryReader.java 5220 2006-11-20 13:52:20Z cwilper $ */ public class DirectoryBasedRepositoryReader implements RepositoryReader { /** Logger for this class. */ private static final Logger LOG = Logger.getLogger( DirectoryBasedRepositoryReader.class.getName()); private File m_directory; private DOTranslator m_translator; private String m_exportFormat; private String m_storageFormat; private String m_encoding; private HashMap m_files=new HashMap(); /** * Initializes the RepositoryReader by looking at all files in the * provided directory and ensuring that they're all serialized * digital objects and that there are no PID conflicts. * * @param directory the directory where this repository is based. * @param translator the serialization/deserialization engine for objects. * @param exportFormat the format to use for exportObject requests. * @param storageFormat the format of the objects on disk. * @param encoding The character encoding used across all formats. */ public DirectoryBasedRepositoryReader(File directory, DOTranslator translator, String exportFormat, String storageFormat, String encoding) throws StorageDeviceException, ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_directory=directory; m_translator=translator; m_exportFormat=exportFormat; m_storageFormat=storageFormat; m_encoding=encoding; File[] files=directory.listFiles(); if (!directory.isDirectory()) { throw new StorageDeviceException("Repository storage directory not found."); } try { for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy