Import samples
Basics
We suggest executing the methods below for huge import or for simple creation cases.
These methods execute fewer steps in the background either what is described in Document samples and Folder samples. That means you will get extra performance in the action because there are executed less logic in the server side.
Suggested code sample
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
Then should login using the method "login". You can access the "login" method from webservice object "ws" as is shown below:
ws.login(user, password);
Once you are logged with the webservices the session is keep in the webservice Object. Then you can use the other API method
At this point you can use all the Import methods from "quickImport" class as is shown below:
ws.quickImport.importDocument("1be884f4-5758-4985-94d1-f18bfe004db8", file);
Methods
importDocument
Description:
Method | Return values | Description |
---|---|---|
importDocument(String uuid, File file) |
String |
Creates a new document. Return the UUID of the Document. |
The values 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();
}
}
}
importDocument
Description:
Method | Return values | Description |
---|---|---|
importDocument(String uuid, File file, Calendar date, String author) |
String |
Creates a new document. Return the UUID of the Document. |
The value of the uuid parameter should be a folder or record node UUID. The value of the date parameter may be null (the current date ) or a specific date, which will be used to set the repository's creation date. The value of the author parameter may be null ( current session of the user ) or a user ID which will be used to set the creator. |
Example:
package com.openkm;
import java.io.File;
import java.util.Calendar;
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");
Calendar date = Calendar.getInstance();
date.add(-10, Calendar.DATE);
author = "okmAdmin";
String uuid = ws.quickImport.importDocument("1be884f4-5758-4985-94d1-f18bfe004db8", file, date);
System.out.println(uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
}
importFolder
Description:
Method | Return values | Description |
---|---|---|
importFolder(String uuid, String name) |
String |
Creates a new folder. Return the UUID of the folder. |
The values 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();
}
}
}
importFolder
Description:
Method | Return values | Description |
---|---|---|
importFolder(String uuid, String name, Calendar date, String author) |
String |
Creates a new folder. Return the UUID of the folder. |
The values of the uuid parameter should be a folder or record node UUID. The value of the date parameter may be null (the current date ) or a specific date, which will be used to set the repository's creation date. The value of the author parameter may be null ( current session of the user ) or a user ID which will be used to set the creator. |
Example:
package com.openkm;
import java.util.Calendar;
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);
Calendar date = Calendar.getInstance();
date.add(-10, Calendar.DATE);
author = "okmAdmin";
String uuid = ws.quickImport.importFolder("1be884f4-5758-4985-94d1-f18bfe004db8", "folder-name", date, author);
System.out.println(uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
}
importRecord
Description:
Method | Return values | Description |
---|---|---|
importRecord(String uuid, String name) |
String |
Creates a new folder. Return the UUID of the record. |
The values 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.importRecord("1be884f4-5758-4985-94d1-f18bfe004db8", "record-name");
System.out.println(uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
}
importRecord
Description:
Method | Return values | Description |
---|---|---|
importRecord(String uuid, String name, Calendar date, String author) |
String |
Creates a new folder. Return the UUID of the record. |
The values of the uuid parameter should be a folder or record node UUID. The value of the date parameter may be null (the current date ) or a specific date, which will be used to set the repository's creation date. The value of the author parameter may be null ( current session of the user ) or a user ID which will be used to set the creator. |
Example:
package com.openkm;
import java.util.Calendar;
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);
Calendar date = Calendar.getInstance();
date.add(-10, Calendar.DATE);
author = "okmAdmin";
String uuid = ws.quickImport.importRecord("1be884f4-5758-4985-94d1-f18bfe004db8", "record-name", date, author);
System.out.println(uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
}
importMail
Description:
Method | Return values | Description |
---|---|---|
importMail(String uuid, File file) |
String |
Creates a new mail. Return the UUID of the mail. |
The values of the uuid parameter should be a folder or record node UUID. The file must be MSG or EML file type. |
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/mail.msg");
String uuid = ws.quickImport.importMail("1be884f4-5758-4985-94d1-f18bfe004db8", file);
System.out.println(uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
}