Skip to content
Snippets Groups Projects
Commit 508841c8 authored by srosse's avatar srosse
Browse files

OO-4212: reload the configuration every time

parent 1b697791
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ public class UserSession implements HttpSessionBindingListener, GenericEventList
* things to put into that should not be clear when signing on (e.g. remember url for a direct jump)
*/
private transient Map<String,Object> nonClearedStore = new HashMap<>();
private String lockStores = new String();
private String lockStores = "";
private boolean authenticated = false;
private boolean savedSession = false;
private transient Preferences guiPreferences;
......@@ -258,7 +258,7 @@ public class UserSession implements HttpSessionBindingListener, GenericEventList
*/
public void setIdentity(Identity identity) {
identityEnvironment.setIdentity(identity);
//fxdiff FXOLAT-231: event on GUI Preferences extern changes
//event on GUI Preferences external changes
if(identity.getKey() != null) {
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Preferences.class, identity.getKey());
CoordinatorManager.getInstance().getCoordinator().getEventBus().deregisterFor(this, ores);
......
......@@ -69,7 +69,7 @@ public class ExportOptionsController extends FormBasicController {
@Override
protected void doDispose() {
//
}
@Override
......@@ -106,12 +106,12 @@ public class ExportOptionsController extends FormBasicController {
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
allOk &= downloadOptionsEl.isAtLeastSelected(1);
if(!allOk) {
downloadOptionsEl.setErrorKey("nodechoose.config.error", null);
boolean allOk = super.validateFormLogic(ureq);
if(!downloadOptionsEl.isAtLeastSelected(1)) {
downloadOptionsEl.setErrorKey("nodechoose.config.error", null);
allOk &= false;
}
return allOk &= super.validateFormLogic(ureq);
return allOk;
}
......
......@@ -19,15 +19,15 @@
*/
package org.olat.course.archiver;
import org.olat.core.gui.UserRequest;
import org.apache.logging.log4j.Logger;
import org.olat.core.gui.UserRequest;
import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
import org.olat.core.util.prefs.Preferences;
import org.olat.core.util.xml.XStreamHelper;
import org.olat.course.nodes.ArchiveOptions;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.security.ExplicitTypePermission;
/**
* this class reads and writes XML serialized config data to personal gui prefs and retrieves them
......@@ -40,8 +40,11 @@ public class FormatConfigHelper {
private static final String QTI_EXPORT_ITEM_FORMAT_CONFIG = "QTIExportItemFormatConfig";
private static final Logger log = Tracing.createLoggerFor(FormatConfigHelper.class);
private static XStream configXstream = XStreamHelper.createXStreamInstance();
private static final XStream configXstream = XStreamHelper.createXStreamInstance();
static {
XStream.setupDefaultSecurity(configXstream);
Class<?>[] types = new Class[] { ExportFormat.class };
configXstream.addPermission(new ExplicitTypePermission(types));
configXstream.alias(QTI_EXPORT_ITEM_FORMAT_CONFIG, ExportFormat.class);
}
......@@ -77,11 +80,4 @@ public class FormatConfigHelper {
}
}
}
public static ArchiveOptions getArchiveOptions(UserRequest ureq) {
ArchiveOptions options = new ArchiveOptions();
ExportFormat formatConfig = loadExportFormat(ureq);
options.setExportFormat(formatConfig);
return options;
}
}
......@@ -79,7 +79,7 @@ public class GenericArchiveController extends FormBasicController {
private ChooseGroupController chooseGroupCtrl;
private ExportOptionsController exportOptionsCtrl;
private ArchiveOptions options;
private final ArchiveOptions options;
private final boolean withOptions;
private final OLATResourceable ores;
private final CourseNode[] nodeTypes;
......@@ -175,9 +175,6 @@ public class GenericArchiveController extends FormBasicController {
archiveNode(ureq, courseNodes, group);
}
} else if (source == exportOptionsCtrl) {
if (event == Event.DONE_EVENT) {
setOptions(FormatConfigHelper.getArchiveOptions(ureq));
}
cmc.deactivate();
cleanUpPopups();
} else if (source == cmc) {
......@@ -304,6 +301,8 @@ public class GenericArchiveController extends FormBasicController {
private void archiveNode(UserRequest ureq, List<CourseNode> nodes, BusinessGroup group) {
options.setGroup(group);
options.setExportFormat(FormatConfigHelper.loadExportFormat(ureq));
ArchiveResource aResource = new ArchiveResource(nodes, ores, options, getLocale());
ureq.getDispatchResult().setResultingMediaResource(aResource);
}
......@@ -316,8 +315,4 @@ public class GenericArchiveController extends FormBasicController {
cmc.activate();
listenTo(cmc);
}
public void setOptions(ArchiveOptions options) {
this.options = options;
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.archiver;
import java.util.Locale;
import org.junit.Assert;
import org.junit.Test;
import org.olat.core.commons.persistence.DB;
import org.olat.core.gui.util.SyntheticUserRequest;
import org.olat.core.id.Identity;
import org.olat.core.id.Roles;
import org.olat.core.util.UserSession;
import org.olat.test.JunitTestHelper;
import org.olat.test.OlatTestCase;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
*
* Initial date: 2 sept. 2019<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class FormatConfigHelperTest extends OlatTestCase {
@Autowired
private DB dbInstance;
@Test
public void readWritePreferences() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("archive-1");
UserSession usess = new UserSession();
SyntheticUserRequest ureq = new SyntheticUserRequest(id, Locale.ENGLISH, usess);
usess.setIdentity(id);
usess.setRoles(Roles.userRoles());
usess.reloadPreferences();
FormatConfigHelper.updateExportFormat(ureq, true, true, false, false, true);
dbInstance.commitAndCloseSession();
// mimic an other session
UserSession readUsess = new UserSession();
SyntheticUserRequest readUreq = new SyntheticUserRequest(id, Locale.ENGLISH, readUsess);
readUsess.setIdentity(id);
readUsess.setRoles(Roles.userRoles());
readUsess.reloadPreferences();
ExportFormat exportFormat = FormatConfigHelper.loadExportFormat(readUreq);
Assert.assertTrue(exportFormat.isResponseCols());
Assert.assertTrue(exportFormat.isPositionsOfResponsesCol());
Assert.assertFalse(exportFormat.isPointCol());
Assert.assertFalse(exportFormat.isTimeCols());
Assert.assertTrue(exportFormat.isCommentCol());
}
}
......@@ -168,6 +168,7 @@ import org.junit.runners.Suite;
org.olat.instantMessaging.InstantMessagePreferencesDAOTest.class,
org.olat.instantMessaging.RosterDAOTest.class,
org.olat.instantMessaging.InstantMessageServiceTest.class,
org.olat.course.archiver.FormatConfigHelperTest.class,
org.olat.course.condition.ConditionTest.class,
org.olat.course.condition.KeyAndNameConverterTest.class,
org.olat.course.highscore.HighScoreManagerTest.class,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment