Csharp webservice dll

From OpenKM Documentation
Jump to: navigation, search

Nota clasica.png DLL have been compiled for net 2.0 that should ensure go with any upper .net version


OpenKM Supported webservices versions

OpenKM version Version
OpenKM 6.4.12 Websercices 2.0
OpenKM Professional 6.2.27 and OpenKM Community 6.3 Websercices 1.0
OpenKM Professional 6.4.6+ OpenKM Professional 6.4.6+
OpenKM Professional 6.4+ OpenKM Professional 6.4+
OpenKM Professional 6.2+ OpenKM Professional 6.2+
OpenKM Professional 6.0+ OpenKM Professional 6.0+

Nota clasica.png From OpenKM professional 6.4.12 and OpenKM Community 6.3 the webservices names are based on their own numeration

Advantage of use

We recommend to use OKMWebservices DLL because it implements an extra layer between webservices and logic -factory- which allow transparently change between webservices versions without major effors. Simply instance other webservices version from factory in your source code.

Understanding the basics

For all webservices methods are available two methods one with token and other without it. For example to get granted roles of some node path can be used:

Dictionary<String, int> getGrantedRoles(String nodePath);
Dictionary<String, int> getGrantedRoles(String token, String nodePath);

First case getGrantedRoles(nodePath) internally controls login and logout actions for you and is not needed a token.

On second getGrantedRoles(token, nodePath) is necessary provide a token. That means you take control of login and logout actions in your source code.

Example

String host = "http://localhost:8080/OpenKM";
String user = "okmAdmin";
String password = "admin";

int serverVersion = OKMWebServiceFactory.PROFESSIONAL_6_4;
OKMWebservice webservice= null;
if (serverVersion == OKMWebServiceFactory.PROFESSIONAL_6_4)
{
	webservice= OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.PROFESSIONAL_6_4);
}
else
{
	webservice= OKMWebServiceFactory.getInstance(host, user, password, OKMWebServiceFactory.COMMUNITY_6_0);
}

Controlling exceptions

OKMWebservice DLL will throw OKMWebserviceException if happens some error. Is good practice take control in your source code.

try {
  String token = webservice.login();
} catch (OKMWebserviceExceptione){

}

Refresh

To change the user, password or host while code execution must called method refreshConfiguration(host, serName, password).

try {
  String token = webservice.login();
  webservice.logout(token);
  // Until here we're using some username / password and host
  webservice.refreshConfiguration("http://localhost:8080/OpenKM","user1","pass1");
  // From here we're using other credentils
  token = webservice.login();
  webservice.logout(token);
} catch (OKMWebserviceException e){

}

Available methods

Classes

  • OKMActualVersionBean
  • OKMAppVersionBean
  • OKMBookmarkBean
  • OKMCommentBean
  • OKMDashboardDocumentResultBean
  • OKMDashboardFolderResultBean
  • OKMDashboardMailResultBean
  • OKMDocumentBean
  • OKMFolderBean
  • OKMFormElementBean
  • OKMLockInfoBean
  • OKMMailBean
  • OKMNotesBean
  • OKMOptionBean
  • OKMPermissions
  • OKMProcessDefinitionBean
  • OKMProcessInstanceBean
  • OKMProcessInstanceEntryBean
  • OKMPropertyGroupBean
  • OKMQueryParamsBean
  • OKMQueryParamsEntryBean
  • OKMQueryResultBean
  • OKMTaskInstanceBean
  • OKMTaskInstanceEntryBean
  • OKMTokenBean
  • OKMTransitionBean
  • OKMValidatorBean

General

void refreshConfiguration(String host, String userName, String password);

Auth

        String login();
        void logout(String token);
        Dictionary<String, int> getGrantedRoles(String nodePath);
        Dictionary<String, int> getGrantedRoles(String token, String nodePath);
        Dictionary<String, int> getGrantedUsers(String nodePath);
        Dictionary<String, int> getGrantedUsers(String token, String nodePath);
        String[] getRoles(String nodePath);
        String[] getRoles(String token, String nodePath);
        String[] getUsers(String nodePath);
        String[] getUsers(String token, String nodePath);
        void grantRole(String nodePath, String role, int permission, bool recursive);
        void grantRole(String token, String nodePath, String role, int permission, bool recursive);
        void grantUser(String nodePath, String user, int permission, bool recursive);
        void grantUser(String token, String nodePath, String user, int permission, bool recursive);
        void revokeRole(String nodePath, String role, int permission, bool recursive);
        void revokeRole(String token, String nodePath, String role, int permission, bool recursive);
        void revokeUser(String nodePath, String user, int permission, bool recursive);
        void revokeUser(String token, String nodePath, String user, int permission, bool recursive);
        String[] getRolesByUser(String nodePath, String user);
        String[] getRolesByUser(String token, String nodePath, String user);
        String[] getUsersByRole(String nodePath, String role);
        String[] getUsersByRole(String token, String nodePath, String role);
        String getMail(String nodePath, String user);
        String getMail(String token, String nodePath, String user);
        String getName(String nodePath, String user);
        String getName(String token, String nodePath, String user);

