Folder samples

Basics

On most methods you'll see parameter named "fldId". The value of this parameter can be some valid folder UUID or path.

Example of fldId:

  • Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db";
  • Using path -> "/okm:root/test"

Methods

createFolder

Description:

MethodReturn valuesDescription

createFolder(Folder fld)

Folder

Creates a new folder and returns as a result an object Folder.

The variable path into the parameter fld, must be initializated. It indicates the folder path into OpenKM.

Folder fld = new Folder();
fld.setPath("/okm:root/test");

The other variables of Folder ( fld ) will not take any effect on folder creation.

We suggest using the method below to create FolderSimple rather this one.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try {             Folder fld = new Folder();             fld.setPath("/okm:root/test");             ws.createFolder(fld);         } catch (Exception e) {             e.printStackTrace();         }     } }

createFolderSimple

Description:

MethodReturn valuesDescription

createFolderSimple(String fldPath)

Folder

Creates a new folder and returns as a result an object Folder.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try {             ws.createFolderSimple("/okm:root/test");         } catch (Exception e) {             e.printStackTrace();         }     } }

getFolderProperties

Description:

MethodReturn valuesDescription

getFolderProperties(String fldId)

Folder

Returns the folder properties.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try {             System.out.println(ws.getFolderProperties("/okm:root/test"));         } catch (Exception e) {             e.printStackTrace();         }     } }

deleteFolder

Description:

MethodReturn valuesDescription

deleteFolder(String fldId)

void

Deletes a folder.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try {             ws.deleteFolder("/okm:root/test");         } catch (Exception e) {             e.printStackTrace();         }     } }

renameFolder

Description:

MethodReturn valuesDescription

renameFolder(String fldId, String newName)

void

Renames a folder.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try {             // Exists folder /okm:root/test             ws.renameFolder("/okm:root/test","renamedFolder");    
            // Folder has renamed to /okm:root/renamedFolder         } catch (Exception e) {             e.printStackTrace();         }     } }

moveFolder

Description:

MethodReturn valuesDescription

moveFolder(String fldId, String dstId)

void

Moves folder into some folder or record.

The values of the dstId parameter should be a folder or record UUID or path.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try {             // Exists folder /okm:root/test             ws.moveFolder("/okm:root/test","/okm:root/tmp");             // Folder has moved to /okm:root/tmp/test         } catch (Exception e) {             e.printStackTrace();         }     } }

getFolderChildren

Description:

MethodReturn valuesDescription

getFolderChildren(String fldId)

List<Folder>

Returns a list of all folder which their parent is fldId.

The parameter fldId can be a folder or a record node.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username =  "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
         try {             for (Folder fld : ws.getFolderChildren("/okm:root")) {                 System.out.println(fld);             } } catch (Exception e) { e.printStackTrace(); } } }

isValidFolder

Description:

MethodReturn valuesDescription

isValidFolder(String fldId)

Boolean

Returns a boolean that indicates if the node is a folder or not.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
         try { // Return false ws.isValidFolder("/okm:root/logo.png");
             // Return true ws.isValidFolder("/okm:root"); } catch (Exception e) { e.printStackTrace(); } } }

getFolderPath

Description:

MethodReturn valuesDescription

getFolderPath(String uuid)

String

Converts folder UUID to folder path.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

public class Test {
    public static void main(String[] args) {
        String host = "http://localhost:8080/OpenKM";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
         try { System.out.println(ws.getFolderPath("f123a950-0329-4d62-8328-0ff500fd42db")); } catch (Exception e) { e.printStackTrace(); } } }