Repository samples
Métodos
Sección titulada «Métodos»getRootFolder
Sección titulada «getRootFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getRootFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:root” |
Ejemplo:
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.getRootFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getTrashFolder
Sección titulada «getTrashFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getTrashFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:trash/{userId}”. |
- La carpeta devuelta será la papelera del usuario.
Ejemplo:
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.getTrashFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getTrashFolderBase
Sección titulada «getTrashFolderBase»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getTrashFolderBase() | Folder | Devuelve el objeto Folder del nodo “/okm:trash”. |
Ejemplo:
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.getTrashFolderBase()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getTemplatesFolder
Sección titulada «getTemplatesFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getTemplatesFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:templates”. |
Ejemplo:
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.getTemplatesFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getPersonalFolder
Sección titulada «getPersonalFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getPersonalFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:personal/{userId}”. |
- La carpeta devuelta será la carpeta personal del usuario.
Ejemplo:
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.getPersonalFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getPersonalFolderBase
Sección titulada «getPersonalFolderBase»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getPersonalFolderBase() | Folder | Devuelve el objeto Folder del nodo “/okm:personal” |
Ejemplo:
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.getPersonalFolderBase()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getMailFolder
Sección titulada «getMailFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getMailFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:mail/{userId}”. |
- La carpeta devuelta será la carpeta de correo del usuario.
Ejemplo:
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.getMailFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getMailFolderBase
Sección titulada «getMailFolderBase»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getMailFolderBase() | Folder | Devuelve el objeto Folder del nodo “/okm:mail”. |
Ejemplo:
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.getMailFolderBase()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getThesaurusFolder
Sección titulada «getThesaurusFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getThesaurusFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:thesaurus”. |
Ejemplo:
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.getThesaurusFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getCategoriesFolder
Sección titulada «getCategoriesFolder»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getCategoriesFolder() | Folder | Devuelve el objeto Folder del nodo “/okm:categories”. |
Ejemplo:
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.getCategoriesFolder()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}purgeTrash
Sección titulada «purgeTrash»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| purgeTrash() | void | Elimina definitivamente del repositorio todos los nodos de “/okm:trash/{userId}” |
Ejemplo:
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.purgeTrash(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getUpdateMessage
Sección titulada «getUpdateMessage»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getUpdateMessage() | String | Recupera un mensaje cuando hay disponible una nueva versión de OpenKM. |
- Existe un servicio oficial de mensajes de actualización de OpenKM basado en su versión local de OpenKM.
Ejemplo:
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:8180/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password); try { System.Console.WriteLine(ws.getUpdateMessage()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getRepositoryUuid
Sección titulada «getRepositoryUuid»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getRepositoryUuid() | String | Recupera el identificador único de la instalación. |
Ejemplo:
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.getRepositoryUuid()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}hasNode
Sección titulada «hasNode»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| hasNode(String nodeId) | Boolean | Devuelve un nodo que indica si un nodo existe o no. |
Ejemplo:
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("Exists node:" + ws.hasNode("064ff51a-b815-4f48-a096-b4946876784f")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getNodePath
Sección titulada «getNodePath»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getNodePath(String uuid) | String | Convierte un UUID de nodo en una ruta. |
Ejemplo:
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.getNodePath("e339f14b-4d3a-489c-91d3-05e4575709d2")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getNodeUuid
Sección titulada «getNodeUuid»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getNodeUuid(String path) | String | Convierte una ruta de nodo en un UUID. |
Ejemplo:
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.getNodeUuid("/okm:root/tmp")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getAppVersion
Sección titulada «getAppVersion»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getAppVersion() | AppVersion | Devuelve información sobre la versión de OpenKM. |
Ejemplo:
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.getAppVersion()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}copyAttributes
Sección titulada «copyAttributes»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| copyAttributes(String nodeId, String dstId, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean wiki) |
void | Copia los atributos de un nodo a otro. |
- El valor del parámetro dstId debe ser un UUID o una ruta de nodo.
Ejemplo:
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.copyAttributes("/okm:root/invoice.pdf", "/okm:root/cloned_invoice.pdf", true, true, true, true, true); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}executeScript
Sección titulada «executeScript»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| executeScript(FileStream fs) | ScriptExecutionResult | Ejecuta un script. |
- El script local - test.bsh - usado en el ejemplo de abajo:
Ejemplo:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using System.IO;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 { FileStream fs = new FileStream("E:\\test.bsh", FileMode.Open); ScriptExecutionResult result = ws.executeScript(fs); System.Console.WriteLine(result.result); System.Console.WriteLine(result.stdout); if (!result.stderr.Equals("")) { System.Console.WriteLine("Error happened"); System.Console.WriteLine(result.stderr); } fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}executeSqlQuery
Sección titulada «executeSqlQuery»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| executeSqlQuery(FileStream fs) | SqlQueryResults | Ejecuta sentencias SQL. |
- El script test.sql usado en el ejemplo de abajo:
Ejemplo:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using System.IO;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 { FileStream fs = new FileStream("E:\\test.sql", FileMode.Open); SqlQueryResults result = ws.executeSqlQuery(fs); foreach (SqlQueryResultColumns row in result.sqlQueryResults) { System.Console.WriteLine("uuid:" + row.sqlQueryResultColumn[0] + ", name:" + row.sqlQueryResultColumn[1]); } fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}executeHqlQuery
Sección titulada «executeHqlQuery»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| executeHqlQuery(FileStream fs) | HqlQueryResults | Ejecuta sentencias HQL. |
- El script test.sql usado en el ejemplo de abajo:
Ejemplo:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using System.IO;
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 { FileStream fs = new FileStream(@"C:\Desktop\test.sql", FileMode.Open); HqlQueryResults result = ws.executeHqlQuery(fs);
foreach (HqlQueryResultColumns row in result.hqlQueryResults) { foreach (string column in row.hqlQueryResultColumn) { System.Console.WriteLine(column); } }
fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getTranslations
Sección titulada «getTranslations»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getTranslations(String lang, String module) | Dictionary<String, String> | Recupera las traducciones de un módulo como un mapa de valores |
Ejemplo:
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 { Dictionary<string,string>translations = ws.getTranslations("en-GB", "frontend"); foreach (KeyValuePair<string, string> kvp in translations) { Console.WriteLine("key:{0},with translation:{1}", kvp.Key, kvp.Value); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getConfiguration
Sección titulada «getConfiguration»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getConfiguration(String key) | Configuration | Recupera el valor de un parámetro de configuración. |
Ejemplo:
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 { Configuration configuration = ws.getConfiguration("system.ocr"); System.Console.WriteLine(configuration); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}executePlugin
Sección titulada «executePlugin»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| executePlugin(String className, Dictionary<String, String> parameters, FileStream fs) | String | Devuelve el valor String resultante de ejecutar una clase que implementa RestPlugin. |
Ejemplo:
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 { Dictionary<String, String> parameters = new Dictionary<string, string>(); parameters.Add("param1", "value1"); parameters.Add("param2", "value2"); FileStream fileStream = new FileStream(@"C:\Desktop\img.png", FileMode.Open); String value = (String)ws.executePlugin("com.openkm.plugin.rest.TestRestPlugin", parameters, fileStream); System.Console.WriteLine(value); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getChangeLog
Sección titulada « getChangeLog»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getChangeLog(String nodePath, DateTime modificationsFrom) | List |
Devuelve la lista de cambios en una ruta y sus subcarpetas. |
Ejemplo:
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 { List<ChangeLogged> changeLoggedList = ws.getChangeLog("/okm:root/test", DateTime.Now); foreach (var cl in changeLoggedList) { System.Console.WriteLine(cl.toString()); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}getServerTime()
Sección titulada «getServerTime()»Descripción:
| Método | Valores de retorno | Descripción |
|---|---|---|
| getServerTime() | String | Devuelve la hora actual del servidor. |
Ejemplo:
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.getServerTime()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}