PHP Class Jackalope\Transport\Jackrabbit\Client

This class handles the communication between Jackalope and Jackrabbit over Davex. Once the login method has been called, the workspace is set and can not be changed anymore. We make one exception to the rule that nothing may be cached in the transport: Repository descriptors are considered immutable and cached (because they are also used in startup to check the backend version is compatible).
Author: Christian Stocker ([email protected])
Author: David Buchmann ([email protected])
Author: Tobias Ebnöther ([email protected])
Author: Roland Schilter ([email protected])
Author: Uwe Jäger ([email protected])
Author: Lukas Kahwe Smith ([email protected])
Author: Daniel Barsotti ([email protected])
Author: Markus Schmucker ([email protected])
Inheritance: extends Jackalope\Transport\BaseTransport, implements Jackalope\Transport\QueryInterface, implements Jackalope\Transport\PermissionInterface, implements Jackalope\Transport\WritingInterface, implements Jackalope\Transport\VersioningInterface, implements Jackalope\Transport\NodeTypeCndManagementInterface, implements Jackalope\Transport\LockingInterface, implements Jackalope\Transport\ObservationInterface, implements Jackalope\Transport\WorkspaceManagementInterface
Afficher le fichier Open project: jackalope/jackalope-jackrabbit Class Usage Examples

Protected Properties

Свойство Type Description
$checkLoginOnServer boolean Check if an initial PROPFIND should be send to check if repository exists This is according to the JCR specifications and set to true by default
$credentials PHPCR\SimpleCredentials Set once login() has been executed and may not be changed later on.
$curl Jackalope\Transport\Jackrabbit\curl The cURL resource handle
$defaultHeaders array[]string A list of additional HTTP headers to be sent on each request
$descriptors This is our exception to the rule that nothing may be cached in transport.
$factory Jackalope\FactoryInterface The factory to instantiate objects
$jsopBody
$nodeTypeManager Jackalope\NodeType\NodeTypeManager
$sendExpect Send Expect: 100-continue header
$server string i.e http://localhost:8080/server/ constructor ensures the trailing slash /
$typeXmlConverter Jackalope\NodeType\NodeTypeXmlConverter
$userData
$valueConverter PHPCR\Util\ValueConverter
$workspace string Set once login() has been executed and may not be changed later on.
$workspaceUri string "$server/$workspace" without trailing slash
$workspaceUriRoot string "$server/$workspace/jcr%3aroot (make sure you never hardcode the jcr%3aroot, its ugly)

Méthodes publiques

Méthode Description
__construct ( Jackalope\FactoryInterface $factory, string $serverUri ) Create a transport pointing to a server url.
__destruct ( ) Tidies up the current cUrl connection.
addCurlOptions ( array $options ) : array Add global curl-options.
addDefaultHeader ( string $header ) Add a HTTP header which is sent on each Request.
addVersionLabel ( $versionPath, $label, $moveLabel )
checkinItem ( $path ) {@inheritDoc}
checkoutItem ( $path ) {@inheritDoc}
cloneFrom ( $srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting ) {@inheritDoc}
copyNode ( $srcAbsPath, $dstAbsPath, $srcWorkspace = null ) {@inheritDoc}
createWorkspace ( $name, $srcWorkspace = null ) {@inheritDoc}
deleteNodeImmediately ( $path ) {@inheritDoc}
deleteNodes ( array $operations ) {@inheritDoc}
deleteProperties ( array $operations ) {@inheritDoc}
deletePropertyImmediately ( $path ) {@inheritDoc}
deleteWorkspace ( $name )
fetchEventData ( $date ) : array Internal method to fetch event data.
finishSave ( ) {@inheritDoc}
forceHttpVersion10 ( $forceHttpVersion10 = true ) Set to true to force HTTP version 1.0
getAccessibleWorkspaceNames ( ) {@inheritDoc}
getBinaryStream ( $path ) {@inheritDoc}
getEvents ( $date, PHPCR\Observation\EventFilterInterface $filter, PHPCR\SessionInterface $session ) {@inheritDoc}
getNamespaces ( ) {@inheritDoc}
getNode ( $path ) {@inheritDoc}
getNodeByIdentifier ( $uuid ) {@inheritDoc}
getNodePathForIdentifier ( $uuid, $workspace = null ) {@inheritDoc}
getNodeTypes ( $nodeTypes = [] ) {@inheritDoc}
getNodes ( $paths, $query = ':include' ) {@inheritDoc}
getNodesByIdentifier ( $identifiers ) {@inheritDoc}
getPermissions ( $path ) {@inheritDoc}
getProperty ( $path ) {@inheritDoc}
getReferences ( $path, $name = null ) {@inheritDoc}
getRepositoryDescriptors ( ) {@inheritDoc}
getSupportedQueryLanguages ( ) {@inheritDoc}
getUserData ( ) : mixed
getWeakReferences ( $path, $name = null ) {@inheritDoc}
getWorkspaceUri ( ) : null | string Return the URL to the workspace determined during login
isLocked ( $absPath ) {@inheritDoc}
lockNode ( $absPath, $isDeep, $isSessionScoped, $timeoutHint = PHP_INT_MAX, $ownerInfo = null ) {@inheritDoc}
login ( PHPCR\CredentialsInterface $credentials = null, $workspaceName = null ) {@inheritDoc}
logout ( ) {@inheritDoc}
moveNodeImmediately ( $srcAbsPath, $dstAbsPath ) {@inheritDoc}
moveNodes ( array $operations ) {@inheritDoc}
prepareSave ( ) {@inheritDoc}
query ( Query $query ) {@inheritDoc}
registerNamespace ( $prefix, $uri ) {@inheritDoc}
registerNodeTypesCnd ( $cnd, $allowUpdate ) {@inheritDoc}
removeVersion ( $versionPath, $versionName ) {@inheritDoc}
removeVersionLabel ( $versionPath, $label )
reorderChildren ( Node $node ) {@inheritDoc}
restoreItem ( $removeExisting, $versionPath, $path ) {@inheritDoc}
rollbackSave ( ) {@inheritDoc}
sendExpect ( boolean $send = true ) If you want to send the "Expect: 100-continue" header on larger PUT and POST requests, set this to true.
setCheckLoginOnServer ( $bool ) Configure whether to check if we are logged in before doing a request.
setNodeTypeManager ( $nodeTypeManager ) {@inheritDoc}
setUserData ( $userData ) {@inheritDoc}
storeNodes ( array $operations ) {@inheritDoc}
unlock ( $absPath, $lockToken ) {@inheritDoc}
unregisterNamespace ( $prefix ) {@inheritDoc}
updateNode ( Node $node, $srcWorkspace ) {@inheritDoc}
updateProperties ( Node $node ) {@inheritDoc}

Méthodes protégées

Méthode Description
addWorkspacePathToUri ( string $uri ) : string Prepends the workspace root to the uris that contain an absolute path
buildLocateRequest ( string $uuid ) : string Build REPORT XML request for locating a node path by uuid
buildNodeTypesRequest ( array $nodeTypes ) : string Returns the XML required to request nodetypes
buildPropfindRequest ( array $properties ) : string Build PROPFIND request XML for the specified property names
buildRegisterNamespaceRequest ( array $mappings ) Build the xml to update the namespaces
buildRegisterNodeTypeRequest ( string $cnd, $allowUpdate ) : string Build the xml required to register node types
buildReportRequest ( string $name ) : string Build a REPORT XML request string
checkForExistingNode ( $srcWorkspace, $srcAbsPath, $destAbsPath ) Prevent accidental creation of same name siblings during clone operation.
createNodeJsop ( string $path, array $properties ) : string create the node markup and a list of value dispatches for multivalue properties
deleteItem ( string $path ) Record that we need to delete the item at $path
encodeAndValidatePathForDavex ( string $path ) : string Checks if the path is absolute and valid, and properly urlencodes special characters
generateLockFromDavResponse ( DOMElement $response, boolean $sessionOwning = false, string $path = null ) : Lock Extract the information from a LOCK DAV response and create the corresponding Lock object.
getCurl ( )
getMimePart ( $name, $value, $mime_boundary )
getNodeReferences ( string $path, string $name = null, boolean $weak_reference = false ) : array
getRequest ( $method, $uri, $addWorkspacePathToUri = true ) : Request Makes sure there is an open curl connection.
getRequiredDomElementByTagNameNS ( DOMNode $dom, string $namespace, string $element, string $errorMessage = '' ) : boolean | DOMNode Retrieve a child DOM element from a DOM element.
isStringValid ( $string ) : boolean Checks for occurrence of invalid UTF characters, that can not occur in valid XML document.
parseTimeout ( string $timeoutValue ) : integer Parse the timeout value from a WebDAV response and calculate the expire timestamp.
propertyToJsopString ( Property $property ) : mixed | string This method is used when building a JSOP of the properties
setJsopBody ( $value, $key = ":diff", $type = null )
stripServerRootFromUri ( string $uri ) : string remove the server and workspace part from an uri, leaving the absolute path inside the current workspace
updateLastModified ( Node $node ) Update the lastModified fields if they where not set manually.

Private Methods

Méthode Description
copyNodeOtherWorkspace ( string $srcAbsPath, $dstAbsPath, string $srcWorkspace ) For copy from a different workspace, needs to be a JSOP.
copyNodeSameWorkspace ( string $srcAbsPath, $dstAbsPath ) For copy within the same workspace, this is a COPY request.
decodeBinaryDom ( string $xml ) : array parse the multivalue binary response (a list of base64 encoded values)
getDcrValue ( DOMElement $node ) : mixed Get the value of a dcr:value node in the right format specified by the dcr type.
removeTrailingSlash ( string $path ) : string Remove the trailing slash if present. Used for backend responses when jackrabbit is sloppy
storeProperty ( Property $property )

Method Details

__construct() public méthode

Create a transport pointing to a server url.
public __construct ( Jackalope\FactoryInterface $factory, string $serverUri )
$factory Jackalope\FactoryInterface the object factory
$serverUri string location of the server

__destruct() public méthode

Tidies up the current cUrl connection.
public __destruct ( )

addCurlOptions() public méthode

This options will be used foreach curl-request.
public addCurlOptions ( array $options ) : array
$options array
Résultat array all curl-options

addDefaultHeader() public méthode

This is used for example for a session identifier header to help a proxy to route all requests from the same session to the same server. This is a Jackrabbit Davex specific option called from the repository factory.
public addDefaultHeader ( string $header )
$header string a valid HTTP header to add to each request

addVersionLabel() public méthode

public addVersionLabel ( $versionPath, $label, $moveLabel )

addWorkspacePathToUri() protected méthode

Prepends the workspace root to the uris that contain an absolute path
protected addWorkspacePathToUri ( string $uri ) : string
$uri string The absolute path in the current workspace or server uri
Résultat string The server uri with this path

buildLocateRequest() protected méthode

Build REPORT XML request for locating a node path by uuid
protected buildLocateRequest ( string $uuid ) : string
$uuid string Unique identifier of the node to be asked for.
Résultat string XML sring representing the content of the request.

buildNodeTypesRequest() protected méthode

Returns the XML required to request nodetypes
protected buildNodeTypesRequest ( array $nodeTypes ) : string
$nodeTypes array
Résultat string XML with the request information.

buildPropfindRequest() protected méthode

Build PROPFIND request XML for the specified property names
protected buildPropfindRequest ( array $properties ) : string
$properties array names of the properties to search for
Résultat string XML to post in the body

buildRegisterNamespaceRequest() protected méthode

You need to repeat all existing node type plus add your new ones
protected buildRegisterNamespaceRequest ( array $mappings )
$mappings array hashmap of prefix => uri for all existing and new namespaces

buildRegisterNodeTypeRequest() protected méthode

Build the xml required to register node types
Author: david at liip.ch
protected buildRegisterNodeTypeRequest ( string $cnd, $allowUpdate ) : string
$cnd string the node type definition
Résultat string XML with register request

buildReportRequest() protected méthode

Build a REPORT XML request string
protected buildReportRequest ( string $name ) : string
$name string Name of the resource to be requested.
Résultat string XML string representing the head of the request.

checkForExistingNode() protected méthode

Jackrabbit supports them, but jackalope does not.
protected checkForExistingNode ( $srcWorkspace, $srcAbsPath, $destAbsPath )
$srcWorkspace
$srcAbsPath
$destAbsPath

