Sign inSign up

isaitb/zip-processing

By isaitb

Updated 2 days ago

GITB processing service to allow GITB TDL test cases to extract information from ZIP archives.

Image
Integration & delivery
Developer tools
Monitoring & observability
0

4.5K

isaitb/zip-processing repository overview

Banner

Introduction

A web application implementing the GITB processing service API to allow GITB TDL test cases to extract information from ZIP (or ZIP-like) archives. This service is meant to be used as the service handler for GITB TDL processing transactions, to realise process steps.

This image is maintained by the European Commission's DIGIT and specifically the Interoperability Test Bed, a conformance testing service for projects involved in the delivery of cross-border public services. Find out more here.

Capabilities

The purpose of this service is to extract information from a ZIP archive:

  • Obtain the table of contents of a provided archive.
  • Extract one or more files from the archive based on provided search criteria.

This component functions as a stateful processing service, with extraction operations carried out within the scope of a processing transaction. This allows the ZIP archive to be provided once to the service and then maintained as state across calls to efficiently carry out several extraction operations. The archive in question is removed once the processing transaction or the overall test session ends.

The operations supported by the service are listed in the following table:

OperationDescriptionInput(s)Output(s)
initializeProvide the ZIP archive to the service for subsequent extraction operations.YesA map with two elements (entries: a number representing the count of entries included in the archive; entryPaths: a string including a summary of the included paths, listing them one by one in square brackets)
extractExtract one or more files from the archive.YesA map containing three entries (matched: a boolean representing if matches were made; entries: a number representing the count of entries that were matched; entry: a list with one item per matched entry). Each item in the entry list (corresponding to a matched entry) is a map with two further fields (path, a string with the file's precise path; content: the binary content of the file)

The input parameters expected by the different operations are as follows:

OperationInput nameRequired?Description
initializezipYesA binary input for the archive to process.
extractpathYesA string with the path of the archive's entry (or entries) to return.
casepathNoA string set as "true" or "false" (the default) specifying whether the path matching should be case sensitive.
matchpathNoA string set as "exact" or "regexp" (the default) specifying whether the path should be considered for an exact match or as a regular expression.

Configuration and deployment

To deploy this service the simplest approach is to use it via Docker Compose. The following is a sample docker-compose.yml file to use for its deployment that represents the minimum configuration needed:

version: '2'

services:
   zip-processing:
      image: isaitb/zip-processing:latest
      restart: unless-stopped
      ports:
       - "8080:8080"

Regarding the configuration of the service, the key points to take into account are the following:

  • The internal port on which the service is listening on is 8080. This needs to be mapped to your host or accessed directly if within the same Docker network.
  • The web application context used by the service is /zip.

The following table lists the supported configuration properties that can be used as environment variables as well as any assumed defaults:

VariableDescriptionDefault value
processing.dataFolderThe folder under which uploaded ZIP archives will be temporarily maintained for ongoing test sessions./processor/tmp
processing.sessionTimeOutThe maximum time (in hours) provided archives will be retained for active test sessions.24

In addition, is it interesting to note that the service is implemented using Spring Boot and as such any standard Spring Boot configuration properties can also be similarly set via environment variables. Properties you may consider to override are relevant to logging, the server.servlet.context-path (set by default to /zip) and the server.port (set by default to 8080).

Once your docker-compose.yml file has been prepared to match your environment you may start the service using docker compose up -d. Assuming a deployment using the default configuration on your localhost's port 8080, the service will be available at http://localhost:8080/zip/api/processing. This means that when used in the Test Bed as a messaging handler (which requires the WSDL address), this would be provided as http://localhost:8080/zip/api/processing?wsdl.

Use within GITB TDL test cases

The following code sample explains how to use the service from GITB TDL test cases.

<steps>
   <!-- 
      As a first step create processing transaction pointing to the service
   -->
   <bptxn txnId="t1" handler="http://localhost:8080/zip/api/processing?wsdl"/>
   <!--
      Call the 'initialize' operation to pass the binary archiveContent as an input named 'zip'
   -->
   <process id="toc" txnId="t1" operation="initialize">
      <input name="zip">$archiveContent</input>
   </process>		
   <!--
      Call the 'extract' operation to retrieve a file with an exact but not case-sensitive match
   -->
   <process output="zip" txnId="t1" operation="extract">
      <input name="path">'META-INF/manifest.xml'</input>
      <input name="match">'exact'</input>
      <input name="case">'false'</input>
   </process>
   <!--
      Use if needed the number of returned entries
   -->
   <log>"Extracted " || $zip{entries} || " file(s)"</log>
   <if hidden="true">
      <cond>$zip{matched}</cond>
      <then>
         <!--
            Use the extracted file (first match)
         -->
         <log>"Processing file " || $zip{entry}{0}{path} || "..."</log>
         <assign to="file">$zip{entry}{0}{content}</assign>
      </then>
   </if>
   <!--
      Close the processing transaction to release the processed archive.
   -->
   <eptxn txnId="t1"/>
</steps>

Licence

This tool is shared using the European Union Public Licence (EUPL) version 1.2.

The authors of this tool waive any and all liability linked to its usage. In terms of data, the tool does not harvest, collect or process in any way data nor does it maintain any state besides the temporary storage of archives for the duration of active processing transactions.

Contact

To get in touch for feedback or questions please send an email to [email protected].

Tag summary

Content type

Image

Digest

sha256:833bf5c9f

Size

150.8 MB

Last updated

2 days ago

docker pull isaitb/zip-processing