示例#1
0
 /**
  * Initializes the NodeTypeDefinition from the given DOM
  * @param DOMElement NodeTypeElement
  */
 public function __construct(DOMElement $node, jackalope_NodeType_NodeTypeManager $nodeTypeManager)
 {
     $this->nodeTypeManager = $nodeTypeManager;
     $this->name = $node->getAttribute('name');
     $this->isAbstract = jackalope_Helper::getBoolAttribute($node, 'isAbstract');
     $this->isMixin = jackalope_Helper::getBoolAttribute($node, 'isMixin');
     $this->isQueryable = jackalope_Helper::getBoolAttribute($node, 'isQueryable');
     $this->hasOrderableChildNodes = jackalope_Helper::getBoolAttribute($node, 'hasOrderableChildNodes');
     $this->primaryItemName = $node->getAttribute('primaryItemName');
     if (empty($this->primaryItemName)) {
         $this->primaryItemName = null;
     }
     $xp = new DOMXPath($node->ownerDocument);
     $supertypes = $xp->query('supertypes/supertype', $node);
     foreach ($supertypes as $supertype) {
         array_push($this->declaredSuperTypeNames, $supertype->nodeValue);
     }
     $properties = $xp->query('propertyDefinition', $node);
     foreach ($properties as $property) {
         array_push($this->declaredPropertyDefinitions, jackalope_Factory::get('NodeType_PropertyDefinition', array($property, $nodeTypeManager)));
     }
     $declaredNodeDefinitions = $xp->query('childNodeDefinition', $node);
     foreach ($declaredNodeDefinitions as $nodeDefinition) {
         array_push($this->declaredNodeDefinitions, jackalope_Factory::get('NodeType_NodeDefinition', array($nodeDefinition, $this->nodeTypeManager)));
     }
 }
示例#2
0
 /** creates the corresponding workspace */
 public function __construct(jackalope_Repository $repository, $workspaceName, PHPCR_SimpleCredentials $credentials, jackalope_TransportInterface $transport)
 {
     $this->repository = $repository;
     $this->objectManager = jackalope_Factory::get('ObjectManager', array($transport, $this));
     $this->workspace = jackalope_Factory::get('Workspace', array($this, $this->objectManager, $workspaceName));
     $this->credentials = $credentials;
 }
示例#3
0
 public function __construct($rawData, $path, $session, $objectManager)
 {
     parent::__construct($rawData, $path, $session, $objectManager);
     $this->isNode = true;
     //TODO: determine the index if != 1
     foreach ($rawData as $key => $value) {
         if (is_object($value)) {
             array_push($this->nodes, $key);
         } else {
             if (0 === strpos($key, ':')) {
                 continue;
             }
             //It's a property type
             switch ($key) {
                 case 'jcr:index':
                     $this->index = $value;
                     break;
                 case 'jcr:primaryType':
                     $this->primaryType = $value;
                     $this->properties[$key] = jackalope_Factory::get('Property', array(array('type' => $rawData->{':jcr:primaryType'}, 'value' => $value), $this->getPath() . '/jcr:primaryType', $this->session, $this->objectManager));
                     break;
                 case 'jcr:uuid':
                     $this->uuid = $value;
                     break;
                     //TODO: more special information?
                 //TODO: more special information?
                 default:
                     $type = isset($rawData->{':' . $key}) ? $rawData->{':' . $key} : 'undefined';
                     $this->properties[$key] = jackalope_Factory::get('Property', array(array('type' => $type, 'value' => $value), $this->getPath() . '/' . $key, $this->session, $this->objectManager));
                     break;
             }
         }
     }
 }
示例#4
0
 /**
  * Get the node identified by an absolute path.
  * Uses the factory to instantiate Node
  *
  * @param string $path The absolute path of the node to create
  * @return PHPCR_Node
  * @throws PHPCR_RepositoryException    If the path is not absolute or not well-formed
  */
 public function getNodeByPath($absPath)
 {
     $absPath = $this->normalizePath($absPath);
     $this->verifyAbsolutePath($absPath);
     if (empty($this->objectsByPath[$absPath])) {
         $node = jackalope_Factory::get('Node', array($this->transport->getItem($absPath), $absPath, $this->session, $this));
         $this->objectsByUuid[$node->getIdentifier()] = $absPath;
         $this->objectsByPath[$absPath] = $node;
     }
     return $this->objectsByPath[$absPath];
 }
示例#5
0
 /**
  * Authenticates the user using the supplied credentials. If workspaceName is recognized as the
  * name of an existing workspace in the repository and authorization to access that workspace
  * is granted, then a new Session object is returned. workspaceName is a single string token.
  *
  * null credentials are currently not supported
  *
  * If workspaceName is null, a default workspace is automatically selected by the repository
  * implementation. This may, for example, be the "home workspace" of the user whose credentials
  * were passed, though this is entirely up to the configuration and implementation of the
  * repository. Alternatively, it may be a "null workspace" that serves only to provide the
  * method Workspace.getAccessibleWorkspaceNames(), allowing the client to select from among
  * available "real" workspaces.
  *
  * Note: The Java API defines this method with multiple differing signatures.
  *
  * @param PHPCR_CredentialsInterface $credentials The credentials of the user
  * @param string $workspaceName the name of a workspace
  * @return PHPCR_SessionInterface a valid session for the user to access the repository
  * @throws PHPCR_LoginException if authentication or authorization (for the specified workspace) fails
  * @throws PHPCR_NoSuchWorkspacexception if the specified workspaceName is not recognized
  * @throws PHPCR_RepositoryException if another error occurs
  * @api
  */
 public function login($credentials = NULL, $workspaceName = NULL)
 {
     if ($workspaceName == null) {
         $workspaceName = 'default';
     }
     //TODO: can default workspace have other name?
     if (!$this->transport->login($credentials, $workspaceName)) {
         throw new PHPCR_RepositoryException('transport failed to login without telling why');
     }
     $session = jackalope_Factory::get('Session', array($this, $workspaceName, $credentials, $this->transport));
     return $session;
 }