checkinItem() public méthode

{@inheritDoc}
public checkinItem ( $path )

checkoutItem() public méthode

{@inheritDoc}
public checkoutItem ( $path )

cloneFrom() public méthode

{@inheritDoc}
public cloneFrom ( $srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting )

copyNode() public méthode

{@inheritDoc}
public copyNode ( $srcAbsPath, $dstAbsPath, $srcWorkspace = null )

createNodeJsop() protected méthode

create the node markup and a list of value dispatches for multivalue properties
protected createNodeJsop ( string $path, array $properties ) : string
$path string path to the current node with the last path segment being the node name
$properties array of this node
Résultat string the xml for the node

createWorkspace() public méthode

{@inheritDoc}
public createWorkspace ( $name, $srcWorkspace = null )

deleteItem() protected méthode

Record that we need to delete the item at $path
protected deleteItem ( string $path )
$path string path to node or property

deleteNodeImmediately() public méthode

{@inheritDoc}
public deleteNodeImmediately ( $path )

deleteNodes() public méthode

{@inheritDoc}
public deleteNodes ( array $operations )
$operations array

deleteProperties() public méthode

{@inheritDoc}
public deleteProperties ( array $operations )
$operations array

deletePropertyImmediately() public méthode

{@inheritDoc}
public deletePropertyImmediately ( $path )

deleteWorkspace() public méthode

public deleteWorkspace ( $name )

encodeAndValidatePathForDavex() protected méthode

This is to be used in the Davex headers. The XML requests can cope with unencoded stuff
protected encodeAndValidatePathForDavex ( string $path ) : string
$path string to check
Résultat string the cleaned path

fetchEventData() public méthode

Internal method to fetch event data.
public fetchEventData ( $date ) : array
$date
Résultat array hashmap with 'data' containing unfiltered DOM of xml atom feed of events, 'nextMillis' is the next timestamp if there are more events to be found, false otherwise.

finishSave() public méthode

{@inheritDoc}
public finishSave ( )

forceHttpVersion10() public méthode

Set to true to force HTTP version 1.0
Deprecation: use addCurlOptions([CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0]) instead
public forceHttpVersion10 ( $forceHttpVersion10 = true )

generateLockFromDavResponse() protected méthode

Extract the information from a LOCK DAV response and create the corresponding Lock object.
protected generateLockFromDavResponse ( DOMElement $response, boolean $sessionOwning = false, string $path = null ) : Lock
$response DOMElement
$sessionOwning boolean whether the current session is owning the lock (aka we created it in this request)
$path string the owning node path, if we created this node
Résultat Jackalope\Lock\Lock

getAccessibleWorkspaceNames() public méthode

{@inheritDoc}

getBinaryStream() public méthode

{@inheritDoc}
public getBinaryStream ( $path )

getCurl() protected méthode

protected getCurl ( )

getEvents() public méthode

{@inheritDoc}
public getEvents ( $date, PHPCR\Observation\EventFilterInterface $filter, PHPCR\SessionInterface $session )
$filter PHPCR\Observation\EventFilterInterface
$session PHPCR\SessionInterface

getMimePart() protected méthode

protected getMimePart ( $name, $value, $mime_boundary )

getNamespaces() public méthode

{@inheritDoc}
public getNamespaces ( )

getNode() public méthode

{@inheritDoc}
public getNode ( $path )

getNodeByIdentifier() public méthode

{@inheritDoc}
public getNodeByIdentifier ( $uuid )

getNodePathForIdentifier() public méthode

{@inheritDoc}
public getNodePathForIdentifier ( $uuid, $workspace = null )

getNodeReferences() protected méthode

protected getNodeReferences ( string $path, string $name = null, boolean $weak_reference = false ) : array
$path string the path for which we need the references
$name string the name of the referencing properties or null for all
$weak_reference boolean whether to get weak or strong references
Résultat array list of paths to nodes that reference $path

getNodeTypes() public méthode

{@inheritDoc}
public getNodeTypes ( $nodeTypes = [] )

getNodes() public méthode

{@inheritDoc}
public getNodes ( $paths, $query = ':include' )

