Move requesthandler controller to LoggerInterface
* LoggerInterface * executeUpdate * log exception when there is one (just so we ahve the trace) Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
2f70397b03
commit
f421fd25ba
|
@ -38,11 +38,11 @@ use OCP\Federation\ICloudFederationFactory;
|
||||||
use OCP\Federation\ICloudFederationProviderManager;
|
use OCP\Federation\ICloudFederationProviderManager;
|
||||||
use OCP\Federation\ICloudIdManager;
|
use OCP\Federation\ICloudIdManager;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\Share\Exceptions\ShareNotFound;
|
use OCP\Share\Exceptions\ShareNotFound;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RequestHandlerController
|
* Class RequestHandlerController
|
||||||
|
@ -53,7 +53,7 @@ use OCP\Share\Exceptions\ShareNotFound;
|
||||||
*/
|
*/
|
||||||
class RequestHandlerController extends Controller {
|
class RequestHandlerController extends Controller {
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/** @var IUserManager */
|
/** @var IUserManager */
|
||||||
|
@ -79,7 +79,7 @@ class RequestHandlerController extends Controller {
|
||||||
|
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
IURLGenerator $urlGenerator,
|
IURLGenerator $urlGenerator,
|
||||||
|
|
|
@ -42,11 +42,11 @@ use OCP\Federation\ICloudFederationFactory;
|
||||||
use OCP\Federation\ICloudFederationProviderManager;
|
use OCP\Federation\ICloudFederationProviderManager;
|
||||||
use OCP\Federation\ICloudIdManager;
|
use OCP\Federation\ICloudIdManager;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\Share;
|
use OCP\Share;
|
||||||
use OCP\Share\Exceptions\ShareNotFound;
|
use OCP\Share\Exceptions\ShareNotFound;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class RequestHandlerController extends OCSController {
|
class RequestHandlerController extends OCSController {
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class RequestHandlerController extends OCSController {
|
||||||
/** @var ICloudIdManager */
|
/** @var ICloudIdManager */
|
||||||
private $cloudIdManager;
|
private $cloudIdManager;
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/** @var ICloudFederationFactory */
|
/** @var ICloudFederationFactory */
|
||||||
|
@ -83,23 +83,7 @@ class RequestHandlerController extends OCSController {
|
||||||
/** @var ICloudFederationProviderManager */
|
/** @var ICloudFederationProviderManager */
|
||||||
private $cloudFederationProviderManager;
|
private $cloudFederationProviderManager;
|
||||||
|
|
||||||
/**
|
public function __construct(string $appName,
|
||||||
* Server2Server constructor.
|
|
||||||
*
|
|
||||||
* @param string $appName
|
|
||||||
* @param IRequest $request
|
|
||||||
* @param FederatedShareProvider $federatedShareProvider
|
|
||||||
* @param IDBConnection $connection
|
|
||||||
* @param Share\IManager $shareManager
|
|
||||||
* @param Notifications $notifications
|
|
||||||
* @param AddressHandler $addressHandler
|
|
||||||
* @param IUserManager $userManager
|
|
||||||
* @param ICloudIdManager $cloudIdManager
|
|
||||||
* @param ILogger $logger
|
|
||||||
* @param ICloudFederationFactory $cloudFederationFactory
|
|
||||||
* @param ICloudFederationProviderManager $cloudFederationProviderManager
|
|
||||||
*/
|
|
||||||
public function __construct($appName,
|
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
FederatedShareProvider $federatedShareProvider,
|
FederatedShareProvider $federatedShareProvider,
|
||||||
IDBConnection $connection,
|
IDBConnection $connection,
|
||||||
|
@ -108,7 +92,7 @@ class RequestHandlerController extends OCSController {
|
||||||
AddressHandler $addressHandler,
|
AddressHandler $addressHandler,
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
ICloudIdManager $cloudIdManager,
|
ICloudIdManager $cloudIdManager,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
ICloudFederationFactory $cloudFederationFactory,
|
ICloudFederationFactory $cloudFederationFactory,
|
||||||
ICloudFederationProviderManager $cloudFederationProviderManager
|
ICloudFederationProviderManager $cloudFederationProviderManager
|
||||||
) {
|
) {
|
||||||
|
@ -227,9 +211,9 @@ class RequestHandlerController extends OCSController {
|
||||||
} catch (ProviderDoesNotExistsException $e) {
|
} catch (ProviderDoesNotExistsException $e) {
|
||||||
throw new OCSException('Server does not support federated cloud sharing', 503);
|
throw new OCSException('Server does not support federated cloud sharing', 503);
|
||||||
} catch (ShareNotFound $e) {
|
} catch (ShareNotFound $e) {
|
||||||
$this->logger->debug('Share not found: ' . $e->getMessage());
|
$this->logger->debug('Share not found: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new OCSBadRequestException();
|
throw new OCSBadRequestException();
|
||||||
|
@ -262,9 +246,9 @@ class RequestHandlerController extends OCSController {
|
||||||
} catch (ProviderDoesNotExistsException $e) {
|
} catch (ProviderDoesNotExistsException $e) {
|
||||||
throw new OCSException('Server does not support federated cloud sharing', 503);
|
throw new OCSException('Server does not support federated cloud sharing', 503);
|
||||||
} catch (ShareNotFound $e) {
|
} catch (ShareNotFound $e) {
|
||||||
$this->logger->debug('Share not found: ' . $e->getMessage());
|
$this->logger->debug('Share not found: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Http\DataResponse();
|
return new Http\DataResponse();
|
||||||
|
@ -294,9 +278,9 @@ class RequestHandlerController extends OCSController {
|
||||||
} catch (ProviderDoesNotExistsException $e) {
|
} catch (ProviderDoesNotExistsException $e) {
|
||||||
throw new OCSException('Server does not support federated cloud sharing', 503);
|
throw new OCSException('Server does not support federated cloud sharing', 503);
|
||||||
} catch (ShareNotFound $e) {
|
} catch (ShareNotFound $e) {
|
||||||
$this->logger->debug('Share not found: ' . $e->getMessage());
|
$this->logger->debug('Share not found: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Http\DataResponse();
|
return new Http\DataResponse();
|
||||||
|
@ -324,7 +308,7 @@ class RequestHandlerController extends OCSController {
|
||||||
$notification = ['sharedSecret' => $token];
|
$notification = ['sharedSecret' => $token];
|
||||||
$provider->notificationReceived('SHARE_UNSHARED', $id, $notification);
|
$provider->notificationReceived('SHARE_UNSHARED', $id, $notification);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->debug('processing unshare notification failed: ' . $e->getMessage());
|
$this->logger->debug('processing unshare notification failed: ' . $e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Http\DataResponse();
|
return new Http\DataResponse();
|
||||||
|
@ -398,7 +382,7 @@ class RequestHandlerController extends OCSController {
|
||||||
$notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions];
|
$notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions];
|
||||||
$provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification);
|
$provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->debug($e->getMessage());
|
$this->logger->debug($e->getMessage(), ['exception' => $e]);
|
||||||
throw new OCSBadRequestException();
|
throw new OCSBadRequestException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +442,7 @@ class RequestHandlerController extends OCSController {
|
||||||
->set('remote_id', $qb->createNamedParameter($newRemoteId))
|
->set('remote_id', $qb->createNamedParameter($newRemoteId))
|
||||||
->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id)))
|
->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id)))
|
||||||
->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token)));
|
->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token)));
|
||||||
$affected = $query->execute();
|
$affected = $query->executeUpdate();
|
||||||
|
|
||||||
if ($affected > 0) {
|
if ($affected > 0) {
|
||||||
return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]);
|
return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]);
|
||||||
|
|
|
@ -36,11 +36,11 @@ use OCP\Federation\ICloudFederationProviderManager;
|
||||||
use OCP\Federation\ICloudFederationShare;
|
use OCP\Federation\ICloudFederationShare;
|
||||||
use OCP\Federation\ICloudIdManager;
|
use OCP\Federation\ICloudIdManager;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\Share;
|
use OCP\Share;
|
||||||
use OCP\Share\IShare;
|
use OCP\Share\IShare;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RequestHandlerTest
|
* Class RequestHandlerTest
|
||||||
|
@ -77,7 +77,7 @@ class RequestHandlerControllerTest extends \Test\TestCase {
|
||||||
/** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
private $cloudIdManager;
|
private $cloudIdManager;
|
||||||
|
|
||||||
/** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
|
@ -127,7 +127,7 @@ class RequestHandlerControllerTest extends \Test\TestCase {
|
||||||
$this->cloudFederationShare = $this->createMock(ICloudFederationShare::class);
|
$this->cloudFederationShare = $this->createMock(ICloudFederationShare::class);
|
||||||
|
|
||||||
|
|
||||||
$this->logger = $this->createMock(ILogger::class);
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$this->requestHandler = new RequestHandlerController(
|
$this->requestHandler = new RequestHandlerController(
|
||||||
'federatedfilesharing',
|
'federatedfilesharing',
|
||||||
|
|
Loading…
Reference in New Issue