SDMS System
This module works only for Ontimize Boot version 3.11.0 or above. Actual release version:
Introduction
The Storage Document Management System (SDMS) is a system that allows you to manage documents related to an entity in your project. Ontimize Boot provides a DMS that allows to store files in external services according to the engine set in its configuration.
Previous concepts
- Workspace: Represents the base folder where the documents for an entity will be stored.
Prerequisites
You can follow this tutorial using your own application, although for this example we will use an application created using the archetype that can be found on this page and with a REST service.
There are 2 options to follow this tutorial, clone the repository with the initial state and follow the tutorial step by step, or download the final example and see which files are new and which have been updated.
Initial project
/$ git clone https://github.com/ontimize/ontimize-examples
/ontimize-examples$ cd ontimize-examples
/ontimize-examples$ git checkout boot-sdms-initial
Final example
/$ git clone https://github.com/ontimize/ontimize-examples
/ontimize-examples$ cd ontimize-examples
/ontimize-examples$ git checkout boot-sdms
To simplify the code being written, three dots (…) may appear in some parts of the code. This indicates that there may be previous code before and after those dots.
Steps
Server
Add SDMS dependencies
/pom.xml
ws/pom.xml
model/pom.xml
boot/pom.xml
- ontimize-examples
- projectwiki-api
- src
- main
- java
- com
- ontimize
- projectwiki
- api
- core
- service
- ICandidateService.java
- IUserService.java
- service
- core
- api
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- projectwiki-boot
- src
- main
- java
- com
- ontimize
- projectwiki
- ServerApplication.java
- projectwiki
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- projectwiki-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- projectwiki
- model
- core
- dao
- CandidateDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- UserService.java
- dao
- core
- model
- projectwiki
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- placeholders.properties
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- projectwiki-ws
- src
- main
- java
- com
- ontimize
- projectwiki
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- projectwiki-api
Modify application.yml
The application.yml file will be modified the engine to be used by the SDMS, for this example we will set up the S3 engine. Information on the configuration of the SDMS system in the application.yml file can be found at this link.
Currently only the S3 engine using the Amazon AWS S3 service API is available.
application.yml
- ontimize-examples
- projectwiki-api
- src
- main
- java
- com
- ontimize
- projectwiki
- api
- core
- service
- ICandidateService.java
- IUserService.java
- service
- core
- api
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- projectwiki-boot
- src
- main
- java
- com
- ontimize
- projectwiki
- ServerApplication.java
- projectwiki
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- projectwiki-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- projectwiki
- model
- core
- dao
- CandidateDao.java
- DMSCategoryDao.java
- DMSDocumentDao.java
- DMSDocumentFileDao.java
- DMSDocumentFileVersionDao.java
- DMSDocumentPropertyDao.java
- DMSRelatedDocumentDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- UserService.java
- dao
- core
- model
- projectwiki
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- DMSCategoryDao.xml
- DMSDocumentDao.xml
- DMSDocumentFileDao.xml
- DMSDocumentFileVersionDao.xml
- DMSDocumentPropertyDao.xml
- DMSRelatedDocumentDao.xml
- placeholders.properties
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- projectwiki-ws
- src
- main
- java
- com
- ontimize
- projectwiki
- ws
- core
- rest
- CandidateRestController.java
- DMSNameConverter.java
- FileManagerRestController.java
- MainRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- projectwiki-api
Modify the entity service to add the methods of the SDMS service
All methods available by the SDMS service will be added to the service interface of our entity. Our method names are constructed with the name of the entity followed by the SDMS method name.
The SDMS methods available are:
- SdmsFindById: It allows us to retrieve the information of an SDMS element by its ID (Base64 encrypted id).
- SdmsFind: It allows us to retrieve the information of several elements of the SDMS from a filter.
- SdmsDownloadById: It allows us to download an SDMS document by its ID (Base64 encrypted id)
- SdmsDownload: It allows us to download several SDMS documents from a filter.
- SdmsUpload: It allows us to upload a document to the SDMS.
- SdmsCreate: It allows us to create an SDMS element in the system.
- SdmsUpdate: It allows us to update an SDMS element in the system.
- SdmsCopy: It allows us to copy an SDMS element in the system to another space in the SDMS.
- SdmsMove: It allows us to move an SDMS element in the system to another space in the SDMS.
- SdmsDeleteById: It allows us to delete an SDMS element in the system by its ID (Base64 encrypted id).
- SdmsDelete: It allows us to delete several SDMS elements in the system from a filter.
ICandidateService.java
- ontimize-examples
- projectwiki-api
- src
- main
- java
- com
- ontimize
- projectwiki
- api
- core
- service
- ICandidateService.java
- IUserService.java
- service
- core
- api
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- projectwiki-boot
- src
- main
- java
- com
- ontimize
- projectwiki
- ServerApplication.java
- projectwiki
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- projectwiki-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- projectwiki
- model
- core
- dao
- CandidateDao.java
- DMSCategoryDao.java
- DMSDocumentDao.java
- DMSDocumentFileDao.java
- DMSDocumentFileVersionDao.java
- DMSDocumentPropertyDao.java
- DMSRelatedDocumentDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- UserService.java
- dao
- core
- model
- projectwiki
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- DMSCategoryDao.xml
- DMSDocumentDao.xml
- DMSDocumentFileDao.xml
- DMSDocumentFileVersionDao.xml
- DMSDocumentPropertyDao.xml
- DMSRelatedDocumentDao.xml
- placeholders.properties
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- projectwiki-ws
- src
- main
- java
- com
- ontimize
- projectwiki
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- projectwiki-api
Now in the implementation of the service we implement the methods with the help of the IOSdmsService
component of the SDMS system and by calling the corresponding method.
We will also establish the workspace where the entity will store and manage the files. We will do this via the OSdmsWorkspace
annotation which admits 2 parameters:
name
: Sets the name of the workspace. If this parameter is not set, the value will bedefault
.value
: Sets the path to the workspace, and can be set to variable between braces.
The annotation can be set at class level by enabling the workspace for all SDMS methods, and/or at method level by setting its scope to the annotated method. It can also be set as many workspaces as required.
CandidateService.java
- ontimize-examples
- projectwiki-api
- src
- main
- java
- com
- ontimize
- projectwiki
- api
- core
- service
- ICandidateService.java
- IUserService.java
- service
- core
- api
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- projectwiki-boot
- src
- main
- java
- com
- ontimize
- projectwiki
- ServerApplication.java
- projectwiki
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- projectwiki-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- projectwiki
- model
- core
- dao
- CandidateDao.java
- DMSCategoryDao.java
- DMSDocumentDao.java
- DMSDocumentFileDao.java
- DMSDocumentFileVersionDao.java
- DMSDocumentPropertyDao.java
- DMSRelatedDocumentDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- UserService.java
- dao
- core
- model
- projectwiki
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- DMSCategoryDao.xml
- DMSDocumentDao.xml
- DMSDocumentFileDao.xml
- DMSDocumentFileVersionDao.xml
- DMSDocumentPropertyDao.xml
- DMSRelatedDocumentDao.xml
- placeholders.properties
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- projectwiki-ws
- src
- main
- java
- com
- ontimize
- projectwiki
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- projectwiki-api
Modify the entity Rest controller
We modify the Rest controller of our entity so that instead of inheriting from the ORestController
class, it inherits from the OSdmsRestController
class. This class adds all the endpoints of the ORestController
class and the SDMS endpoints, linking them with the corresponding SDMS methods that we have established in the service of our entity.
ICandidateService.java
- ontimize-examples
- projectwiki-api
- src
- main
- java
- com
- ontimize
- projectwiki
- api
- core
- service
- ICandidateService.java
- IUserService.java
- service
- core
- api
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- projectwiki-boot
- src
- main
- java
- com
- ontimize
- projectwiki
- ServerApplication.java
- projectwiki
- ontimize
- com
- resources
- application.yml
- java
- main
- pom.xml
- src
- projectwiki-model
- src
- main
- db
- templateDB.properties
- templateDB.txt
- java
- com
- ontimize
- projectwiki
- model
- core
- dao
- CandidateDao.java
- DMSCategoryDao.java
- DMSDocumentDao.java
- DMSDocumentFileDao.java
- DMSDocumentFileVersionDao.java
- DMSDocumentPropertyDao.java
- DMSRelatedDocumentDao.java
- UserDao.java
- UserRoleDao.java
- service
- CandidateService.java
- UserService.java
- dao
- core
- model
- projectwiki
- ontimize
- com
- resources
- dao
- CandidateDao.xml
- DMSCategoryDao.xml
- DMSDocumentDao.xml
- DMSDocumentFileDao.xml
- DMSDocumentFileVersionDao.xml
- DMSDocumentPropertyDao.xml
- DMSRelatedDocumentDao.xml
- placeholders.properties
- RoleDao.xml
- RoleServerPermissionDao.xml
- ServerPermissionDao.xml
- UserDao.xml
- UserRoleDao.xml
- dao
- db
- main
- pom.xml
- src
- projectwiki-ws
- src
- main
- java
- com
- ontimize
- projectwiki
- ws
- core
- rest
- CandidateRestController.java
- MainRestController.java
- TestRestController.java
- UserRestController.java
- rest
- core
- ws
- projectwiki
- ontimize
- com
- java
- main
- pom.xml
- src
- .gitignore
- pom.xml
- README.md
- projectwiki-api
Endpoints
The endpoints set by the OSdmsRestController
are the following:
If the workspace is not sent in an http request, the SDMS will set the
default
workspace as the active workspace. But if the default workspace has variables, you will need to pass it the workspace with the variable values to access the workspace.
Find by ID
This endpoint maps the request to the SdmsFindById
method of the SDMS service.
The id of the requested document is passed in Base64 encrypted in the url and the data parameter is added with the workspace information in JSON format.
The data value must be encoded with percent-encoding to be read correctly.
Find
This endpoint maps the request to the SdmsFind
method of the SDMS service.
The id of the requested document is passed in Base64 encrypted in the url and the data parameter is added with the workspace information in JSON format.
Download by ID
This endpoint maps the request to the SdmsDownloadById
method of the SDMS service.
The id of the requested document is passed in Base64 encrypted in the url and the data parameter is added with the workspace information in JSON format.
The data value must be encoded with percent-encoding to be read correctly.
Download
This endpoint maps the request to the SdmsDownload
method of the SDMS service.
The id of the requested document is passed in Base64 encrypted in the url and the data parameter is added with the workspace information in JSON format.
Upload
This endpoint maps the request to the SdmsUpload
method of the SDMS service.
The data parameter is added with the workspace information in JSON format.
The data value must be encoded with percent-encoding to be read correctly.
Create
This endpoint maps the request to the SdmsCreate
method of the SDMS service.
Update
This endpoint maps the request to the SdmsUpdate
method of the SDMS service.
Copy
This endpoint maps the request to the SdmsCopy
method of the SDMS service.
Move
This endpoint maps the request to the SdmsMove
method of the SDMS service.
Delete by ID
This endpoint maps the request to the SdmsDeleteById
method of the SDMS service.
The id of the requested document is passed in Base64 encrypted in the url and the data parameter is added with the workspace information in JSON format.
The data value must be encoded with percent-encoding to be read correctly.
Delete
This endpoint maps the request to the SdmsDelete
method of the SDMS service.
The id of the requested document is passed in Base64 encrypted in the url and the data parameter is added with the workspace information in JSON format.
Request Parameters
The data parameter of the SDMS system always goes to the “filter” and “data” sections.
The “filter” section contains the parameters related to the selection of elements of the SDMS. Here you will always find the information related to the workspace you want to use.
In the “data” section are the parameters related to the information to be sent to the SDMS.
The rest of the parameters that can be sent in each of the sections will depend on the engine used.
Possible parameters in the S3 engine
- Filter
-
workspace
: The name of the workspace to use.
example:"workspace": "default"
-
data
: The variables values of the workspace.
example:"data": "{"id": "ID-1"}"
|"data": "{"id": 1}"
|"data": "{"id": [1, 2, 3]}"
-
id
: The S3 key of the document encoded in Base64 (several can be in an array).
example:"id": "Y2FuZGlkYXRlLzEvZmlsZS0wMS50eHQ="
|"id": ["Y2FuZGlkYXRlLzEvZmlsZS0wMS50eHQ=", "Y2FuZGlkYXRlLzEvZmlsZS0wMi50eHQ="]
-
key
: The S3 key of the document (several can be in an array).
example:"key": "candidate/1/file-01.txt"
|"key": ["candidate/1/file-01.txt", "candidate/1/file-02.txt"]
-
prefix
: The S3 prefix of the document (several can be in an array).
example:"prefix": "candidate/1/folder-1"
|"prefix": ["candidate/1/folder-1", "candidate/1/folder-2"]
-
fileName
: The S3 name of the document (several can be in an array).
example:"fileName": "file-01.txt"
|"fileName": ["file-01.txt", "file-02.txt"]
-
maxKeys
: The maximum number of S3 documents to return.
example:"maxKeys": 10
-
delimiter
: The delimiter to use in the S3 documents search.
example:"delimiter": "/"
-
marker
: The marker to use in the S3 documents search.
example:"marker": "candidate/1/file-01.txt"
-
- Data
-
id
: The S3 key of the document encoded in Base64.
example:"id": "Y2FuZGlkYXRlLzEvZmlsZS0wMS50eHQ="
-
key
: The S3 key of the document.
example:"key": "candidate/1/file-01.txt"
-
prefix
: The S3 prefix of the document.
example:"prefix": "/folder-1"
-
fileName
: The S3 name of the document.
example:"fileName": "file-01.txt"
-
currentPrefix
: The current S3 prefix of the document.
example:"currentPrefix": "candidate/1/folder-1"
-