Sample client
You can make use of the OpenKM Maven Repository and the right SDK version. This is a sample pom.xml configuration:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.openkm.sample</groupId>
<artifactId>sample</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>openkm.com</id>
<name>OpenKM Maven Repository</name>
<url>https://maven.openkm.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.openkm</groupId>
<artifactId>sdk4j</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
Your first class:
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
import com.openkm.sdk4j.exception.*;
/**
* Sample OpenKM SDK client
*/
public class Main {
public static void main(String var[]) throws Exception {
String url = "http://demo.openkm.com/OpenKM";
String user = "user5";
String pass = "pass5";
OKMWebservices okm = OKMWebservicesFactory.newInstance(url, user, pass);
for (Folder fld : okm.getFolderChildren("/okm:root")) {
System.out.println("Folder -> " + fld.getPath());
}
}
}
Jar sample
If you use "maven-assembly-plugin" rather "maven-shade-plugin" you will get an error "missing MessageBodyWriter" while uploading a new file across the SDK.
<?xml version="1.0" encoding="UTF-8"?>
<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>com.openkm.sample</groupId>
<artifactId>sample</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.compiler>1.8</java.compiler>
<sdk4j.version>1.2</sdk4j.version>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>openkm.com</id>
<name>OpenKM Maven Repository</name>
<url>https://maven.openkm.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.openkm</groupId>
<artifactId>sdk4j</artifactId>
<version>${sdk4j.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.compiler}</source>
<target>${java.compiler}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.openkm.Main</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/javax.ws.rs.ext.MessageBodyWriter</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>