use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project openolat by klemens.
the class LearningGroupWebService method getFolder.
@Path("{groupKey}/folder")
public VFSWebservice getFolder(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
if (bg == null) {
return null;
}
if (!isGroupManager(request)) {
Identity identity = RestSecurityHelper.getIdentity(request);
if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
return null;
}
}
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
if (!collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
return null;
}
String relPath = collabTools.getFolderRelPath();
QuotaManager qm = QuotaManager.getInstance();
Quota folderQuota = qm.getCustomQuota(relPath);
if (folderQuota == null) {
Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS);
folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
SubscriptionContext subsContext = null;
VFSSecurityCallback secCallback = new VFSWebServiceSecurityCallback(true, true, true, folderQuota, subsContext);
OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(relPath, null);
rootContainer.setLocalSecurityCallback(secCallback);
return new VFSWebservice(rootContainer);
}
use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project openolat by klemens.
the class GroupfoldersWebDAVMergeSource method getGroupContainer.
private VFSContainer getGroupContainer(String name, BusinessGroup group, boolean isOwner) {
String folderPath = collaborationManager.getFolderRelPath(group);
// create container and set quota
OlatRootFolderImpl localImpl = new OlatRootFolderImpl(folderPath, this);
// already done in OlatRootFolderImpl localImpl.getBasefile().mkdirs(); // lazy initialize dirs
String containerName = RequestUtil.normalizeFilename(name);
NamedContainerImpl grpContainer = new GroupNamedContainer(containerName, localImpl);
boolean writeAccess;
if (!isOwner) {
// check if participants have read/write access
int folderAccess = CollaborationTools.FOLDER_ACCESS_ALL;
Long lFolderAccess = collaborationManager.lookupFolderAccess(group);
if (lFolderAccess != null) {
folderAccess = lFolderAccess.intValue();
}
writeAccess = (folderAccess == CollaborationTools.FOLDER_ACCESS_ALL);
} else {
writeAccess = true;
}
VFSSecurityCallback secCallback;
if (writeAccess) {
SubscriptionContext sc = new SubscriptionContext(group, "toolfolder");
secCallback = new FullAccessWithLazyQuotaCallback(folderPath, QuotaConstants.IDENTIFIER_DEFAULT_GROUPS, sc);
} else {
secCallback = new ReadOnlyCallback();
}
grpContainer.setLocalSecurityCallback(secCallback);
return grpContainer;
}
use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project openolat by klemens.
the class BCWebService method createFolderVO.
public static FolderVO createFolderVO(IdentityEnvironment ienv, ICourse course, BCCourseNode bcNode, Collection<String> subscribed) {
OlatNamedContainerImpl container = BCCourseNode.getSecurisedNodeFolderContainer(bcNode, course.getCourseEnvironment(), ienv);
VFSSecurityCallback secCallback = container.getLocalSecurityCallback();
FolderVO folderVo = new FolderVO();
folderVo.setName(course.getCourseTitle());
folderVo.setDetailsName(bcNode.getShortTitle());
if (subscribed != null && subscribed.contains(bcNode.getIdent())) {
folderVo.setSubscribed(true);
} else {
folderVo.setSubscribed(false);
}
folderVo.setCourseKey(course.getResourceableId());
folderVo.setCourseNodeId(bcNode.getIdent());
folderVo.setWrite(secCallback.canWrite());
folderVo.setRead(secCallback.canRead());
folderVo.setDelete(secCallback.canDelete());
folderVo.setList(secCallback.canList());
return folderVo;
}
use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project openolat by klemens.
the class VFSResourceRoot method write.
@Override
public boolean write(String path, InputStream is, boolean overwrite, WebResource movedFrom) throws QuotaExceededException {
VFSLeaf childLeaf;
VFSItem file = resolveFile(path);
if (file instanceof VFSLeaf) {
if (overwrite) {
// overwrite the file
childLeaf = (VFSLeaf) file;
// versioning
if (childLeaf instanceof Versionable && ((Versionable) childLeaf).getVersions().isVersioned()) {
if (childLeaf.getSize() == 0) {
VersionsManager.getInstance().createVersionsFor(childLeaf, true);
} else {
VersionsManager.getInstance().addToRevisions((Versionable) childLeaf, identity, "");
}
}
} else {
return false;
}
} else if (file instanceof VFSContainer) {
return false;
} else {
// create a new file
int lastSlash = path.lastIndexOf('/');
if (lastSlash == -1)
return false;
String parentPath = path.substring(0, lastSlash);
VFSItem parentItem = resolveFile(parentPath);
if (parentItem instanceof VFSContainer) {
VFSContainer folder = (VFSContainer) parentItem;
String name = path.substring(lastSlash + 1);
childLeaf = folder.createChildLeaf(name);
} else {
return false;
}
}
if (childLeaf == null) {
return false;
}
try {
copyVFS(childLeaf, is);
} catch (QuotaExceededException e) {
throw e;
} catch (Exception e) {
log.error("", e);
return false;
}
VFSContainer inheritingCont = VFSManager.findInheritingSecurityCallbackContainer(childLeaf.getParentContainer());
if (inheritingCont != null) {
VFSSecurityCallback callback = inheritingCont.getLocalSecurityCallback();
if (callback != null && callback.getSubscriptionContext() != null) {
SubscriptionContext subContext = callback.getSubscriptionContext();
NotificationsManager.getInstance().markPublisherNews(subContext, null, true);
}
}
if (childLeaf instanceof MetaTagged && identity != null) {
MetaInfo infos = ((MetaTagged) childLeaf).getMetaInfo();
if (infos != null && !infos.hasAuthorIdentity()) {
infos.setAuthor(identity);
addLicense(infos, identity);
infos.clearThumbnails();
// infos.write(); the clearThumbnails call write()
}
}
if (movedFrom instanceof VFSResource) {
VFSResource vfsResource = (VFSResource) movedFrom;
if (vfsResource.getItem() instanceof Versionable && ((Versionable) vfsResource.getItem()).getVersions().isVersioned()) {
VFSLeaf currentVersion = (VFSLeaf) vfsResource.getItem();
VersionsManager.getInstance().move(currentVersion, childLeaf, identity);
}
}
return true;
}
use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project openolat by klemens.
the class BCCourseNode method getSecurisedNodeFolderContainer.
public static OlatNamedContainerImpl getSecurisedNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv, IdentityEnvironment ienv) {
boolean isOlatAdmin = ienv.getRoles().isOLATAdmin();
boolean isGuestOnly = ienv.getRoles().isGuestOnly();
UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
NodeEvaluation ne = node.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
OlatNamedContainerImpl container = getNodeFolderContainer(node, courseEnv);
VFSSecurityCallback secCallback = new FolderNodeCallback(container.getRelPath(), ne, isOlatAdmin, isGuestOnly, null);
container.setLocalSecurityCallback(secCallback);
return container;
}
Aggregations