Search in sources :

Example 6 with OLATResourceableJustBeforeDeletedEvent

use of org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method deleteBusinessGroup.

@Override
public void deleteBusinessGroup(BusinessGroup group) {
    try {
        OLATResourceableJustBeforeDeletedEvent delEv = new OLATResourceableJustBeforeDeletedEvent(group);
        // notify all (currently running) BusinessGroupXXXcontrollers
        // about the deletion which will occur.
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(delEv, group);
        // refresh object to avoid stale object exceptions
        group = loadBusinessGroup(group);
        // 0) Loop over all deletableGroupData
        Map<String, DeletableGroupData> deleteListeners = CoreSpringFactory.getBeansOfType(DeletableGroupData.class);
        for (DeletableGroupData deleteListener : deleteListeners.values()) {
            if (log.isDebug()) {
                log.debug("deleteBusinessGroup: call deleteListener=" + deleteListener);
            }
            deleteListener.deleteGroupDataFor(group);
        }
        // 1) Delete all group properties
        CollaborationTools ct = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
        // deletes everything concerning properties&collabTools
        ct.deleteTools(group);
        // 1.c)delete user in security groups
        // removeFromRepositoryEntrySecurityGroup(group);
        // 2) Delete the group areas
        areaManager.deleteBGtoAreaRelations(group);
        // 3) Delete the relations
        businessGroupRelationDAO.deleteRelationsToRepositoryEntry(group);
        assessmentModeDao.deleteAssessmentModesToGroup(group);
        // 4) delete properties
        propertyManager.deleteProperties(null, group, null, null, null);
        propertyManager.deleteProperties(null, null, group, null, null);
        // 5) delete the publisher attached to this group (e.g. the forum and folder
        // publisher)
        notificationsManager.deletePublishersOf(group);
        // 6) delete info messages and subscription context associated with this group
        infoMessageManager.removeInfoMessagesAndSubscriptionContext(group);
        // 7) the group
        businessGroupDAO.delete(group);
        // 8) delete the associated security groups
        // TODO group
        dbInstance.commit();
        log.audit("Deleted Business Group", group.toString());
    } catch (DBRuntimeException dbre) {
        Throwable th = dbre.getCause();
        if ((th instanceof ObjectNotFoundException) && th.getMessage().contains("org.olat.group.BusinessGroupImpl")) {
            // group already deleted
            return;
        }
        if ((th instanceof StaleObjectStateException) && (th.getMessage().startsWith("Row was updated or deleted by another transaction"))) {
            // known issue OLAT-3654
            log.info("Group was deleted by another user in the meantime. Known issue OLAT-3654");
            throw new KnownIssueException("Group was deleted by another user in the meantime", 3654);
        } else {
            throw dbre;
        }
    }
}
Also used : DeletableGroupData(org.olat.group.DeletableGroupData) DBRuntimeException(org.olat.core.logging.DBRuntimeException) KnownIssueException(org.olat.core.logging.KnownIssueException) ObjectNotFoundException(org.hibernate.ObjectNotFoundException) CollaborationTools(org.olat.collaboration.CollaborationTools) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) StaleObjectStateException(org.hibernate.StaleObjectStateException)

Example 7 with OLATResourceableJustBeforeDeletedEvent

use of org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent in project openolat by klemens.

the class NoteController method event.

/**
 * @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
 */
public void event(Event event) {
    if (event instanceof OLATResourceableJustBeforeDeletedEvent) {
        OLATResourceableJustBeforeDeletedEvent bdev = (OLATResourceableJustBeforeDeletedEvent) event;
        Long key = n.getKey();
        if (key != null) {
            // already persisted
            if (bdev.getOresId().equals(key)) {
                dispose();
            }
        }
    }
}
Also used : OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)

Example 8 with OLATResourceableJustBeforeDeletedEvent

use of org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent in project openolat by klemens.

the class NoteListController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    // if row has been clicked
    if (source == tableC) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            int rowid = te.getRowId();
            this.chosenN = nLModel.getObject(rowid);
            if (actionid.equals("choose")) {
                removeAsListenerAndDispose(nc);
                nc = new NoteController(ureq, getWindowControl(), chosenN);
                listenTo(nc);
                removeAsListenerAndDispose(cmc);
                cmc = new CloseableModalController(getWindowControl(), translate("close"), nc.getInitialComponent());
                listenTo(cmc);
                cmc.activate();
            } else if (actionid.equals("delete")) {
                deleteDialogCtr = activateYesNoDialog(ureq, null, translate("note.delete.confirmation"), deleteDialogCtr);
            }
        }
    } else if (source == deleteDialogCtr) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // delete is ok
            nm.deleteNote(chosenN);
            // fire local event (for the same user)
            // TODO:fj:a make Note (and all persistables) olatresourceables: problem: type is then NoteImpl instead of Note
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(Note.class, chosenN.getKey());
            ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(new OLATResourceableJustBeforeDeletedEvent(ores), ores);
            showInfo("note.delete.successfull");
            populateNLTable();
            chosenN = null;
        } else {
            // answer was "no"
            chosenN = null;
        }
    } else if (source == nc) {
        if (event == Event.BACK_EVENT) {
            cmc.deactivate();
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) OLATResourceable(org.olat.core.id.OLATResourceable) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)

Example 9 with OLATResourceableJustBeforeDeletedEvent

use of org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent in project openolat by klemens.

the class FileHandler method cleanupOnDelete.

@Override
public boolean cleanupOnDelete(RepositoryEntry entry, OLATResourceable res) {
    // notify all current users of this resource (content packaging file resource) that it will be deleted now.
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new OLATResourceableJustBeforeDeletedEvent(res), res);
    FileResourceManager.getInstance().deleteFileResource(res);
    return true;
}
Also used : OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)

Example 10 with OLATResourceableJustBeforeDeletedEvent

use of org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent in project openolat by klemens.

the class SharedFolderHandler method cleanupOnDelete.

@Override
public boolean cleanupOnDelete(RepositoryEntry entry, OLATResourceable res) {
    // do not need to notify all current users of this resource, since the only
    // way to access this resource
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new OLATResourceableJustBeforeDeletedEvent(res), res);
    DBFactory.getInstance().commitAndCloseSession();
    SharedFolderManager.getInstance().deleteSharedFolder(res);
    return true;
}
Also used : OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)

Aggregations

OLATResourceableJustBeforeDeletedEvent (org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)28 AssertException (org.olat.core.logging.AssertException)6 ObjectNotFoundException (org.hibernate.ObjectNotFoundException)2 StaleObjectStateException (org.hibernate.StaleObjectStateException)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)2 TreeModel (org.olat.core.gui.components.tree.TreeModel)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 DBRuntimeException (org.olat.core.logging.DBRuntimeException)2 KnownIssueException (org.olat.core.logging.KnownIssueException)2 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)2 PublishEvent (org.olat.course.editor.PublishEvent)2 AssessmentEvent (org.olat.course.nodes.iq.AssessmentEvent)2 DeletableGroupData (org.olat.group.DeletableGroupData)2 BusinessGroupModifiedEvent (org.olat.group.ui.edit.BusinessGroupModifiedEvent)2 OLATResource (org.olat.resource.OLATResource)2 OLATResourceManager (org.olat.resource.OLATResourceManager)2