Folder samples
Basics
Section titled “Basics”On most methods, you’ll see the parameter named “fldId”. The value of this parameter can be some valid folder UUID.
Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(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);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
Section titled “Methods”createFolder
Section titled “createFolder”Description:
| Method | Return values | Description |
|---|---|---|
| createFolder(String fldId, String name) | 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);
try{ws.login(user, password);ws.folder.createFolder("f123a950-0329-4d62-8328-0ff500fd42db", "test");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getFolderProperties
Section titled “getFolderProperties”Description:
| Method | Return values | Description |
|---|---|---|
| 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);
try{ws.login(user, password);System.Console.WriteLine(ws.folder.getFolderProperties("f123a950-0329-4d62-8328-0ff500fd42db").toString());} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}deleteFolder
Section titled “deleteFolder”Description:
| Method | Return values | Description |
|---|---|---|
| deleteFolder(String fldId) | void | Delete 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);
try{ws.login(user, password);ws.folder.deleteFolder("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}renameFolder
Section titled “renameFolder”Description:
| Method | Return values | Description |
|---|---|---|
| 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);
try{ws.login(user, password);// Exists folder /okm:root/testws.folder.renameFolder("f123a950-0329-4d62-8328-0ff500fd42db", "renamedFolder");// Folder has renamed to /okm:root/renamedFolder} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}moveFolder
Section titled “moveFolder”Description:
| Method | Return values | Description |
|---|---|---|
| moveFolder(String fldId, String dstId) | void | Moves a folder into some 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);
try{ws.login(user, password);// Exists folder /okm:root/testws.folder.moveFolder("f123a950-0329-4d62-8328-0ff500fd42db", "ac165cab-a62a-4b17-89fc-2480a1d784db");// Folder has moved to /okm:root/tmp/test} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getFolderChildren
Section titled “getFolderChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getFolderChildren(String fldId) | List |
Returns a list of all folder 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);
try{ws.login(user, password);foreach (Folder fld in ws.folder.getFolderChildren("f123a950-0329-4d62-8328-0ff500fd42db")){System.Console.WriteLine(fld.toString());}}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}isValidFolder
Section titled “isValidFolder”Description:
| Method | Return values | Description |
|---|---|---|
| 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);
try{ws.login(user, password);// Return truews.folder.isValidFolder("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getFolderPath
Section titled “getFolderPath”Description:
| Method | Return values | Description |
|---|---|---|
| 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);
try{ws.login(user, password);System.Console.WriteLine(ws.folder.getFolderPath("f123a950-0329-4d62-8328-0ff500fd42db"));} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}copyFolder
Section titled “copyFolder”Description:
| Method | Return values | Description |
|---|---|---|
| copyFolder(String fldId, String dstId, String newName) | Folder | Copies a folder into a folder or record. |
The values of the dstId parameter should be a folder or record UUID or path.
When parameter newName value is null, the folder will preserve the same name.
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);
try{ws.login(user, password);ws.folder.copyFolder("f123a950-0329-4d62-8328-0ff500fd42db", "a321a950-0329-4d62-8328-0ff500fd42db", "new_name");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}extendedFolderCopy
Section titled “extendedFolderCopy”Description:
| Method | Return values | Description |
|---|---|---|
| extendedFolderCopy(String fldId, String dstId, String newName, bool categories, bool keywords, bool propertyGroups, bool notes, bool wiki, bool security) | Folder | Copies a folder with 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.
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);
try{ws.login(user, password);ws.folder.extendedFolderCopy("f123a950-0329-4d62-8328-0ff500fd42db", "055e4384-7c70-4456-b32b-f5a55a79861f", "new_name", true, true, true, true, true, true);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}getContentInfo
Section titled “getContentInfo”Description:
| Method | Return values | Description |
|---|---|---|
| getContentInfo(String fldId) | ContentInfo | Returne an object ContentInfo with information about folder. |
The ContentInfo object retrieves information about:
- The number of folders.
- The number of documents.
- The number of records.
- The number of emails.
- 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);
try{ws.login(user, password); System.Console.WriteLine(ws.folder.getContentInfo(fldUUid).toString());} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}purgeFolder
Section titled “purgeFolder”Description:
| Method | Return values | Description |
|---|---|---|
| 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 is possible to directly purge any folder from the whole 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);
try{ws.login(user, password);ws.folder.purgeFolder("f123a950-0329-4d62-8328-0ff500fd42db");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setStyle
Section titled “setStyle”Description:
| Method | Return values | Description |
|---|---|---|
| setStyle(String fldId, long styleId) | void | Sets the 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);
try{ws.login(user, password);ws.folder.setStyle("f123a950-0329-4d62-8328-0ff500fd42db", 1);} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}createMissingFolders
Section titled “createMissingFolders”Description:
| Method | Return values | Description |
|---|---|---|
| createMissingFolders(String fldPath) | void | Create missing folders. |
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);
try{ws.login(user, password);ws.folder.createMissingFolders("/okm:root/missingfld1/missingfld2/missingfld3");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}setFolderDescription
Section titled “setFolderDescription”Description:
| Method | Return values | Description |
|---|---|---|
| setFolderDescription(string fldId, String description) | void | Set the folder description. |
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);
try{ws.login(user, password);ws.folder.setFolderDescription("f123a950-0329-4d62-8328-0ff500fd42db","Any description");} catch (Exception e) {System.Console.WriteLine(e.ToString());}}}}createFolderFromTemplate
Section titled “createFolderFromTemplate”Description:
| Method | Return values | Description |
|---|---|---|
| createFolderFromTemplate(String uuid, String dstPath, bool categories, bool keywords, bool notes, bool propertyGroups, bool security, Dictionary<String, String> properties) | Folder | Creates a new folder from the template and returns an object Folder. |
The uuid parameter is the template file.
The dstPath can be a folder or a record path.
When the template uses metadata groups to fill in fields, then these values are mandatory and must be set into properties parameter.
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);
try{ws.login(user, password);Dictionary<String, String> properties = new Dictionary<String, String>();properties.Add("okp:tpl.name", "Some name");DateTime date = DateTime.Now;// Value must be converted to String ISO 8601 compliantproperties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));properties.Add("okp:tpl.language", "[ \"java\" ]");Folder foder = ws.folder.createFolderFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "/okm:root/test/dst", true, true, false, false, false, properties));}catch (Exception e){System.Console.WriteLine(e.ToString());}}}}