Customization of the REST API

The REST API can be customized to support different resource representations, such as the XHTML or Atom formats. It can also be customized by adding attributes to the representation of a business object resource or by changing the structure of a representation.

To support a new resource representation, you must provide custom serializers that support the new formats.

If you add attributes, such as an attribute to the work order MBO resource in JSON representation, you must add a custom JSON serializer for the resource. To support additional query parameters, you must extend the MBO or OS handler.

Ensure that your customizations do not affect existing business processes or users. By creating a separate instance of the REST API for the resource types, you can avoid adverse affects.

For any customization, the class files must be included in the application EAR file as part of the commonweb library.

Example

The following steps customize the REST API:
  1. Create a system property by copying the mxe.rest.handler.mbo property, giving the property the name mxe.rest.handler.abcmbo, and assigning it the value com.ibm.tivoli.maximo.rest.ABCMboResourceRequestHandler.

    If the customization is generic to all MBOs, the custom class extends the base MBO handler. The URI context is abcmbo, and therefore URLs are in the following form: /maxrest/rest/abcmbo/workorder?...

    This step creates an instance of the REST API for the MBO resource.

  2. To handle query parameters that are specific to the work order MBO, provide a custom handler by creating the mxe.rest.handler.abcmbo.workorder system property and assigning it the value com.ibm.tivoli.maximo.rest.WOMboResourceRequestHandler.

    The class could extend the default MBO handler by using ABCMboResourceRequestHandler for MboResourceRequestHandler, for example.

  3. To customize the JSON serializer for the work order MBO, register the serializer by creating the mxe.rest.serializer.abcmbo.workorder.json system property and assigning it the value com.ibm.tivoli.maximo.rest.WOMboJSONSerializer.
  4. To support a new format, such as Atom, add the value atom to the mxe.rest.supported.formats system property. The name atom uniquely identifies the serializer for the format. You can specify any name as long as a serializer that has the name does not exist.
  5. Add a serializer class by creating the mxe.rest.serializer.abcmbo.atom system property and assigning it the value com.ibm.tivoli.maximo.rest.MboATOMSerializer.
  6. To identify the new format by using the HTTP Accept header, provide the mime type mapping by creating the mxe.rest.format.atom.mimetypes system property and assigning it the value application/atom+xml.
  7. Set the default format by assigning the value atom to the mxe.rest.abcmbo.defaultformat system property.

By following these steps, the customization does not affect other MBO or OS resource handlers because it is within the context of the abcmbo handler.