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 it 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.path = "/okm:root/test";

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

We suggests using the method below to createFolderSimple rather this one.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { Folder fld = new Folder(); fld.path ="/okm:root/test"; ws.createFolder(fld); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createFolderSimple

Description:

MethodReturn valuesDescription

createFolderSimple(String fldPath)

Folder

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

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { ws.createFolderSimple("/okm:root/test"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getFolderProperties

Description:

MethodReturn valuesDescription

getFolderProperties(String fldId)

Folder

Returns the folder properties.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { System.Console.WriteLine(ws.getFolderProperties("/okm:root/test")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

deleteFolder

Description:

MethodReturn valuesDescription

deleteFolder(String fldId)

void

Deletes a folder.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { ws.deleteFolder("/okm:root/test"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

renameFolder

Description:

MethodReturn valuesDescription

renameFolder(String fldId, String newName)

Folder

Renames a folder.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice 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) { System.Console.WriteLine(e.ToString()); } } } }

moveFolder

Description:

MethodReturn valuesDescription

moveFolder(String fldId, String dstId)

void

Moves a folder into other folder or record.

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

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice 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) { System.Console.WriteLine(e.ToString()); } } } }

getFolderChildren

Description:

MethodReturn valuesDescription

getFolderChildren(String fldId)

List<Folder>

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

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

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { foreach (Folder fld in ws.getFolderChildren("/okm:root")) { System.Console.WriteLine(fld); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isValidFolder

Description:

MethodReturn valuesDescription

isValidFolder(String fldId)

Boolean

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

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { // Return false ws.isValidFolder("/okm:root/logo.png"); // Return true ws.isValidFolder("/okm:root"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getFolderPath

Description:

MethodReturn valuesDescription

getFolderPath(String uuid)

String

Converts a folder UUID to folder path.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { System.Console.WriteLine(ws.getFolderPath("f123a950-0329-4d62-8328-0ff500fd42db")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

copyFolder

Description:

MethodReturn valuesDescription

copyFolder(String fldId, String dstId)

void

Copies a folder into other folder or record.

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

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:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { ws.copyFolder("/okm:root/test", "/okm:root/temp"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

extendedFolderCopy

Description:

MethodReturn valuesDescription

extendedFolderCopy(String fldId, String dstId, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean wiki)

void

Copies a folder with associated data into other folder or record.

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

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

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.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { ws.extendedFolderCopy("/okm:root/test", "/okm:root/tmp", true, true, true, true, true); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getContentInfo

Description:

MethodReturn valuesDescription

getContentInfo(String fldId)

ContentInfo

Returns and object ContentInfo with information about folder.

The ContentInfo object retrieves 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:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { System.Console.WriteLine(ws.getContentInfo("/okm:root/test")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

purgeFolder

Description:

MethodReturn valuesDescription

purgeFolder(String fldId)

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 remove the folder definitely from the repository.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { ws.purgeFolder("/okm:trash/okmAdmin/test"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setStyle

Description:

MethodReturn valuesDescription

setStyle(String fldId, long styleId)

void

Sets the folder style.

More information at Folder style.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

namespace OKMRest
{
    public class Program
    {
        static void Main(string[] args)
        {
            String host = "http://localhost:8080/OpenKM";
            String username = "okmAdmin";
            String password = "admin";
            OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
             try { ws.setStyle("/okm:trash/okmAdmin/test", 1); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }