use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.
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.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.
the class ReturnboxController method initReturnbox.
protected void initReturnbox(UserRequest ureq, WindowControl wControl, CourseNode node, UserCourseEnvironment userCourseEnv, boolean previewMode) {
// returnbox display
myContent = createVelocityContainer("returnbox");
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), null);
String fullName = StringHelper.escapeHtml(userManager.getUserDisplayName(getIdentity()));
OlatNamedContainerImpl namedContainer = new OlatNamedContainerImpl(fullName, rootFolder);
namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
returnboxFolderRunController = new FolderRunController(namedContainer, false, ureq, wControl);
returnboxFolderRunController.addControllerListener(this);
myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
// notification
if (!previewMode && !ureq.getUserSession().getRoles().isGuestOnly()) {
// offer subscription, but not to guests
subsContext = ReturnboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity());
if (subsContext != null) {
contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, wControl, getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), subsContext, ReturnboxController.class);
myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
myContent.contextPut("hasNotification", Boolean.TRUE);
}
} else {
myContent.contextPut("hasNotification", Boolean.FALSE);
}
putInitialPanel(myContent);
}
use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.
the class TACourseNode method getNodeFolderContainer.
/**
* @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
public static OlatNamedContainerImpl getNodeFolderContainer(TACourseNode node, CourseEnvironment courseEnvironment) {
String path = getFoldernodePathRelToFolderBase(courseEnvironment, node);
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(path, null);
OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(TACourseNode.SOLUTION_FOLDER_NAME, rootFolder);
return namedFolder;
}
use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.
the class BCCourseNodeEditController method doOpenFolder.
private void doOpenFolder(UserRequest ureq) {
VFSContainer namedContainer = null;
if (bcNode.getModuleConfiguration().getBooleanSafe(CONFIG_AUTO_FOLDER)) {
OlatNamedContainerImpl directory = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
directory.setLocalSecurityCallback(getSecurityCallbackWithQuota(directory.getRelPath()));
namedContainer = directory;
} else {
VFSContainer courseContainer = course.getCourseFolderContainer();
String path = bcNode.getModuleConfiguration().getStringValue(CONFIG_SUBPATH, "");
VFSItem pathItem = courseContainer.resolve(path);
if (pathItem instanceof VFSContainer) {
namedContainer = (VFSContainer) pathItem;
if (bcNode.isSharedFolder()) {
if (course.getCourseConfig().isSharedFolderReadOnlyMount()) {
namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
} else {
String relPath = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment()).getRelPath();
namedContainer.setLocalSecurityCallback(getSecurityCallbackWithQuota(relPath));
}
} else {
VFSContainer inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(namedContainer);
if (inheritingContainer != null && inheritingContainer.getLocalSecurityCallback() != null && inheritingContainer.getLocalSecurityCallback().getQuota() != null) {
Quota quota = inheritingContainer.getLocalSecurityCallback().getQuota();
namedContainer.setLocalSecurityCallback(new FullAccessWithQuotaCallback(quota));
} else {
namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
}
}
}
}
folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
listenTo(folderCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.
the class UserMgmtTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
if (setuped)
return;
// create identities
owner1 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-zero");
assertNotNull(owner1);
id1 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-one-" + UUID.randomUUID().toString());
id2 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-two");
dbInstance.intermediateCommit();
id2.getUser().setProperty("telMobile", "39847592");
id2.getUser().setProperty("gender", "female");
id2.getUser().setProperty("birthDay", "20091212");
dbInstance.updateObject(id2.getUser());
dbInstance.intermediateCommit();
id3 = JunitTestHelper.createAndPersistIdentityAsUser("user-rest-three");
OlatRootFolderImpl id3HomeFolder = new OlatRootFolderImpl(FolderConfig.getUserHome(id3.getName()), null);
VFSContainer id3PublicFolder = (VFSContainer) id3HomeFolder.resolve("public");
if (id3PublicFolder == null) {
id3PublicFolder = id3HomeFolder.createChildContainer("public");
}
VFSItem portrait = id3PublicFolder.resolve("portrait.jpg");
if (portrait == null) {
URL portraitUrl = CoursesElementsTest.class.getResource("portrait.jpg");
File ioPortrait = new File(portraitUrl.toURI());
FileUtils.copyFileToDirectory(ioPortrait, ((LocalImpl) id3PublicFolder).getBasefile(), false);
}
OLATResourceManager rm = OLATResourceManager.getInstance();
// create course and persist as OLATResourceImpl
OLATResourceable resourceable = OresHelper.createOLATResourceableInstance("junitcourse", System.currentTimeMillis());
OLATResource course = rm.createOLATResourceInstance(resourceable);
dbInstance.saveObject(course);
dbInstance.intermediateCommit();
// create learn group
// 1) context one: learning groups
RepositoryEntry c1 = JunitTestHelper.createAndPersistRepositoryEntry();
// create groups without waiting list
g1externalId = UUID.randomUUID().toString();
g1 = businessGroupService.createBusinessGroup(null, "user-rest-g1", null, g1externalId, "all", 0, 10, false, false, c1);
g2 = businessGroupService.createBusinessGroup(null, "user-rest-g2", null, 0, 10, false, false, c1);
// members g1
businessGroupRelationDao.addRole(id1, g1, GroupRoles.coach.name());
businessGroupRelationDao.addRole(id2, g1, GroupRoles.participant.name());
// members g2
businessGroupRelationDao.addRole(id2, g2, GroupRoles.coach.name());
businessGroupRelationDao.addRole(id1, g2, GroupRoles.participant.name());
// 2) context two: right groups
RepositoryEntry c2 = JunitTestHelper.createAndPersistRepositoryEntry();
// groups
g3ExternalId = UUID.randomUUID().toString();
g3 = businessGroupService.createBusinessGroup(null, "user-rest-g3", null, g3ExternalId, "all", -1, -1, false, false, c2);
g4 = businessGroupService.createBusinessGroup(null, "user-rest-g4", null, -1, -1, false, false, c2);
// members
businessGroupRelationDao.addRole(id1, g3, GroupRoles.participant.name());
businessGroupRelationDao.addRole(id2, g4, GroupRoles.participant.name());
dbInstance.closeSession();
// add some collaboration tools
CollaborationTools g1CTSMngr = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(g1);
g1CTSMngr.setToolEnabled(CollaborationTools.TOOL_FORUM, true);
// create the forum
Forum g1Forum = g1CTSMngr.getForum();
Message m1 = ForumManager.getInstance().createMessage(g1Forum, id1, false);
m1.setTitle("Thread-1");
m1.setBody("Body of Thread-1");
ForumManager.getInstance().addTopMessage(m1);
dbInstance.commitAndCloseSession();
// add some folder tool
CollaborationTools g2CTSMngr = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(g2);
g2CTSMngr.setToolEnabled(CollaborationTools.TOOL_FOLDER, true);
OlatRootFolderImpl g2Folder = new OlatRootFolderImpl(g2CTSMngr.getFolderRelPath(), null);
g2Folder.getBasefile().mkdirs();
VFSItem groupPortrait = g2Folder.resolve("portrait.jpg");
if (groupPortrait == null) {
URL portraitUrl = UserMgmtTest.class.getResource("portrait.jpg");
File ioPortrait = new File(portraitUrl.toURI());
FileUtils.copyFileToDirectory(ioPortrait, g2Folder.getBasefile(), false);
}
dbInstance.commitAndCloseSession();
// prepare some courses
Identity author = JunitTestHelper.createAndPersistIdentityAsUser("auth-" + UUID.randomUUID().toString());
RepositoryEntry entry = JunitTestHelper.deployDemoCourse(author);
if (!repositoryService.hasRole(id1, entry, GroupRoles.participant.name())) {
repositoryService.addRole(id1, entry, GroupRoles.participant.name());
}
demoCourse = CourseFactory.loadCourse(entry);
TreeVisitor visitor = new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof FOCourseNode) {
if (demoForumNode == null) {
demoForumNode = (FOCourseNode) node;
Forum courseForum = demoForumNode.loadOrCreateForum(demoCourse.getCourseEnvironment());
Message message1 = ForumManager.getInstance().createMessage(courseForum, id1, false);
message1.setTitle("Thread-1");
message1.setBody("Body of Thread-1");
ForumManager.getInstance().addTopMessage(message1);
}
} else if (node instanceof BCCourseNode) {
if (demoBCCourseNode == null) {
demoBCCourseNode = (BCCourseNode) node;
OlatNamedContainerImpl container = BCCourseNode.getNodeFolderContainer(demoBCCourseNode, demoCourse.getCourseEnvironment());
VFSItem example = container.resolve("singlepage.html");
if (example == null) {
try {
InputStream htmlUrl = UserMgmtTest.class.getResourceAsStream("singlepage.html");
VFSLeaf htmlLeaf = container.createChildLeaf("singlepage.html");
IOUtils.copy(htmlUrl, htmlLeaf.getOutputStream(false));
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}, demoCourse.getRunStructure().getRootNode(), false);
visitor.visitAll();
dbInstance.commitAndCloseSession();
setuped = true;
}
Aggregations