Difference between revisions of "Csharp webservice dll"

From OpenKM Documentation
Jump to: navigation, search
Line 7: Line 7:
 
'''Available api:'''
 
'''Available api:'''
 
* Webservices for OpenKM Professional 6.4
 
* Webservices for OpenKM Professional 6.4
* Webservices for OpenKM Professional 6.2
+
* Webservices for OpenKM Professional 6.2+
 
* Webservices for OpenKM Community 6.0+
 
* Webservices for OpenKM Community 6.0+
  

Revision as of 14:09, 23 September 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 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.

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);
// 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);
// Folder
OKMFolderBean[] getChildren(String fldPath);
OKMFolderBean[] getChildren(String token, String fldPath);
OKMQueryResultBean[] find(OKMQueryParamsBean queryParams);
OKMQueryResultBean[] find(String token, OKMQueryParamsBean queryParams);
void create(OKMFolderBean folderBean);
void create(String token, OKMFolderBean folderBean);
void rename(String fldPath, String newName);
void rename(String token, String fldPath, String newName);
void delete(String fldPath);
void delete(String token, String fldPath);
// PropertyGroup
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);