Skip to content

Latest commit

 

History

History
95 lines (70 loc) · 2.91 KB

File metadata and controls

95 lines (70 loc) · 2.91 KB

Interacting with MC using XML Format

Model Catalogue is providing limited XML API for getting the catalogue elements in XML format and to modify the catalogue. Examples in this documentation are using cURL for brevity.

Getting document as XML

You can download any catalogue element from the catalogue in the XML format by taking it’s Model Catalogue ID and appending /export to that URL. You need to sign in using the HTTP Basic Authentication to retrieve the document.

curl -u <mc username>:<mc password> <model catalogue id>/export

For example while running the catalogue in development environment you can run following command:

curl -u admin:admin http://localhost:8080/catalogue/measurementUnit/1.1/export

Result

<catalogue xmlns="http://www.metadataregistry.org.uk/assets/schema/1.2/metadataregistry.xsd">
  <measurementUnit name="celsius" id="http://localhost:8080/catalogue/measurementUnit/1" symbol="&#176;C">
    <description>degrees celsius</description>
  </measurementUnit>
</catalogue>

Uploading XML

You can upload the XML file to /catalogue/upload endpoint as file form parameter of POST request.

curl -D - -u <mc username>:<mc password> --form "file=@<path to the file>" <model catalogue URL>/catalogue/upload

For example in development environment it would look like

curl -D - -u admin:admin --form "[email protected]" http://localhost:8080/catalogue/upload

Result

HTTP/1.1 100 Continue

HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
X-Asset-ID: 232282
Location: http://localhost:8080/api/modelCatalogue/core/asset/228
Set-Cookie: JSESSIONID=785C02E9DEBADBD74263AD1FB1D73707; Path=/; HttpOnly
Content-Length: 0
Date: Wed, 04 Nov 2015 14:15:56 GMT

The upload will create new asset where you can monitor the progress. The X-Asset-ID header contains the newly created asset’s ID. You can use it to fetch the XML representation of the asset including the current processing status:

curl -u admin:admin http://localhost:8080/catalogue/asset/228/export

If your import takes longer time use to process you may get information about the pending asset:

<catalogue xmlns="http://www.metadataregistry.org.uk/assets/schema/1.2/metadataregistry_asset.xsd">
  <asset name="Import for celsius.xml" id="http://localhost:8080/catalogue/asset/228" status="PENDING">
    <description>Your import will be available in this asset soon. Use Refresh action to reload.</description>
  </asset>
</catalogue>

When the upload is fully processed you should get following result:

<catalogue xmlns="http://www.metadataregistry.org.uk/assets/schema/1.2/metadataregistry_asset.xsd">
  <asset name="Import for celsius.xml" id="http://localhost:8080/catalogue/asset/228">
    <description>Your import has finished.</description>
  </asset>
</catalogue>