use of com.evolveum.midpoint.web.session.SessionStorage in project midpoint by Evolveum.
the class PageRepositoryQuery method useInObjectListPerformed.
private void useInObjectListPerformed(AjaxRequestTarget target) {
final RepoQueryDto dto = model.getObject();
String queryText = dto.getMidPointQuery();
if (StringUtils.isBlank(queryText)) {
queryText = "<query/>";
}
RepositoryQueryDiagRequest request = new RepositoryQueryDiagRequest();
Task task = createSimpleTask(OPERATION_CHECK_QUERY);
OperationResult result = task.getResult();
try {
// just to parse the query
updateRequestWithMidpointQuery(request, dto.getObjectType(), queryText, task, result);
ObjectFilter parsedFilter = request.getQuery().getFilter();
String filterAsString;
if (parsedFilter != null) {
SearchFilterType filterType = QueryConvertor.createSearchFilterType(parsedFilter, getPrismContext());
filterAsString = getPrismContext().xmlSerializer().serializeRealValue(filterType, SchemaConstantsGenerated.Q_FILTER);
// TODO remove extra xmlns from serialized value
} else {
filterAsString = "";
}
Class<? extends PageBase> listPageClass = WebComponentUtil.getObjectListPage(request.getType());
String storageKey = listPageClass != null ? WebComponentUtil.getStorageKeyForPage(listPageClass) : null;
if (storageKey == null) {
// shouldn't occur because of button visibility
error("No page to redirect for " + dto.getObjectType());
target.add(getFeedbackPanel());
return;
}
Search search = SearchFactory.createSearch(request.getType(), this);
search.setAdvancedQuery(filterAsString);
search.setShowAdvanced(true);
if (!search.isAdvancedQueryValid(getPrismContext())) {
// shouldn't occur because the query was already parsed
error("Query is not valid: " + search.getAdvancedError());
target.add(getFeedbackPanel());
return;
}
SessionStorage sessionStorage = ((MidPointAuthWebSession) getSession()).getSessionStorage();
PageStorage storage = sessionStorage.getPageStorageMap().get(storageKey);
if (storage == null) {
storage = sessionStorage.initPageStorage(storageKey);
}
storage.setSearch(search);
setResponsePage(listPageClass);
} catch (CommonException | RuntimeException e) {
result.recordFatalError("Couldn't parse query: " + e.getMessage(), e);
showResult(result);
target.add(this);
}
}
Aggregations