Tech Blog

How to Replace a File in an Existing IE

In this use case a single file with a known (and unique) filename needs to be replaced. For this purpose we created a sample program called updateAIP.

The program requires:

  • The original filename.
  • The IE PID of the existing file, if not provided, will be retrieved by an SRU search for the filename.
  • The file PID of the existing file, if not provided, will be searched in the relevant IE using the following XPath:
/mets:mets/mets:amdSec/mets:techMD/mets:mdWrap/mets:xmlData/dnx:dnx[dnx:section/dnx:record/dnx:key[@id='fileOriginalName' and text() ='{0}']]/dnx:section/dnx:record[dnx:key[@id='internalIdentifierType' and text() ='PID']]/dnx:key[@id='internalIdentifierValue']

The target file is retrievable over scp.

The following APIs are used (see Open Platform APIs and javadoc for full details):

  • getIE
  • updateRepresentation

Usage

Update AIP can be used to replace or delete a file in an existing AIP stored in Rosetta. It uses Rosetta APIs to create a new revision of the representation which contains the file.

C:\>UpdateAIP.exe

Update AIP can be used to replace or delete a file in an existing AIP stored in Rosetta. It uses Rosetta APIs to create a new revision of the representation which contains the file.
UpdateAIP [-replace|-delete] [IEPID] [FLPID] [config options] file

Parameters:
        action:     replace (default) or delete
        PID:        PID of IE (IEXXXX) and/or file (FLXXXX) (optional)
        file:       Path to the local file to replace. Needs to be the same name as the file to be replaced/deleted.

Configuration Parameters (saved between sessions):
        user|u:     Server username for scp
        pass|p:     Server password for scp
        host|h:     Server host
        port:       Server application port (default 1801)
        appuser|au: Application username for web services
        apppass|ap: Application password for web services
        remotedir:  Directory on remote server to place file (default /tmp/updateaip)
        inst:       Application institution for web services (default INS00)

Example

Here’s the output for a case where it gets only a (unique) file name:

Settings saved.
2013-06-18 10:36:49,741 [1] INFO  Exlibris.Rosetta.UpdateAIP.UpdateAIP - Logged in user admin1 and received PDS Handle 18620131049370071453054536605.
2013-06-18 10:36:49,991 [1] INFO  Exlibris.Rosetta.UpdateAIP.UpdateAIP - Retrieved IE PID IE4474 for file name web-api-0001.png
2013-06-18 10:36:51,997 [1] INFO  Exlibris.Rosetta.UpdateAIP.UpdateAIP - Retrieved REP PID REP4475, FL PID FL4477 for file name web-api-0001.png
2013-06-18 10:36:52,006 [1] INFO  Exlibris.Rosetta.UpdateAIP.UpdateAIP - Uploading web-api-0001.png to /exlibris/tmp/aipupdate/web-api-0001.png on il-dps02
Connecting...OK

100% [##################################################] 36K/36K
Transfer completed successfuly (36069 bytes).

Disconnecting...OK
2013-06-18 10:36:53,883 [1] INFO  Exlibris.Rosetta.UpdateAIP.UpdateAIP - File web-api-0001.png replaced in IE4474, REP4475

 

Leave a Reply