Skip to content

Instantly share code, notes, and snippets.

@chregu
Created December 21, 2010 15:44
Show Gist options
  • Save chregu/750083 to your computer and use it in GitHub Desktop.
Save chregu/750083 to your computer and use it in GitHub Desktop.
diff --git a/src/Jackalope/Transport/Davex/Client.php b/src/Jackalope/Transport/Davex/Client.php
index ce77994..045b45f 100644
--- a/src/Jackalope/Transport/Davex/Client.php
+++ b/src/Jackalope/Transport/Davex/Client.php
@@ -143,7 +143,6 @@ class Client implements TransportInterface
}
$uri = $this->normalizeUri($uri);
-
$request = new Request($this->curl, $method, $uri);
$request->setCredentials($this->credentials);
@@ -272,6 +271,37 @@ class Client implements TransportInterface
$request = $this->getRequest(Request::GET, $path);
return $request->executeJson();
}
+
+ public function checkinItem($path)
+ {
+ try {
+ $request = $this->getRequest(Request::CHECKIN, $path);
+ return $request->execute();
+ } catch (\Jackalope\Transport\Davex\HTTPErrorException $e) {
+ if ($e->getCode() == 405) {
+ throw new \PHPCR\UnsupportedRepositoryOperationException();
+ } else {
+ throw new \PHPCR\RepositoryException();
+ }
+ }
+ }
+
+ public function checkoutItem($path)
+ {
+ $this->ensureAbsolutePath($path);
+ try {
+ $request = $this->getRequest(Request::CHECKOUT, $path);
+ $request->execute();
+ } catch (\Jackalope\Transport\Davex\HTTPErrorException $e) {
+ if ($e->getCode() == 405) {
+ throw new \PHPCR\UnsupportedRepositoryOperationException();
+ } else {
+ throw new \PHPCR\RepositoryException();
+ }
+ }
+ return;
+ }
+
/**
* checks if the path is absolute, throws an exception if it is not
diff --git a/src/Jackalope/Transport/Davex/Request.php b/src/Jackalope/Transport/Davex/Request.php
index 4a6ddec..8ddb15d 100644
--- a/src/Jackalope/Transport/Davex/Request.php
+++ b/src/Jackalope/Transport/Davex/Request.php
@@ -89,7 +89,18 @@ class Request
*/
const MOVE = 'MOVE';
-
+ /**
+ * Identifier of the 'CHECKIN' http request method.
+ * @var string
+ */
+ const CHECKIN = 'CHECKIN';
+
+ /**
+ * Identifier of the 'CHECKOUT' http request method.
+ * @var string
+ */
+ const CHECKOUT = 'CHECKOUT';
+
/** @var string Possible argument for {@link setDepth()} */
const INFINITY = 'infinity';
@@ -280,11 +291,15 @@ class Request
if (404 === $httpCode) {
throw new \PHPCR\PathNotFoundException("HTTP 404 Path Not Found: {$this->method} {$this->uri}");
+ } elseif (405 == $httpCode) {
+ throw new \Jackalope\Transport\Davex\HTTPErrorException("HTTP 405 Method Not Allowed: {$this->method} {$this->uri}", 405);
} elseif ($httpCode >= 500) {
throw new \PHPCR\RepositoryException("HTTP $httpCode Error from backend on: {$this->method} {$this->uri} \n\n$response");
}
$curlError = $this->curl->error();
+
+
$msg = "Unexpected error: \nCURL Error: $curlError \nResponse (HTTP $httpCode): {$this->method} {$this->uri} \n\n$response";
throw new \PHPCR\RepositoryException($msg);
}
diff --git a/src/Jackalope/Workspace.php b/src/Jackalope/Workspace.php
index c1907ff..4ea757c 100644
--- a/src/Jackalope/Workspace.php
+++ b/src/Jackalope/Workspace.php
@@ -278,7 +278,7 @@ class Workspace implements \PHPCR\WorkspaceInterface
*/
public function getVersionManager()
{
- throw new \PHPCR\UnsupportedRepositoryOperationException();
+ return Factory::get('Version\VersionManager', array($this->session->getObjectManager()));
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment