Add initial cache support
This commit is contained in:
parent
85f3079b47
commit
2d2edffa80
@ -48,7 +48,8 @@ class Application extends App {
|
|||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
$c->query('CoreConfig'),
|
$c->query('CoreConfig'),
|
||||||
$c->query('L10N'),
|
$c->query('L10N'),
|
||||||
$c->query('UserId')
|
$c->query('UserId'),
|
||||||
|
$c->query('ICacheFactory')
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
$container->registerService('SettingsController', function($c) {
|
$container->registerService('SettingsController', function($c) {
|
||||||
@ -84,5 +85,8 @@ class Application extends App {
|
|||||||
$uid = is_null($user) ? '' : $user->getUID();
|
$uid = is_null($user) ? '' : $user->getUID();
|
||||||
return $uid;
|
return $uid;
|
||||||
});
|
});
|
||||||
|
$container->registerService('ICacheFactory', function($c) {
|
||||||
|
return $c->query('ServerContainer')->getMemCacheFactory();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,23 +25,26 @@ use \OCA\Richdocuments\Storage;
|
|||||||
use \OCA\Richdocuments\Download;
|
use \OCA\Richdocuments\Download;
|
||||||
use \OCA\Richdocuments\DownloadResponse;
|
use \OCA\Richdocuments\DownloadResponse;
|
||||||
use \OCA\Richdocuments\File;
|
use \OCA\Richdocuments\File;
|
||||||
use OCA\Richdocuments\Genesis;
|
use \OCA\Richdocuments\Genesis;
|
||||||
use \OC\Files\View;
|
use \OC\Files\View;
|
||||||
|
use \OCP\ICacheFactory;
|
||||||
|
|
||||||
class DocumentController extends Controller{
|
class DocumentController extends Controller{
|
||||||
|
|
||||||
private $uid;
|
private $uid;
|
||||||
private $l10n;
|
private $l10n;
|
||||||
private $settings;
|
private $settings;
|
||||||
|
private $cache;
|
||||||
|
|
||||||
const ODT_TEMPLATE_PATH = '/assets/odttemplate.odt';
|
const ODT_TEMPLATE_PATH = '/assets/odttemplate.odt';
|
||||||
const CLOUDSUITE_TMP_PATH = '/documents-tmp/';
|
const CLOUDSUITE_TMP_PATH = '/documents-tmp/';
|
||||||
|
|
||||||
public function __construct($appName, IRequest $request, IConfig $settings, IL10N $l10n, $uid){
|
public function __construct($appName, IRequest $request, IConfig $settings, IL10N $l10n, $uid, ICacheFactory $cache){
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->uid = $uid;
|
$this->uid = $uid;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
|
$this->cache = $cache->create($appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,14 +65,18 @@ class DocumentController extends Controller{
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
+ $policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $this->settings->getAppValue('richdocuments', 'wopi_url'));
|
$policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $this->settings->getAppValue('richdocuments', 'wopi_url'));
|
||||||
+ $policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $this->settings->getAppValue('richdocuments', 'wopi_url'));
|
$policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $this->settings->getAppValue('richdocuments', 'wopi_url'));
|
||||||
$policy->addAllowedConnectDomain('ws://' . $_SERVER['SERVER_NAME'] . ':9980');
|
$policy->addAllowedConnectDomain('ws://' . $_SERVER['SERVER_NAME'] . ':9980');
|
||||||
$policy->addAllowedImageDomain('*');
|
$policy->addAllowedImageDomain('*');
|
||||||
$policy->allowInlineScript(true);
|
$policy->allowInlineScript(true);
|
||||||
$policy->addAllowedFontDomain('data:');
|
$policy->addAllowedFontDomain('data:');
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
|
|
||||||
|
if(is_null($this->cache->get('discovery.xml'))) {
|
||||||
|
// TODO GET http://domain/hosting/discovery
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class DocumentControllerTest extends \PHPUnit_Framework_TestCase {
|
|||||||
private $request;
|
private $request;
|
||||||
private $l10n;
|
private $l10n;
|
||||||
private $settings;
|
private $settings;
|
||||||
|
private $cache;
|
||||||
private $uid = 'jack_the_documents_tester';
|
private $uid = 'jack_the_documents_tester';
|
||||||
private $password = 'password';
|
private $password = 'password';
|
||||||
private $controller;
|
private $controller;
|
||||||
@ -33,12 +34,17 @@ class DocumentControllerTest extends \PHPUnit_Framework_TestCase {
|
|||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
|
$this->cache = $this->getMockBuilder('\OCP\ICacheFactory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock()
|
||||||
|
;
|
||||||
$this->controller = new DocumentController(
|
$this->controller = new DocumentController(
|
||||||
$this->appName,
|
$this->appName,
|
||||||
$this->request,
|
$this->request,
|
||||||
$this->settings,
|
$this->settings,
|
||||||
$this->l10n,
|
$this->l10n,
|
||||||
$this->uid
|
$this->uid,
|
||||||
|
$this->cache
|
||||||
);
|
);
|
||||||
|
|
||||||
$userManager = \OC::$server->getUserManager();
|
$userManager = \OC::$server->getUserManager();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user