SDK for Java 2.1

From OpenKM Documentation
Jump to: navigation, search

Contents


Nota clasica.png If you want to collaborate extending features or add newer contact with us at contact website form indicating this URL.

OpenKM SDK for Java is a set of software developement tools that allows for the creation of applications for OpenKM. The OpenKM SDK for Java include a webservices library. This webservices library is a complete API layer to access OpenKM through webservices and provides complete compatibility between OpenKM webservices versions without change code.

Available jar file

Library dependences File:Sdk-lib-dependences.zip

catch-exception-1.2.0.jar    
commons-beanutils-1.8.3.jar  
commons-io-1.3.2.jar         
commons-lang-2.5.jar         
commons-logging-1.1.1.jar    
dozer-5.3.2.jar              
hamcrest-core-1.3.jar        
jersey-client-1.17.1.jar
jersey-core-1.17.1.jar
jersey-multipart-1.17.1.jar
mimepull-1.6.jar
mockito-core-1.9.5.jar
objenesis-1.0.jar
slf4j-api-1.7.2.jar

Sample client using this JDK

You can make use of the OpenKM Maven Repository and will be using the right JDK version. This is a sample pom.xml configuration:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>com.openkm.sample</groupId>
  <artifactId>sample</artifactId>
  <version>1.0-SNAPSHOT</version>
 
  <repositories>
    <repository>
      <id>openkm.com</id>
      <name>OpenKM Maven Repository</name>
      <url>http://maven.openkm.com/maven2</url>
    </repository>
  </repositories>
 
  <dependencies>
    <dependency>
      <groupId>com.openkm</groupId>
      <artifactId>sdk4j</artifactId>
      <version>2.1</version>
    </dependency>
  </dependencies>
</project>

In this class you can see how to call an API method to request all folder children from "/okm:root":

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
import com.openkm.sdk4j.exception.*;
 
/**
 * Sample OpenKM JDK client
 */
public class Main {
    public static void main(String var[]) throws Exception {
        String url = "http://demo.openkm.com/OpenKM";
        String user = "user5";
        String pass = "pass5";
        OKMWebservices okm = OKMWebservicesFactory.newInstance(url, user, pass);
 
        for (Folder fld : okm.getFolderChildren("/okm:root")) {
            System.out.println("Fodler -> " + fld.getPath());
        }
    }

Example

String host = "http://localhost:8080/OpenKM";
String user = "okmAdmin";
String password = "admin";
OKMWebservices ws= OKMWebservicesFactory.newInstance(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();
}

Description

Classes