Repository

        OKMFolderBean getTemplatesFolder();
        OKMFolderBean getTemplatesFolder(String token);
        OKMFolderBean getPersonalFolder();
        OKMFolderBean getPersonalFolder(String token);
        OKMFolderBean getRootFolder();
        OKMFolderBean getRootFolder(String token);
        OKMFolderBean getTrashFolder();
        OKMFolderBean getTrashFolder(String token);
        OKMFolderBean getMailFolder();
        OKMFolderBean getMailFolder(String token);
        OKMFolderBean getThesaurusFolder();
        OKMFolderBean getThesaurusFolder(String token);
        OKMFolderBean getCategoriesFolder();
        OKMFolderBean getCategoriesFolder(String token);
        void purgeTrash();
        void purgeTrash(String token);
        Boolean hasNode(String path);
        Boolean hasNode(String token, String path);
        String getNodePath(String uuid);
        String getNodePath(String token,String uuid);
        String getNodeUuid(String path);
        String getNodeUuid(String token, String path);
        OKMAppVersionBean getAppVersion();
        OKMAppVersionBean getAppVersion(String token);

Document

        OKMDocumentBean create(String docPath, byte[] data);
        OKMDocumentBean create(String token, String docPath, byte[] data);
        void checkout(String docPath);
        void checkout(String token, String docPath);
        void cancelCheckout(String docPath);
        void cancelCheckout(String token, String docPath);
        void checkin(String docPath, byte[] data, String comment);
        void checkin(String token, String docPath, byte[] data, String comment);
        bool documentExists(String docPath);
        bool documentExists(String token, String docPath);
        OKMDocumentBean createSimple(String docPath, byte[] data);
        OKMDocumentBean createSimple(String token, String docPath, byte[] data);
        void deleteDocument(String docPath);
        void deleteDocument(String token, String docPath);
        OKMDocumentBean getDocumentProperties(String docPath);
        OKMDocumentBean getDocumentProperties(String token, String docPath);
        Byte[] getContent(String docPath, Boolean checkout);
        Byte[] getContent(String token, String docPath, Boolean checkout);
        Byte[] getContentByVersion(String docId, String versionId);
        Byte[] getContentByVersion(String token, String docId, String versionId);
        OKMDocumentBean[] getDocumentChilds(String dstId);
        OKMDocumentBean[] getDocumentChilds(String token, String dstId);
        OKMDocumentBean[] getDocumentChildren(String docPath);
        OKMDocumentBean[] getDocumentChildren(String token, String docPath);
        void documentRename(String docId, String newName);
        void documentRename(String token, String docId, String newName);
        void setProperties(OKMDocumentBean doc);
        void setProperties(String token, OKMDocumentBean doc);
        void forceCancelCheckout(String docPath);
        void forceCancelCheckout(String token, String docPath);
        OKMVersionBean[] getVersionHistory(String docPath);
        OKMVersionBean[] getVersionHistory(String token, String docPath);
        void unlock(String docPath);
        void unlock(String token, String docPath);
        void forceUnlock(String docPath);
        void forceUnlock(String token, String docPath);
        void purge(String docPath);
        void purge(String token, String docPath);
        void move(String docPath, String fldPath);
        void move(String token, String docPath, String fldPath);
        void restoreVersion(String docPath, String versionId);
        void restoreVersion(String token, String docPath, String versionId);
        void purgeVersionHistory(String docPath);
        void purgeVersionHistory(String token, String docPath);
        long getVersionHistorySize(String docPath);
        long getVersionHistorySize(String token, String docPath);
        Boolean isValid(String docPath);
        Boolean isValid(String token, String docPath);
        String getPath(String uuid);
        String getPath(String token, String uuid);
        OKMLockInfoBean documentLock(String docPath);
        OKMLockInfoBean documentLock(String token, String docPath);

