minor fixes
This commit is contained in:
parent
18a85b4333
commit
71fb39749b
11 changed files with 66 additions and 25 deletions
|
@ -68,7 +68,7 @@ public class ClientHttpRequestFactoryService {
|
|||
final Environment environment,
|
||||
final ClientCredentialService clientCredentialService,
|
||||
@Value("${sebserver.http.client.connect-timeout:15000}") final int connectTimeout,
|
||||
@Value("${sebserver.http.client.connection-request-timeout:10000}") final int connectionRequestTimeout,
|
||||
@Value("${sebserver.http.client.connection-request-timeout:20000}") final int connectionRequestTimeout,
|
||||
@Value("${sebserver.http.client.read-timeout:10000}") final int readTimeout) {
|
||||
|
||||
this.environment = environment;
|
||||
|
|
|
@ -199,7 +199,7 @@ public class APIMessage implements Serializable {
|
|||
|
||||
public static String toHTML(final String errorMessage, final List<APIMessage> messages) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("<b>Failure: </b>").append(errorMessage).append("<br/><br/>");
|
||||
builder.append("<b>Failure: </b>").append("<br/><br/>").append(errorMessage).append("<br/><br/>");
|
||||
builder.append("<b>Detail Messages:</b><br/><br/>");
|
||||
messages.stream()
|
||||
.forEach(message -> {
|
||||
|
|
|
@ -144,6 +144,14 @@ public final class Result<T> {
|
|||
return this.value;
|
||||
}
|
||||
|
||||
public T getOrThrow(final Function<Exception, RuntimeException> errorWrapper) {
|
||||
if (this.error != null) {
|
||||
throw errorWrapper.apply(this.error);
|
||||
}
|
||||
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/** Use this to get the resulting value or (if null) to get a given other value
|
||||
*
|
||||
* @param supplier supplier to get the value from if the computed value is null
|
||||
|
|
|
@ -173,15 +173,6 @@ public class SebExamConfigPropForm implements TemplateComposer {
|
|||
.putStaticValue(
|
||||
Domain.CONFIGURATION_NODE.ATTR_TYPE,
|
||||
ConfigurationType.EXAM_CONFIG.name())
|
||||
.addField(FormBuilder.text(
|
||||
Domain.CONFIGURATION_NODE.ATTR_NAME,
|
||||
FORM_NAME_TEXT_KEY,
|
||||
examConfig.name))
|
||||
.addField(FormBuilder.text(
|
||||
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
|
||||
FORM_DESCRIPTION_TEXT_KEY,
|
||||
examConfig.description)
|
||||
.asArea())
|
||||
.addFieldIf(
|
||||
() -> !examConfigTemplateResources.isEmpty(),
|
||||
() -> FormBuilder.singleSelection(
|
||||
|
@ -192,11 +183,23 @@ public class SebExamConfigPropForm implements TemplateComposer {
|
|||
: String.valueOf(examConfig.templateId),
|
||||
resourceService::getExamConfigTemplateResources)
|
||||
.readonly(!isNew))
|
||||
.addField(FormBuilder.text(
|
||||
Domain.CONFIGURATION_NODE.ATTR_NAME,
|
||||
FORM_NAME_TEXT_KEY,
|
||||
examConfig.name))
|
||||
.addField(FormBuilder.text(
|
||||
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
|
||||
FORM_DESCRIPTION_TEXT_KEY,
|
||||
examConfig.description)
|
||||
.asArea()
|
||||
.withInputSpan(3))
|
||||
|
||||
.addField(FormBuilder.singleSelection(
|
||||
Domain.CONFIGURATION_NODE.ATTR_STATUS,
|
||||
FORM_STATUS_TEXT_KEY,
|
||||
examConfig.status.name(),
|
||||
() -> resourceService.examConfigStatusResources(isAttachedToExam)))
|
||||
() -> resourceService.examConfigStatusResources(isAttachedToExam))
|
||||
.withEmptyCellSeparation(false))
|
||||
.buildFor((isNew)
|
||||
? this.restService.getRestCall(NewExamConfig.class)
|
||||
: this.restService.getRestCall(SaveExamConfig.class));
|
||||
|
|
|
@ -120,7 +120,7 @@ public class FormHandle<T extends Entity> {
|
|||
return resultAction;
|
||||
})
|
||||
.onError(this::handleError)
|
||||
.getOrThrow();
|
||||
.getOrThrow(error -> new FormPostException(error));
|
||||
}
|
||||
|
||||
public boolean handleError(final Exception error) {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.form;
|
||||
|
||||
public class FormPostException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 5693899812633519455L;
|
||||
|
||||
public FormPostException(final Exception cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
|||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.form.FormPostException;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys;
|
||||
|
@ -172,6 +173,12 @@ public final class PageAction {
|
|||
restCallError);
|
||||
}
|
||||
return Result.ofError(restCallError);
|
||||
} catch (final FormPostException e) {
|
||||
log.error("Failed to execute action: {} | error: {} | cause: {}",
|
||||
PageAction.this.getName(),
|
||||
e.getMessage(),
|
||||
Utils.getErrorCauseMessage(e));
|
||||
return Result.ofError(e);
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to execute action: {} | error: {} | cause: {}",
|
||||
PageAction.this.getName(),
|
||||
|
|
|
@ -300,7 +300,7 @@ public class PageContextImpl implements PageContext {
|
|||
final MessageBox messageBox = new Message(
|
||||
getShell(),
|
||||
this.i18nSupport.getText("sebserver.error.unexpected"),
|
||||
Utils.formatHTMLLines(errorMessage),
|
||||
Utils.formatHTMLLines(errorMessage + "<br/><br/> Cause: " + error.getMessage()),
|
||||
SWT.ERROR);
|
||||
messageBox.open(null);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import org.eclipse.swt.layout.GridLayout;
|
|||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
||||
|
||||
public final class Message extends MessageBox {
|
||||
|
||||
private static final int NORMAL_WIDTH = 400;
|
||||
|
@ -28,6 +30,7 @@ public final class Message extends MessageBox {
|
|||
super(parent, type);
|
||||
super.setText(title);
|
||||
super.setMessage(message);
|
||||
super.setMarkupEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +42,8 @@ public final class Message extends MessageBox {
|
|||
layout.marginRight = 10;
|
||||
layout.verticalSpacing = 10;
|
||||
layout.horizontalSpacing = 10;
|
||||
super.shell.setData(RWT.CUSTOM_VARIANT, "message");
|
||||
super.shell.setData(RWT.CUSTOM_VARIANT, CustomVariant.MESSAGE.key);
|
||||
|
||||
final Rectangle bounds = super.shell.getBounds();
|
||||
if (bounds.width < NORMAL_WIDTH) {
|
||||
bounds.x = bounds.x - (NORMAL_WIDTH - bounds.width) / 2;
|
||||
|
|
|
@ -15,9 +15,9 @@ spring.datasource.hikari.connectionTimeout=30000
|
|||
spring.datasource.hikari.idleTimeout=600000
|
||||
spring.datasource.hikari.maxLifetime=1800000
|
||||
|
||||
sebserver.http.client.connect-timeout=1500
|
||||
sebserver.http.client.connect-timeout=15000
|
||||
sebserver.http.client.connection-request-timeout=10000
|
||||
sebserver.http.client.read-timeout=1000
|
||||
sebserver.http.client.read-timeout=10000
|
||||
|
||||
# webservice configuration
|
||||
sebserver.webservice.distributed=false
|
||||
|
|
|
@ -81,14 +81,14 @@ sebserver.dialog.confirm.title=Confirmation
|
|||
sebserver.dialog.confirm.deactivation=Note that there are {0} other entities that belongs to this entity.<br/>Those will also be deactivated by deactivating this entity.<br/><br/>Are You sure to deactivate this entity?
|
||||
sebserver.dialog.confirm.deactivation.noDependencies=Are You sure you want to deactivate?
|
||||
|
||||
sebserver.error.action.unexpected.message=<br/><br/>Failed to process action. There was an unexpected error.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.get.entity=<br/><br/>Failed to load {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.remove.entity=<br/><br/>Failed to remove {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.activate.entity=<br/><br/>Failed to activate/deactivate {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.save.entity=<br/><br/>Failed to save {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.action.unexpected.message=Failed to process action. There was an unexpected error.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.get.entity=Failed to load {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.remove.entity=Failed to remove {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.activate.entity=Failed to activate/deactivate {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.save.entity=Failed to save {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.exam.seb.restriction=<br/><br/>Failed to automatically set Safe Exam Browser restriction on/off for this exam on the corresponding LMS.<br/> Please check the LMS Setup and try again or contact a system-administrator if this error persists
|
||||
sebserver.error.import=<br/><br/>Failed to import {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.logout=<br/><br/>Failed to logout properly.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.import=Failed to import {0}.<br/> Please try again or contact a system-administrator if this error persists
|
||||
sebserver.error.logout=Failed to logout properly.<br/> Please try again or contact a system-administrator if this error persists
|
||||
################################
|
||||
# Login Page
|
||||
################################
|
||||
|
@ -481,7 +481,7 @@ sebserver.examconfig.form.title=Exam Configuration
|
|||
sebserver.examconfig.form.name=Name
|
||||
sebserver.examconfig.form.description=Description
|
||||
sebserver.examconfig.form.with-history=With History
|
||||
sebserver.examconfig.form.template=From Template
|
||||
sebserver.examconfig.form.template=Template
|
||||
sebserver.examconfig.form.status=Status
|
||||
sebserver.examconfig.form.config-key.title=Config Key
|
||||
sebserver.examconfig.form.attched-to=Attached To Exam
|
||||
|
|
Loading…
Reference in a new issue