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));
}
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());
}
}
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);
}
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);
}
}
}
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);
}
}
}
Aggregations