Import samples
Basics
Section titled “Basics”Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);Then you should log in using the method “login”. You can access the “login” method from the webservice object “ws” as shown below:
ws.login(user, password);At this point you can use all the import methods from “quickImport” class as shown below:
ws.quickImport.importDocument("1be884f4-5758-4985-94d1-f18bfe004db8", file);Methods
Section titled “Methods”importDocument
Section titled “importDocument”Description:
| Method | Return values | Description |
|---|---|---|
| importDocument(String uuid, File file) | String | Creates a new document. Returns the UUID of the document. |
- The value of the uuid parameter should be a folder or record node UUID.
Example:
package com.openkm;
import java.io.File;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); File file = new File("/home/gnujavasergio/okm/logo.png"); String uuid = ws.quickImport.importDocument("1be884f4-5758-4985-94d1-f18bfe004db8", file); System.out.println(uuid); } catch (Exception e) { e.printStackTrace(); } }}importFolder
Section titled “importFolder”Description:
| Method | Return values | Description |
|---|---|---|
| importFolder(String uuid, String name) | String | Creates a new folder. Returns the UUID of the folder. |
- The value of the uuid parameter should be a folder or record node UUID.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); String uuid = ws.quickImport.importFolder("1be884f4-5758-4985-94d1-f18bfe004db8", "folder-name"); System.out.println(uuid); } catch (Exception e) { e.printStackTrace(); } }}