Skip to content
Other versions

Loading…

Folder samples

First, you must create the web service object:

OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

Then you should log in using the method “login”. You can access the “login” method from the web service object “ws” as shown below:

ws.login(user, password);

At this point you can use all the Folder methods from the “folder” class as shown below:

ws.folder.create("1be884f4-5758-4985-94d1-f18bfe004db8", "test");

Description:

Method Return values Description
create(String uuid, String name) Folder Creates a new folder and returns a Folder object.
  • The parameter uuid should be a valid folder or record UUID.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
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);
Folder folder = ws.folder.create("1be884f4-5758-4985-94d1-f18bfe004db8", "test");
System.out.println(folder);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createWithPropertyGroup(String uuid, String name, long nodeClass, String grpName, Map<String, String> properties) Folder Creates a new folder and sets a property group’s properties in the same call. Returns a Folder object.
  • The parameter uuid should be a valid folder or record UUID.
  • The nodeClass parameter should be a valid business type (series) value. A nodeClass with value 0 means there is no business type (series) selected.
  • The grpName should be a valid Metadata group name.
  • It is not mandatory to set all field values in the properties parameter; only the properties belonging to grpName are applied.

Example:

package com.openkm;
import java.util.HashMap;
import java.util.Map;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
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);
long nodeClass = 0;
Map<String, String> properties = new HashMap<>();
properties.put("okp:technology.comment", "comment sample");
properties.put("okp:technology.description", "description sample");
Folder folder = ws.folder.createWithPropertyGroup("1be884f4-5758-4985-94d1-f18bfe004db8", "test", nodeClass, "okg:technology", properties);
System.out.println(folder);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getProperties(String uuid) Folder Returns the folder properties.

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);
System.out.println(ws.folder.getProperties("76f4155e-42af-4be4-9a1c-756497616fb6"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
delete(String fldId) void Deletes a folder.

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);
ws.folder.delete("76f4155e-42af-4be4-9a1c-756497616fb6");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
rename(String fldId, String newName) void Renames a folder.

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);
// Exists folder /okm:root/test
ws.folder.rename("91264771-02b9-471d-b7a3-ba8cc49a10dd", "renamedFolder");
// Folder has renamed to /okm:root/renamedFolder
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
move(String uuid, String dstId) void Moves a folder into another folder or record.

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);
// Exists folder /okm:root/test
ws.folder.move("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63");
// Folder has moved to /okm:root/tmp/test
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getChildren(String uuid) List Returns a list of all folders whose parent is fldId.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
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);
for (Folder fld : ws.folder.getChildren("1be884f4-5758-4985-94d1-f18bfe004db8")) {
System.out.println(fld);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
isValid(String uuid) Boolean Returns a boolean indicating whether the node is a folder.

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);
// Return false
ws.folder.isValid("8cd1e072-8595-4dd3-b121-41d622c43f08");
// Return true
ws.folder.isValid("1be884f4-5758-4985-94d1-f18bfe004db8");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getPath(String uuid) String Converts a folder UUID to a folder path.

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);
System.out.println(ws.folder.getPath("1be884f4-5758-4985-94d1-f18bfe004db8"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
copy(String uuid, String dstId, String newName) void Copies a folder into another folder or record.
  • The values of the dstId parameter should be a folder or record UUID.
  • When the newName parameter value is null, the folder will preserve the same name.

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);
ws.folder.copy("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63", "new_name");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
extendedCopy(String uuid, String dstId, String newName, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean security) void Copies a folder with the associated data into some folder or record.
  • The values of the dstId parameter should be a folder or record UUID.
  • When the newName parameter value is null, the folder will preserve the same name.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
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);
Folder folder = ws.folder.extendedCopy("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63",
"new name folder", true, true, true, true, true);
System.out.println(folder);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getContentInfo(String uuid) ContentInfo Returns a ContentInfo object with information about the folder.
  • The ContentInfo object retrieves information about:

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);
System.out.println(ws.folder.getContentInfo("ada67d44-b081-4b23-bdc1-74181cafbc5d"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
purge(String uuid) void The folder is permanently removed from the repository.
  • Usually you will purge folders to /okm:trash/userId - the personal trash user locations - but it is possible to directly purge any folder from the repository.

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);
ws.folder.purge("ada67d44-b081-4b23-bdc1-74181cafbc5d");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setStyle(String uuid, long styleId) void Sets the folder style.

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);
ws.folder.setStyle("ada67d44-b081-4b23-bdc1-74181cafbc5d", 1);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createMissingFolders(String fldPath) String Creates missing folders.

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);
ws.folder.createMissingFolders("/okm:root/missingfld1/missingfld2/missingfld3");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setDescription(String uuid, String description) void Sets a description.

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);
ws.folder.setDescription("4c195453-246b-4ce9-86ba-b84e68d1f284", "some description");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createFromTemplate(String uuid, String dstPath, boolean categories,
            boolean keywords, boolean notes, Map<String, String> properties)
Folder Creates a new folder from the template and returns a Folder object.
  • The uuid parameter is the UUID value of the template file.
  • The dstPath value is the folder destination path.
  • When the template uses metadata groups to fill in fields, these values are mandatory and must be set in the properties parameter.

Example:

package com.openkm.example;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
import com.openkm.sdk4j.bean.PropertyGroup;
import com.openkm.sdk4j.impl.OKMWebservices;
import com.openkm.sdk4j.util.ISO8601;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FolderExample {
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);
// createFolderFromTemplate
Map<String, String> properties = new HashMap<>();
// okg:tpl
properties.put("okp:tpl.name", "sdk name");
Calendar cal = Calendar.getInstance();
// Value must be converted to String ISO 8601 compliant
properties.put("okp:tpl.bird_date", ISO8601.formatBasic(cal));
properties.put("okp:tpl.language", "[ \"java\" ]");
// Property okg:technology
properties.put("okp:technology.comment", "sdk name");
Folder folder = ws.folder.createFromTemplate("47c70047-2924-483c-bc42-23d0cbef6b17", "/okm:root/sdk/template", true, true, true, properties);
System.out.println(folder);
} catch (Exception e) {
e.printStackTrace();
}
}
}