use of org.olat.core.util.vfs.QuotaManager in project openolat by klemens.
the class FullAccessWithLazyQuotaCallback method getQuota.
@Override
public Quota getQuota() {
if (super.getQuota() == null) {
QuotaManager qm = QuotaManager.getInstance();
Quota q = qm.getCustomQuota(folderPath);
if (q == null) {
Quota defQuota = qm.getDefaultQuota(defaultQuota);
q = QuotaManager.getInstance().createQuota(folderPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
super.setQuota(q);
}
return super.getQuota();
}
use of org.olat.core.util.vfs.QuotaManager 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.QuotaManager in project openolat by klemens.
the class ModifyCourseEvent method copyCourse.
/**
* Copies a course. More specifically, the run and editor structures and the
* course folder will be copied to create a new course.
*
* @param sourceRes
* @param ureq
* @return copy of the course.
*/
public static OLATResourceable copyCourse(OLATResourceable sourceRes, OLATResource targetRes) {
PersistingCourseImpl sourceCourse = (PersistingCourseImpl) loadCourse(sourceRes);
PersistingCourseImpl targetCourse = new PersistingCourseImpl(targetRes);
File fTargetCourseBasePath = targetCourse.getCourseBaseContainer().getBasefile();
// close connection before file copy
DBFactory.getInstance().commitAndCloseSession();
synchronized (sourceCourse) {
// o_clusterNOK - cannot be solved with doInSync since could take too long (leads to error: "Lock wait timeout exceeded")
// copy configuration
CourseConfig courseConf = CourseConfigManagerImpl.getInstance().copyConfigOf(sourceCourse);
targetCourse.setCourseConfig(courseConf);
// save structures
targetCourse.setRunStructure((Structure) XStreamHelper.xstreamClone(sourceCourse.getRunStructure()));
targetCourse.saveRunStructure();
targetCourse.setEditorTreeModel((CourseEditorTreeModel) XStreamHelper.xstreamClone(sourceCourse.getEditorTreeModel()));
targetCourse.saveEditorTreeModel();
// copy course folder
File fSourceCourseFolder = sourceCourse.getIsolatedCourseBaseFolder();
if (fSourceCourseFolder.exists())
FileUtils.copyDirToDir(fSourceCourseFolder, fTargetCourseBasePath, false, "copy course folder");
// copy folder nodes directories
File fSourceFoldernodesFolder = new File(FolderConfig.getCanonicalRoot() + BCCourseNode.getFoldernodesPathRelToFolderBase(sourceCourse.getCourseEnvironment()));
if (fSourceFoldernodesFolder.exists())
FileUtils.copyDirToDir(fSourceFoldernodesFolder, fTargetCourseBasePath, false, "copy folder nodes directories");
// copy task folder directories
File fSourceTaskfoldernodesFolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFoldersPathRelToFolderRoot(sourceCourse.getCourseEnvironment()));
if (fSourceTaskfoldernodesFolder.exists())
FileUtils.copyDirToDir(fSourceTaskfoldernodesFolder, fTargetCourseBasePath, false, "copy task folder directories");
// update references
List<Reference> refs = referenceManager.getReferences(sourceCourse);
int count = 0;
for (Reference ref : refs) {
referenceManager.addReference(targetCourse, ref.getTarget(), ref.getUserdata());
if (count % 20 == 0) {
DBFactory.getInstance().intermediateCommit();
}
}
// set quotas
Quota sourceQuota = VFSManager.isTopLevelQuotaContainer(sourceCourse.getCourseFolderContainer());
Quota targetQuota = VFSManager.isTopLevelQuotaContainer(targetCourse.getCourseFolderContainer());
if (sourceQuota != null && targetQuota != null) {
QuotaManager qm = QuotaManager.getInstance();
if (sourceQuota.getQuotaKB() != qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_COURSE).getQuotaKB()) {
targetQuota = qm.createQuota(targetQuota.getPath(), sourceQuota.getQuotaKB(), sourceQuota.getUlLimitKB());
qm.setCustomQuotaKB(targetQuota);
}
}
}
return targetRes;
}
use of org.olat.core.util.vfs.QuotaManager in project openolat by klemens.
the class FolderNodeCallback method getQuota.
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#getQuotaKB(org.olat.modules.bc.Path)
*/
@Override
public Quota getQuota() {
if (nodeFolderQuota == null) {
QuotaManager qm = QuotaManager.getInstance();
nodeFolderQuota = qm.getCustomQuota(relPath);
if (nodeFolderQuota == null) {
Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
nodeFolderQuota = qm.createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
}
return nodeFolderQuota;
}
use of org.olat.core.util.vfs.QuotaManager in project openolat by klemens.
the class BriefcaseWebDAVMergeSource method getLocalSecurityCallback.
@Override
public VFSSecurityCallback getLocalSecurityCallback() {
if (super.getLocalSecurityCallback() == null) {
// set quota for this merge source
QuotaManager qm = QuotaManager.getInstance();
Quota quota = qm.getCustomQuotaOrDefaultDependingOnRole(identity, PersonalFolderManager.getInstance().getRootPathFor(identity));
FullAccessWithQuotaCallback secCallback = new FullAccessWithQuotaCallback(quota);
setLocalSecurityCallback(secCallback);
}
return super.getLocalSecurityCallback();
}
Aggregations