Example: Checking the integrity of files in a file space

You can check the integrity of the files in a file space by submitting an HTTP request to the WebSphere® MQ Managed File Transfer Web Gateway. For example, if you are restoring a file system after data loss, you can check that the files in a file space exist in the correct location on the file system. The Web Gateway returns a response in XML or JSON format that lists the contents of a file space with an additional attribute to indicate the result of an integrity check on each file.

About this task

A successful request returns an HTTP status code of 200 and a payload that lists the first 100 files in the file space. You can request that the details of the files are returned in either XML or JSON format. You can write a web application to parse the content of the response and display it in an appropriate format to a web user. Only an administrator is authorized to list the files in a file space with the integrity-check attribute.

The following steps describe how to submit a request. In this example, the server hosting the WebSphere MQ Managed File Transfer Web Gateway is example.com. The name of the file space to list is john and it contains two files. The header Accept: application/xml specifies that the query returns the results in XML format. The header x-fte-check-integrity specifies that the query returns the results with the additional integrity check attribute included for each file.

Procedure

  1. Create an HTTP request with the following format:
    GET HTTP/1.1 /filespace/john
    Host: example.com
    User-Agent: mozilla
    Accept: application/xml
    x-fte-check-integrity: true
  2. Submit the request to the Web Gateway. The Web Gateway returns an HTTP response with the following format:
    <fileSpaces xsi:noNamespaceSchemaLocation="WebTransferStatus.xsd">
      <fileSpace size="2" name="john"> 
        <file fileLink="/wmqfte/filespace/john/
          414d51205745422e4654452020202020c1a1a34b03720120/ar5erh" 
              transferLink="/wmqfte/transfer/
              414d51205745422e4654452020202020c1a1a34b03720120" 
              transferID="414d51205745422e4654452020202020c1a1a34b03720120" 
              name="/tmp/file1.zip"
              fsLocation="/filespaces/john/
              414d51205745422e4654452020202020c1a1a34b03720120/file-0">
          <attribute-values mode="text" time="2010-08-26T11:45:02.000Z" 
    file-size="259354303" 
                            checksum-value="98611a272a27d373f92d73a08cf0d4f4" 
                            checksum-method="none"
                            integrity-check-result="OK"/>
        </file>
        <file fileLink="/wmqfte/filespace/john/
          414d51205745422e4654452020202020c1a1a34b06520120/ar5erh" 
              transferLink="/wmqfte/transfer/
               414d51205745422e4654452020202020c1a1a34b06520120" 
              transferID="414d51205745422e4654452020202020c1a1a34b06520120" 
              name="/tmp/file2.zip"
              fsLocation="/filespaces/john/
               414d51205745422e4654452020202020c1a1a34b06520120/file-0">
          <attribute-values mode="text" time="2010-08-26T12:15:02.260Z" 
              file-size="259554303" 
                            checksum-value="98611a272a27d37bf22d73a08cf0d4f4" 
                              checksum-method="none"
                            integrity-check-result="MISSING-FILESYSTEM"/>
        </file>
      </fileSpace>
    </fileSpaces>

Results

This example result indicates that the first file has passed the integrity check. The integrity-check-result attribute value of OK shows that the file exists in the Web Gateway database and that the matching file has been found on the file system. The second file has failed the integrity check. The integrity-check-result attribute value of MISSING-FILESYSTEM shows that the file exists in the Web Gateway database but that the file cannot be found on the file system in the location given by the fsLocation attribute. In this case it might be necessary for an administrator to delete the file from the file space, or restore the file space directory from a backup.

For the possible values of the integrity-check-result attribute, see File space information response format.