Folder samples
Basics
On most methods, you'll see the parameter named "fldId". The value of this parameter can be a valid folder UUID.
Example of fldId:
- Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db"
Suggested code sample
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(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);
Once you are logged in with the web service, the session is kept in the web service object. Then you can use the other API methods.
At this point you can use all the Folder methods of "folder" class as shown below:
ws.folder.create("1be884f4-5758-4985-94d1-f18bfe004db8", "test");
Methods
create
Description:
| Method | Return values | Description |
|---|---|---|
|
create(String fldId, String name) |
Folder |
Creates a new folder and returns a Folder object. |
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.create("f123a950-0329-4d62-8328-0ff500fd42db", "test");
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
create
Description:
| Method | Return values | Description |
|---|---|---|
|
create(String uuid, String name, long nodeClass) |
Folder |
Creates a new folder and returns a Folder object. |
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);
long nodeClass = 0;
ws.folder.create("f123a950-0329-4d62-8328-0ff500fd42db", "test", nodeClass);
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
getProperties
Description:
| Method | Return values | Description |
|---|---|---|
|
getProperties(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.getProperties("f123a950-0329-4d62-8328-0ff500fd42db").toString());
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
delete
Description:
| Method | Return values | Description |
|---|---|---|
|
delete(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);
try
{
ws.login(user, password);
ws.folder.delete("f123a950-0329-4d62-8328-0ff500fd42db");
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
rename
Description:
| Method | Return values | Description |
|---|---|---|
|
rename(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/test
ws.folder.rename("f123a950-0329-4d62-8328-0ff500fd42db", "renamedFolder");
// Folder has renamed to /okm:root/renamedFolder
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
move
Description:
| Method | Return values | Description |
|---|---|---|
|
move(String fldId, String dstId) |
void |
Moves a folder into another folder or record. |
| The values of the dstId parameter should be a folder or record UUID or a 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/test
ws.folder.move("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());
}
}
}
}
getChildren
Description:
| Method | Return values | Description |
|---|---|---|
|
getChildren(String fldId) |
List<Folder> |
Returns a list of all folders whose 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.getChildren("f123a950-0329-4d62-8328-0ff500fd42db"))
{
System.Console.WriteLine(fld.toString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}
isValid
Description:
| Method | Return values | Description |
|---|---|---|
|
isValid(String fldId) |
Boolean |
Returns a boolean that indicates whether the node is 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);
// Return true
ws.folder.isValid("f123a950-0329-4d62-8328-0ff500fd42db");
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
getPath
Description:
| Method | Return values | Description |
|---|---|---|
|
getPath(String uuid) |
String |
Converts a folder UUID to a 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.getPath("f123a950-0329-4d62-8328-0ff500fd42db"));
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
copy
Description:
| Method | Return values | Description |
|---|---|---|
|
copy(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 a path. When the newName parameter value is null, the folder will preserve the same name. Only the security grants are copied to the destination. The folder's metadata, keywords, etc. are not copied. See the "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);
try
{
ws.login(user, password);
ws.folder.copy("f123a950-0329-4d62-8328-0ff500fd42db", "a321a950-0329-4d62-8328-0ff500fd42db", "new_name");
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
extendedCopy
Description:
| Method | Return values | Description |
|---|---|---|
|
extendedCopy(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 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. By default, only the binary data and the security grants are copied; the folder's metadata, keywords, etc. are not copied. Additional:
|
||
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.extendedCopy("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
Description:
| Method | Return values | Description |
|---|---|---|
|
getContentInfo(String fldId) |
ContentInfo |
Returns a ContentInfo object with information about the folder. |
|
The ContentInfo object retrieves information about:
|
||
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());
}
}
}
}
purge
Description:
| Method | Return values | Description |
|---|---|---|
|
purge(String fldId) |
void |
The folder is permanently removed from the repository. |
|
Usually, you will purge folders into /okm:trash/userId - the personal trash user location - but it is possible to directly purge any folder from the repository. When a folder is purged, it can only be restored from a previous repository backup. The purge action removes the folder permanently 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);
try
{
ws.login(user, password);
ws.folder.purge("f123a950-0329-4d62-8328-0ff500fd42db");
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
setStyle
Description:
| Method | Return values | Description |
|---|---|---|
|
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);
try
{
ws.login(user, password);
ws.folder.setStyle("f123a950-0329-4d62-8328-0ff500fd42db", 1);
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
createMissingFolders
Description:
| Method | Return values | Description |
|---|---|---|
|
createMissingFolders(String fldPath) |
void |
Creates 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());
}
}
}
}
setDescription
Description:
| Method | Return values | Description |
|---|---|---|
|
setDescription(string fldId, String description) |
void |
Sets 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.setDescription("f123a950-0329-4d62-8328-0ff500fd42db","Any description");
} catch (Exception e) {
System.Console.WriteLine(e.ToString());
}
}
}
}
createFromTemplate
Description:
| Method | Return values | Description |
|---|---|---|
|
createFromTemplate(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 a Folder object. |
|
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, these values are mandatory and must be set in the properties parameter. For more information about Templates and metadata check: Creating templates. Additional:
|
||
Example:
The example below is based on the Creating PDF template sample.
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 compliant
properties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));
properties.Add("okp:tpl.language", "[ \"java\" ]");
Folder foder = ws.folder.createFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "/okm:root/test/dst", true, true, false, true, true, properties));
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}