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

java.fedora.server.storage.translation.DOTranslatorModule 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.translation; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import fedora.server.Module; import fedora.server.Server; import fedora.server.errors.ModuleInitializationException; import fedora.server.errors.ObjectIntegrityException; import fedora.server.errors.ServerException; import fedora.server.errors.StreamIOException; import fedora.server.errors.UnsupportedTranslationException; import fedora.server.storage.types.DigitalObject; /** * DOTranslatorImpl as a Module. * * @author [email protected] * @version $Id: DOTranslatorModule.java 5220 2006-11-20 13:52:20Z cwilper $ */ public class DOTranslatorModule extends Module implements DOTranslator { private DOTranslatorImpl m_wrappedTranslator; public DOTranslatorModule(Map params, Server server, String role) throws ModuleInitializationException { super(params, server, role); } public void initModule() throws ModuleInitializationException { HashMap serMap=new HashMap(); HashMap deserMap=new HashMap(); Iterator nameIter=parameterNames(); while (nameIter.hasNext()) { String paramName=(String) nameIter.next(); if (paramName.startsWith("serializer_")) { String serName=paramName.substring(11); try { DOSerializer ser=(DOSerializer) Class.forName( getParameter(paramName)).newInstance(); serMap.put(serName, ser); } catch (Exception e) { throw new ModuleInitializationException( "Can't instantiate serializer class for format=" + serName + " : " + e.getClass().getName() + ": " + e.getMessage(), getRole()); } } else if (paramName.startsWith("deserializer_")) { String deserName=paramName.substring(13); try { DODeserializer deser=(DODeserializer) Class.forName( getParameter(paramName)).newInstance(); deserMap.put(deserName, deser); } catch (Exception e) { throw new ModuleInitializationException( "Can't instantiate deserializer class for format=" + deserName + " : " + e.getClass().getName() + ": " + e.getMessage(), getRole()); } } } m_wrappedTranslator=new DOTranslatorImpl(serMap, deserMap); } public void deserialize(InputStream in, DigitalObject out, String format, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_wrappedTranslator.deserialize(in, out, format, encoding, transContext); } public void serialize(DigitalObject in, OutputStream out, String format, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_wrappedTranslator.serialize(in, out, format, encoding, transContext); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy