public VFSContainer getContainer(Identity identity) {
MergeSource cfRoot = new MergeSource(null, null);
// collect buddy groups
BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
QuotaManager qm = QuotaManager.getInstance();
List<BusinessGroup> groups = bgm.findBusinessGroupsAttendedBy(null, identity, null);
groups.addAll(bgm.findBusinessGroupsOwnedBy(null, identity, null));
List<Long> addedGroupKeys = new ArrayList<Long>();
List<String> addedGroupNames = new ArrayList<String>();
for (BusinessGroup group : groups) {
if (addedGroupKeys.contains(group.getKey())) continue; // check for duplicate groups
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
if (tools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
String name = group.getName();
if (addedGroupNames.contains(name)) {
// attach a serial to the group name to avoid duplicate mount points...
int serial = 1;
int serialMax = 100;
while (addedGroupNames.contains(name + serial) && serial < serialMax) {
serial++;
}
if (serial == serialMax) continue; // continue without adding mount point
name = name + serial;
}
// create container and set quota
OlatRootFolderImpl localImpl = new OlatRootFolderImpl(tools.getFolderRelPath(), cfRoot);
localImpl.getBasefile().mkdirs(); // lazy initialize dirs
NamedContainerImpl grpContainer = new NamedContainerImpl(Formatter.makeStringFilesystemSave(name), localImpl);
Quota q = qm.getCustomQuota(tools.getFolderRelPath());
if (q == null) {
Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS);
q = QuotaManager.getInstance().createQuota(tools.getFolderRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
FullAccessWithQuotaCallback secCallback = new FullAccessWithQuotaCallback(q);
grpContainer.setLocalSecurityCallback(secCallback);