use of org.olat.resource.accesscontrol.ui.AccessEvent in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRuntimeController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (cmc == source) {
cleanUp();
} else if (source == accessController) {
if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
doPostSuccessfullAccess(ureq);
} else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
String msg = ((AccessEvent) event).getMessage();
if (StringHelper.containsNonWhitespace(msg)) {
getWindowControl().setError(msg);
} else {
showError("error.accesscontrol");
}
}
} else if (accessCtrl == source) {
if (event == Event.CHANGED_EVENT) {
refreshRepositoryEntry(accessCtrl.getEntry());
if (ordersLink != null) {
boolean booking = acService.isResourceAccessControled(re.getOlatResource(), null);
ordersLink.setVisible(!corrupted && booking);
}
} else if (event == Event.CLOSE_EVENT) {
doClose(ureq);
}
} else if (descriptionCtrl == source) {
if (event == Event.CHANGED_EVENT) {
RepositoryEntry entry = descriptionCtrl.getEntry();
refreshRepositoryEntry(entry);
handler.onDescriptionChanged(entry);
// update name of root bread crumb and opened tabs in top nav in case the title has been modified
if (toolbarPanel.getBreadCrumbs().size() > 0) {
String newTitle = entry.getDisplayname();
String oldTitle = toolbarPanel.getBreadCrumbs().get(0).getCustomDisplayText();
if (!newTitle.equals(oldTitle)) {
// 1: update breadcrumb in toolbar
toolbarPanel.getBreadCrumbs().get(0).setCustomDisplayText(newTitle);
// 2: update dynamic tab in topnav
OLATResourceable reOres = OresHelper.clone(entry);
getWindowControl().getWindowBackOffice().getWindow().getDTabs().updateDTabTitle(reOres, newTitle);
}
}
} else if (event == Event.CLOSE_EVENT) {
doClose(ureq);
}
} else if (detailsCtrl == source) {
if (event instanceof LeavingEvent) {
doClose(ureq);
} else if (event == Event.DONE_EVENT) {
popToRoot(ureq);
cleanUp();
if (getRuntimeController() == null) {
doRun(ureq, reSecurity);
}
}
} else if (confirmDeleteCtrl == source) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
removeAsListenerAndDispose(confirmDeleteCtrl);
removeAsListenerAndDispose(cmc);
confirmDeleteCtrl = null;
cmc = null;
} else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
cmc.deactivate();
EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.deleted, "runtime");
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
doClose(ureq);
cleanUp();
}
} else if (copyCtrl == source) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
RepositoryEntryRef copy = copyCtrl.getCopiedEntry();
String businessPath = "[RepositoryEntry:" + copy.getKey() + "][EditDescription:0]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.added, "runtime");
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
}
cleanUp();
}
}
use of org.olat.resource.accesscontrol.ui.AccessEvent in project openolat by klemens.
the class TokenAccessController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String token = tokenEl.getValue();
AccessResult result = acService.accessResource(getIdentity(), link, token);
if (result.isAccessible()) {
fireEvent(ureq, AccessEvent.ACCESS_OK_EVENT);
} else {
String msg = translate("invalid.token");
fireEvent(ureq, new AccessEvent(AccessEvent.ACCESS_FAILED, msg));
}
}
use of org.olat.resource.accesscontrol.ui.AccessEvent in project OpenOLAT by OpenOLAT.
the class TokenAccessController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String token = tokenEl.getValue();
AccessResult result = acService.accessResource(getIdentity(), link, token);
if (result.isAccessible()) {
fireEvent(ureq, AccessEvent.ACCESS_OK_EVENT);
} else {
String msg = translate("invalid.token");
fireEvent(ureq, new AccessEvent(AccessEvent.ACCESS_FAILED, msg));
}
}
use of org.olat.resource.accesscontrol.ui.AccessEvent in project openolat by klemens.
the class RepositoryEntryRuntimeController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (cmc == source) {
cleanUp();
} else if (source == accessController) {
if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
doPostSuccessfullAccess(ureq);
} else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
String msg = ((AccessEvent) event).getMessage();
if (StringHelper.containsNonWhitespace(msg)) {
getWindowControl().setError(msg);
} else {
showError("error.accesscontrol");
}
}
} else if (accessCtrl == source) {
if (event == Event.CHANGED_EVENT) {
refreshRepositoryEntry(accessCtrl.getEntry());
if (ordersLink != null) {
boolean booking = acService.isResourceAccessControled(re.getOlatResource(), null);
ordersLink.setVisible(!corrupted && booking);
}
} else if (event == Event.CLOSE_EVENT) {
doClose(ureq);
}
} else if (descriptionCtrl == source) {
if (event == Event.CHANGED_EVENT) {
RepositoryEntry entry = descriptionCtrl.getEntry();
refreshRepositoryEntry(entry);
handler.onDescriptionChanged(entry);
// update name of root bread crumb and opened tabs in top nav in case the title has been modified
if (toolbarPanel.getBreadCrumbs().size() > 0) {
String newTitle = entry.getDisplayname();
String oldTitle = toolbarPanel.getBreadCrumbs().get(0).getCustomDisplayText();
if (!newTitle.equals(oldTitle)) {
// 1: update breadcrumb in toolbar
toolbarPanel.getBreadCrumbs().get(0).setCustomDisplayText(newTitle);
// 2: update dynamic tab in topnav
OLATResourceable reOres = OresHelper.clone(entry);
getWindowControl().getWindowBackOffice().getWindow().getDTabs().updateDTabTitle(reOres, newTitle);
}
}
} else if (event == Event.CLOSE_EVENT) {
doClose(ureq);
}
} else if (detailsCtrl == source) {
if (event instanceof LeavingEvent) {
doClose(ureq);
} else if (event == Event.DONE_EVENT) {
popToRoot(ureq);
cleanUp();
if (getRuntimeController() == null) {
doRun(ureq, reSecurity);
}
}
} else if (confirmDeleteCtrl == source) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
removeAsListenerAndDispose(confirmDeleteCtrl);
removeAsListenerAndDispose(cmc);
confirmDeleteCtrl = null;
cmc = null;
} else if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
cmc.deactivate();
EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.deleted, "runtime");
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
doClose(ureq);
cleanUp();
}
} else if (copyCtrl == source) {
cmc.deactivate();
if (event == Event.DONE_EVENT) {
RepositoryEntryRef copy = copyCtrl.getCopiedEntry();
String businessPath = "[RepositoryEntry:" + copy.getKey() + "][EditDescription:0]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
EntryChangedEvent e = new EntryChangedEvent(getRepositoryEntry(), getIdentity(), Change.added, "runtime");
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, RepositoryService.REPOSITORY_EVENT_ORES);
}
cleanUp();
}
}
Aggregations