Search in sources :

Example 1 with MapValueResolver

use of org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver in project mule by mulesoft.

the class OAuthConnectionProviderObjectBuilder method getInitialOAuthConfig.

private OAuthConfig getInitialOAuthConfig() throws MuleException {
    CoreEvent initialiserEvent = null;
    try {
        initialiserEvent = getInitialiserEvent(muleContext);
        MapValueResolver mapResolver = staticOnly((MapValueResolver) resolverSet.getResolvers().get(OAUTH_AUTHORIZATION_CODE_GROUP_NAME));
        AuthCodeConfig authCodeConfig = buildAuthCodeConfig(mapResolver.resolve(from(initialiserEvent)));
        Optional<OAuthObjectStoreConfig> storeConfig = buildOAuthObjectStoreConfig(initialiserEvent);
        mapResolver = staticOnly((MapValueResolver) resolverSet.getResolvers().get(OAUTH_CALLBACK_GROUP_NAME));
        OAuthCallbackConfig callbackConfig = buildOAuthCallbackConfig(mapResolver.resolve(from(initialiserEvent)));
        return new OAuthConfig(ownerConfigName, authCodeConfig, callbackConfig, storeConfig, grantType, getCustomParameters(initialiserEvent), callbackValues);
    } finally {
        if (initialiserEvent != null) {
            ((BaseEventContext) initialiserEvent.getContext()).success();
        }
    }
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) MapValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver)

Example 2 with MapValueResolver

use of org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver in project mule by mulesoft.

the class OAuthConnectionProviderObjectBuilder method staticOnly.

private MapValueResolver staticOnly(MapValueResolver resolver) throws MuleException {
    List<ValueResolver> staticKeyResolvers = new ArrayList<>(resolver.getKeyResolvers().size());
    List<ValueResolver> staticValueResolvers = new ArrayList<>(resolver.getValueResolvers().size());
    Iterator<ValueResolver> keyResolvers = resolver.getKeyResolvers().iterator();
    Iterator<ValueResolver> valueResolvers = resolver.getValueResolvers().iterator();
    while (keyResolvers.hasNext() && valueResolvers.hasNext()) {
        ValueResolver keyResolver = keyResolvers.next();
        ValueResolver valueResolver = valueResolvers.next();
        if (!keyResolver.isDynamic() && !valueResolver.isDynamic()) {
            staticKeyResolvers.add(keyResolver);
            staticValueResolvers.add(valueResolver);
        }
    }
    MapValueResolver result = new MapValueResolver(HashMap.class, staticKeyResolvers, staticValueResolvers, getReflectionCache(), muleContext);
    initialiseIfNeeded(result, muleContext);
    return result;
}
Also used : MapValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) MapValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver) ArrayList(java.util.ArrayList)

Aggregations

MapValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver)2 ArrayList (java.util.ArrayList)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)1 ValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver)1