Skip to content
Snippets Groups Projects
Commit 441e5e3f authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 10.2 to OpenOLAT default branch with 46b887fed9efedce12aaa4a4c23ab7b4fa5ddd36

parents bebcfeed cb6b4eed
No related branches found
No related tags found
No related merge requests found
......@@ -47,11 +47,11 @@ import org.olat.core.util.vfs.VFSManager;
*/
public class CustomCSS extends LogDelegator implements Disposable {
private String relCssFilename;
private String relCssFileIframe;
private Mapper cssUriMapper;
private MapperKey cssUriMapperKey;
private JSAndCSSComponent jsAndCssComp;
private final String relCssFilename;
private final String relCssFileIframe;
private final Mapper cssUriMapper;
private final MapperKey cssUriMapperKey;
private final JSAndCSSComponent jsAndCssComp;
private Object DISPOSE_LOCK = new Object();
/**
......@@ -67,9 +67,10 @@ public class CustomCSS extends LogDelegator implements Disposable {
*/
public CustomCSS(final VFSContainer cssBaseContainer,
final String relCssFilename, UserSession uSess) {
createCSSUriMapper(cssBaseContainer);
cssUriMapper = createCSSUriMapper(cssBaseContainer);
this.relCssFilename = relCssFilename;
registerMapper(cssBaseContainer, uSess);
this.relCssFileIframe = null;
cssUriMapperKey = registerMapper(cssBaseContainer, uSess);
// initialize js and css component
jsAndCssComp = new JSAndCSSComponent("jsAndCssComp", this.getClass(), false);
String fulluri = cssUriMapperKey.getUrl() + relCssFilename;
......@@ -79,10 +80,10 @@ public class CustomCSS extends LogDelegator implements Disposable {
public CustomCSS(final VFSContainer cssBaseContainer,
final String relCssFileMain, final String relCssFileIFrame, UserSession uSess ) {
createCSSUriMapper(cssBaseContainer);
cssUriMapper = createCSSUriMapper(cssBaseContainer);
this.relCssFilename = relCssFileMain;
this.relCssFileIframe = relCssFileIFrame;
registerMapper(cssBaseContainer, uSess);
cssUriMapperKey = registerMapper(cssBaseContainer, uSess);
// initialize js and css component
jsAndCssComp = new JSAndCSSComponent("jsAndCssComp", this.getClass(), false);
......@@ -96,25 +97,27 @@ public class CustomCSS extends LogDelegator implements Disposable {
* @param cssBaseContainer
* @param uSess
*/
private void registerMapper(final VFSContainer cssBaseContainer, UserSession uSess) {
private MapperKey registerMapper(final VFSContainer cssBaseContainer, UserSession uSess) {
// Register mapper as cacheable
String mapperID = VFSManager.getRealPath(cssBaseContainer);
MapperKey mapperKey;
if (mapperID == null) {
// Can't cache mapper, no cacheable context available
cssUriMapperKey = CoreSpringFactory.getImpl(MapperService.class).register(uSess, cssUriMapper);
mapperKey = CoreSpringFactory.getImpl(MapperService.class).register(uSess, cssUriMapper);
} else {
// Add classname to the file path to remove conflicts with other
// usages of the same file path
mapperID = this.getClass().getSimpleName() + ":" + mapperID + System.currentTimeMillis();
cssUriMapperKey = CoreSpringFactory.getImpl(MapperService.class).register(uSess, mapperID, cssUriMapper);
mapperKey = CoreSpringFactory.getImpl(MapperService.class).register(uSess, mapperID, cssUriMapper);
}
return mapperKey;
}
/**
* @param cssBaseContainer
*/
private void createCSSUriMapper(final VFSContainer cssBaseContainer) {
cssUriMapper = new VFSContainerMapper(cssBaseContainer);
private Mapper createCSSUriMapper(final VFSContainer cssBaseContainer) {
return new VFSContainerMapper(cssBaseContainer);
}
/**
......@@ -149,13 +152,11 @@ public class CustomCSS extends LogDelegator implements Disposable {
/**
* @see org.olat.core.gui.control.Disposable#dispose()
*/
@Override
public void dispose() {
synchronized (DISPOSE_LOCK) {
if (cssUriMapper != null) {
CoreSpringFactory.getImpl(MapperService.class).cleanUp(Collections.singletonList(cssUriMapperKey));
cssUriMapper = null;
cssUriMapperKey = null;
jsAndCssComp = null;
if (cssUriMapperKey != null) {
CoreSpringFactory.getImpl(MapperService.class).cleanUp(Collections.singletonList(cssUriMapperKey));
}
}
}
......
......@@ -288,7 +288,7 @@ public class EPPolicyManager {
private EPStructureElementToGroupRelation applyPolicyToGroup(Group group, EPMapPolicy policy, PortfolioStructureMap map) {
Collection<EPStructureElementToGroupRelation> currentRelations = map.getGroups();
for(EPStructureElementToGroupRelation currentRelation:currentRelations) {
if(currentRelation.getGroup().equals(group)) {
if(currentRelation.getGroup() != null && currentRelation.getGroup().equals(group)) {
updatePolicy(currentRelation, policy.getFrom(), policy.getTo());
return currentRelation;
}
......
......@@ -131,7 +131,8 @@ public class InvitationDAO {
public Invitation findInvitation(Group group) {
StringBuilder sb = new StringBuilder();
sb.append("select invitation from binvitation as invitation ")
.append(" where invitation.baseGroup=:group");
.append(" inner join fetch invitation.baseGroup bGroup")
.append(" where bGroup=:group");
List<Invitation> invitations = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Invitation.class)
......@@ -149,6 +150,7 @@ public class InvitationDAO {
public Invitation findInvitation(String token) {
StringBuilder sb = new StringBuilder();
sb.append("select invitation from binvitation as invitation ")
.append(" inner join fetch invitation.baseGroup bGroup")
.append(" where invitation.token=:token");
List<Invitation> invitations = dbInstance.getCurrentEntityManager()
......
......@@ -280,7 +280,7 @@ public class EPMultipleMapController extends BasicController implements Activate
EPTargetResource resource = structMap.getTargetResource();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(resource.getOLATResourceable(), false);
if(repoEntry != null) {
vC.contextPut("courseName" + i, repoEntry.getDisplayname());
vC.contextPut("courseName" + i, StringHelper.escapeHtml(repoEntry.getDisplayname()));
String url = Settings.getServerContextPathURI();
url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
vC.contextPut("courseLink" + i, url);
......
......@@ -26,6 +26,7 @@ import java.util.UUID;
import org.junit.Assert;
import org.junit.Test;
import org.olat.basesecurity.Group;
import org.olat.basesecurity.Invitation;
import org.olat.core.commons.persistence.DB;
import org.olat.core.id.Identity;
......@@ -64,6 +65,21 @@ public class InvitationDAOTest extends OlatTestCase {
Assert.assertNotNull(invitation.getToken());
}
@Test
public void findInvitation_group() {
Invitation invitation = invitationDao.createAndPersistInvitation();
Group baseGroup = invitation.getBaseGroup();
Assert.assertNotNull(invitation);
dbInstance.commitAndCloseSession();
Invitation reloadedInvitation = invitationDao.findInvitation(baseGroup);
Assert.assertNotNull(reloadedInvitation);
Assert.assertNotNull(reloadedInvitation.getKey());
Assert.assertEquals(baseGroup, reloadedInvitation.getBaseGroup());
Assert.assertEquals(invitation, reloadedInvitation);
Assert.assertEquals(invitation.getToken(), reloadedInvitation.getToken());
}
@Test
public void findInvitation_token() {
Invitation invitation = invitationDao.createAndPersistInvitation();
......@@ -78,6 +94,7 @@ public class InvitationDAOTest extends OlatTestCase {
Assert.assertEquals(invitation.getToken(), reloadedInvitation.getToken());
}
@Test
public void hasInvitationPolicies_testHQL() {
String token = UUID.randomUUID().toString();
......
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