Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note
titleNote

This documentation relates to a work in progress during three focused sprints starting on August 29, 2016 and as such, the features and procedures described here may not be finalized and released.

Exporting resources

There are two different methods available for exporting metadata and digital objects from a Fedora 4 repository, the first uses the Camel Serialization Module https://github.com/fcrepo4-exts/fcrepo-camel-toolbox/tree/master/fcrepo-serialization , . The first relies on Camel and the second uses is a stand alone command line tool
utility. Both methods can export RDF and can be configured to also export binary resources. 
Use of the

Exporting Resources Using the Camel Serialization Module


The Camel Serializer is documented here https://wiki.duraspace.org/display/FF/Export+Format .  This method is considered a Module is currently a proof of concept but has documentation and code.   It works by listening for events about newly created resources, or edits to existing resources, and as such it cannot . As such, the re-indexer Camel component must be invoked to export resources that were created before it started listening, unless they are edited while the camel serializer Camel Serializer is turned on.

Exporting Resources Using the Export Tool

The command line tool is part of the Import Export Utilityhttps://github.com/fcrepo4-labs/fcrepo-import-export . This tool can export an entire repository, or a subset, and is intended as a method of for creating a complete backup of the content of a single Fedora container and all its descendant resources, in a format that . From there, it can be imported , back into the same Fedora repository, a different Fedora Repository, or into an another external system.

Installing the import-export

...

With fcrepo4-vagrant

This example uses a Fedora 4 Vagrant https://github.com/fcrepo4-exts/fcrepo4-vagrant instance as a test environment.  By following these instructions, you should be able to duplicate these exact results.

Pre-requisites

Vagrant
Virtualbox
Git

Installation

...

    run the following commands:
   

Code Block
languagebash
git clone https://github.com/fcrepo4-exts/fcrepo4-vagrant.git
cd fcrepo4-vagrant

utility

Fedora 4

The import/export utility is designed to work against the Fedora 4 REST API. Therefore, you first must have a running Fedora repository.

There are several ways to install a Fedora repository if you do not have one already available, see either:

