|
|
@ -10,6 +10,7 @@ use Drupal\flysystem\Plugin\FlysystemPluginInterface; |
|
|
|
use Drupal\flysystem\Plugin\FlysystemUrlTrait; |
|
|
|
use Drupal\flysystem\Plugin\FlysystemUrlTrait; |
|
|
|
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter; |
|
|
|
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter; |
|
|
|
use Drupal\jwt\Authentication\Provider\JwtAuth; |
|
|
|
use Drupal\jwt\Authentication\Provider\JwtAuth; |
|
|
|
|
|
|
|
use GuzzleHttp\Exception\ConnectException; |
|
|
|
use GuzzleHttp\HandlerStack; |
|
|
|
use GuzzleHttp\HandlerStack; |
|
|
|
use GuzzleHttp\Client; |
|
|
|
use GuzzleHttp\Client; |
|
|
|
use Islandora\Chullo\IFedoraApi; |
|
|
|
use Islandora\Chullo\IFedoraApi; |
|
|
@ -123,20 +124,28 @@ class Fedora implements FlysystemPluginInterface, ContainerFactoryPluginInterfac |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function ensure($force = FALSE) { |
|
|
|
public function ensure($force = FALSE) { |
|
|
|
// Check fedora root for sanity. |
|
|
|
// Check fedora root for sanity. |
|
|
|
|
|
|
|
try { |
|
|
|
$response = $this->fedora->getResourceHeaders(''); |
|
|
|
$response = $this->fedora->getResourceHeaders(''); |
|
|
|
|
|
|
|
$statusCode = $response->getStatusCode(); |
|
|
|
if ($response->getStatusCode() != 200) { |
|
|
|
$message = '%url returned %status'; |
|
|
|
return [[ |
|
|
|
} |
|
|
|
|
|
|
|
catch (ConnectException $e) { |
|
|
|
|
|
|
|
// Fedora is unavailable. |
|
|
|
|
|
|
|
$message = '%url is unavailable, cannot connect.'; |
|
|
|
|
|
|
|
$statusCode = 500; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ($statusCode != 200) { |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
[ |
|
|
|
'severity' => RfcLogLevel::ERROR, |
|
|
|
'severity' => RfcLogLevel::ERROR, |
|
|
|
'message' => '%url returned %status', |
|
|
|
'message' => $message, |
|
|
|
'context' => [ |
|
|
|
'context' => [ |
|
|
|
'%url' => $this->fedora->getBaseUri(), |
|
|
|
'%url' => $this->fedora->getBaseUri(), |
|
|
|
'%status' => $response->getStatusCode(), |
|
|
|
'%status' => $statusCode, |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return []; |
|
|
|
return []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|