Folder samples

Basics

Example of uuid:

  • Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db";

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 Folder methods from "folder" class as is shown below:

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

Methods

createFolder

Description:

MethodReturn valuesDescription

createFolder(String uuid, String name)

Folder

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

The parameters uuid should be any 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.createFolder("1be884f4-5758-4985-94d1-f18bfe004db8", "test");
            System.out.println(folder);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createFolderFromTemplate

Description:

MethodReturn valuesDescription

createFolderFromTemplate(String uuid, String dstPath, String language, boolean categories,
            boolean keywords, boolean propertyGroups, boolean notes, boolean wiki, Map<String, String> properties)

Folder

Creates a new folder from the template.

The uuid parameter is the UUID value of the template folder.

The dstPath is the folder destination path.

The parameter language is optional.

When the template uses metadata groups to fill in fields, then these values are mandatory and must be set into properties parameter. 

For more information about Templates and metadata check: Creating templates.

Additional:

  • When category parameter is true the original values of the categories will be copied.
  • When keywords parameter is true the original values of the keywords will be copied.
  • When property Groups parameter is true the original values of the metadata groups will be copied.
  • When notes parameter is true the original values of the notes will be copied.
  • When wiki parameter is true the original values of the wiki will be copied.

Example:

package com.openkm;

import java.util.Calendar;
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;
import com.openkm.sdk4j.util.ISO8601;

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);
            Map<String, String> properties = new HashMap<>();
            properties.put("okp:tpl.name", "Some 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\" ]");

            Folder foder = ws.folder.createFolderFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "/okm:root/test/folder", "es", true, true, true, false, false, properties);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

}

getFolderProperties

Description:

MethodReturn valuesDescription

getFolderProperties(String uuid)

Folder

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

deleteFolder

Description:

MethodReturn valuesDescription

deleteFolder(String fldId)

void

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

renameFolder

Description:

MethodReturn valuesDescription

renameFolder(String fldId, String newName)

void

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

moveFolder

Description:

MethodReturn valuesDescription

moveFolder(String uuid, String dstId)

void

Moves folder into some folder or record.

The values of the dstId parameter should be a folder or record 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);
            // Exists folder /okm:root/test
            ws.folder.moveFolder("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63");
            // Folder has moved to /okm:root/tmp/test
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getFolderChildren

Description:

MethodReturn valuesDescription

getFolderChildren(String uuid)

List<Folder>

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

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

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

isValidFolder

Description:

MethodReturn valuesDescription

isValidFolder(String uuid)

Boolean

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

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.isValidFolder("8cd1e072-8595-4dd3-b121-41d622c43f08");

            // Return true
            ws.folder.isValidFolder("1be884f4-5758-4985-94d1-f18bfe004db8");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getFolderPath

Description:

MethodReturn valuesDescription

getFolderPath(String uuid)

String

Convert folder UUID to 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.getFolderPath("1be884f4-5758-4985-94d1-f18bfe004db8"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

copyFolder

Description:

MethodReturn valuesDescription

copyFolder(String uuid, String dstId, String newName)

void

Copies a folder into a folder or record.

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

When parameter newName value is null, folder will preservate the same name.

Only the security grants are copied to destination, the metadata, keywords, etc. of the folder are not copied.

See "extendedFolderCopy" method for this feature.

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

extendedFolderCopy

Description:

MethodReturn valuesDescription

extendedFolderCopy(String uuid, String dstId, String newName, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean wiki, 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 parameter newName value is null, folder will preservate the same name.

By default only the binary data and the security grants, the metadata, keywords, etc. of the folder are not copyed.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.
  • When the security parameter is true the original value of the security will be copied.

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

getContentInfo

Description:

MethodReturn valuesDescription

getContentInfo(String uuid)

ContentInfo

Return and object ContentInfo with information about folder.

The ContentInfo object retrives information about:

  • The number of folders into.
  • The number of documents into.
  • The number of records into.
  • The number of mails into.
  • The size in bytes of all objects into the 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);
            System.out.println(ws.folder.getContentInfo("ada67d44-b081-4b23-bdc1-74181cafbc5d"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

purgeFolder

Description:

MethodReturn valuesDescription

purgeFolder(String uuid)

void

The folder is definitely removed from the repository.

Usually you will purge folders into /okm:trash/userId - the personal trash user locations - but it is possible to directly purge any folder from the whole repository.

When a folder is purged, it will  only be able to be restored from a previously repository backup. The purge action removes the folder definitely 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.purgeFolder("ada67d44-b081-4b23-bdc1-74181cafbc5d");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setStyle

Description:

MethodReturn valuesDescription

setStyle(String uuid, long styleId)

void

Set the folder style.

More information at 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();
        }
    }
}

createMissingFolders

Description:

MethodReturn valuesDescription

createMissingFolders(String fldPath)

void

Create 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();
        }
    }
}

setFolderDescription

Description:

MethodReturn valuesDescription

setFolderDescription(String uuid, String description)

void

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