Search in sources :

Example 1 with OfferAccess

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);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess)

Example 2 with OfferAccess

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);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 3 with OfferAccess

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);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) Offer(org.olat.resource.accesscontrol.Offer) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 4 with OfferAccess

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;
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess)

Example 5 with 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);
}
Also used : IdentifierKey(org.olat.resource.accesscontrol.provider.auto.IdentifierKey) OfferAccess(org.olat.resource.accesscontrol.OfferAccess) AutoAccessMethod(org.olat.resource.accesscontrol.provider.auto.model.AutoAccessMethod) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Aggregations

OfferAccess (org.olat.resource.accesscontrol.OfferAccess)44 Offer (org.olat.resource.accesscontrol.Offer)18 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)16 OLATResource (org.olat.resource.OLATResource)14 Test (org.junit.Test)12 AccessMethodHandler (org.olat.resource.accesscontrol.method.AccessMethodHandler)12 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 BusinessGroup (org.olat.group.BusinessGroup)8 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 Identity (org.olat.core.id.Identity)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ACService (org.olat.resource.accesscontrol.ACService)6 IdentifierKey (org.olat.resource.accesscontrol.provider.auto.IdentifierKey)6 AutoAccessMethod (org.olat.resource.accesscontrol.provider.auto.model.AutoAccessMethod)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)4 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)4 CatalogEntry (org.olat.repository.CatalogEntry)4