use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class RemoveQosModel method setMessage.
private void setMessage() {
ArrayList<QueryParametersBase> parameters = new ArrayList<>();
ArrayList<QueryType> queryTypes = new ArrayList<>();
for (T qos : sourceListModel.getSelectedItems()) {
QueryParametersBase parameter = new IdQueryParameters(qos.getId());
parameters.add(parameter);
queryTypes.add(getUsingEntitiesByQosIdQueryType());
}
Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> handleSetMessageQueryResult(result));
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class RemoveNetworkQoSModel method setMessage.
private void setMessage() {
ArrayList<QueryParametersBase> parameters = new ArrayList<>();
ArrayList<QueryType> queryTypes = new ArrayList<>();
for (Object networkQoS : sourceListModel.getSelectedItems()) {
QueryParametersBase parameter = new IdQueryParameters(((NetworkQoS) networkQoS).getId());
parameters.add(parameter);
queryTypes.add(QueryType.GetVnicProfilesByNetworkQosId);
}
Frontend.getInstance().runMultipleQueries(queryTypes, parameters, result -> {
ArrayList<VnicProfileView> vnicProfiles = new ArrayList<>();
setHelpTag(HelpTag.remove_network_qos);
// $NON-NLS-1$
setHashName("remove_network_qos");
for (QueryReturnValue returnValue : result.getReturnValues()) {
vnicProfiles.addAll((ArrayList<VnicProfileView>) returnValue.getReturnValue());
}
if (vnicProfiles.isEmpty()) {
ArrayList<String> list = new ArrayList<>();
for (Object item : sourceListModel.getSelectedItems()) {
NetworkQoS i = (NetworkQoS) item;
list.add(i.getName());
}
setItems(list);
} else {
setMessage(ConstantsManager.getInstance().getMessages().removeNetworkQoSMessage(vnicProfiles.size()));
ArrayList<String> list = new ArrayList<>();
for (VnicProfileView item : vnicProfiles) {
list.add(item.getName());
}
setItems(list);
}
});
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderModel method initQuotaForStorageDomains.
private void initQuotaForStorageDomains() {
List<QueryType> queryTypeList = new ArrayList<>();
List<QueryParametersBase> queryParamsList = new ArrayList<>();
for (StorageDomain storage : getStorage().getItems()) {
queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
queryParamsList.add(new IdQueryParameters(storage.getId()));
}
storageQuotaMap = new HashMap<>();
Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
Iterator<QueryReturnValue> returnValuesIter = result.getReturnValues().iterator();
Iterator<StorageDomain> domainsIter = getStorage().getItems().iterator();
boolean noQuota = true;
while (domainsIter.hasNext()) {
ArrayList<Quota> quotaList = returnValuesIter.next().getReturnValue();
noQuota = noQuota && quotaList.isEmpty();
storageQuotaMap.put(domainsIter.next().getId(), quotaList);
}
if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
}
initDisksStorageDomainsList();
});
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class FiltersHelper method isSessionValid.
public static boolean isSessionValid(String session) {
try {
InitialContext ctx = null;
try {
ctx = new InitialContext();
QueryReturnValue returnValue = FiltersHelper.getBackend(ctx).runPublicQuery(QueryType.ValidateSession, new QueryParametersBase(session));
return returnValue.getSucceeded();
} finally {
if (ctx != null) {
ctx.close();
}
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.
the class SsoLogoutServlet method service.
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.debug("Entered SsoLogoutServlet");
String token = null;
try {
String engineSessionId = (String) request.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY);
if (StringUtils.isEmpty(engineSessionId) && request.getSession(false) != null) {
engineSessionId = (String) request.getSession(false).getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY);
}
if (StringUtils.isNotEmpty(engineSessionId)) {
InitialContext ctx = new InitialContext();
try {
QueryParametersBase params = new QueryParametersBase(engineSessionId);
params.setFiltered(true);
QueryReturnValue retValue = FiltersHelper.getBackend(ctx).runQuery(QueryType.GetEngineSessionIdToken, params);
token = retValue.getReturnValue();
FiltersHelper.getBackend(ctx).runAction(ActionType.LogoutSession, new ActionParametersBase(engineSessionId));
} finally {
ctx.close();
}
}
} catch (Exception ex) {
log.error("Unable to clear user session {}", ex.getMessage());
}
HttpSession session = request.getSession(false);
if (session != null) {
log.debug("Setting session attribute {}", FiltersHelper.Constants.LOGOUT_INPROGRESS);
session.setAttribute(FiltersHelper.Constants.LOGOUT_INPROGRESS, true);
}
Map<String, Object> revokeResponse = SsoOAuthServiceUtils.revoke(token);
String error_description = (String) revokeResponse.get("error_description");
String error = (String) revokeResponse.get("error");
if (StringUtils.isNotEmpty(error_description)) {
log.error("Unable to logout user: {}", error_description);
}
String url = String.format("%s://%s:%s%s/oauth2-callback", request.getScheme(), FiltersHelper.getRedirectUriServerName(request.getServerName()), request.getServerPort(), EngineLocalConfig.getInstance().getProperty("ENGINE_URI"));
String redirectUri = new URLBuilder(url).addParameter("error_description", StringUtils.defaultIfEmpty(error_description, "")).addParameter("error", StringUtils.defaultIfEmpty(error, "")).build();
if (session != null) {
log.debug("Invalidating existing session");
session.invalidate();
}
log.debug("Redirecting to {}", redirectUri);
response.sendRedirect(redirectUri);
log.debug("Exiting SsoLogoutServlet");
}
Aggregations