CIB webRec technical documentation
CIB webRec and remote document storage
Connector
How to write an implementation:
- Create a maven project
- Reference de.cib.webrec.cib-webrec-backend with scope provided (see pom.xml)
- Create an implementation of your own connector
- Define own fields needed
- Implement fetchContent and storeContent
Your connector should extend following base class:
package de.cib.webrec.backend.service.document;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
public interface StorageConnector {
byte[] fetchContent();
void storeContent(byte[] content);
}
Example
package de.cib.webrec.backend.service.document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MockStorageConnector implements StorageConnector {
private Logger LOGGER = LoggerFactory.getLogger(DocumentProcessingService.class);
public String documentId;
public byte[] fetchContent() {
LOGGER.debug("Retrieve document by documentId=" + this.documentId + " from remote database");
String rtf = "{\\rtf documentId=" + this.documentId + ".\\par Created by de.cib.crowdsource.rest.CrowdsourceDocumentRequest.\\par}";
return rtf.getBytes();
}
public void storeContent(byte[] content) {
LOGGER.debug("Store document by documentId=" + this.documentId + " into remote database");
}
}
Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>webrec</groupId>
<artifactId>integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>de.cib.webrec</groupId>
<artifactId>cib-webrec-backend</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.4.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>