Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
vneecious
Advisor
Advisor

Hello SAP Community!

I'm happy to introduce you to the sap-cap-sdm-plugin, a plugin designed to streamline the integration between CAP (Node.js) and DMS (Document Management Service).

This idea came when I stumbled upon Daniel’s blog post about cds.plugins. In his example, Daniel creates a custom annotation that appends an emoji to the end of the text for properties that are annotated with it. Although simplistic, his example gave me some ideas.

Before developing this plugin, I conceived the sap-cloud-cmis-client library, aiming to streamline the integration between CAP/cloud-sdk projects and DMS on Cloud Foundry. Although useful, it fell short of providing a truly effortless experience for developers, which prompted me to explore this relatively new possibility.

The main goal was clear: Provide a tool where developers could integrate their CAP projects with SAP DMS by just annotating their entities using `SDM.Entity` and `SDM.Property` while the plugin would handles the technical details in the background. After addressing numerous questions, reviewing extensive documentation, and investing some hours, `sap-cap-sdm-plugin` came into existence.

How to Use

Here’s a step-by-step guide:

1. Install the Plugin:

 

npm i sap-cap-sdm-plugin

 

2. Configure the Plugin:

Add it to the `cds.requires` section of your package.json.

 

"cds": {
    "requires": {
        "sap-cap-sdm-plugin": {
            "impl": "sap-cap-sdm-plugin",
            "settings": {
                "destination": "<YOUR_SDM_DESTINATION_NAME>",
                "repositoryId": "<YOUR_REPOSITORY_ID>" // Optional. Remove if you have only one repository.
            }
        }
    }
}

 

You have to specify the destination related to the DMS service. If you have multiple repositories, you can optionally specify the repositoryId you want to use. Since it's CAP, you can also set specific configurations for different profiles.

 

"cds": {
    "requires": {
        "sap-cap-sdm-plugin": {
            "impl": "sap-cap-sdm-plugin",
            "[development]": { // development profile
              "settings": {
                  "destination": "<YOUR_SDM_DESTINATION_NAME>",
                  "repositoryId": "123"
              }
            },
            "[production]": { // production profile
              "settings": {
                  "destination": "<YOUR_SDM_DESTINATION_NAME>",
                  "repositoryId": "456"
              }
            }
        }
    }
}

 

3. Create an Entity:

Create an entity that should be "linked" to the DMS, using the right annotations.

 

service SampleService {
    @cds.persistence.skip
    @Former Member.Entity
    entity Files {
        key id       : String      @Former Member.Field      : { type : 'property', path : 'cmis:objectId' };
        name         : String      @Former Member.Field      : { type : 'property', path : 'cmis:name' };
        content      : LargeBinary @Core.MediaType : contentType  @Core.ContentDisposition.Filename : name;
        contentType  : String      @Core.IsMediaType
                                   @Former Member.Field      : { type : 'property', path : 'cmis:contentStreamMimeType' };
        createdBy    : String      @Former Member.Field      : { type : 'property', path : 'cmis:createdBy' };
        creationDate : Date        @Former Member.Field      : { type : 'property', path : 'cmis:creationDate' };
    }
}

 

With this setup, you can perform basic CRUD operations directly on DMS, using this OData Entity as a "proxy". For additional functionalities, you may refer to examples provided in the example folder.  

Limitations to Consider

While sap-cap-sdm-plugin is efficient for a majority of scenarios, it has its limitations, like not supporting versioned repositories, thumbnail generation, among others. I’m on it and looking forward to enhancing its capabilities. Your feedback is invaluable, so don’t hesitate to share your thoughts or seek assistance on GitHub.

Hope you like it! 🙂

2 Comments
mcselvan03
Discoverer
0 Kudos

 

I discovered an error in the way query parameters are encoded. Currently, they are transmitted in their raw form without encoding, causing issues with the Open API. Specifically, the API doesn't accept unencoded values for the {directoryPath} parameter. To resolve this, we need to implement proper URL encoding for all query parameters before sending the request. This will ensure compatibility with the Open API and prevent further errors. Please prioritize fixing this issue as soon as possible.

mcselvan03_0-1707452575819.png

 

mcselvan03
Discoverer
0 Kudos

Please reply for above the post