More improvements in the error handling.
This commit is contained in:
parent
b48ae81a99
commit
ea47464459
@ -120,6 +120,8 @@ class DocumentController extends Controller {
|
||||
throw new ResponseException($this->l10n->t('Collabora Online: Malformed URL "%s".', array($wopiRemote)), $admin_check);
|
||||
case '6':
|
||||
throw new ResponseException($this->l10n->t('Collabora Online: Cannot resolve the host "%s".', array($wopiRemote)), $admin_check);
|
||||
case '7':
|
||||
throw new ResponseException($this->l10n->t('Collabora Online: Cannot connect to the host "%s".', array($wopiRemote)), $admin_check);
|
||||
case '60':
|
||||
throw new ResponseException($this->l10n->t('Collabora Online: SSL certificate is not installed.'), $this->l10n->t('Please ask your administrator to add CollaboraCloudSuiteCA_ca-chain.cert.pem to the ownCloud\'s ca-bundle.crt, for example "cat /etc/loolwsd/CollaboraCloudSuiteCA_ca-chain.cert.pem >> owncloud/resources/config/ca-bundle.crt" . The exact error message was: ') . $error_message);
|
||||
}
|
||||
@ -144,7 +146,7 @@ class DocumentController extends Controller {
|
||||
*/
|
||||
public function index(){
|
||||
$wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url');
|
||||
if (($parts = parse_url($wopiRemote))) {
|
||||
if (($parts = parse_url($wopiRemote)) && isset($parts['scheme']) && isset($parts['host'])) {
|
||||
$webSocketProtocol = "ws://";
|
||||
if ($parts['scheme'] == "https") {
|
||||
$webSocketProtocol = "wss://";
|
||||
@ -152,7 +154,7 @@ class DocumentController extends Controller {
|
||||
$webSocket = sprintf(
|
||||
"%s%s%s",
|
||||
$webSocketProtocol,
|
||||
isset($parts['host']) ? $parts['host'] : "",
|
||||
$parts['host'],
|
||||
isset($parts['port']) ? ":" . $parts['port'] : "");
|
||||
}
|
||||
else {
|
||||
@ -411,12 +413,21 @@ class DocumentController extends Controller {
|
||||
|
||||
if ($discovery_parsed === false) {
|
||||
$this->cache->remove('discovery.xml');
|
||||
$wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url');
|
||||
|
||||
return responseError($this->l10n->t('Collabora Online: discovery.xml from "%s" is not a well-formed XML string.', array($wopiRemote)), $this->l10n->t('Please contact the "%s" administrator.', array($wopiRemote)));
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'message' => $this->l10n->t('Collabora Online: discovery.xml from "%s" is not a well-formed XML string.', array($wopiRemote)),
|
||||
'hint' => $this->l10n->t('Please contact the "%s" administrator.', array($wopiRemote))
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (ResponseException $e) {
|
||||
return $this->responseError($e->getMessage(), $e->getHint());
|
||||
return array(
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage(),
|
||||
'hint' => $e->getHint()
|
||||
);
|
||||
}
|
||||
|
||||
$fileIds = array();
|
||||
|
@ -5,7 +5,9 @@ $.widget('oc.documentGrid', {
|
||||
context : '.documentslist',
|
||||
documents : {},
|
||||
sessions : {},
|
||||
members : {}
|
||||
members : {},
|
||||
errorMessage : '',
|
||||
errorHint : ''
|
||||
},
|
||||
|
||||
_create : function (){
|
||||
@ -80,10 +82,25 @@ $.widget('oc.documentGrid', {
|
||||
var that = this;
|
||||
var def = new $.Deferred();
|
||||
$.getJSON(OC.generateUrl('apps/richdocuments/ajax/documents/list'))
|
||||
.done(function (data) {
|
||||
that.options.documents = data.documents;
|
||||
that.options.sessions = data.sessions;
|
||||
that.options.members = data.members;
|
||||
.done(function (result) {
|
||||
if (!result || result.status === 'error') {
|
||||
documentsMain.loadError = true;
|
||||
if (result && result.message) {
|
||||
that.options.errorMessage = result.message;
|
||||
}
|
||||
else {
|
||||
that.options.errorMessage = t('richdocuments', 'Failed to load the document, please contact your administrator.');
|
||||
}
|
||||
|
||||
if (result && result.hint) {
|
||||
that.options.errorHint = result.hint;
|
||||
}
|
||||
}
|
||||
else {
|
||||
that.options.documents = result.documents;
|
||||
that.options.sessions = result.sessions;
|
||||
that.options.members = result.members;
|
||||
}
|
||||
def.resolve();
|
||||
})
|
||||
.fail(function(data){
|
||||
@ -102,6 +119,15 @@ $.widget('oc.documentGrid', {
|
||||
|
||||
$(this.options.context + ' .document:not(.template,.progress)').remove();
|
||||
|
||||
if (documentsMain.loadError) {
|
||||
$(this.options.context).after('<div id="errormessage">'
|
||||
+ '<p>' + this.options.errorMessage + '</p><p>'
|
||||
+ this.options.errorHint
|
||||
+ '</p></div>'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$.each(documents, function(i, document){
|
||||
hasDocuments = true;
|
||||
that.add(document);
|
||||
@ -155,6 +181,7 @@ var documentsMain = {
|
||||
fileName: null,
|
||||
baseName: null,
|
||||
canShare : false,
|
||||
loadError : false,
|
||||
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
|
||||
|
||||
UI : {
|
||||
@ -181,7 +208,7 @@ var documentsMain = {
|
||||
$('title').text(title + ' - ' + documentsMain.UI.mainTitle);
|
||||
|
||||
$.get(OC.generateUrl('apps/richdocuments/wopi/token/{fileId}', { fileId: documentsMain.fileId }),
|
||||
function (result) {
|
||||
function (result) {
|
||||
if (!result || result.status === 'error') {
|
||||
if (result && result.message){
|
||||
documentsMain.IU.notify(result.message);
|
||||
@ -310,7 +337,7 @@ var documentsMain = {
|
||||
|
||||
documentsMain.show();
|
||||
|
||||
if (fileId){
|
||||
if (fileId && !documentMain.loadError) {
|
||||
documentsMain.overlay.documentOverlay('show');
|
||||
documentsMain.prepareSession();
|
||||
documentsMain.joinSession(fileId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user