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