diff --git a/src/main/java/org/olat/collaboration/CollaborationManagerImpl.java b/src/main/java/org/olat/collaboration/CollaborationManagerImpl.java index 57a3b92575bc69e0e550d474884ff156fa4b825a..17c3dc84e0033e05d330bf49d3fdc91c3b014dd6 100644 --- a/src/main/java/org/olat/collaboration/CollaborationManagerImpl.java +++ b/src/main/java/org/olat/collaboration/CollaborationManagerImpl.java @@ -57,12 +57,13 @@ public class CollaborationManagerImpl extends BasicManager implements Collaborat private CalendarManager calendarManager; @Autowired private BusinessGroupService businessGroupService; - + + @Override public String getFolderRelPath(OLATResourceable ores) { return "/cts/folders/" + ores.getResourceableTypeName() + "/" + ores.getResourceableId(); } - //fxdiff VCRP-8: collaboration tools folder access control + @Override public Long lookupFolderAccess(OLATResourceable ores) { StringBuilder query = new StringBuilder(); query.append("select prop.longValue from ").append(Property.class.getName()).append(" as prop where ") diff --git a/src/main/java/org/olat/collaboration/CollaborationTools.java b/src/main/java/org/olat/collaboration/CollaborationTools.java index 8d9decbf069cc405d8e404bb9b1a4cde26d5fb6a..49598542c6fdc7d978c97f405fc2b5501a0317e6 100644 --- a/src/main/java/org/olat/collaboration/CollaborationTools.java +++ b/src/main/java/org/olat/collaboration/CollaborationTools.java @@ -864,18 +864,18 @@ public class CollaborationTools implements Serializable { */ public void archive(String archivFilePath) { if (isToolEnabled(CollaborationTools.TOOL_FORUM)) { - archiveForum(this.ores, archivFilePath); + archiveForum(archivFilePath); } if (isToolEnabled(CollaborationTools.TOOL_WIKI)) { - archiveWiki(this.ores, archivFilePath); + archiveWiki(archivFilePath); } if (isToolEnabled(CollaborationTools.TOOL_FOLDER)) { - archiveFolder(this.ores, archivFilePath); + archiveFolder(archivFilePath); } } - private void archiveForum(OLATResourceable formRes, String archivFilePath) { - Property forumKeyProperty = NarrowedPropertyManager.getInstance(formRes).findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM); + private void archiveForum(String archivFilePath) { + Property forumKeyProperty = NarrowedPropertyManager.getInstance(ores).findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM); if (forumKeyProperty != null) { VFSContainer archiveContainer = new LocalFolderImpl(new File(archivFilePath)); String archiveForumName = "del_forum_" + forumKeyProperty.getLongValue(); @@ -885,10 +885,10 @@ public class CollaborationTools implements Serializable { } } - private void archiveWiki(OLATResourceable wikiRes, String archivFilePath) { - VFSContainer wikiContainer = WikiManager.getInstance().getWikiRootContainer(wikiRes); + private void archiveWiki(String archivFilePath) { + VFSContainer wikiContainer = WikiManager.getInstance().getWikiRootContainer(ores); VFSLeaf wikiZip = WikiToZipUtils.getWikiAsZip(wikiContainer); - String exportFileName = "del_wiki_" + wikiRes.getResourceableId() + ".zip"; + String exportFileName = "del_wiki_" + ores.getResourceableId() + ".zip"; File archiveDir = new File(archivFilePath); if (!archiveDir.exists()) { archiveDir.mkdir(); @@ -898,17 +898,17 @@ public class CollaborationTools implements Serializable { try { FileUtils.bcopy(wikiZip.getInputStream(), new File(fullFilePath), "archive wiki"); } catch (FileNotFoundException e) { - log.warn("Can not archive wiki repoEntry=" + wikiRes.getResourceableId()); + log.warn("Can not archive wiki repoEntry=" + ores.getResourceableId()); } catch (IOException ioe) { - log.warn("Can not archive wiki repoEntry=" + wikiRes.getResourceableId()); + log.warn("Can not archive wiki repoEntry=" + ores.getResourceableId()); } } - private void archiveFolder(OLATResourceable folderRes, String archiveFilePath) { + private void archiveFolder(String archiveFilePath) { OlatRootFolderImpl folderContainer = new OlatRootFolderImpl(getFolderRelPath(), null); File fFolderRoot = folderContainer.getBasefile(); if (fFolderRoot.exists()) { - String zipFileName = "del_folder_" + folderRes.getResourceableId() + ".zip"; + String zipFileName = "del_folder_" + ores.getResourceableId() + ".zip"; String fullZipFilePath = archiveFilePath + File.separator + zipFileName; ZipUtil.zipAll(fFolderRoot, new File(fullZipFilePath), true); } diff --git a/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java b/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java index 8529a7c1c5db2dea10dc75d2668cbb06350bac3a..943017d359294e787fb4851c7a9019462a892512 100644 --- a/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java +++ b/src/main/java/org/olat/collaboration/CollaborationToolsFactory.java @@ -37,7 +37,6 @@ import org.olat.core.logging.Tracing; import org.olat.core.util.ArrayHelper; import org.olat.core.util.cache.CacheWrapper; import org.olat.core.util.coordinate.CoordinatorManager; -import org.olat.core.util.coordinate.SyncerCallback; import org.olat.group.BusinessGroup; import org.olat.instantMessaging.InstantMessagingModule; import org.olat.modules.openmeetings.OpenMeetingsModule; @@ -72,6 +71,7 @@ public class CollaborationToolsFactory { */ private CollaborationToolsFactory(CoordinatorManager coordinatorManager) { this.coordinatorManager = coordinatorManager; + cache = coordinatorManager.getCoordinator().getCacher().getCache(CollaborationToolsFactory.class.getSimpleName(), "tools"); instance = this; } @@ -135,37 +135,33 @@ public class CollaborationToolsFactory { */ public CollaborationTools getOrCreateCollaborationTools(final BusinessGroup ores) { if (ores == null) throw new AssertException("Null is not allowed here, you have to provide an existing ores here!"); + final String cacheKey = Long.valueOf(ores.getResourceableId()).toString(); + boolean debug = log.isDebug(); //sync operation cluster wide - //TODO gsync - return coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<CollaborationTools>() { - - public CollaborationTools execute() { - if (cache == null) { - cache = coordinatorManager.getCoordinator().getCacher().getCache(CollaborationToolsFactory.class.getSimpleName(), "tools"); - } - CollaborationTools collabTools = cache.get(cacheKey); - if (collabTools != null) { - - if (log.isDebug()) log .debug("loading collabTool from cache. Ores: " + ores.getResourceableId()); - - if (collabTools.isDirty()) { - if (log.isDebug()) log .debug("CollabTools were in cache but dirty. Creating new ones. Ores: " + ores.getResourceableId()); - CollaborationTools tools = new CollaborationTools(coordinatorManager, ores); - //update forces clusterwide invalidation of this object - cache.update(cacheKey, tools); - return tools; - } - - return collabTools; - - } - if (log.isDebug()) log .debug("collabTool not in cache. Creating new ones. Ores: " + ores.getResourceableId()); + + CollaborationTools collabTools = cache.get(cacheKey); + if (collabTools != null) { + if (debug) log .debug("loading collabTool from cache. Ores: " + ores.getResourceableId()); + if (collabTools.isDirty()) { + if (debug) log .debug("CollabTools were in cache but dirty. Creating new ones. Ores: " + ores.getResourceableId()); CollaborationTools tools = new CollaborationTools(coordinatorManager, ores); - cache.put(cacheKey, tools); - return tools; + //update forces clusterwide invalidation of this object + cache.update(cacheKey, tools); + collabTools = tools; + } + } else { + if (debug) log .debug("collabTool not in cache. Creating new ones. Ores: " + ores.getResourceableId()); + + CollaborationTools tools = new CollaborationTools(coordinatorManager, ores); + CollaborationTools cachedTools = cache.putIfAbsent(cacheKey, tools); + if(cachedTools != null) { + collabTools = cachedTools; + } else { + collabTools = tools; } - }); + } + return collabTools; } /** diff --git a/src/main/java/org/olat/collaboration/_spring/collaborationToolsContext.xml b/src/main/java/org/olat/collaboration/_spring/collaborationToolsContext.xml index 8ca42a13fbeb25c5c8ad2fa9bdcbd048aed50987..e07076356255e3af4233bbceb30212a61b2ea17f 100644 --- a/src/main/java/org/olat/collaboration/_spring/collaborationToolsContext.xml +++ b/src/main/java/org/olat/collaboration/_spring/collaborationToolsContext.xml @@ -3,15 +3,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd"> -<bean id="collaborationToolsFactory" class="org.olat.collaboration.CollaborationToolsFactory" -depends-on="instantMessagingModule,baseSecurityModule,portfolioModule,openmeetingsModule"> - <constructor-arg ref="coordinatorManager" /> -</bean> + <bean id="collaborationToolsFactory" class="org.olat.collaboration.CollaborationToolsFactory" + depends-on="instantMessagingModule,baseSecurityModule,portfolioModule,openmeetingsModule"> + <constructor-arg ref="coordinatorManager" /> + </bean> -<bean id="collaborationManager" class="org.olat.collaboration.CollaborationManagerImpl"/> - -<!-- TODO: add im property enabled here --> + <bean id="collaborationManager" class="org.olat.collaboration.CollaborationManagerImpl"/> </beans> \ No newline at end of file