Search in sources :

Example 46 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class ProjectBrokerManagerImpl method signOutFormAllCandidateList.

public void signOutFormAllCandidateList(final List<Identity> chosenIdentities, final Long projectBrokerId) {
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        public void execute() {
            ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
            for (Iterator<Project> iterator = projectBroker.getProjects().iterator(); iterator.hasNext(); ) {
                Project project = iterator.next();
                // loop over all identities
                for (Iterator<Identity> iterator2 = chosenIdentities.iterator(); iterator2.hasNext(); ) {
                    Identity identity = iterator2.next();
                    securityManager.removeIdentityFromSecurityGroup(identity, project.getCandidateGroup());
                    logAudit("ProjectBroker: AutoSignOut: identity=" + identity + " from project=" + project);
                }
            }
        }
    });
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) OLATResourceable(org.olat.core.id.OLATResourceable) Iterator(java.util.Iterator) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Identity(org.olat.core.id.Identity)

Example 47 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class ProjectBrokerManagerImpl method setProjectState.

@Override
public void setProjectState(final Project project, final String state) {
    final Long projectBrokerId = project.getProjectBroker().getKey();
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        @Override
        public void execute() {
            // For cluster-safe : reload project object here another node might have changed this in the meantime
            Project reloadedProject = (Project) dbInstance.loadObject(project, true);
            reloadedProject.setState(state);
            updateProjectAndInvalidateCache(reloadedProject);
        }
    });
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 48 with SyncerExecutor

use of org.olat.core.util.coordinate.SyncerExecutor in project openolat by klemens.

the class ProjectBrokerManagerImpl method deleteProject.

/**
 * Delete a project and delete project-groups related to this project.
 * This method is cluster-save.
 * @see org.olat.course.nodes.projectbroker.service.ProjectBrokerManager#deleteProject(org.olat.course.nodes.projectbroker.datamodel.Project)
 */
public void deleteProject(final Project project, final boolean deleteGroup, final CourseEnvironment courseEnv, final CourseNode cNode) {
    logDebug("start deleteProject project=" + project);
    final Long projectBrokerId = project.getProjectBroker().getKey();
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        public void execute() {
            Project reloadedProject = (Project) dbInstance.loadObject(project, true);
            // delete first candidate-group, project-group will be deleted after deleting project
            SecurityGroup candidateGroup = reloadedProject.getCandidateGroup();
            if ((courseEnv != null) && (cNode != null)) {
                deleteAllAttachmentFilesOfProject(reloadedProject, courseEnv, cNode);
                deleteAllDropboxFilesOfProject(reloadedProject, courseEnv, cNode);
                deleteAllReturnboxFilesOfProject(reloadedProject, courseEnv, cNode);
            }
            dbInstance.deleteObject(reloadedProject);
            logInfo("deleteSecurityGroup(project.getCandidateGroup())=" + candidateGroup.getKey());
            securityManager.deleteSecurityGroup(candidateGroup);
            // invalide with removing from cache
            projectCache.remove(projectBrokerId.toString());
        }
    });
    if (deleteGroup) {
        logDebug("start deleteProjectGroupFor project=" + project);
        projectGroupManager.deleteProjectGroupFor(project);
    }
    logDebug("DONE deleteProjectGroupFor project=" + project);
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) SecurityGroup(org.olat.basesecurity.SecurityGroup)

Aggregations

SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)48 OLATResourceable (org.olat.core.id.OLATResourceable)30 ICourse (org.olat.course.ICourse)12 Property (org.olat.properties.Property)12 Project (org.olat.course.nodes.projectbroker.datamodel.Project)8 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)8 Identity (org.olat.core.id.Identity)6 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)6 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)6 Date (java.util.Date)4 Iterator (java.util.Iterator)4 Test (org.junit.Test)4 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)4 ProjectBroker (org.olat.course.nodes.projectbroker.datamodel.ProjectBroker)4 PropertyManager (org.olat.properties.PropertyManager)4 OLATResource (org.olat.resource.OLATResource)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 CountDownLatch (java.util.concurrent.CountDownLatch)2