getNodesByIdentifier() public méthode

{@inheritDoc}
public getNodesByIdentifier ( $identifiers )

getPermissions() public méthode

{@inheritDoc}
public getPermissions ( $path )

getProperty() public méthode

{@inheritDoc}
public getProperty ( $path )

getReferences() public méthode

{@inheritDoc}
public getReferences ( $path, $name = null )

getRepositoryDescriptors() public méthode

{@inheritDoc}

getRequest() protected méthode

Makes sure there is an open curl connection.
protected getRequest ( $method, $uri, $addWorkspacePathToUri = true ) : Request
Résultat Request The Request

getRequiredDomElementByTagNameNS() protected méthode

If the element is not found and $errorMessage is set, then a RepositoryException is thrown. If the element is not found and $errorMessage is empty, then false is returned.
protected getRequiredDomElementByTagNameNS ( DOMNode $dom, string $namespace, string $element, string $errorMessage = '' ) : boolean | DOMNode
$dom DOMNode The DOM element which content should be searched
$namespace string The namespace of the searched element
$element string The name of the searched element
$errorMessage string The error message in case the element is not found
Résultat boolean | DOMNode

getSupportedQueryLanguages() public méthode

{@inheritDoc}

getUserData() public méthode

public getUserData ( ) : mixed
Résultat mixed null or string

getWeakReferences() public méthode

{@inheritDoc}
public getWeakReferences ( $path, $name = null )

getWorkspaceUri() public méthode

Return the URL to the workspace determined during login
public getWorkspaceUri ( ) : null | string
Résultat null | string

isLocked() public méthode

{@inheritDoc}
public isLocked ( $absPath )

isStringValid() protected méthode

If occurrence is found, returns false, otherwise true. Invalid characters were taken from this list: http://en.wikipedia.org/wiki/Valid_characters_in_XML#XML_1.0 Uses regexp mentioned here: http://stackoverflow.com/a/961504
protected isStringValid ( $string ) : boolean
$string string value
Résultat boolean true if string is OK, false otherwise.

lockNode() public méthode

{@inheritDoc}
public lockNode ( $absPath, $isDeep, $isSessionScoped, $timeoutHint = PHP_INT_MAX, $ownerInfo = null )

login() public méthode

{@inheritDoc}
public login ( PHPCR\CredentialsInterface $credentials = null, $workspaceName = null )
$credentials PHPCR\CredentialsInterface

logout() public méthode

{@inheritDoc}
public logout ( )

moveNodeImmediately() public méthode

{@inheritDoc}
public moveNodeImmediately ( $srcAbsPath, $dstAbsPath )

moveNodes() public méthode

{@inheritDoc}
public moveNodes ( array $operations )
$operations array

parseTimeout() protected méthode

The timeout value follows the syntax defined in RFC2518: Timeout Header. Here we just parse the values in the form "Second-XXXX" or "Infinite". Any other value will produce an error. The function returns the unix epoch timestamp for the second when this lock will expire in case of normal timeout, or PHP_INT_MAX in case of an "Infinite" timeout.
protected parseTimeout ( string $timeoutValue ) : integer
$timeoutValue string The timeout in seconds or PHP_INT_MAX for infinite
Résultat integer the expire timestamp to be used with Lock::setExpireTime, that is when this lock expires in seconds since 1970 or null for inifinite

prepareSave() public méthode

{@inheritDoc}
public prepareSave ( )

propertyToJsopString() protected méthode

This method is used when building a JSOP of the properties
protected propertyToJsopString ( Property $property ) : mixed | string
$property Jackalope\Property
Résultat mixed | string

query() public méthode

{@inheritDoc}
public query ( Query $query )
$query Jackalope\Query\Query

registerNamespace() public méthode

{@inheritDoc}
public registerNamespace ( $prefix, $uri )

registerNodeTypesCnd() public méthode

{@inheritDoc}
public registerNodeTypesCnd ( $cnd, $allowUpdate )

removeVersion() public méthode

{@inheritDoc}
public removeVersion ( $versionPath, $versionName )

removeVersionLabel() public méthode

public removeVersionLabel ( $versionPath, $label )

reorderChildren() public méthode

