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