fixed import settings and tests
This commit is contained in:
parent
273d9fd923
commit
8c29d7e8f2
5 changed files with 57 additions and 24 deletions
|
@ -68,9 +68,19 @@ public class SEBExamConfigImportPopup {
|
||||||
this.pageService = pageService;
|
this.pageService = pageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Function<PageAction, PageAction> importFunction(final boolean newConfig) {
|
public Function<PageAction, PageAction> importFunction() {
|
||||||
|
return importFunction(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Function<PageAction, PageAction> importFunction(final Supplier<String> tabSelectionSupplier) {
|
||||||
return action -> {
|
return action -> {
|
||||||
|
|
||||||
|
final boolean newConfig = tabSelectionSupplier == null || tabSelectionSupplier.get() == null;
|
||||||
|
final PageContext context = (tabSelectionSupplier != null)
|
||||||
|
? action.pageContext()
|
||||||
|
.withAttribute(SEBSettingsForm.ATTR_VIEW_INDEX, tabSelectionSupplier.get())
|
||||||
|
: action.pageContext();
|
||||||
|
|
||||||
final ModalInputDialog<FormHandle<ConfigurationNode>> dialog =
|
final ModalInputDialog<FormHandle<ConfigurationNode>> dialog =
|
||||||
new ModalInputDialog<FormHandle<ConfigurationNode>>(
|
new ModalInputDialog<FormHandle<ConfigurationNode>>(
|
||||||
action.pageContext().getParent().getShell(),
|
action.pageContext().getParent().getShell(),
|
||||||
|
@ -79,7 +89,7 @@ public class SEBExamConfigImportPopup {
|
||||||
|
|
||||||
final ImportFormContext importFormContext = new ImportFormContext(
|
final ImportFormContext importFormContext = new ImportFormContext(
|
||||||
this.pageService,
|
this.pageService,
|
||||||
action.pageContext(),
|
context,
|
||||||
newConfig);
|
newConfig);
|
||||||
|
|
||||||
dialog.open(
|
dialog.open(
|
||||||
|
@ -147,18 +157,6 @@ public class SEBExamConfigImportPopup {
|
||||||
|
|
||||||
if (!configuration.hasError()) {
|
if (!configuration.hasError()) {
|
||||||
context.publishInfo(SEBExamConfigForm.FORM_IMPORT_CONFIRM_TEXT_KEY);
|
context.publishInfo(SEBExamConfigForm.FORM_IMPORT_CONFIRM_TEXT_KEY);
|
||||||
final PageAction action = (newConfig)
|
|
||||||
? this.pageService.pageActionBuilder(context)
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG)
|
|
||||||
.create()
|
|
||||||
: this.pageService.pageActionBuilder(context)
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_MODIFY)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
this.pageService.firePageEvent(
|
|
||||||
new ActionEvent(action),
|
|
||||||
action.pageContext());
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final Exception error = configuration.getError();
|
final Exception error = configuration.getError();
|
||||||
if (error instanceof RestCallError) {
|
if (error instanceof RestCallError) {
|
||||||
|
@ -177,14 +175,15 @@ public class SEBExamConfigImportPopup {
|
||||||
.notifyImportError(EntityType.CONFIGURATION_NODE, error);
|
.notifyImportError(EntityType.CONFIGURATION_NODE, error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
|
} else {
|
||||||
|
formHandle.getContext().notifyError(
|
||||||
|
SEBExamConfigForm.FORM_TITLE,
|
||||||
|
configuration.getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
formHandle.getContext().notifyError(
|
|
||||||
SEBExamConfigForm.FORM_TITLE,
|
|
||||||
configuration.getError());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
reloadPage(newConfig, context);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
formHandle.getContext().publishPageMessage(
|
formHandle.getContext().publishPageMessage(
|
||||||
|
@ -194,11 +193,26 @@ public class SEBExamConfigImportPopup {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
reloadPage(newConfig, formHandle.getContext());
|
||||||
formHandle.getContext().notifyError(SEBExamConfigForm.FORM_TITLE, e);
|
formHandle.getContext().notifyError(SEBExamConfigForm.FORM_TITLE, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reloadPage(final boolean newConfig, final PageContext context) {
|
||||||
|
final PageAction action = (newConfig)
|
||||||
|
? this.pageService.pageActionBuilder(context)
|
||||||
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG)
|
||||||
|
.create()
|
||||||
|
: this.pageService.pageActionBuilder(context)
|
||||||
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_MODIFY)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
this.pageService.firePageEvent(
|
||||||
|
new ActionEvent(action),
|
||||||
|
action.pageContext());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkInput(final FormHandle<ConfigurationNode> formHandle, final boolean newConfig,
|
private boolean checkInput(final FormHandle<ConfigurationNode> formHandle, final boolean newConfig,
|
||||||
final Form form) {
|
final Form form) {
|
||||||
if (newConfig) {
|
if (newConfig) {
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class SEBExamConfigList implements TemplateComposer {
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG)
|
||||||
.withSelect(
|
.withSelect(
|
||||||
configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
|
configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
|
||||||
this.sebExamConfigImportPopup.importFunction(true),
|
this.sebExamConfigImportPopup.importFunction(),
|
||||||
EMPTY_SELECTION_TEXT_KEY)
|
EMPTY_SELECTION_TEXT_KEY)
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(examConfigGrant::im);
|
.publishIf(examConfigGrant::im);
|
||||||
|
|
|
@ -69,6 +69,8 @@ public class SEBSettingsForm implements TemplateComposer {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SEBSettingsForm.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBSettingsForm.class);
|
||||||
|
|
||||||
|
public static final String ATTR_VIEW_INDEX = "VIEW_INDEX";
|
||||||
|
|
||||||
private static final String VIEW_TEXT_KEY_PREFIX =
|
private static final String VIEW_TEXT_KEY_PREFIX =
|
||||||
"sebserver.examconfig.props.form.views.";
|
"sebserver.examconfig.props.form.views.";
|
||||||
private static final String KEY_SAVE_TO_HISTORY_SUCCESS =
|
private static final String KEY_SAVE_TO_HISTORY_SUCCESS =
|
||||||
|
@ -194,7 +196,7 @@ public class SEBSettingsForm implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set selection if available
|
// set selection if available
|
||||||
final String viewIndex = pageContext.getAttribute("VIEW_INDEX");
|
final String viewIndex = pageContext.getAttribute(ATTR_VIEW_INDEX);
|
||||||
if (StringUtils.isNotBlank(viewIndex)) {
|
if (StringUtils.isNotBlank(viewIndex)) {
|
||||||
try {
|
try {
|
||||||
tabFolder.setSelection(Integer.parseInt(viewIndex));
|
tabFolder.setSelection(Integer.parseInt(viewIndex));
|
||||||
|
@ -217,7 +219,7 @@ public class SEBSettingsForm implements TemplateComposer {
|
||||||
.call()
|
.call()
|
||||||
.onError(t -> notifyErrorOnSave(t, pageContext));
|
.onError(t -> notifyErrorOnSave(t, pageContext));
|
||||||
return action.withAttribute(
|
return action.withAttribute(
|
||||||
"VIEW_INDEX",
|
ATTR_VIEW_INDEX,
|
||||||
String.valueOf(tabFolder.getSelectionIndex()));
|
String.valueOf(tabFolder.getSelectionIndex()));
|
||||||
})
|
})
|
||||||
.withSuccess(KEY_SAVE_TO_HISTORY_SUCCESS)
|
.withSuccess(KEY_SAVE_TO_HISTORY_SUCCESS)
|
||||||
|
@ -232,7 +234,7 @@ public class SEBSettingsForm implements TemplateComposer {
|
||||||
.call()
|
.call()
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
return action.withAttribute(
|
return action.withAttribute(
|
||||||
"VIEW_INDEX",
|
ATTR_VIEW_INDEX,
|
||||||
String.valueOf(tabFolder.getSelectionIndex()));
|
String.valueOf(tabFolder.getSelectionIndex()));
|
||||||
})
|
})
|
||||||
.withSuccess(KEY_UNDO_SUCCESS)
|
.withSuccess(KEY_UNDO_SUCCESS)
|
||||||
|
@ -254,7 +256,9 @@ public class SEBSettingsForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_EXISTING_CONFIG)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_EXISTING_CONFIG)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(this.sebExamConfigImportPopup.importFunction(false))
|
.withExec(this.sebExamConfigImportPopup.importFunction(
|
||||||
|
() -> String.valueOf(tabFolder.getSelectionIndex())))
|
||||||
|
.noEventPropagation()
|
||||||
.publishIf(() -> examConfigGrant.iw() && !readonly && !isAttachedToExam)
|
.publishIf(() -> examConfigGrant.iw() && !readonly && !isAttachedToExam)
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_VIEW_PROP)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_VIEW_PROP)
|
||||||
|
|
|
@ -36,6 +36,8 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.OAuth2AuthorizationContextHolder;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.OAuth2AuthorizationContextHolder;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.SEBServerAuthorizationContext;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.SEBServerAuthorizationContext;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.WebserviceURIService;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.WebserviceURIService;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.WebserviceInfoDAO;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(
|
@SpringBootTest(
|
||||||
|
@ -59,13 +61,19 @@ public abstract class GuiIntegrationTest {
|
||||||
protected JSONMapper jsonMapper;
|
protected JSONMapper jsonMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected FilterChainProxy springSecurityFilterChain;
|
protected FilterChainProxy springSecurityFilterChain;
|
||||||
|
@Autowired
|
||||||
|
private WebserviceInfoDAO webserviceInfoDAO;
|
||||||
|
@Autowired
|
||||||
|
private WebserviceInfo webserviceInfo;
|
||||||
|
|
||||||
protected MockMvc mockMvc;
|
protected MockMvc mockMvc;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
this.webserviceInfoDAO.unregister(this.webserviceInfo.getWebserviceUUID());
|
||||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
|
||||||
.addFilter(this.springSecurityFilterChain).build();
|
.addFilter(this.springSecurityFilterChain).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected OAuth2AuthorizationContextHolder getAuthorizationContextHolder() {
|
protected OAuth2AuthorizationContextHolder getAuthorizationContextHolder() {
|
||||||
|
|
|
@ -53,6 +53,8 @@ import ch.ethz.seb.sebserver.SEBServer;
|
||||||
import ch.ethz.seb.sebserver.WebSecurityConfig;
|
import ch.ethz.seb.sebserver.WebSecurityConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.WebserviceInfoDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
||||||
import ch.ethz.seb.sebserver.webservice.weblayer.oauth.AdminAPIClientDetails;
|
import ch.ethz.seb.sebserver.webservice.weblayer.oauth.AdminAPIClientDetails;
|
||||||
import ch.ethz.seb.sebserver.webservice.weblayer.oauth.WebClientDetailsService;
|
import ch.ethz.seb.sebserver.webservice.weblayer.oauth.WebClientDetailsService;
|
||||||
|
@ -77,6 +79,10 @@ public abstract class ExamAPIIntegrationTester {
|
||||||
protected JSONMapper jsonMapper;
|
protected JSONMapper jsonMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected FilterChainProxy springSecurityFilterChain;
|
protected FilterChainProxy springSecurityFilterChain;
|
||||||
|
@Autowired
|
||||||
|
private WebserviceInfoDAO webserviceInfoDAO;
|
||||||
|
@Autowired
|
||||||
|
private WebserviceInfo webserviceInfo;
|
||||||
|
|
||||||
protected MockMvc mockMvc;
|
protected MockMvc mockMvc;
|
||||||
|
|
||||||
|
@ -88,6 +94,7 @@ public abstract class ExamAPIIntegrationTester {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
this.webserviceInfoDAO.unregister(this.webserviceInfo.getWebserviceUUID());
|
||||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
|
||||||
.addFilter(this.springSecurityFilterChain).build();
|
.addFilter(this.springSecurityFilterChain).build();
|
||||||
Mockito.when(this.webClientDetailsService.loadClientByClientId(Mockito.anyString())).thenReturn(
|
Mockito.when(this.webClientDetailsService.loadClientByClientId(Mockito.anyString())).thenReturn(
|
||||||
|
|
Loading…
Add table
Reference in a new issue