Search in sources :

Example 61 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class SharedFolderManager method createSharedFolder.

public SharedFolderFileResource createSharedFolder() {
    SharedFolderFileResource resource = new SharedFolderFileResource();
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    if (rootContainer.createChildContainer(FOLDER_NAME) == null)
        return null;
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : SharedFolderFileResource(org.olat.fileresource.types.SharedFolderFileResource) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource)

Example 62 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class PaypalManagerImpl method cancelTransaction.

private synchronized void cancelTransaction(PaypalTransaction trx) {
    if (trx.getStatus() == PaypalTransactionStatus.SUCCESS || trx.getStatus() == PaypalTransactionStatus.CANCELED) {
        // already completed: if successed -> let it in this state
        return;
    }
    updateTransaction(trx, PaypalTransactionStatus.CANCELED);
    Order order = orderManager.loadOrderByNr(trx.getRefNo());
    orderManager.save(order, OrderStatus.CANCELED);
    // cancel the reservations
    Identity identity = order.getDelivery();
    for (OrderPart part : order.getParts()) {
        if (part.getKey().equals(trx.getOrderPartId())) {
            for (OrderLine line : part.getOrderLines()) {
                OLATResource resource = line.getOffer().getResource();
                ResourceReservation reservation = acService.getReservation(identity, resource);
                if (reservation != null) {
                    acService.removeReservation(identity, identity, reservation);
                    log.audit("Remove reservation after cancellation for: " + reservation + " to " + identity, null);
                }
            }
        }
    }
}
Also used : Order(org.olat.resource.accesscontrol.Order) OrderLine(org.olat.resource.accesscontrol.OrderLine) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) OrderPart(org.olat.resource.accesscontrol.OrderPart) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity)

Example 63 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ACFrontendManager method removeReservation.

@Override
public void removeReservation(Identity ureqIdentity, Identity identity, ResourceReservation reservation) {
    OLATResource resource = reservation.getResource();
    reservationDao.deleteReservation(reservation);
    if ("BusinessGroup".equals(resource.getResourceableTypeName())) {
        // needed to have the right number of participants to calculate upgrade from waiting list
        dbInstance.commit();
        businessGroupService.cancelPendingParticipation(ureqIdentity, reservation);
    }
}
Also used : OLATResource(org.olat.resource.OLATResource)

Example 64 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ACFrontendManager method reserveAccessToResource.

@Override
public boolean reserveAccessToResource(final Identity identity, final OfferAccess offer) {
    final OLATResource resource = offer.getOffer().getResource();
    String resourceType = resource.getResourceableTypeName();
    if ("BusinessGroup".equals(resourceType)) {
        boolean reserved = false;
        final BusinessGroup group = businessGroupDao.loadForUpdate(resource.getResourceableId());
        if (group.getMaxParticipants() == null && group.getMaxParticipants() <= 0) {
            // don't need reservation
            reserved = true;
        } else {
            BusinessGroup reloadedGroup = businessGroupService.loadBusinessGroup(resource);
            ResourceReservation reservation = reservationDao.loadReservation(identity, resource);
            if (reservation != null) {
                reserved = true;
            }
            int currentCount = businessGroupService.countMembers(reloadedGroup, GroupRoles.participant.name());
            int reservations = reservationDao.countReservations(resource);
            if (currentCount + reservations < reloadedGroup.getMaxParticipants().intValue()) {
                reservationDao.createReservation(identity, offer.getMethod().getType(), null, resource);
                reserved = true;
            }
        }
        return reserved;
    }
    return true;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) OLATResource(org.olat.resource.OLATResource)

Example 65 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ACFrontendManager method filterRepositoryEntriesWithAC.

@Override
public List<OLATResourceAccess> filterRepositoryEntriesWithAC(List<RepositoryEntry> repoEntries) {
    if (repoEntries == null || repoEntries.isEmpty()) {
        return Collections.emptyList();
    }
    Set<String> resourceTypes = new HashSet<String>();
    List<Long> resourceKeys = new ArrayList<Long>();
    for (RepositoryEntry entry : repoEntries) {
        OLATResource ores = entry.getOlatResource();
        resourceKeys.add(ores.getKey());
        resourceTypes.add(ores.getResourceableTypeName());
    }
    String resourceType = null;
    if (resourceTypes.size() == 1) {
        resourceType = resourceTypes.iterator().next();
    }
    Date now = dateNow();
    return methodManager.getAccessMethodForResources(resourceKeys, resourceType, "BusinessGroup", true, now);
}
Also used : ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

OLATResource (org.olat.resource.OLATResource)706 Test (org.junit.Test)304 RepositoryEntry (org.olat.repository.RepositoryEntry)198 Identity (org.olat.core.id.Identity)170 File (java.io.File)80 Date (java.util.Date)72 Feed (org.olat.modules.webFeed.Feed)72 ArrayList (java.util.ArrayList)64 ICourse (org.olat.course.ICourse)64 RepositoryService (org.olat.repository.RepositoryService)62 OLATResourceable (org.olat.core.id.OLATResourceable)60 BusinessGroup (org.olat.group.BusinessGroup)58 Item (org.olat.modules.webFeed.Item)44 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)38 OLATResourceManager (org.olat.resource.OLATResourceManager)34 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)34 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)30 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)30 FreeAccessMethod (org.olat.resource.accesscontrol.model.FreeAccessMethod)28 Group (org.olat.basesecurity.Group)26