Search in sources :

Example 6 with OfferAccess

use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.

the class AutoAccessManagerImplTest method shouldMarkAccessOrderAsDone.

@Test
public void shouldMarkAccessOrderAsDone() {
    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(advanceOrderDaoMock, times(2)).accomplishAndSave(any(AdvanceOrder.class));
}
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) AdvanceOrder(org.olat.resource.accesscontrol.provider.auto.AdvanceOrder) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Example 7 with OfferAccess

use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.

the class BusinessGroupDAOTest method findPublicGroups.

@Test
public void findPublicGroups() {
    // create a group with an access control
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-11");
    BusinessGroup group = businessGroupDao.createAndPersist(null, "access-grp-1", "access-grp-1-desc", 0, 5, true, false, true, false, false);
    // create and save an offer
    Offer offer = acService.createOffer(group.getResource(), "TestBGWorkflow");
    assertNotNull(offer);
    offer = acService.save(offer);
    acMethodManager.enableMethod(TokenAccessMethod.class, true);
    List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
    AccessMethod method = methods.get(0);
    OfferAccess access = acMethodManager.createOfferAccess(offer, method);
    acMethodManager.save(access);
    dbInstance.commitAndCloseSession();
    // retrieve the offer
    // check the search with the views
    BusinessGroupQueryParams queryAllParams = new BusinessGroupQueryParams();
    queryAllParams.setPublicGroups(Boolean.TRUE);
    List<OpenBusinessGroupRow> accessGroupViews = businessGroupDao.searchPublishedBusinessGroups(queryAllParams, identity);
    Assert.assertNotNull(accessGroupViews);
    Assert.assertTrue(accessGroupViews.size() >= 1);
    Assert.assertTrue(contains(accessGroupViews, group));
    for (OpenBusinessGroupRow accessGroup : accessGroupViews) {
        OLATResource resource = resourceManager.findResourceById(accessGroup.getResourceKey());
        List<Offer> offers = acService.findOfferByResource(resource, true, new Date());
        Assert.assertNotNull(offers);
        Assert.assertFalse(offers.isEmpty());
    }
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) TokenAccessMethod(org.olat.resource.accesscontrol.model.TokenAccessMethod) OfferAccess(org.olat.resource.accesscontrol.OfferAccess) BusinessGroup(org.olat.group.BusinessGroup) Offer(org.olat.resource.accesscontrol.Offer) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 8 with OfferAccess

use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.

the class PublishProcess method changeAccessAndProperties.

public void changeAccessAndProperties(Identity author, CourseAccessAndProperties accessAndProps) {
    RepositoryManager manager = RepositoryManager.getInstance();
    manager.setAccessAndProperties(accessAndProps.getRepositoryEntry(), accessAndProps.getAccess(), accessAndProps.isMembersOnly(), accessAndProps.isCanCopy(), accessAndProps.isCanReference(), accessAndProps.isCanDownload());
    manager.setLeaveSetting(accessAndProps.getRepositoryEntry(), accessAndProps.getSetting());
    List<OfferAccess> offerAccess = accessAndProps.getOfferAccess();
    // 1: add new and update existing offerings
    ACService acService = CoreSpringFactory.getImpl(ACService.class);
    for (OfferAccess newLink : offerAccess) {
        if (accessAndProps.getConfirmationEmail() != null) {
            Offer offer = newLink.getOffer();
            boolean confirmation = accessAndProps.getConfirmationEmail().booleanValue();
            if (offer.isConfirmationEmail() != confirmation) {
                offer.setConfirmationEmail(confirmation);
                if (offer.getKey() != null) {
                    offer = acService.save(offer);
                }
            }
        }
        acService.saveOfferAccess(newLink);
    }
    // 2: remove offerings not available anymore
    List<OfferAccess> deletedOfferAccess = accessAndProps.getDeletedOfferAccess();
    for (OfferAccess deletedLink : deletedOfferAccess) {
        acService.deletedLinkToMethod(deletedLink);
    }
    MultiUserEvent modifiedEvent = new EntryChangedEvent(repositoryEntry, author, Change.modifiedAtPublish, "publish");
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, repositoryEntry);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) Offer(org.olat.resource.accesscontrol.Offer) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) ACService(org.olat.resource.accesscontrol.ACService) RepositoryManager(org.olat.repository.RepositoryManager) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Example 9 with OfferAccess

use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.

the class PublishStep01AccessForm method loadConfigurations.

protected void loadConfigurations() {
    List<Offer> offers = acService.findOfferByResource(resource, true, null);
    for (Offer offer : offers) {
        List<OfferAccess> offerAccessList = acService.getOfferAccess(offer, true);
        for (OfferAccess access : offerAccessList) {
            button_id++;
            addConfiguration(access);
        }
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) Offer(org.olat.resource.accesscontrol.Offer)

Example 10 with OfferAccess

use of org.olat.resource.accesscontrol.OfferAccess in project OpenOLAT by OpenOLAT.

the class PublishStep01AccessForm method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    super.formInnerEvent(ureq, source, event);
    if (source == authorsSwitch) {
        if (authorsSwitch.getSelectedKey().equals(YES_KEY)) {
            authorConfigLayout.setVisible(true);
        } else {
            authorConfigLayout.setVisible(false);
            if (!publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY)) {
                usersSwitch.select(NO_KEY, false);
                userConfigLayout.setVisible(false);
            }
        }
    } else if (source == usersSwitch || source == publishedForUsers) {
        if (usersSwitch.getSelectedKey().equals(YES_KEY)) {
            userConfigLayout.setVisible(true);
            accessLayout.setVisible(true);
            if (publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY)) {
                authorConfigLayout.setVisible(false);
                authorsSwitch.select(NO_KEY, false);
                authorsSwitch.setEnabled(false);
            } else {
                authorsSwitch.select(YES_KEY, false);
                authorsSwitch.setEnabled(true);
                authorConfigLayout.setVisible(true);
            }
        } else {
            userConfigLayout.setVisible(false);
            accessLayout.setVisible(false);
            authorsSwitch.setEnabled(true);
        }
    } else if (addMethods.contains(source)) {
        AccessMethod method = (AccessMethod) source.getUserObject();
        addMethod(ureq, method);
    } else if (confirmationEmailEl == source) {
        for (AccessInfo info : confControllers) {
            if (!offerAccess.contains(info.getLink())) {
                offerAccess.add(info.getLink());
            }
        }
    } else if (source instanceof FormLink) {
        FormLink button = (FormLink) source;
        String cmd = button.getCmd();
        if ("delete".equals(cmd)) {
            AccessInfo infos = (AccessInfo) source.getUserObject();
            OfferAccess deleteOffer = infos.getLink();
            offerAccess.remove(deleteOffer);
            if (deleteOffer.getKey() != null) {
                deletedOfferAccess.add(deleteOffer);
            }
            confControllers.remove(infos);
            updateConfirmationEmail();
            fireEvent(ureq, Event.CHANGED_EVENT);
        } else if ("edit".equals(cmd)) {
            AccessInfo infos = (AccessInfo) source.getUserObject();
            editMethod(ureq, infos);
        }
    }
}
Also used : AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) OfferAccess(org.olat.resource.accesscontrol.OfferAccess) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

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