Difference between revisions of "Csharp webservice dll"

From OpenKM Documentation
Jump to: navigation, search
(Object classes)
Line 75: Line 75:
  
 
=== Object classes ===
 
=== Object classes ===
* OKMVersionBean
+
* OKMActualVersionBean
 
* OKMAppVersionBean
 
* OKMAppVersionBean
 +
* OKMBookmarkBean
 +
* OKMCommentBean
 
* OKMDocumentBean
 
* OKMDocumentBean
 
* OKMFolderBean
 
* OKMFolderBean
 
* OKMFormElementBean
 
* OKMFormElementBean
 
* OKMLockInfoBean
 
* OKMLockInfoBean
* OKMLockInfoBean
+
* OKMMailBean
 +
* OKMNotesBean
 
* OKMOptionBean
 
* OKMOptionBean
 
* OKMPermissions
 
* OKMPermissions
 +
* OKMProcessDefinitionBean
 +
* OKMProcessInstanceBean
 +
* OKMProcessInstanceEntryBean
 
* OKMPropertyGroupBean
 
* OKMPropertyGroupBean
 
* OKMQueryParamsBean
 
* OKMQueryParamsBean
 +
* OKMQueryParamsEntryBean
 
* OKMQueryResultBean
 
* OKMQueryResultBean
 +
* OKMTaskInstanceBean
 +
* OKMTaskInstanceEntryBean
 +
* OKMTaskInstanceEntryBean
 +
* OKMTransitionBean
 
* OKMValidatorBean
 
* OKMValidatorBean
  

Revision as of 12:25, 16 October 2013


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

Available api:

  • Webservices for OpenKM Professional 6.4
  • Webservices for OpenKM Professional 6.2+
  • Webservices for OpenKM Community 6.0+

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();
  // 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();
} catch (OKMWebserviceExceptione){

}

Available methods


Nota advertencia.png OKMWebservice library methods are still not 100% finished, this is a list of actuals.

Object classes

  • OKMActualVersionBean
  • OKMAppVersionBean
  • OKMBookmarkBean
  • OKMCommentBean
  • OKMDocumentBean
  • OKMFolderBean
  • OKMFormElementBean
  • OKMLockInfoBean
  • OKMMailBean
  • OKMNotesBean
  • OKMOptionBean
  • OKMPermissions
  • OKMProcessDefinitionBean
  • OKMProcessInstanceBean
  • OKMProcessInstanceEntryBean
  • OKMPropertyGroupBean
  • OKMQueryParamsBean
  • OKMQueryParamsEntryBean
  • OKMQueryResultBean
  • OKMTaskInstanceBean
  • OKMTaskInstanceEntryBean
  • OKMTaskInstanceEntryBean
  • 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

        void create(String docPath, byte[] data);
        void 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);
        void create(OKMFolderBean folderBean);
        void create(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);

Property Group

        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);
        void setProperties(String nodePath, String grpName, OKMFormElementBean[] properties);
        void setProperties(String token, String nodePath, String grpName, OKMFormElementBean[] properties);