Developing custom REST API

You can develop custom REST API in the Persona-based UI using Eclipse.

Procedure

  1. Open Eclipse, and go to File > New > Project > Maven Project.
  2. Extract the sample project (custom-rest.zip) located in the $TOP/mdmui/samples folder to the new maven project.
  3. Right-click the maven project, and go to Build Path > Configure Build Path.
  4. In the Java Build Path window, add the following.
    • JRE System Library,
    • Admin UI JAR files located in the $TOP/jars folder,
    • REST API JAR file dependencies located in the $TOP/mdmui/libs folder,
    • Custom REST API JAR file (mdm-rest.jar) located in the $TOP/mdmui/libs/custom folder.
    Following are the project structure guidelines.
    • The package name should have prefix of com.ibm.rs.custom.
    • The controller class should contain public methods and follow package structure com.ibm.rs.custom.api.
    • The service class should perform business validations for input and invoke Data Access Object (DAO) class. It should follow package structure com.ibm.rs.custom.service.
    • The DAO class should invoke the Java™ APIs to perform business operations and convert them to some higher-level constructs (objects, collections). It should follow package structure com.ibm.rs.custom.dao and com.ibm.rs.custom.bean.
  5. To compile, right-click the cd custom-rest folder (pom.xml file), and go to Maven > Update project.
  6. Stop the services by using the following command.
    cd $TOP/bin/go
    ./stop_local.sh
  7. To copy the custom modifications to the WebSphere® Application Server folder where REST and Persona-based UI war files are extracted after the deployment, run the updateRtProperties.sh script present in the $TOP/mdmui/bin folder.
    To copy custom modifications successfully, place the custom code to the $TOP/mdmui/custom folder. The custom folder has following structure.
    API folder (custom code for REST API)
    classes (class files)
    Place the REST API custom code as a folder structure $TOP/mdmui/custom/api/classes/com/ibm/rs/custom/…
    OR
    As a JAR file $TOP/mdmui/custom/api/my-new-customapi.jar.
    The custom code should follow package structure as <directory>/com.ibm.rs.custom.<directory/files> folder structure.
    UI folder (custom files for UI)
    JS folder (JS file for UI)
    JSON folder (JSON file for UI)
  8. Start the services by using the following command.
    cd $TOP/bin/go
    ./start_local.sh

What to do next

You can test the custom REST APIs by using a REST client like Postman or Advanced REST Client plug-in in the Google Chrome browser.