Source for file Workspace.php
Documentation is available at Workspace.php
* The Workspace object represents a "view" of an actual repository workspace entity as seen through the authorization settings of its associated Session.
* Each Workspace object is associated one-to-one with a Session object.
* The Workspace object can be acquired by calling Session->getWorkspace() on the associated Session object.
* Creates a new Workspace object, given an active session (i.e. PersistenceManager).
* @param generic $pm the active PersistenceManager.
$this->workspace =
$pm->getWorkspace();
* Clones the subtree at the node $sourcePath in $workspace to the new location at $destinationPath in this workspace.
* If successful, the change is persisted immediately.
* Strictly speaking, the $destinationPath parameter is actually an absolute path to the parent node of the new location, appended with the new name desired for the cloned node.
* This method cannot be used to clone just an individual property by itself. It clones an entire node and its subtree (including, of course, any properties contained therein).
* A NoSuchWorkspaceException is thrown if $workspace does not exist or if the current Session does not have permission to access it.
* A PathNotFoundException is thrown if the node at $sourcePath in $workspace or the parent of $destinationPath in this workspace does not exist.
* An ItemExistsException is thrown if a node or property already exists at $destinationPath.
* An ItemExistException is thrown if a node already exists at $destinationPath.
* @param string $workspace - The name of the workspace from which the node is to be copied.
* @param string $sourcePath - the path of the node to be cloned in $workspace.
* @param string $destinationPath - the location to which the node at $workspace=>$sourcePath is to be cloned in this workspace.
public function _clone($workspace, $sourcePath, $destinationPath) {
if (!file_exists($_SERVER['PCR'] .
"/config/$workspace.xml")) {
$persistenceManager = (string)
$config->persistenceManager;
if (!file_exists($_SERVER['PCR'] .
"/PMs/$persistenceManager.php")) {
throw
new RepositoryException("persistence manager does not exist for workspace: $workspace=>$persistenceManager");
require_once $_SERVER['PCR'] .
"/PMs/$persistenceManager.php";
$pm =
new $persistenceManager($this->pm->getCredentials(), $workspace, $config);
throw
new LoginException("workspace=>$workspace, persistenceManager=>$persistenceManager, userID=>" .
$credentials->getUserID());
if ($sourcePath ==
'pcr:root') {
} else if ($pm->getNode($sourcePath) ===
null) {
} else if ($this->pm->getNode($destinationPath) !==
null) {
$parent =
substr($destinationPath, 0, strrpos($destinationPath, '/'));
if ($parent !=
'pcr:root') {
if ($this->pm->getNode($parent) ===
null) {
Log4PCR::info("Cloned node (and its descendants, if any): $workspace=>$sourcePath to $this->workspace=>$destinationPath");
$this->pm->_clone($workspace, $sourcePath, $destinationPath);
* This method copies the node at $sourcePath to the new location at $destinationPath.
* If successful, the change is persisted immediately.
* Strictly speaking, the $destinationPath parameter is actually an absolute path to the parent node of the new location, appended with the new name desired for the copied node.
* This method cannot be used to copy just an individual property by itself.
* It copies an entire node and its subtree (including, of course, any properties contained therein).
* A PathNotFoundException is thrown if the node at $sourcePath or the parent of $destinationPath does not exist.
* An ItemExistException is thrown if a Node already exists at $destinationPath.
* @param string $sourcePath the root of the subtree to be copied.
* @param string $destinationPath the location to which the subtree is to be copied.
public function copy($sourcePath, $destinationPath) {
if ($sourcePath ==
'pcr:root') {
} else if ($this->pm->getNode($sourcePath) ===
null) {
} else if ($this->pm->getNode($destinationPath) !==
null) {
$parent =
substr($destinationPath, 0, strrpos($destinationPath, '/'));
if ($parent !=
'pcr:root') {
if ($this->pm->getNode($parent) ===
null) {
Log4PCR::info("Copied node (and its descendants, if any): $this->workspace=>$sourcePath to $this->workspace=>$destinationPath");
$this->pm->copy($sourcePath, $destinationPath);
* Returns an string array containing the names of all workspaces in the repository.
* In order to access one of the listed workspaces, the user performs another Repository->login, specifying the name of the desired workspace, and receives a new Session object.
* @return array string array of names of accessible workspaces.
$accessibleWorkspaceNames =
array();
if ($handle =
opendir($_SERVER['PCR'] .
'/config')) {
while (false !==
($workspace =
readdir($handle))) {
if ($workspace !=
'.' &&
$workspace !=
'..') {
$accessibleWorkspaceNames[] =
substr($workspace, 0, strrpos($workspace, '.'));
return $accessibleWorkspaceNames;
* Returns the name of the actual persistent workspace represented by this Workspace object.
* @return string the name of this workspace.
* Returns the QueryManager object, through search methods are accessed.
* @return QueryManager the QueryManager object.
Documentation generated on Sun, 04 Oct 2009 07:13:13 +0800 by phpDocumentor 1.4.3