Folder

        OKMFolderBean[] getFolderChildren(String fldPath);
        OKMFolderBean[] getFolderChildren(String token, String fldPath);
        OKMFolderBeancreate(OKMFolderBean folderBean);
        OKMFolderBeancreate(String token, OKMFolderBean folderBean);
        void renameFolder(String fldPath, String newName);
        void renameFolder(String token, String fldPath, String newName);
        void deleteFolder(String fldPath);
        void deleteFolder(String token, String fldPath);
        OKMFolderBean createSimple(String fldPath);
        OKMFolderBean createSimple(String token, String fldPath);
        OKMFolderBean[] getFolderChilds(String fldPath);
        OKMFolderBean[] getFolderChilds(String token, String fldPath);
        bool folderExist(String docPath);
        bool folderExist(String token, String docPath);
        String getFolderPath(String uuid);
        String getFolderPath(String token, String uuid);
        void folderMove(String fldPath, String dstPath);
        void folderMove(String token, String fldPath, String dstPath);
        OKMFolderBean getFolderProperties(String fldPath);
        OKMFolderBean getFolderProperties(String token, String fldPath);

Mail

        OKMMailBean create(OKMMailBean mailBean);
        OKMMailBean create(String token, OKMMailBean mailBean);
        OKMMailBean getMailProperties(String mailPath);
        OKMMailBean getMailProperties(String token, String mailPath);
        void mailDelete(String mailPath);
        void mailDelete(String token, String mailPath);
        void mailRename(String mailPath, String newName);
        void mailRename(String token, String mailPath, String newName);
        void mailMove(String mailPath, String dstPath);
        void mailMove(String token, String mailPath, String dstPath);
        OKMMailBean[] getMailChilds(String mailPath);
        OKMMailBean[] getMailChilds(String token, String mailPath);
        OKMMailBean[] getMailChildren(String mailPath);
        OKMMailBean[] getMailChildren(String token, String mailPath);
        bool mailExists(String mailPath);
        bool mailExists(String token, String mailPath);
        String getMailPath(String uuid);
        String getMailPath(String token, String uuid);

Note

        OKMNotesBean add(String nodePath, String text);
        OKMNotesBean add(String token, String nodePath, String text);
        OKMNotesBean get(String notePath);
        OKMNotesBean get(String token, String notePath);
        void delete(String notePath);
        void delete(String token, String notePath);
        void set(String notePath, String text);
        void set(String token, String notePath, String text);
        OKMNotesBean[] list(String nodePath);
        OKMNotesBean[] list(String token, String nodePath);

Notification

        void subscribe(String nodePath);
        void subscribe(String token, String nodePath);
        void unsubscribe(String nodePath);
        void unsubscribe(String token, String nodePath);
        String[] getSubscriptors(String nodePath);
        String[] getSubscriptors(String token, String nodePath);
        void notify(String nodePath, String[] users, String[] mails, String message, Boolean attachment);
        void notify(String token, String nodePath, String[] users, String[] mails, String message, Boolean attachment);

Search

When you build your query domain value is important, that will determinate if you're looking for documents, folders, mails or records. for example to searching for documents should be used:

OKMQueryParamsBean qParam = new OKMQueryParamsBean();
qParam.setDomain(OKMQueryParamsBean.DOCUMENT);


        OKMQueryResultBean[] find(OKMQueryParamsBean queryParams);
        OKMQueryResultBean[] find(String token, OKMQueryParamsBean queryParams);
        OKMQueryResultBean[] findByName(String name);
        OKMQueryResultBean[] findByName(String token, String name);
        OKMQueryResultBean[] findByContent(String content);
        OKMQueryResultBean[] findByContent(String token, String content);
        OKMQueryResultBean[] findByKeywords(String[] keywords);
        OKMQueryResultBean[] findByKeywords(String token, String[] keywords);
        OKMDocumentBean[] getCategorizedDocuments(String categoryId);
        OKMDocumentBean[] getCategorizedDocuments(String token, String categoryId);
        long saveSearch(OKMQueryParamsBean param);
        long saveSearch(String token, OKMQueryParamsBean param);
        void updateSearch(OKMQueryParamsBean param);
        void updateSearch(String token, OKMQueryParamsBean param);
        void deleteSearch(int qpId);
        void deleteSearch(String token, int qpId);
        OKMQueryParamsBean getSearch(int qpId);
        OKMQueryParamsBean getSearch(String token, int qpId);
        OKMQueryParamsBean[] getAllSearchs();
        OKMQueryParamsBean[] getAllSearchs(String token);
        Dictionary<String, int> getKeywordMap(String[] filter);
        Dictionary<String, int> getKeywordMap(String token, String[] filter);

Property Group


