Search in sources :

Example 26 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class SearchResourceContext method getResourceUrl.

/**
 * @return Returns the resourcePath.
 */
public String getResourceUrl() {
    BusinessControl bControl = myBusinessControl == null ? parentBusinessControl : myBusinessControl;
    String resourceUrl = BusinessControlFactory.getInstance().getAsString(bControl);
    if (filePath != null) {
        // It is a file resource => Append file path
        StringBuilder buf = new StringBuilder(resourceUrl);
        buf.append(FILEPATH_PREFIX).append(filePath).append(ENDTAG);
        resourceUrl = buf.toString();
    }
    return resourceUrl;
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl)

Example 27 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class SearchResultsImpl method createResultDocument.

/**
 * Create a result document. Return null if the identity has not enough privileges to see the document.
 * @param doc
 * @param query
 * @param analyzer
 * @param doHighlight
 * @param identity
 * @param roles
 * @return
 * @throws IOException
 */
private ResultDocument createResultDocument(Document doc, int pos, Query query, Analyzer analyzer, boolean doHighlight, Identity identity, Roles roles) throws IOException {
    boolean hasAccess = false;
    if (roles.isOLATAdmin()) {
        hasAccess = true;
    } else {
        String resourceUrl = doc.get(AbstractOlatDocument.RESOURCEURL_FIELD_NAME);
        if (resourceUrl == null) {
            resourceUrl = "";
        }
        BusinessControl businessControl = BusinessControlFactory.getInstance().createFromString(resourceUrl);
        hasAccess = mainIndexer.checkAccess(null, businessControl, identity, roles);
    }
    ResultDocument resultDoc;
    if (hasAccess) {
        resultDoc = new ResultDocument(doc, pos);
        if (doHighlight) {
            doHighlight(query, analyzer, doc, resultDoc);
        }
    } else {
        resultDoc = null;
    }
    return resultDoc;
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) ResultDocument(org.olat.search.model.ResultDocument)

Example 28 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class SearchControllerFactory method createInputController.

@Override
public SearchInputController createInputController(UserRequest ureq, WindowControl wControl, DisplayOption displayOption, Form mainForm) {
    String resourceUrl = null;
    BusinessControl bc = wControl.getBusinessControl();
    if (bc != null) {
        resourceUrl = bc.getAsString();
    }
    SearchInputController searchCtrl;
    if (mainForm == null) {
        searchCtrl = new SearchInputController(ureq, wControl, resourceUrl, displayOption);
    } else {
        searchCtrl = new SearchInputController(ureq, wControl, resourceUrl, displayOption, mainForm);
    }
    return searchCtrl;
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl)

Example 29 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class SearchControllerFactory method createSearchController.

@Override
public SearchInputController createSearchController(UserRequest ureq, WindowControl wControl) {
    String resourceUrl = null;
    BusinessControl bc = wControl.getBusinessControl();
    if (bc != null) {
        resourceUrl = bc.getAsString();
    }
    return new ResultsSearchController(ureq, wControl, resourceUrl);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl)

Example 30 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project openolat by klemens.

the class SearchInputController method gotoSearchResult.

/**
 * @param ureq
 * @param command
 */
public void gotoSearchResult(UserRequest ureq, ResultDocument document) {
    try {
        // attach the launcher data
        closeSearchDialogBox();
        String url = document.getResourceUrl();
        if (!StringHelper.containsNonWhitespace(url)) {
            // no url, no document
            getWindowControl().setWarning(getTranslator().translate("error.resource.could.not.found"));
        } else {
            BusinessControl bc = BusinessControlFactory.getInstance().createFromString(url);
            WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
            NewControllerFactory.getInstance().launch(ureq, bwControl);
        }
    } catch (Exception ex) {
        log.debug("Document not found");
        getWindowControl().setWarning(getTranslator().translate("error.resource.could.not.found"));
    }
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) WindowControl(org.olat.core.gui.control.WindowControl) ParseException(org.apache.lucene.queryparser.classic.ParseException) QueryException(org.olat.search.QueryException) ServiceNotAvailableException(org.olat.search.ServiceNotAvailableException)

Aggregations

BusinessControl (org.olat.core.id.context.BusinessControl)80 WindowControl (org.olat.core.gui.control.WindowControl)56 OLATResourceable (org.olat.core.id.OLATResourceable)24 ContextEntry (org.olat.core.id.context.ContextEntry)22 RepositoryEntry (org.olat.repository.RepositoryEntry)16 ArrayList (java.util.ArrayList)14 Controller (org.olat.core.gui.control.Controller)8 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 Window (org.olat.core.gui.components.Window)6 HistoryPoint (org.olat.core.id.context.HistoryPoint)6 CourseNode (org.olat.course.nodes.CourseNode)6 Date (java.util.Date)4 UserRequest (org.olat.core.gui.UserRequest)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)4 Identity (org.olat.core.id.Identity)4 Roles (org.olat.core.id.Roles)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)4 IOException (java.io.IOException)3