use of org.olat.search.service.indexer.Indexer in project OpenOLAT by OpenOLAT.
the class RepositoryIndexer method checkAccess.
/**
* @see org.olat.search.service.indexer.Indexer#checkAccess(org.olat.core.id.context.ContextEntry, org.olat.core.id.context.BusinessControl, org.olat.core.id.Identity, org.olat.core.id.Roles)
*/
@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
boolean debug = isLogDebugEnabled();
if (debug)
logDebug("checkAccess for businessControl=" + businessControl + " identity=" + identity + " roles=" + roles);
Long repositoryKey = contextEntry.getOLATResourceable().getResourceableId();
RepositoryEntry repositoryEntry = repositoryManager.lookupRepositoryEntry(repositoryKey);
if (repositoryEntry == null) {
return false;
}
if (roles.isGuestOnly()) {
if (repositoryEntry.getAccess() != RepositoryEntry.ACC_USERS_GUESTS) {
return false;
}
}
boolean isOwner = repositoryManager.isOwnerOfRepositoryEntry(identity, repositoryEntry);
boolean isAllowedToLaunch = false;
if (!isOwner) {
isAllowedToLaunch = repositoryManager.isAllowedToLaunch(identity, roles, repositoryEntry);
if (isAllowedToLaunch) {
List<ContextEntry> entries = businessControl.getEntriesDownTheControls();
if (entries.size() > 1) {
boolean hasAccess = false;
ACService acService = CoreSpringFactory.getImpl(ACService.class);
AccessResult acResult = acService.isAccessible(repositoryEntry, identity, false);
if (acResult.isAccessible()) {
hasAccess = true;
} else if (!acResult.getAvailableMethods().isEmpty()) {
for (OfferAccess offer : acResult.getAvailableMethods()) {
String type = offer.getMethod().getType();
if (type.equals(FreeAccessHandler.METHOD_TYPE) || type.equals(PaypalAccessHandler.METHOD_TYPE)) {
hasAccess = true;
}
}
}
isAllowedToLaunch = hasAccess;
}
}
}
if (debug)
logDebug("isOwner=" + isOwner + " isAllowedToLaunch=" + isAllowedToLaunch);
if (isOwner || isAllowedToLaunch) {
Indexer repositoryEntryIndexer = getRepositoryEntryIndexer(repositoryEntry);
if (debug)
logDebug("repositoryEntryIndexer=" + repositoryEntryIndexer);
if (repositoryEntryIndexer != null) {
return super.checkAccess(contextEntry, businessControl, identity, roles) && repositoryEntryIndexer.checkAccess(contextEntry, businessControl, identity, roles);
}
}
return false;
}
Aggregations