{@inheritDoc}
public reorderChildren ( Node $node )
$node Jackalope\Node

restoreItem() public méthode

{@inheritDoc}
public restoreItem ( $removeExisting, $versionPath, $path )

rollbackSave() public méthode

{@inheritDoc}
public rollbackSave ( )

sendExpect() public méthode

This is a Jackrabbit Davex specific option.
public sendExpect ( boolean $send = true )
$send boolean Whether to send the header or not

setCheckLoginOnServer() public méthode

Will improve error reporting at the cost of some round trips.
public setCheckLoginOnServer ( $bool )

setJsopBody() protected méthode

protected setJsopBody ( $value, $key = ":diff", $type = null )

setNodeTypeManager() public méthode

{@inheritDoc}
public setNodeTypeManager ( $nodeTypeManager )

setUserData() public méthode

{@inheritDoc}
public setUserData ( $userData )

storeNodes() public méthode

{@inheritDoc}
public storeNodes ( array $operations )
$operations array

stripServerRootFromUri() protected méthode

remove the server and workspace part from an uri, leaving the absolute path inside the current workspace
protected stripServerRootFromUri ( string $uri ) : string
$uri string a full uri including the server path, workspace and jcr%3aroot
Résultat string absolute path in the current work space

unlock() public méthode

{@inheritDoc}
public unlock ( $absPath, $lockToken )

unregisterNamespace() public méthode

{@inheritDoc}
public unregisterNamespace ( $prefix )

updateLastModified() protected méthode

Note that we can drop this if this jackrabbit issue ever gets implemented https://issues.apache.org/jira/browse/JCR-2233
protected updateLastModified ( Node $node )
$node Jackalope\Node

updateNode() public méthode

{@inheritDoc}
public updateNode ( Node $node, $srcWorkspace )
$node Jackalope\Node

updateProperties() public méthode

{@inheritDoc}
public updateProperties ( Node $node )
$node Jackalope\Node

Property Details

$checkLoginOnServer protected_oe property

Check if an initial PROPFIND should be send to check if repository exists This is according to the JCR specifications and set to true by default
See also: setCheckLoginOnServer
protected bool $checkLoginOnServer
Résultat boolean

$credentials protected_oe property

Set once login() has been executed and may not be changed later on.
protected SimpleCredentials,PHPCR $credentials
Résultat PHPCR\SimpleCredentials

$curl protected_oe property

The cURL resource handle
protected curl,Jackalope\Transport\Jackrabbit $curl
Résultat Jackalope\Transport\Jackrabbit\curl

$defaultHeaders protected_oe property

A list of additional HTTP headers to be sent on each request
protected array[]string $defaultHeaders
Résultat array[]string

$descriptors protected_oe property

This is our exception to the rule that nothing may be cached in transport.
protected $descriptors

$factory protected_oe property

The factory to instantiate objects
protected FactoryInterface,Jackalope $factory
Résultat Jackalope\FactoryInterface

$jsopBody protected_oe property

protected $jsopBody

$nodeTypeManager protected_oe property

protected NodeTypeManager,Jackalope\NodeType $nodeTypeManager
Résultat Jackalope\NodeType\NodeTypeManager

$sendExpect protected_oe property

Send Expect: 100-continue header
protected $sendExpect

$server protected_oe property

i.e http://localhost:8080/server/ constructor ensures the trailing slash /
protected string $server
Résultat string

$typeXmlConverter protected_oe property

protected NodeTypeXmlConverter,Jackalope\NodeType $typeXmlConverter
Résultat Jackalope\NodeType\NodeTypeXmlConverter

$userData protected_oe property

protected $userData

$valueConverter protected_oe property

protected ValueConverter,PHPCR\Util $valueConverter
Résultat PHPCR\Util\ValueConverter

$workspace protected_oe property

Set once login() has been executed and may not be changed later on.
protected string $workspace
Résultat string

$workspaceUri protected_oe property

"$server/$workspace" without trailing slash
protected string $workspaceUri
Résultat string

$workspaceUriRoot protected_oe property

"$server/$workspace/jcr%3aroot (make sure you never hardcode the jcr%3aroot, its ugly)
protected string $workspaceUriRoot
Résultat string