use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.
the class AccessConfigurationController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (newMethodCtrl == source) {
if (event.equals(Event.DONE_EVENT)) {
OfferAccess newLink = newMethodCtrl.commitChanges();
newLink = acService.saveOfferAccess(newLink);
addConfiguration(newLink);
fireEvent(ureq, Event.CHANGED_EVENT);
}
cmc.deactivate();
cleanUp();
} else if (editMethodCtrl == source) {
if (event.equals(Event.DONE_EVENT)) {
OfferAccess newLink = editMethodCtrl.commitChanges();
newLink = acService.saveOfferAccess(newLink);
replace(newLink);
fireEvent(ureq, Event.CHANGED_EVENT);
}
cmc.deactivate();
cleanUp();
} else if (cmc == source) {
cleanUp();
} else {
super.event(ureq, source, event);
}
}
use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.
the class AccessConfigurationController method editMethod.
private void editMethod(UserRequest ureq, AccessInfo infos) {
OfferAccess link = infos.getLink();
removeAsListenerAndDispose(editMethodCtrl);
AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType());
if (handler != null) {
editMethodCtrl = handler.editConfigurationController(ureq, getWindowControl(), link);
}
if (editMethodCtrl != null) {
listenTo(editMethodCtrl);
String title = handler.getMethodName(getLocale());
cmc = new CloseableModalController(getWindowControl(), translate("close"), editMethodCtrl.getInitialComponent(), true, title);
cmc.activate();
listenTo(cmc);
}
}
use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.
the class AccessConfigurationController method addMethod.
protected void addMethod(UserRequest ureq, AccessMethod method) {
boolean confirmationEmail = confirmationEmailEl.isVisible() && confirmationEmailEl.isAtLeastSelected(1);
Offer offer = acService.createOffer(resource, displayName);
offer.setConfirmationEmail(confirmationEmail);
OfferAccess link = acService.createOfferAccess(offer, method);
removeAsListenerAndDispose(newMethodCtrl);
AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType());
if (handler != null) {
newMethodCtrl = handler.createConfigurationController(ureq, getWindowControl(), link);
}
if (newMethodCtrl != null) {
listenTo(newMethodCtrl);
String title = handler.getMethodName(getLocale());
cmc = new CloseableModalController(getWindowControl(), translate("close"), newMethodCtrl.getInitialComponent(), true, title);
cmc.activate();
listenTo(cmc);
} else {
OfferAccess newLink = acService.saveOfferAccess(link);
addConfiguration(newLink);
}
}
use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.
the class AutoAccessManagerImpl method getOrCreateOfferAccess.
private OfferAccess getOrCreateOfferAccess(OLATResource resource, RepositoryEntry entry, AccessMethod method) {
OfferAccess offerAccess;
List<OfferAccess> offerAccesses = acService.getValidOfferAccess(resource, method);
if (offerAccesses.isEmpty()) {
offerAccess = createOfferAccess(resource, entry, method);
} else {
offerAccess = offerAccesses.get(0);
}
return offerAccess;
}
use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.
the class AutoAccessManagerImplTest method shouldGrantAccessIfNoAccess.
@Test
public void shouldGrantAccessIfNoAccess() {
when(identifierHandlerMock.findRepositoryEntries(any(IdentifierKey.class), anyString())).thenReturn(listWithRespositotyEntryMock);
OfferAccess offerAccessDummy = mock(OfferAccess.class);
List<OfferAccess> offerAccess = Arrays.asList(offerAccessDummy);
when(acServiceMock.getValidOfferAccess(any(OLATResource.class), any(AccessMethod.class))).thenReturn(offerAccess);
sut.grantAccess(getPendingAdvanceOrders());
verify(acServiceMock, times(2)).accessResource(IDENTITY, offerAccessDummy, null);
}
Aggregations