Search in sources :

Example 11 with MCRUsageException

use of org.mycore.common.MCRUsageException in project mycore by MyCoRe-Org.

the class MCRMetadataVersion method retrieve.

/**
 * Retrieves this version of the metadata
 *
 * @return the metadata document as it was in this version
 * @throws MCRUsageException
 *             if this is a deleted version, which can not be retrieved
 */
public MCRContent retrieve() throws IOException {
    if (type == DELETED) {
        String msg = "You can not retrieve a deleted version, retrieve a previous version instead";
        throw new MCRUsageException(msg);
    }
    try {
        SVNRepository repository = vm.getStore().getRepository();
        MCRByteArrayOutputStream baos = new MCRByteArrayOutputStream();
        repository.getFile(vm.getStore().getSlotPath(vm.getID()), revision, null, baos);
        baos.close();
        return new MCRByteContent(baos.getBuffer(), 0, baos.size(), getDate().getTime());
    } catch (SVNException e) {
        throw new IOException(e);
    }
}
Also used : MCRUsageException(org.mycore.common.MCRUsageException) MCRByteArrayOutputStream(org.mycore.common.content.streams.MCRByteArrayOutputStream) MCRByteContent(org.mycore.common.content.MCRByteContent) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException)

Aggregations

MCRUsageException (org.mycore.common.MCRUsageException)11 IOException (java.io.IOException)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)2 BufferedInputStream (java.io.BufferedInputStream)1 NameNotFoundException (javax.naming.NameNotFoundException)1 NamingException (javax.naming.NamingException)1 Attribute (javax.naming.directory.Attribute)1 Attributes (javax.naming.directory.Attributes)1 DirContext (javax.naming.directory.DirContext)1 InitialDirContext (javax.naming.directory.InitialDirContext)1 SearchControls (javax.naming.directory.SearchControls)1 SearchResult (javax.naming.directory.SearchResult)1 Document (org.jdom2.Document)1 Element (org.jdom2.Element)1 Test (org.junit.Test)1 MCRAccessException (org.mycore.access.MCRAccessException)1 MCRException (org.mycore.common.MCRException)1