...

  1. Quick Start, or
  2. Fedora Vagrant
        1. (optional step to turn off user authentication) edit the file at install_scripts/config and

      ...

        1. change FEDORA_AUTH=

      ...

        1. true to FEDORA_AUTH=false

      ...

        1.  and save the file

      ...

      Code Block
      languagebash
      vagrant up

      ...

      Import/Export Utility

      The import/export utility maybe be installed in one of two ways:

      1. Download executable jar
      2. Build from source

      Preparing sample data

      1. Go to Fedora in a browser. If you're using the Quick Start method, this will located at: http://localhost:8080/

      ...

      Code Block
      languagebash
      vagrant ssh
      sudo su -
      cd /opt
      git clone https://github.com/fcrepo4-labs/fcrepo-import-export
      cd fcrepo-import-export
      mvn clean install

         

      Without vagrant

      The export tool can be run on any computer that has access to the Fedora repository.

      Pre-requisites

      Java 8
      Mave
      Git

      Code Block
      languagebash
      git clone https://github.com/fcrepo4-labs/fcrepo-import-export
      cd fcrepo-import-export
      mvn clean install

      Preparing a sample

      ...

      1. rest

      ...

      1. Under the 
      1. Create New Child Resource

      ...

      1. form on the right-hand side of the page,

      ...

      1. create a new resource called "albums"
      2. Navigate to

      ...

      1. the new resource at http://localhost:8080/

      ...

      1. rest/albums
      2. Under type on the right-hand side of the page, choose "binary" and select a file to upload from the resulting Choose File button
      3. Leave the identifier field blank and click Add

      You will now have a Container with a binary file ready to export at and create a new child resource there.  This time, change the type to binary and upload a sample binary file. I used a jpg image for this example.  The identifier will get filled in by Fedora if you don't choose one yourself.
      You now have a Container to export (http://localhost:8080/fcrepo/rest/albums).

      Using the export tool

      Move to the directory where you downloaded the code (cd . For Vagrant installs, this will be under /opt/fcrepo-import-export for the vagrant install).   ; otherwise, it will located in the directory where you cloned the GitHub repository when you build the tool from source. From there, you will need to locate the compiled jar file. If you build it from source, it will be in the GitHub repo at fcrepo-import-export/target/fcrepo-import-export-0.3.0-SNAPSHOT.jar.

      To see all the available command line options:

      Code Block
      languagebashtext
      java -jar fcrepo-import-export-driver/target/fcrepo-import-export-driver-0.3.0.1-SNAPSHOT.jar -h

      Note: You will see "Error parsing args: Unrecognized option: -h" but this is bug and will be addressed in forthcoming releases.

      To export all the RDF and binary resources in your sample container:

      Code Block
      languagebashtext
      java -jar fcrepo-import-export-driver/target/fcrepo-import-export-driver-0.3.0.1-SNAPSHOT.jar -m-mode export --rresource http://localhost:8080/fcrepo/rest/albums -d-dir /tmp/descriptionstest --b /tmp/binaries
      


      You should now have RDF resources and binaries exported to /tmp/test.

      Logging

      To change the import-export logging level (default is INFO), set the fcrepo.log.importexport system property when running the command:

      • Note, available logging levels are: TRACE, DEBUG, INFO, WARN, and ERROR
      Code Block
      languagetext
      java -Dfcrepo.log.importexport=WARN -jar fcrepo-import-export/target/fcrepo-import-export-0.3.0-SNAPSHOT.jar --mode export --resource http://localhost:8080/rest/albums --dir /tmp/test --binaries


      Options

      Exporting only RDF

      descriptions and binary resources in /tmp/binaries.  If you do not want backups of the binaries, omit the --b flagbinaries option.  You cannot export only binaries , you must include the -d flag.
      There are other command line options available, e.g.,:
      -u without the rdf metadata description.

      Authentication

      Pass the -u option to provide a username and password for Fedora basic authentication.
      With the vagrant box, if you If you are using the Vagrant installation, it will have Fedora Auth turned on and are using the default settings, you would enabled and you will need to add the following to your command:

      Code Block
      languagebash
      -u fedoraAdmin:secret3 

      Format Options

      Pass -x option to use a different rdf serialization.
      For file extension on the exported rdf, or -l to change the rdf language used. For example if you want json-ld instead of turtle, use:

      Code Block
      languagebash
      -x .json -l application/ld+json

      The full list of available serializations is:

      • application/ld+json
      • application/n-triples
      • application/rdf+xml
      • text/n3 (or text/rdf+n3)
      • text/plain
      • text/turtle (or application/x-turtle)

      (from RESTful HTTP API)

      Importing resources

      Exported resources may be imported back into the repository from which they came, or into the same path in of another repository instance

      The following command will import the previous export into the same location of the same repository.

      Code Block
      languagetext
      java -jar fcrepo-import

      ...

      -export/target/fcrepo-import-export-0.3.0-SNAPSHOT.jar --mode import --resource http://localhost:8080/rest/albums --dir /tmp/test --binaries
      

      To import into a different repository and/or path,  use the map flag to ensure that the base URIs of the resources are properly translated in the new repository.

      The following command will import the previous export into the same location of the same repository.  In other words,  the import would complete the migration of data from http://localhost:8080/rest/albums to http://localhost:8686/rest/albums.To use the fcrepo-import tool, you'll need to have java 8 (or higher) installed. 

      Code Block
      languagebashtext
      java -jar fcrepo-import-export/target/fcrepo-import-export-0.3.0-SNAPSHOT.jar [options]

       

      Export Package Format

      ...

       --mode import --resource http://localhost:8686/rest/albums --dir /tmp/test --binaries --map http://localhost:8080/rest/albums,http://localhost:8686/rest/albums