Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-12-07 11:13:21 +0300
committerLukas Reschke <lukas@statuscode.ch>2016-12-07 11:13:21 +0300
commit5dd6344629d7287ee52da5cb0fa5decccbd99d4f (patch)
tree20e54bfa1df4c6fc7ce4261cafd8bd71542956fd
parentaa89c908a70dddabb39ea7d0a166e147e31d3f5d (diff)
Delete cached discovery file if settings are changed
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
-rw-r--r--lib/Controller/SettingsController.php30
-rw-r--r--lib/WOPI/DiscoveryManager.php6
2 files changed, 15 insertions, 21 deletions
diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php
index 60d5edc2..b8122658 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -11,45 +11,38 @@
namespace OCA\Richdocuments\Controller;
+use OCA\Richdocuments\WOPI\DiscoveryManager;
use \OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\Files\IAppData;
use \OCP\IRequest;
use \OCP\IL10N;
-
use OCA\Richdocuments\AppConfig;
-use OCA\Richdocuments\Filter;
class SettingsController extends Controller{
/** @var IL10N */
private $l10n;
/** @var AppConfig */
private $appConfig;
+ /** @var DiscoveryManager */
+ private $discoveryManager;
/**
* @param string $appName
* @param IRequest $request
* @param IL10N $l10n
* @param AppConfig $appConfig
- * @param string $userId
+ * @param DiscoveryManager $discoveryManager
*/
public function __construct($appName,
IRequest $request,
IL10N $l10n,
AppConfig $appConfig,
- $userId) {
+ DiscoveryManager $discoveryManager) {
parent::__construct($appName, $request);
$this->l10n = $l10n;
$this->appConfig = $appConfig;
- }
-
- /**
- * @NoAdminRequired
- */
- public function getSupportedMimes(){
- return array(
- 'status' => 'success',
- 'mimes' => Filter::getAll()
- );
+ $this->discoveryManager = $discoveryManager;
}
/**
@@ -65,7 +58,7 @@ class SettingsController extends Controller{
$this->appConfig->setAppValue('wopi_url', $wopi_url);
$colon = strpos($wopi_url, ':', 0);
- if (\OC::$server->getRequest()->getServerProtocol() !== substr($wopi_url, 0, $colon)){
+ if ($this->request->getServerProtocol() !== substr($wopi_url, 0, $colon)){
$message = $this->l10n->t('Saved with error: Collabora Online should use the same protocol as the server installation.');
}
}
@@ -74,13 +67,12 @@ class SettingsController extends Controller{
$this->appConfig->setAppValue('doc_format', $doc_format);
}
- $richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
- $richMemCache->clear('discovery.xml');
+ $this->discoveryManager->refretch();
- $response = array(
+ $response = [
'status' => 'success',
'data' => array('message' => (string) $message)
- );
+ ];
return new JSONResponse($response);
}
diff --git a/lib/WOPI/DiscoveryManager.php b/lib/WOPI/DiscoveryManager.php
index b3d18fed..c3997fe7 100644
--- a/lib/WOPI/DiscoveryManager.php
+++ b/lib/WOPI/DiscoveryManager.php
@@ -61,7 +61,6 @@ class DiscoveryManager {
$this->appData = $appData->newFolder('richdocuments');
}
$this->config = $config;
- $this->l10n = $l10n;
$this->timeFactory = $timeFactory;
}
@@ -74,7 +73,6 @@ class DiscoveryManager {
return $decodedFile['data'];
}
} catch (NotFoundException $e) {
- $file = $this->appData->newFile('discovery.xml');
}
$remoteHost = $this->config->getAppValue('richdocuments', 'wopi_url');
@@ -96,4 +94,8 @@ class DiscoveryManager {
);
return $responseBody;
}
+
+ public function refretch() {
+ $this->appData->getFile('discovery.xml')->delete();
+ }
}