Repository samples
Methods
getRootFolder
Description:
Method | Return values | Description |
---|---|---|
getRootFolder() |
Folder |
Returns the object Folder of node "/okm:root" |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetRoolFolder() {
try {
$folders = $this->ws->getRootFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetRoolFolder();
?>
getTrashFolder
Description:
Method | Return values | Description |
---|---|---|
getTrashFolder() |
Folder |
Returns the object Folder of node "/okm:trash/{userId}" |
The returned folder will be the user trash folder. For example if the method is executed by "okmAdmin" user then the folder returned will be "/okm:trash/okmAdmin". |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetTrashFolder(){
try {
$folders = $this->ws->getTrashFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetTrashFolder();
?>
getTemplatesFolder
Description:
Method | Return values | Description |
---|---|---|
getTemplatesFolder() |
Folder |
Returns the object Folder of node "/okm:templates" |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetTemplatesFolder() {
try {
$folders = $this->ws->getTemplatesFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetTemplatesFolder();
?>
getPersonalFolder
Description:
Method | Return values | Description |
---|---|---|
getPersonalFolder() |
Folder |
Returns the object Folder of node "/okm:personal/{userId}" |
The returned folder will be the user personal folder. For example if the method is executed by "okmAdmin" user then the folder returned will be "/okm:personal/okmAdmin". |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetPersonalFolder(){
try {
$folders = $this->ws->getPersonalFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetPersonalFolder();
?>
getMailFolder
Description:
Method | Return values | Description |
---|---|---|
getMailFolder() |
Folder |
Returns the object Folder of node "/okm:mail/{userId}" |
The returned folder will be the user mail folder. For example if the method is executed by "okmAdmin" user then the folder returned will be "/okm:mail/okmAdmin". |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetMailFolder() {
try {
$folders = $this->ws->getMailFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetMailFolder();
?>
getThesaurusFolder
Description:
Method | Return values | Description |
---|---|---|
getThesaurusFolder() |
Folder |
Returns the object Folder of node "/okm:thesaurus" |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetThesaurusFolder() {
try {
$folders = $this->ws->getThesaurusFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetThesaurusFolder();
?>
getCategoriesFolder
Description:
Method | Return values | Description |
---|---|---|
getCategoriesFolder() |
Folder |
Returns the object Folder of node "/okm:categories" |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetCategoriesFolder() {
try {
$folders = $this->ws->getCategoriesFolder();
var_dump($folders);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetCategoriesFolder();
?>
purgeTrash
Description:
Method | Return values | Description |
---|---|---|
purgeTrash() |
void |
Definitively remove from repository all nodes into "/okm:trash/{userId}" |
For example if the method is executed by "okmAdmin" user then the purged trash will be "/okm:trash/okmAdmin". When a node is purged it will only be able to be restored from a previously repository backup. The purge action removes the node definitely from the repository.
|
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testPurgeTrash() {
try {
$this->ws->purgeTrash();
echo 'correct';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testPurgeTrash();
?>
getUpdateMessage
Description:
Method | Return values | Description |
---|---|---|
getUpdateMessage() |
string |
Retrieves a message when a new OpenKM release is available. |
There's an official OpenKM update message service available which is based on your local OpenKM version. The most common message is that a new OpenKM version has been released. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetUpdateMessage() {
try {
var_dump($this->ws->getUpdateMessage());
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetUpdateMessage();
?>
getRepositoryUuid
Description:
Method | Return values | Description |
---|---|---|
getRepositoryUuid() |
string |
Retrieves an installation unique identifier. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetRepositoryUuid() {
try {
var_dump($this->ws->getRepositoryUuid());
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetRepositoryUuid();
?>
hasNode
Description:
Method | Return values | Description |
---|---|---|
hasNode($nodeId) |
bool |
Returns a node that indicates if a node exists or not. |
Parameters: $nodeId string type is the value of the parameter nodeId can be a valid UUID or path. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testHasNode() {
try {
echo 'Exists node: ' . $this->ws->hasNode('adabdb0f-7ff8-4832-9e43-8bc96fc1c9a5');
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testHasNode();
?>
getNodePath
Description:
Method | Return values | Description |
---|---|---|
getNodePath($uuid) |
string |
Converts a node UUID to path. |
Parameters: $uuid string type is the uuid of the node |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetNodePath() {
try {
var_dump($this->ws->getNodePath('adabdb0f-7ff8-4832-9e43-8bc96fc1c9a5'));
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetNodePath();
?>
getNodeUuid
Description:
Method | Return values | Description |
---|---|---|
getNodeUuid($nodePath) |
string |
Converts a node path to UUID. |
Parameters: $nodePath string type is the path of the node |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetNodeUuid() {
try {
var_dump($this->ws->getNodeUuid('/okm:root/SDK4PHP/logo.png'));
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetNodeUuid();
?>
getAppVersion
Description:
Method | Return values | Description |
---|---|---|
getAppVersion() |
AppVersion |
Returns information about an OpenKM version. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetAppVersion() {
try {
$appVersion = $this->ws->getAppVersion();
var_dump($appVersion);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testGetAppVersion();
?>
executeScript
Description:
Method | Return values | Description |
---|---|---|
executeScript($content) |
ScriptExecutionResult |
Executes an script. |
Parameters: $content string type Recommend using file_get_contents — Reads entire file into a string The local script - test.bsh - used in the sample below:
This action can only be done by a super user ( user with ROLE_ADMIN ). |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testExecuteScript() {
try {
$fileName = dirname(__FILE__) . '/files/test.bsh';
$scriptExecutionResult = new \openkm\bean\ScriptExecutionResult();
$scriptExecutionResult = $this->ws->executeScript(file_get_contents($fileName));
var_dump($scriptExecutionResult->getResult());
var_dump($scriptExecutionResult->getStdout());
if ($scriptExecutionResult->getStderr() != '') {
echo "Error happened";
var_dump($scriptExecutionResult->getStderr());
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testExecuteScript();
?>
executeSqlQuery
Description:
Method | Return values | Description |
---|---|---|
executeSqlQuery($content) |
SqlQueryResults |
Executes SQL sentences. |
Parameters: $content string type Recommends using file_get_contents — Reads entire file into a string The test.sql script used in the sample below:
The SQL script can only contains a single SQL sentence. This action can only be done by a super user ( user with ROLE_ADMIN ). |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
use openkm\bean\SqlQueryResults;
use openkm\bean\SqlQueryResultColumns;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testExecuteSqlQuery() {
try {
$fileName = dirname(__FILE__) . '/files/test.sql';
$sqlQueryResults = new SqlQueryResults();
$sqlQueryResults = $this->ws->executeSqlQuery(file_get_contents($fileName));
foreach ($sqlQueryResults->getResults() as $sqlQueryResultColumns ){
$columns = $sqlQueryResultColumns->getColumns();
var_dump('uuid: ' . $columns[0] . ' name: ' . $columns[1]);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testExecuteSqlQuery();
?>
Also the InputStream can be set as:
$sql = "SELECT NBS_UUID, NBS_NAME FROM OKM_NODE_BASE LIMIT 10;";
$sqlQueryResults = $this->ws->executeSqlQuery($sql);
executeHqlQuery
Description:
Method | Return values | Description |
---|---|---|
executeHqlQuery($content) |
HqlQueryResults |
Executes HQL sentences. |
Parameters: $content string type Recommends using file_get_contents — Reads entire file into a string The testhql.sql script used in the sample below:
The HQL script can only contains a single HQL sentence. This action can only be done by a super user ( user with ROLE_ADMIN ). |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\AppVersion;
class ExampleRepository {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testExecuteHqlQuery() {
try {
$fileName = dirname(__FILE__) . '/files/testhql.sql';
$hqlQueryResults = new \openkm\bean\HqlQueryResults();
$hqlQueryResults = $this->ws->executeHqlQuery(file_get_contents($fileName));
foreach ($hqlQueryResults->getResults() as $hqlQueryResult ){
var_dump($hqlQueryResult);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleRepository = new ExampleRepository();
$exampleRepository->testExecuteHqlQuery();
?>
Also the InputStream can be set as:
$hql = "SELECT uuid, name from NodeBase where name = 'okm:root';";
$hqlQueryResults = $this->ws->executeHqlQuery($hql);