示例#6
0
 public function __construct($data, $path, jackalope_Session $session, jackalope_ObjectManager $objectManager)
 {
     parent::__construct(null, $path, $session, $objectManager);
     $this->type = PHPCR_PropertyType::valueFromName($data['type']);
     if (is_array($data['value'])) {
         $this->isMultiple = true;
         $this->value = array();
         foreach ($data['value'] as $value) {
             array_push($this->value, jackalope_Factory::get('Value', array($data['type'], $value)));
         }
     } else {
         $this->value = jackalope_Factory::get('Value', array($data['type'], $data['value']));
     }
 }
示例#7
0
 public function __construct(DOMElement $node, jackalope_NodeType_NodeTypeManager $nodeTypeManager)
 {
     parent::__construct($node, $nodeTypeManager);
     $this->requiredType = PHPCR_PropertyType::valueFromName($node->getAttribute('requiredType'));
     $this->isMultiple = jackalope_Helper::getBoolAttribute($node, 'multiple');
     $this->isFullTextSearchable = jackalope_Helper::getBoolAttribute($node, 'fullTextSearchable');
     $this->isQueryOrderable = jackalope_Helper::getBoolAttribute($node, 'queryOrderable');
     $xp = new DOMXpath($node->ownerDocument);
     $valueConstraints = $xp->query('valueConstraints/valueConstraint', $node);
     foreach ($valueConstraints as $valueConstraint) {
         array_push($this->valueConstraints, $valueConstraint->nodeValue);
     }
     $availableQueryOperators = $xp->query('availableQueryOperators/availableQueryOperator', $node);
     foreach ($availableQueryOperators as $availableQueryOperator) {
         array_push($this->availableQueryOperators, $availableQueryOperator->nodeValue);
     }
     $defaultValues = $xp->query('defaultValues/defaultValue', $node);
     foreach ($defaultValues as $defaultValue) {
         array_push($this->defaultValues, jackalope_Factory::get('Value', array(PHPCR_PropertyType::valueFromType($defaultValue->nodeValue), $defaultValue->nodeValue)));
     }
 }
示例#8
0
 /**
  * Returns the NamespaceRegistry object, which is used to access the mapping
  * between prefixes and namespaces.
  *
  * @return PHPCR_NamespaceRegistryInterface the NamespaceRegistry.
  * @throws PHPCR_RepositoryException if an error occurs.
  * @api
  */
 public function getNamespaceRegistry()
 {
     if ($this->namespaceRegistry == false) {
         $this->namespaceRegistry = jackalope_Factory::get('NamespaceRegistry', array($this->session->getTransport()));
     }
     return $this->namespaceRegistry;
 }
示例#9
0
 /**
  * Get the repository descriptors from the jackrabbit server
  * This happens without login or accessing a specific workspace.
  *
  * @return Array with name => Value for the descriptors
  * @throws PHPCR_RepositoryException if error occurs
  */
 public function getRepositoryDescriptors()
 {
     $dom = $this->getDomFromBackend(self::REPORT, $this->server, self::buildReportRequest('dcr:repositorydescriptors'));
     if ($dom->firstChild->localName != 'repositorydescriptors-report' || $dom->firstChild->namespaceURI != self::NS_DCR) {
         throw new PHPCR_RepositoryException('Error talking to the backend. ' . $dom->saveXML());
     }
     $descs = $dom->getElementsByTagNameNS(self::NS_DCR, 'descriptor');
     $descriptors = array();
     foreach ($descs as $desc) {
         $values = array();
         foreach ($desc->getElementsByTagNameNS(self::NS_DCR, 'descriptorvalue') as $value) {
             $type = $value->getAttribute('type');
             if ($type == '') {
                 $type = PHPCR_PropertyType::TYPENAME_UNDEFINED;
             }
             $values[] = jackalope_Factory::get('Value', array($type, $value->textContent));
         }
         if ($desc->childNodes->length == 2) {
             $descriptors[$desc->firstChild->textContent] = $values[0];
         } else {
             $descriptors[$desc->firstChild->textContent] = $values;
         }
     }
     return $descriptors;
 }
示例#10
0
 /**
  * Returns an iterator over all available mixin node types. If none are available,
  * an empty iterator is returned.
  *
  * @return PHPCR_NodeType_NodeTypeIteratorInterface An NodeTypeIterator.
  * @throws PHPCR_RepositoryException if an error occurs.
  */
 public function getMixinNodeTypes()
 {
     return jackalope_Factory::get('NodeType_NodeTypeIterator', array(array_values($this->mixinTypes)));
 }
示例#11
0
 /**
  * Returns the direct subtypes of this node type in the node type inheritance
  * hierarchy, that is, those which actually declared this node type in their
  * list of supertypes.
  *
  * @see getSubtypes()
  *
  * @return PHPCR_NodeType_NodeTypeIteratorInterface a NodeTypeIterator.
  */
 public function getDeclaredSubtypes()
 {
     $ret = array();
     foreach ($this->nodeTypeManager->getDeclaredSubtypes($this->name) as $subtype) {
         array_push($ret, $this->nodeTypeManager->getNodeType($subtype));
     }
     return jackalope_Factory::get('NodeType_NodeTypeIterator', array($ret));
 }