Java SDK

From OpenKM Documentation
Revision as of 18:54, 25 November 2013 by Jllort (talk | contribs) (Example)

Jump to: navigation, search

Nota advertencia.png Unders construction

Supported OpenKM Versions:

  • OpenKM Professional 6.4
  • OpenKM Professional 6.2+

Advantage of use

We recommend to use OKMWebservices from jar 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.

Example

String host = "http://localhost:8080/OpenKM";
String user = "okmAdmin";
String password = "admin";
OKMWebservices ws= OKMWebservicesFactory.newInstance(OKMWebservicesFactory.PROFESSIONAL_6_4, host, user, password);
try {
	System.out.println(ws.getName("okmAdmin"));
	System.out.println(ws.getRoles());
	System.out.println(ws.getRolesByUser("okmAdmin"));
	System.out.println(ws.getGrantedRoles("/okm:root"));
	System.out.println(ws.getGrantedUsers("/okm:root"));
	System.out.println(ws.getMail("okmAdmin"));
	System.out.println(ws.getName("okmAdmin"));
	System.out.println(ws.getUsers());
	System.out.println(ws.getUsersByRole("ROLE_ADMIN"));
	ws.revokeRole("/okm:root", "ROLE_ADMIN", Permission.ALL_GRANTS, false);
	ws.revokeUser("/okm:root", "okmAdmin", Permission.ALL_GRANTS, false);
	ws.grantRole("/okm:root", "ROLE_ADMIN", Permission.ALL_GRANTS, false);
	ws.grantUser("/okm:root", "okmAdmin", Permission.ALL_GRANTS, false);
} catch (DatabaseException e) {
	e.printStackTrace();
} catch (RepositoryException e) {
	e.printStackTrace();
} catch (PrincipalAdapterException e) {
	e.printStackTrace();
} catch (AccessDeniedException e) {
	e.printStackTrace();
} catch (WebserviceException e) {
	e.printStackTrace();
} catch (PathNotFoundException e) {			
	e.printStackTrace();
} catch (UnknowException e) {
	e.printStackTrace();
}