Custom UI template
Developer information for Sample Spring Boot base project with OpenKM authentication and support for JSP, JSTL & REST.
To learn more about Spring Boot, please visit https://projects.spring.io/spring-boot/
There is also a very good tutorial about Spring Boot at https://spring.io/guides/gs/spring-boot/
You can download the application from OpenKM Download center.
You have to create a file called custom.properties inside $CATALINA_HOME folder.
This file is located in the root folder of the project. However you could also download from here: custom.properties
All application properties will be read from this file. If you need to change this path you must modify the class MainAppConfig
For more information: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html (section 24.3)
These properties are:
|anonymous.user||Anonymous user name
Used to get web services to OpenKM if no user is provided.
|anonymous.password||Anonymous user password|
|admin.user||Admin user name
Used to get web services to OpenKM if no user is provided.
|admin.password||Admin user password|
|preview.download.url||Document preview url|
|logback.file||Logback file name|
Other properties in this file should not be modified unless you know what are you doing. More information about properties at https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
This project is configured to authenticate against an OpenKM instance. It works using OpenKM SDK through web services.
OpenKM instance URL is defined in the openkm.url configuration property.
You must copy file logback-custom.xml to $CATALINA_HOME folder. This file is used by log system.
This file is located in the root folder of the project. However you could download from here: logback-custom.xml.
To change log level for a particular package:
<?xml version="1.0" encoding="UTF-8"?> <included> <logger name="com.openkm" level="INFO"/> </included>
This sample customization uses H2 database to store remember me data. A database file called custom.mv.db will be created into the user home directory.
There is a file called import.sql which contains SQL sentences that are executed when application starts. In this particular case it only contains one sentence to create the database table to allow the "remember me" feature.
In file menu.jsp you can see how the roles are managed by the application:
Using this code an user is able to see or not to see this menu option, depending on his roles. However, if you does not want to allow a user to access a resource you can con figure it in WebSecurityConfig file.
Spring Security 4 automatically prefixes any role with ROLE_
The application uses Bootstrap in order to make a beautiful and responsive design. More information about Bootstrap at http://getbootstrap.com/
This application could be packaged as well as a jar and war. In this pom configuration the artifact will be a war.
If you need to change packaging please see this url: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging (section 66.2)
If you packaged the application as a jar you could change the port.
To do that please visit: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#cli-default-import-statements (section 72.4)
This sample contains a catalog system for OpenKM:
- Using OpenKM a user could upload files to a folder cp.pending.folder (we will se what is this folder)
- An automation we will add okg:type metadata to this document
- Using the catalog system of this application we will add some metadata to this document
- An automation we will move this document to other folder
The main classes of the catalog system are:
- CatalogController: app routing of the catalog system
- CatalogServiceImpl: services for the catalog system
- WSCacheDAOImpl: manages the webservices to communicate OpenKM and this app
You must read the following steps in order to configure the application correctly:
Step 1: Download
Download the application from OpenKM Download center.
This will downlaod a zip file contaning a Maven project. For more information about Maven: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
Step 2: Role creation
Create ROLE_CATALOG and add to the user used in the application.
See Manage roles section for more information.
Step 3: SQL data needed
In order to execute SQL sentences go to Administration > Utilities > Database query and enter these queries:
CREATE TABLE CP_DOCUMENT_TYPE(ID INT NOT NULL, TYPE VARCHAR(100) NOT NULL, METADATA_GROUP VARCHAR(100) NOT NULL); CREATE TABLE CP_AGENCY(ID INT NOT NULL, NAME VARCHAR(100) NOT NULL); INSERT INTO CP_DOCUMENT_TYPE (ID, TYPE, METADATA_GROUP) VALUES (1, 'Consulting', 'okg:consulting'); INSERT INTO CP_DOCUMENT_TYPE (ID, TYPE, METADATA_GROUP) VALUES (2, 'Marketing', 'okg:marketing'); INSERT INTO CP_AGENCY (ID, NAME) VALUES (1, 'Web'); INSERT INTO CP_AGENCY (ID, NAME) VALUES (2, 'Desktop');
SQL sentences could be different depending on your databse.
The parameter cp.pending.folder contains the folder to read documents to catalog. You need also to create this folder in the Taxonomy manually:
INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('cp.pending.folder', 'string', '/okm:root/pending'); INSERT INTO OKM_CONFIG (CFG_KEY, CFG_TYPE, CFG_VALUE) VALUES ('cp.document.type', 'list', '');
Update the values of the property cp.document type:
Step 4: Metadata
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.9//EN" "http://www.openkm.com/dtd/property-groups-2.9.dtd"> <property-groups> <property-group label="Document type" name="okg:type"> <select label="Type" name="okp:type.type" type="simple" optionsQuery="select ID, TYPE from CP_DOCUMENT_TYPE order by TYPE asc" /> </property-group> <property-group label="Consulting" name="okg:consulting"> <input label="Date" type="date" name="okp:consulting.date" /> </property-group> <property-group label="Marketing" name="okg:marketing"> <select label="Agency" name="okp:marketing.agency" type="simple" optionsQuery="select ID, NAME from CP_AGENCY order by NAME asc" /> <input label="Date" type="date" name="okp:marketing.date" /> </property-group> </property-groups>
Right now only these tipes are supported: Input, TextArea, Select and Checkbox
Step 5: Automations
You have to create three automations like the following (see Automation section for more info):
1. Add empty type to a document in pending folder
2. Move consulting documents to "consulting" folder
3. Move marketing documents to "marketing" folder