  • AppVersion
  • CheckBox
  • Document
  • DocumentList
  • Folder
  • FolderList
  • FormElement
  • FormElementComplex
  • FormElementComplexList
  • GrantedRole
  • GrantedRoleList
  • GrantedUser
  • GrantedUserList
  • Input
  • KeywordMap
  • KeywordMapList
  • LanguageList
  • LockInfo
  • Node
  • Note
  • NoteList
  • Option
  • PropertyGroup
  • PropertyGroupList
  • ProposedQueryReceived
  • ProposedQuerySent
  • QueryParamsList
  • QueryResult
  • QueryResultList
  • QueryParams
  • ResultSet
  • RoleList
  • Select
  • Separator
  • SimplePropertyGroup
  • SuggestBox
  • TextArea
  • UserList
  • Validator
  • Version
  • VersionList

Auth

public Map<String, Integer> getGrantedRoles(String nodeId) throws AccessDeniedException, RepositoryException, DatabaseException,
		PathNotFoundException, UnknowException, WebserviceException;
 
public Map<String, Integer> getGrantedUsers(String nodeId) throws AccessDeniedException, RepositoryException, DatabaseException,
		PathNotFoundException, UnknowException, WebserviceException;
 
public String getMail(String user) throws PrincipalAdapterException, AccessDeniedException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public String getName(String user) throws DatabaseException, RepositoryException, PrincipalAdapterException, AccessDeniedException,
		UnknowException, WebserviceException;
 
public List<String> getRoles() throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException,
		UnknowException, WebserviceException;
 
public List<String> getRolesByUser(String user) throws AccessDeniedException, RepositoryException, DatabaseException,
		PrincipalAdapterException, UnknowException, WebserviceException;
 
public List<String> getUsers() throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException,
		UnknowException, WebserviceException;
 
public List<String> getUsersByRole(String role) throws AccessDeniedException, RepositoryException, DatabaseException,
		PrincipalAdapterException, UnknowException, WebserviceException;
 
public void revokeRole(String nodeId, String role, int permissions, boolean recursive) throws AccessDeniedException,
		RepositoryException, DatabaseException, PathNotFoundException, UnknowException, WebserviceException;
 
public void revokeUser(String nodeId, String user, int permissions, boolean recursive) throws AccessDeniedException,
		RepositoryException, DatabaseException, PathNotFoundException, UnknowException, WebserviceException;
 
public void grantRole(String nodeId, String role, int permissions, boolean recursive) throws AccessDeniedException,
		RepositoryException, DatabaseException, PathNotFoundException, UnknowException, WebserviceException;
 
public void grantUser(String nodeId, String role, int permissions, boolean recursive) throws AccessDeniedException,
		RepositoryException, DatabaseException, PathNotFoundException, UnknowException, WebserviceException;
 
public void createUser(String user, String password, String email, String name, boolean active) throws PrincipalAdapterException,
		UnknowException, WebserviceException;
 
public void deleteUser(String user) throws PrincipalAdapterException, UnknowException, WebserviceException;
 
public void updateUser(String user, String password, String email, String name, boolean active) throws PrincipalAdapterException,
		UnknowException, WebserviceException;
 
public void createRole(String role, boolean active) throws PrincipalAdapterException, UnknowException, WebserviceException;
 
public void deleteRole(String role) throws PrincipalAdapterException, UnknowException, WebserviceException;
 
public void updateRole(String role, boolean active) throws PrincipalAdapterException, UnknowException, WebserviceException;
 
public void assignRole(String user, String role) throws PrincipalAdapterException, UnknowException, WebserviceException;
 
public void removeRole(String user, String role) throws PrincipalAdapterException, UnknowException, WebserviceException;

Document

public Document createDocument(Document okmDocument, InputStream is) throws IOException, UnsupportedMimeTypeException,
		FileSizeExceededException, UserQuotaExceededException, VirusDetectedException, ItemExistsException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, ExtensionException, AutomationException, UnknowException,
		WebserviceException;
 
public Document createDocumentSimple(String docPath, InputStream is) throws IOException, UnsupportedMimeTypeException,
		FileSizeExceededException, UserQuotaExceededException, VirusDetectedException, ItemExistsException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, ExtensionException, AutomationException, UnknowException,
		WebserviceException;
 
public void deleteDocument(String docId) throws AccessDeniedException, RepositoryException, PathNotFoundException, LockException,
		DatabaseException, ExtensionException, UnknowException, WebserviceException;
 
public Document getDocumentProperties(String docId) throws RepositoryException, PathNotFoundException, DatabaseException, UnknowException,
		WebserviceException;
 
public InputStream getContent(String docId) throws RepositoryException, IOException, PathNotFoundException, AccessDeniedException,
		DatabaseException, UnknowException, WebserviceException;
 
public InputStream getContentByVersion(String docId, String versionId) throws RepositoryException, IOException, PathNotFoundException,
		AccessDeniedException, DatabaseException, UnknowException, WebserviceException;
 
public List<Document> getDocumentChildren(String fldId) throws RepositoryException, PathNotFoundException, DatabaseException,
		UnknowException, WebserviceException;
 
public void renameDocument(String docId, String newName) throws AccessDeniedException, RepositoryException, PathNotFoundException,
		ItemExistsException, LockException, DatabaseException, ExtensionException, UnknowException, WebserviceException;
 
public void setProperties(Document okmDocument) throws AccessDeniedException, RepositoryException, PathNotFoundException,
		VersionException, LockException, DatabaseException, UnknowException, WebserviceException;
 
public void setLanguage(String docId, String lang) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void setTitle(String docId, String title) throws VersionException, LockException, PathNotFoundException, AccessDeniedException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void setDocumentNodeClass(String docId, long ncId) throws VersionException, LockException, PathNotFoundException, AccessDeniedException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void checkout(String docId) throws AccessDeniedException, RepositoryException, PathNotFoundException, LockException,
		DatabaseException, UnknowException, WebserviceException;
 
public void cancelCheckout(String docId) throws AccessDeniedException, RepositoryException, PathNotFoundException, LockException,
		DatabaseException, UnknowException, WebserviceException;
 
public void forceCancelCheckout(String docId) throws AccessDeniedException, RepositoryException, PathNotFoundException, LockException,
		DatabaseException, PrincipalAdapterException, UnknowException, WebserviceException;
 
public boolean isCheckedOut(String docId) throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Version checkin(String docId, InputStream is, String comment) throws FileSizeExceededException, UserQuotaExceededException,
		VirusDetectedException, LockException, VersionException, PathNotFoundException, AccessDeniedException, RepositoryException,
		IOException, DatabaseException, ExtensionException, UnknowException, WebserviceException;
 
public List<Version> getVersionHistory(String docId) throws PathNotFoundException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public LockInfo lock(String docId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public void unlock(String docId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public void forceUnlock(String docId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, PrincipalAdapterException, UnknowException, WebserviceException;
 
public boolean isLocked(String docId) throws RepositoryException, PathNotFoundException, DatabaseException, UnknowException,
		WebserviceException;
 
public LockInfo getLockInfo(String docId) throws RepositoryException, PathNotFoundException, LockException, DatabaseException,
		UnknowException, WebserviceException;
 
public void purgeDocument(String docId) throws LockException, AccessDeniedException, RepositoryException, PathNotFoundException,
		DatabaseException, ExtensionException, UnknowException, WebserviceException;
 
public void moveDocument(String docId, String dstId) throws LockException, PathNotFoundException, ItemExistsException, AccessDeniedException,
		RepositoryException, DatabaseException, ExtensionException, AutomationException, UnknowException, WebserviceException;
 
public void copyDocument(String docId, String dstId) throws ItemExistsException, PathNotFoundException, AccessDeniedException,
		RepositoryException, IOException, DatabaseException, UserQuotaExceededException, ExtensionException, AutomationException,
		UnknowException, WebserviceException;
 
public void restoreVersion(String docId, String versionId) throws AccessDeniedException, PathNotFoundException, LockException,
		RepositoryException, DatabaseException, ExtensionException, UnknowException, WebserviceException;
 
public void purgeVersionHistory(String docId) throws AccessDeniedException, PathNotFoundException, LockException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public long getVersionHistorySize(String docId) throws RepositoryException, PathNotFoundException, DatabaseException, UnknowException,
		WebserviceException;
 
public boolean isValidDocument(String docId) throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public String getDocumentPath(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public List<String> getDetectedLanguages() throws RepositoryException, DatabaseException, UnknowException, WebserviceException;

Folder

public Folder createFolder(Folder okmFolder) throws AccessDeniedException, RepositoryException, PathNotFoundException,
		ItemExistsException, DatabaseException, ExtensionException, AutomationException, UnknowException, WebserviceException;
 
public Folder createFolderSimple(String fldPath) throws AccessDeniedException, RepositoryException, PathNotFoundException,
		ItemExistsException, DatabaseException, ExtensionException, AutomationException, UnknowException, WebserviceException;
 
public Folder getFolderProperties(String fldId) throws AccessDeniedException, RepositoryException, PathNotFoundException,
		DatabaseException, UnknowException, WebserviceException;
 
public void deleteFolder(String fldId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public void renameFolder(String fldId, String newName) throws PathNotFoundException, ItemExistsException, AccessDeniedException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void moveFolder(String fldId, String dstId) throws PathNotFoundException, ItemExistsException, AccessDeniedException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public List<Folder> getFolderChildren(String fldId) throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public boolean isValidFolder(String fldId) throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public String getFolderPath(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;

Note

public Note addNote(String nodeId, String text) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public Note getNote(String noteId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public void deleteNote(String noteId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public void setNote(String noteId, String text) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public List<Note> listNotes(String nodeId) throws LockException, PathNotFoundException, AccessDeniedException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;

PropertyGroup


Nota clasica.png when you want to set values into select multiple using setPropertyGroupPropertiesSimple 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"

public void addGroup(String nodeId, String grpName) throws NoSuchGroupException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, ExtensionException, AutomationException, UnknowException,
		WebserviceException;
 
public void removeGroup(String nodeId, String grpName) throws AccessDeniedException, NoSuchGroupException, LockException,
		PathNotFoundException, RepositoryException, DatabaseException, ExtensionException, UnknowException, WebserviceException;
 
public List<PropertyGroup> getGroups(String nodeId) throws IOException, ParseException, PathNotFoundException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public List<PropertyGroup> getAllGroups() throws IOException, ParseException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public List<FormElement> getPropertyGroupProperties(String nodeId, String grpName) throws IOException, ParseException,
		NoSuchGroupException, PathNotFoundException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public List<FormElement> getPropertyGroupForm(String grpName) throws IOException, ParseException, NoSuchGroupException,
		PathNotFoundException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void setPropertyGroupProperties(String nodeId, String grpName, List<FormElement> ofeList) throws IOException, ParseException,
		NoSuchPropertyException, NoSuchGroupException, LockException, PathNotFoundException, AccessDeniedException,
		RepositoryException, DatabaseException, ExtensionException, AutomationException, UnknowException, WebserviceException;
 
public void setPropertyGroupPropertiesSimple(String nodeId, String grpName, Map<String, String> properties) throws IOException,
		ParseException, NoSuchPropertyException, NoSuchGroupException, LockException, PathNotFoundException, AccessDeniedException,
		RepositoryException, DatabaseException, ExtensionException, AutomationException, UnknowException, WebserviceException;
 
public boolean hasGroup(String nodeId, String grpName) throws IOException, ParseException, PathNotFoundException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public String getRegisteredDefinition() throws ParseException, DatabaseException, IOException, UnknowException, WebserviceException;
 
public List<String> getSuggestions(String nodeId, String grpName, String propName) throws PathNotFoundException, IOException,
		ParseException, NoSuchGroupException, SuggestionException, DatabaseException, UnknowException, WebserviceException;
 
public void registerDefinition(String pgDef) throws ParseException, DatabaseException, IOException, UnknowException,
		WebserviceException;

Repository

public Folder getRootFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Folder getTrashFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Folder getTemplatesFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Folder getPersonalFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Folder getMailFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Folder getThesaurusFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public Folder getCategoriesFolder() throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public void purgeTrash() throws PathNotFoundException, AccessDeniedException, LockException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public String getUpdateMessage() throws RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public String getRepositoryUuid() throws RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public boolean hasNode(String nodeId) throws RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public String getNodePath(String uuid) throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public String getNodeUuid(String nodePath) throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public AppVersion getAppVersion() throws RepositoryException, DatabaseException, UnknowException, WebserviceException;

Search

public List<QueryResult> findByContent(String content) throws IOException, ParseException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public List<QueryResult> findByName(String name) throws IOException, ParseException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public List<QueryResult> findByKeywords(List<String> keywords) throws IOException, ParseException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public List<QueryResult> find(QueryParams queryParams) throws IOException, ParseException, RepositoryException,
		DatabaseException, UnknowException, WebserviceException;
 
public ResultSet findPaginated(QueryParams queryParams, int offset, int limit) throws IOException, ParseException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public ResultSet findSimpleQueryPaginated(String statement, int offset, int limit) throws IOException, ParseException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public ResultSet findMoreLikeThis(String uuid, int max) throws IOException, ParseException, RepositoryException, DatabaseException,
		UnknowException, WebserviceException;
 
public Map<String, Integer> getKeywordMap(List<String> filter) throws RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public List<Document> getCategorizedDocuments(String categoryId) throws RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public long saveSearch(QueryParams params) throws AccessDeniedException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public void updateSearch(QueryParams params) throws AccessDeniedException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public QueryParams getSearch(int qpId) throws PathNotFoundException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;
 
public List<QueryParams> getAllSearchs() throws RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void deleteSearch(int qpId) throws AccessDeniedException, RepositoryException, DatabaseException, UnknowException,
		WebserviceException;

Property

public void addCategory(String nodeId, String catId) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void removeCategory(String nodeId, String catId) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void addKeyword(String nodeId, String keyword) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void removeKeyword(String nodeId, String keyword) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void setEncryption(String nodeId, String cipherName) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void unsetEncryption(String nodeId) throws VersionException, LockException, PathNotFoundException, AccessDeniedException,
		RepositoryException, DatabaseException, UnknowException, WebserviceException;
 
public void setSigned(String nodeId, boolean signed) throws VersionException, LockException, PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, UnknowException, WebserviceException;