Search in sources :

Example 11 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project openolat by klemens.

the class AuthoringEditAccessController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == propPupForm) {
        if (event == Event.DONE_EVENT) {
            // inform user about inconsistent configuration: doesn't make sense to set a repositoryEntry canReference=true if it is only accessible to owners
            if (!entry.getCanReference() && propPupForm.canReference() && (propPupForm.getAccess() < RepositoryEntry.ACC_OWNERS_AUTHORS && !propPupForm.isMembersOnly())) {
                showError("warn.config.reference.no.access");
            }
            int access = propPupForm.getAccess();
            int numOfBookingConfigs = acCtr.getNumOfBookingConfigurations();
            entry = repositoryManager.setAccessAndProperties(entry, access, propPupForm.isMembersOnly(), propPupForm.canCopy(), propPupForm.canReference(), propPupForm.canDownload());
            if (entry == null) {
                showWarning("repositoryentry.not.existing");
                fireEvent(ureq, Event.CLOSE_EVENT);
            } else {
                boolean managedBookings = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.bookings);
                if (access == RepositoryEntry.ACC_USERS || access == RepositoryEntry.ACC_USERS_GUESTS) {
                    if ((!managedBookings && acModule.isEnabled()) || numOfBookingConfigs > 0) {
                        editproptabpubVC.put("accesscontrol", acCtr.getInitialComponent());
                        editproptabpubVC.contextPut("isGuestAccess", Boolean.valueOf(access == RepositoryEntry.ACC_USERS_GUESTS));
                    }
                } else {
                    editproptabpubVC.remove(acCtr.getInitialComponent());
                }
                // inform anybody interested about this change
                MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authoring");
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        }
    } else if (source == leaveForm) {
        if (event == Event.DONE_EVENT) {
            RepositoryEntryAllowToLeaveOptions leaveSetting = leaveForm.getSelectedLeaveSetting();
            entry = repositoryManager.setLeaveSetting(entry, leaveSetting);
            if (entry == null) {
                showWarning("repositoryentry.not.existing");
                fireEvent(ureq, Event.CLOSE_EVENT);
            } else {
                MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authorings");
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
                CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
                fireEvent(ureq, Event.CHANGED_EVENT);
            }
        }
    } else if (acCtr == source) {
        if (event == Event.CHANGED_EVENT) {
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
    }
}
Also used : EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Example 12 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project openolat by klemens.

the class ConfirmDeletePermanentlyController method deleteEntries.

private boolean deleteEntries(UserRequest ureq, List<RepositoryEntry> entries, List<ErrorList> errorList) {
    boolean allOk = true;
    Roles roles = ureq.getUserSession().getRoles();
    for (RepositoryEntry entry : entries) {
        RepositoryEntry reloadedEntry = repositoryService.loadByKey(entry.getKey());
        if (reloadedEntry != null) {
            ErrorList errors = repositoryService.deletePermanently(reloadedEntry, getIdentity(), roles, getLocale());
            ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_DELETE, getClass(), LoggingResourceable.wrap(reloadedEntry, OlatResourceableType.genRepoEntry));
            if (errors.hasErrors()) {
                allOk = false;
                errorList.add(errors);
            } else {
                EntryChangedEvent e = new EntryChangedEvent(reloadedEntry, getIdentity(), Change.deleted, "delete");
                ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
            }
        }
    }
    return allOk;
}
Also used : ErrorList(org.olat.repository.ErrorList) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 13 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class RepositoryEntryListController method doMark.

protected boolean doMark(UserRequest ureq, RepositoryEntryRow row) {
    OLATResourceable item = OresHelper.createOLATResourceableInstance("RepositoryEntry", row.getKey());
    if (markManager.isMarked(item, getIdentity(), null)) {
        markManager.removeMark(item, getIdentity(), null);
        EntryChangedEvent e = new EntryChangedEvent(row, getIdentity(), Change.removeBookmark, name);
        ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        return false;
    } else {
        String businessPath = "[RepositoryEntry:" + item.getResourceableId() + "]";
        markManager.setMark(item, getIdentity(), null, businessPath);
        EntryChangedEvent e = new EntryChangedEvent(row, getIdentity(), Change.addBookmark, name);
        ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
        return true;
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent)

Example 14 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class ConfirmDeletePermanentlyController method deleteEntries.

private boolean deleteEntries(UserRequest ureq, List<RepositoryEntry> entries, List<ErrorList> errorList) {
    boolean allOk = true;
    Roles roles = ureq.getUserSession().getRoles();
    for (RepositoryEntry entry : entries) {
        RepositoryEntry reloadedEntry = repositoryService.loadByKey(entry.getKey());
        if (reloadedEntry != null) {
            ErrorList errors = repositoryService.deletePermanently(reloadedEntry, getIdentity(), roles, getLocale());
            ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_DELETE, getClass(), LoggingResourceable.wrap(reloadedEntry, OlatResourceableType.genRepoEntry));
            if (errors.hasErrors()) {
                allOk = false;
                errorList.add(errors);
            } else {
                EntryChangedEvent e = new EntryChangedEvent(reloadedEntry, getIdentity(), Change.deleted, "delete");
                ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
            }
        }
    }
    return allOk;
}
Also used : ErrorList(org.olat.repository.ErrorList) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 15 with EntryChangedEvent

use of org.olat.repository.controllers.EntryChangedEvent in project OpenOLAT by OpenOLAT.

the class ConfirmRestoreController method doCompleteRestore.

private void doCompleteRestore(UserRequest ureq) {
    for (RepositoryEntry entry : rows) {
        RepositoryEntry reloadedEntry = repositoryService.loadByKey(entry.getKey());
        if (reloadedEntry != null) {
            repositoryService.restoreRepositoryEntry(reloadedEntry);
            ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_RESTORE, getClass(), LoggingResourceable.wrap(reloadedEntry, OlatResourceableType.genRepoEntry));
            fireEvent(ureq, new EntryChangedEvent(reloadedEntry, getIdentity(), Change.restored, "restored"));
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

EntryChangedEvent (org.olat.repository.controllers.EntryChangedEvent)32 RepositoryEntry (org.olat.repository.RepositoryEntry)12 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)10 OLATResourceable (org.olat.core.id.OLATResourceable)8 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 LicenseType (org.olat.core.commons.services.license.LicenseType)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 Roles (org.olat.core.id.Roles)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 BusinessGroup (org.olat.group.BusinessGroup)2 BusinessGroupSelectionEvent (org.olat.group.model.BusinessGroupSelectionEvent)2 ExportFormatOptions (org.olat.modules.qpool.ExportFormatOptions)2 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)2 QItemList (org.olat.modules.qpool.model.QItemList)2