Nota clasica.png when you want to set values into select multiple using setPropertiesSimple must declare each value into string separated by character ";". For example if want to select values 1,2 should build a string like this "1;2"

        void addGroup(String nodePath, String grpName);
        void addGroup(String token, String nodePath, String grpName);
        void setPropertiesSimple(String nodePath, String grpName, Dictionary<String, String> propertiesMap);
        void setPropertiesSimple(String token, String nodePath, String grpName, Dictionary<String, String> propertiesMap);        
        void removeGroup(String nodePath, String grpName);
        void removeGroup(String token, String nodePath, String grpName);
        OKMPropertyGroupBean[] getGroups(String nodePath);
        OKMPropertyGroupBean[] getGroups(String token, String nodePath);
        OKMPropertyGroupBean[] getAllGroups();
        OKMPropertyGroupBean[] getAllGroups(String token);
        Boolean hasGroup(String nodePath, String grpName);
        Boolean hasGroup(String token, String nodePath, String grpName);
        OKMFormElementBean[] getProperties(String nodePath, String grpName);
        OKMFormElementBean[] getProperties(String token, String nodePath, String grpName);
        OKMFormElementBean[] getPropertyGroupForm(String grpName);
        OKMFormElementBean[] getPropertyGroupForm(String token, String grpName);
        void setProperties(String nodePath, String grpName, OKMFormElementBean[] properties);
        void setProperties(String token, String nodePath, String grpName, OKMFormElementBean[] properties);

Property

        void addCategory(String nodePath, String catId);
        void addCategory(String token, String nodePath, String catId);
        void removeCategory(String nodePath, String catId);
        void removeCategory(String token, String nodePath, String catId);
        String addKeyword(String nodePath, String keyword);
        String addKeyword(String token, String nodePath, String keyword);
        void removeKeyword(String nodePath, String keyword);
        void removeKeyword(String token, String nodePath, String keyword);
        void setEncryption(String nodePath, String cipherName);
        void setEncryption(String token, String nodePath, String cipherName);
        void unsetEncryption(String nodePath);
        void unsetEncryption(String token, String nodePath);
        void setSigned(String nodePath, Boolean signed);
        void setSigned(String token, String nodePath, Boolean signed);

Bookmark

        OKMBookmarkBean bookmarkAdd(String nodePath, String name);
        OKMBookmarkBean bookmarkAdd(String token, String nodePath, String name);
        OKMBookmarkBean bookmarkGet(int bmId);
        OKMBookmarkBean bookmarkGet(String token, int bmId);
        void bookmarkRemove(int bmId);
        void bookmarkRemove(String token, int bmId);
        OKMBookmarkBean bookmarkRename(int bmId, String newName);
        OKMBookmarkBean bookmarkRename(String token, int bmId, String newName);
        OKMBookmarkBean[] getAllBookmark();
        OKMBookmarkBean[] getAllBookmark(String token);

Workflow

        void registerProcessDefinition(Byte[] pda);
        void registerProcessDefinition(String token, Byte[] pda);
        void deleteProcessDefinition(long pdId);
        void deleteProcessDefinition(String token, long pdId);
        OKMProcessDefinitionBean getProcessDefinition(long pdId);
        OKMProcessDefinitionBean getProcessDefinition(String token, long pdId);
        Byte[] getProcessDefinitionImage(long pdId, String node);
        Byte[] getProcessDefinitionImage(String token, long pdId, String node);
        OKMProcessInstanceBean runProcessDefinition(long pdId, String uuId,  OKMFormElementBean[] values);
        OKMProcessInstanceBean runProcessDefinition(String token, long pdId, String uuId, OKMFormElementBean[] values);
        OKMProcessInstanceBean sendProcessInstanceSignal(long piId, String transName);
        OKMProcessInstanceBean sendProcessInstanceSignal(String token, long piId, String transName);
        void endProcessInstance(long piId);
        void endProcessInstance(String token, long piId);
        void deleteProcessInstance(long piId);
        void deleteProcessInstance(String token, long piId);
        OKMProcessInstanceBean[] findProcessInstances(long piId);
        OKMProcessInstanceBean[] findProcessInstances(String token, long piId);
        OKMProcessDefinitionBean[] findAllProcessDefinitions();
        OKMProcessDefinitionBean[] findAllProcessDefinitions(String token);
        OKMProcessDefinitionBean[] findLatestProcessDefinitions();
        OKMProcessDefinitionBean[] findLatestProcessDefinitions(String token);
        OKMProcessInstanceBean getProcessInstance(long piId);
        OKMProcessInstanceBean getProcessInstance(String token, long piId);
        void suspendProcessInstance(long piId);
        void suspendProcessInstance(String token, long piId);
        void resumeProcessInstance(long piId);
        void resumeProcessInstance(String token, long piId);
        OKMTaskInstanceBean[] findUserTaskInstances();
        OKMTaskInstanceBean[] findUserTaskInstances(String token);
        OKMTaskInstanceBean[] findPooledTaskInstances();
        OKMTaskInstanceBean[] findPooledTaskInstances(String token);
        OKMTaskInstanceBean[] findTaskInstances(long piId);
        OKMTaskInstanceBean[] findTaskInstances(String token, long piId);
        void setTaskInstanceValues(long piId, String transName, OKMFormElementBean[] values);
        void setTaskInstanceValues(String token, long piId, String transName, OKMFormElementBean[] values);
        OKMTaskInstanceBean getTaskInstance(long tiId);
        OKMTaskInstanceBean getTaskInstance(String token, long tiId);
        void setTaskInstanceActorId(long tiId, String actorId);
        void setTaskInstanceActorId(String token, long tiId, String actorId); 
        void startTaskInstance(long tiId);
        void startTaskInstance(String token, long tiId);
        void endTaskInstance(long tiId, String transName);
        void endTaskInstance(String token, long tiId, String transName); 
        OKMTokenBean getToken(long tkId);
        OKMTokenBean getToken(String token, long tkId);
        OKMTokenBean sendTokenSignal(long tkId, String transName);
        OKMTokenBean sendTokenSignal(String token, long tkId, String transName);

