java.fedora.server.storage.SimpleBMechReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fcrepo-client Show documentation
Show all versions of fcrepo-client Show documentation
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.util.Date;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import org.xml.sax.InputSource;
import fedora.server.Context;
import fedora.server.errors.DatastreamNotFoundException;
import fedora.server.errors.MethodNotFoundException;
import fedora.server.errors.ObjectIntegrityException;
import fedora.server.errors.RepositoryConfigurationException;
import fedora.server.errors.ServerException;
import fedora.server.errors.StreamIOException;
import fedora.server.errors.GeneralException;
import fedora.server.errors.UnsupportedTranslationException;
import fedora.server.storage.translation.DOTranslator;
import fedora.server.storage.RepositoryReader;
import fedora.server.storage.types.BMechDSBindSpec;
import fedora.server.storage.types.DigitalObject;
import fedora.server.storage.types.MethodDef;
import fedora.server.storage.types.MethodParmDef;
import fedora.server.storage.types.MethodDefOperationBind;
import fedora.server.storage.service.ServiceMapper;
/**
* A BMechReader based on a DigitalObject.
*
* @author [email protected]
* @version $Id: SimpleBMechReader.java 5220 2006-11-20 13:52:20Z cwilper $
*/
public class SimpleBMechReader
extends SimpleServiceAwareReader
implements BMechReader {
private ServiceMapper serviceMapper;
public SimpleBMechReader(Context context, RepositoryReader repoReader,
DOTranslator translator,
String exportFormat, String storageFormat,
String encoding,
InputStream serializedObject)
throws ObjectIntegrityException, StreamIOException,
UnsupportedTranslationException, ServerException {
super(context, repoReader, translator, exportFormat, storageFormat,
encoding, serializedObject);
serviceMapper = new ServiceMapper(GetObjectPID());
}
/**
* Alternate constructor for when a DigitalObject is already
* available for some reason.
*/
public SimpleBMechReader(Context context, RepositoryReader repoReader,
DOTranslator translator, String exportFormat, String encoding,
DigitalObject obj) {
super(context, repoReader, translator, exportFormat,
encoding, obj);
serviceMapper = new ServiceMapper(GetObjectPID());
}
public MethodDef[] getServiceMethods(Date versDateTime)
throws DatastreamNotFoundException, ObjectIntegrityException,
RepositoryConfigurationException, GeneralException {
return serviceMapper.getMethodDefs(
new InputSource(new ByteArrayInputStream(
getMethodMapDatastream(versDateTime).xmlContent)));
}
public MethodParmDef[] getServiceMethodParms(String methodName, Date versDateTime)
throws MethodNotFoundException, ServerException {
return getParms(getServiceMethods(versDateTime), methodName);
}
public MethodDefOperationBind[] getServiceMethodBindings(Date versDateTime)
throws DatastreamNotFoundException, ObjectIntegrityException,
RepositoryConfigurationException, GeneralException {
return serviceMapper.getMethodDefBindings(
new InputSource(new ByteArrayInputStream(
getWSDLDatastream(versDateTime).xmlContent)),
new InputSource(new ByteArrayInputStream(
getMethodMapDatastream(versDateTime).xmlContent)));
}
public BMechDSBindSpec getServiceDSInputSpec(Date versDateTime)
throws DatastreamNotFoundException, ObjectIntegrityException,
RepositoryConfigurationException, GeneralException {
return serviceMapper.getDSInputSpec(
new InputSource(new ByteArrayInputStream(
getDSInputSpecDatastream(versDateTime).xmlContent)));
}
public InputStream getServiceMethodsXML(Date versDateTime)
throws DatastreamNotFoundException, ObjectIntegrityException {
return new ByteArrayInputStream(
getMethodMapDatastream(versDateTime).xmlContent);
}
/**
* Get the parms out of a particular service method definition.
* @param methods
* @return
*/
private MethodParmDef[] getParms(MethodDef[] methods, String methodName)
throws MethodNotFoundException, ServerException
{
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy