diff --git a/src/main/java/org/olat/core/gui/components/htmlheader/jscss/CustomCSS.java b/src/main/java/org/olat/core/gui/components/htmlheader/jscss/CustomCSS.java index 5c68e31af728ea5580319b2da85df21dfcb5da78..e83061ed68c155cc4c10badab3704e5255c41015 100644 --- a/src/main/java/org/olat/core/gui/components/htmlheader/jscss/CustomCSS.java +++ b/src/main/java/org/olat/core/gui/components/htmlheader/jscss/CustomCSS.java @@ -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)); } } } diff --git a/src/main/java/org/olat/portfolio/manager/EPPolicyManager.java b/src/main/java/org/olat/portfolio/manager/EPPolicyManager.java index e8fb11890577407c73ee6630545702edd59ddaee..61d160033d3df55ae53d835dc7805a7ec45fa09a 100644 --- a/src/main/java/org/olat/portfolio/manager/EPPolicyManager.java +++ b/src/main/java/org/olat/portfolio/manager/EPPolicyManager.java @@ -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; } diff --git a/src/main/java/org/olat/portfolio/manager/InvitationDAO.java b/src/main/java/org/olat/portfolio/manager/InvitationDAO.java index e802be56af7ba69f48b539bd4cd7e5bf49365d13..6e9e1fb8259909982774cd0e4aa38ada0f47cff4 100644 --- a/src/main/java/org/olat/portfolio/manager/InvitationDAO.java +++ b/src/main/java/org/olat/portfolio/manager/InvitationDAO.java @@ -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() diff --git a/src/main/java/org/olat/portfolio/ui/structel/EPMultipleMapController.java b/src/main/java/org/olat/portfolio/ui/structel/EPMultipleMapController.java index 7b70ec0bbb71ace8e6a9eab66ea3806a1016d871..86a999c3418b3e363de42c203316ea8309d944b2 100644 --- a/src/main/java/org/olat/portfolio/ui/structel/EPMultipleMapController.java +++ b/src/main/java/org/olat/portfolio/ui/structel/EPMultipleMapController.java @@ -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); diff --git a/src/test/java/org/olat/portfolio/manager/InvitationDAOTest.java b/src/test/java/org/olat/portfolio/manager/InvitationDAOTest.java index c53a6a404d8811b269a5d6f66a3adb3d76fc8492..0d693a13885f99c44c7eed108d22055cc7bcf577 100644 --- a/src/test/java/org/olat/portfolio/manager/InvitationDAOTest.java +++ b/src/test/java/org/olat/portfolio/manager/InvitationDAOTest.java @@ -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();