Search in sources :

Example 26 with ExtMap

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));
    }
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap)

Example 27 with ExtMap

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;
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) ArrayList(java.util.ArrayList)

Example 28 with ExtMap

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);
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap)

Example 29 with ExtMap

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");
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap)

Example 30 with ExtMap

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
        }
    }
}
Also used : ExtMap(org.ovirt.engine.api.extensions.ExtMap) ExtensionProxy(org.ovirt.engine.core.extensions.mgr.ExtensionProxy)

Aggregations

ExtMap (org.ovirt.engine.api.extensions.ExtMap)48 Collection (java.util.Collection)15 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)5 Map (java.util.Map)5 IOException (java.io.IOException)4 AuthenticationProfile (org.ovirt.engine.core.aaa.AuthenticationProfile)4 DirectoryGroup (org.ovirt.engine.core.aaa.DirectoryGroup)4 Properties (java.util.Properties)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 ExtensionProxy (org.ovirt.engine.core.extensions.mgr.ExtensionProxy)3 HashSet (java.util.HashSet)2 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 ServletException (javax.servlet.ServletException)2 ExtKey (org.ovirt.engine.api.extensions.ExtKey)2 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)2 QueryData (org.ovirt.engine.core.aaa.QueryData)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 CreateUserSessionParameters (org.ovirt.engine.core.common.action.CreateUserSessionParameters)2