use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class AuthzUtils method queryImpl.
private static void queryImpl(final ExtensionProxy extension, final String namespace, final ExtMap input, final QueryResultHandler handler) {
Object opaque = extension.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.QUERY_OPEN).mput(Authz.InvokeKeys.NAMESPACE, namespace).mput(input)).get(Authz.InvokeKeys.QUERY_OPAQUE);
Collection<ExtMap> result = null;
try {
do {
result = extension.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.QUERY_EXECUTE).mput(Authz.InvokeKeys.QUERY_OPAQUE, opaque).mput(Authz.InvokeKeys.PAGE_SIZE, PAGE_SIZE)).get(Authz.InvokeKeys.QUERY_RESULT);
} while (result != null && handler.handle(result));
} finally {
extension.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authz.InvokeCommands.QUERY_CLOSE).mput(Authz.InvokeKeys.QUERY_OPAQUE, opaque));
}
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class SearchParsingUtils method generateQueryMap.
public static ExtMap generateQueryMap(String query, ExtUUID queryEntity) {
String queryPrefix = getQueryPrefixByEntity(queryEntity);
ExtMap result = new ExtMap();
result.mput(Authz.InvokeKeys.QUERY_ENTITY, queryEntity);
List<ExtMap> filter = new ArrayList<>();
if (query.indexOf(queryPrefix) == 0) {
query = query.substring(queryPrefix.length(), query.length() - 1);
int openingBracketIndex = -1;
int closingBracketIndex = -1;
while (true) {
boolean negate = false;
openingBracketIndex = query.indexOf('(', closingBracketIndex + 1);
if (openingBracketIndex == -1) {
break;
}
closingBracketIndex = query.indexOf(')', openingBracketIndex + 1);
if (query.charAt(openingBracketIndex + 1) == '|') {
openingBracketIndex += 2;
}
if (query.charAt(openingBracketIndex + 1) == '!') {
openingBracketIndex += 2;
negate = true;
}
String[] betweenBrackets = query.substring(openingBracketIndex + 1, closingBracketIndex).split("=");
String field = betweenBrackets[0];
String value = betweenBrackets[1];
if (negate) {
filter.add(new ExtMap().mput(QueryFilterRecord.OPERATOR, QueryFilterOperator.NOT).mput(QueryFilterRecord.FILTER, Arrays.asList(createMapForKeyAndValue(field, value))));
} else {
filter.add(createMapForKeyAndValue(field, value));
}
}
result.mput(QueryFilterRecord.OPERATOR, QueryFilterOperator.OR).mput(QueryFilterRecord.FILTER, filter);
}
return result;
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class AcctUtils method reportRecords.
public static void reportRecords(int reportReason, String authzName, String user, String message, Object... msgArgs) {
ExtMap input = new ExtMap();
input.put(Acct.InvokeKeys.REASON, reportReason);
input.put(Acct.InvokeKeys.PRINCIPAL_RECORD, new ExtMap().mput(Acct.PrincipalRecord.AUTHZ_NAME, authzName).mput(Acct.PrincipalRecord.USER, user).mput(Acct.InvokeKeys.MESSAGE, String.format(message, msgArgs)));
report(input);
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class ExtensionsManager method dump.
public void dump() {
log.info("Start of enabled extensions list");
for (ExtensionEntry entry : loadedEntries.values()) {
if (entry.extension != null) {
ExtMap context = entry.extension.getContext();
log.info("Instance name: '{}', Extension name: '{}', Version: '{}', Notes: '{}', License: '{}', Home: '{}', Author '{}', Build interface Version: '{}', File: '{}', Initialized: '{}'", emptyIfNull(context.get(Base.ContextKeys.INSTANCE_NAME)), emptyIfNull(context.get(Base.ContextKeys.EXTENSION_NAME)), emptyIfNull(context.get(Base.ContextKeys.VERSION)), emptyIfNull(context.get(Base.ContextKeys.EXTENSION_NOTES)), emptyIfNull(context.get(Base.ContextKeys.LICENSE)), emptyIfNull(context.get(Base.ContextKeys.HOME_URL)), emptyIfNull(context.get(Base.ContextKeys.AUTHOR)), emptyIfNull(context.get(Base.ContextKeys.BUILD_INTERFACE_VERSION)), entry.getFileName(), entry.initialized);
}
}
log.info("End of enabled extensions list");
}
use of org.ovirt.engine.api.extensions.ExtMap in project ovirt-engine by oVirt.
the class LoggerHandler method publish.
@Override
public void publish(LogRecord record) {
ExtMap publishInputMap = new ExtMap().mput(Base.InvokeKeys.COMMAND, Logger.InvokeCommands.PUBLISH).mput(Logger.InvokeKeys.LOG_RECORD, record);
ExtMap publishOutputMap = new ExtMap();
for (ExtensionProxy extension : extensions) {
try {
extension.invoke(publishInputMap, publishOutputMap);
} catch (Exception ex) {
// ignore, logging this exception will result in infinite loop
}
}
}
Aggregations