Dashboard

        OKMDashboardDocumentResultBean[] getUserCheckedOutDocuments();
        OKMDashboardDocumentResultBean[] getUserCheckedOutDocuments(String token);
        OKMDashboardDocumentResultBean[] getUserLastModifiedDocuments();
        OKMDashboardDocumentResultBean[] getUserLastModifiedDocuments(String token);
        OKMDashboardDocumentResultBean[] getUserLockedDocuments();
        OKMDashboardDocumentResultBean[] getUserLockedDocuments(String token);
        OKMDashboardDocumentResultBean[] getUserSubscribedDocuments();
        OKMDashboardDocumentResultBean[] getUserSubscribedDocuments(String token);
        OKMDashboardFolderResultBean[] getUserSubscribedFolders();
        OKMDashboardFolderResultBean[] getUserSubscribedFolders(String token);
        OKMDashboardDocumentResultBean[] getUserLastDownloadedDocuments();
        OKMDashboardDocumentResultBean[] getUserLastDownloadedDocuments(String token);
        OKMDashboardDocumentResultBean[] getUserLastImportedMailAttachments();
        OKMDashboardDocumentResultBean[] getUserLastImportedMailAttachments(String token);
        OKMDashboardMailResultBean[] getUserLastImportedMails();
        OKMDashboardMailResultBean[] getUserLastImportedMails(String token);
        long getUserDocumentsSize();
        long getUserDocumentsSize(String token);
        OKMQueryParamsBean[] getUserSearchs();
        OKMQueryParamsBean[] getUserSearchs(String token);
        OKMDashboardDocumentResultBean[] find(int qpId);
        OKMDashboardDocumentResultBean[] find(String token, int qpId);
        OKMDashboardDocumentResultBean[] getLastWeekTopDownloadedDocuments();
        OKMDashboardDocumentResultBean[] getLastWeekTopDownloadedDocuments(String token);
        OKMDashboardDocumentResultBean[] getLastMonthTopDownloadedDocuments();
        OKMDashboardDocumentResultBean[] getLastMonthTopDownloadedDocuments(String token);
        OKMDashboardDocumentResultBean[] getLastWeekTopModifiedDocuments();
        OKMDashboardDocumentResultBean[] getLastWeekTopModifiedDocuments(String token);
        OKMDashboardDocumentResultBean[] getLastMonthTopModifiedDocuments();
        OKMDashboardDocumentResultBean[] getLastMonthTopModifiedDocuments(String token);
        OKMDashboardDocumentResultBean[] getLastModifiedDocuments();
        OKMDashboardDocumentResultBean[] getLastModifiedDocuments(String token);
        void visiteNode(String source, String node, DateTime date, Boolean dateSpecified);
        void visiteNode(String token, String source, String node, DateTime date, Boolean dateSpecified);

Changes between versions

Method changes

Class Method Action Version
PropertyGroup getPropertyGroupForm Added 6.2.27+ and 6.4.9+

Class changes

Class Type Action Version
OKMQueryParamsBean String var path used to set folder searching path Deprecated WS 2.0+
OKMQueryParamsBean String var folder expected UUID value from where starting searching Added WS 2.0+
OKMQueryParamsBean bool var folderRecursive what indicates if search is limited to actual folder or apply to subfolders Added WS 2.0+