The SAP BTP Document Management Service(DMS) helps in managing business documents. It’s based on the OASIS (Organization for the Advancement of Structured Information Standards) industry standard CMIS (Content Management Interoperability Services) and includes features like versioning, hierarchies, access control, and document management.
In this blog, I will explain how to create a custom spring boot application in SAP BTP cloud foundry and integrate it with SAP BTP DMS.
Business Scenario
- Scenario 1:- Let’s say we have a business requirement to replicate documents from different SAP SaaS applications(e.g. SAP SuccessFactors) to SAP BTP Document Management Service. In this case, we can create a custom Java Spring Boot application and deploy it to BTP Cloud Foundry as an MTA(multi-target application). Spring Boot application can have scheduled Cron Jobs(if there is any need for automation) or REST APIs(to be triggered from UI and any other application) to interact with DMS rest APIs and SuccessFactors.
- Scenario 2: – If we have an existing spring boot application and we want to use SAP BTP DMS for document management then this example will be helpful.
- Scenario 3: – You Are Extending an SAP Product or Service, building a Middleware, and Publishing a Cloud App.
Technical Details
In this blog, I will create a maven-based spring boot application and will expose a REST API that will upload a document in the DMS. Spring Boot application will interact with DMS REST API through BTP destinations. The main reason for using BTP destinations is the DMS authentication will be taken care of by BTP destinations. I will be using SAP Cloud SDK to interact with BTP Destinations from Spring Boot.
Architecture
Prerequisite
- Access to SAP BTP Cloud Foundry, and org & space are created.
- Access to BTP destination.
- Access to SAP BTP DMS service and DMS repository is created.
- Eclipse(with Spring tool suite and Lombok plugin) and JDK(1.8) are installed in the development system.
- Cloud Foundry command line interface (CF CLI) is installed, and the path is set in the environment variable.
- Cloud MTA build tool (MBT) is installed, and the path is set in the environment variable.
- The Make tool is installed, and the path is set in the environment variable.
Create a destination in SAP BTP for DMS service
- Please make sure the URL contains the repository ID and folder name(if no folder is created in the repository, then use root)
Steps to create the application
- Create a maven-based spring boot project in Eclipse.
- Add the following dependencies in the pom.xml file.
- Create a Java class and add the following code to call the newly created destination and consume the DMS service.
- Create a Java class for swagger config and replace the code with the below code.
- Create a mta.yaml file in the workspace (where the project is created) and paste the below code into the mta.yaml file.
- Select the project in Eclipse and update(Maven) the project, please make sure there is no compilation error.
Build and Deployment
- Open the command prompt from the workspace(where the mta.yaml file is placed) folder.
- Build the project to generate the “.tar” file by using the below command in the command prompt.
- If the build is successful, then the SampleApplication.tar file will be created in the generated TAR folder.
- Use the below commands in the command prompt to log in to the BTP cloud foundry and deploy the project. (It will prompt you to enter the username and password for BTP. it will prompt you to select org and space if there is more than one).
- Once the deployment is successful, it will be shown in the applications under the space in SAP BTP.
- If everything is fine, then the status will be showing as started and the application can be accessed by using the URL shown under application routes.Test the application
- The application can be tested by using the swagger URL from the application.
- Click on the “/uploadFile” API to test the file upload functionality.
- Choose any file and click on “Execute”.
- If everything is fine, then the file will be uploaded to DMS and can be found in DMS.