All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.memority.domino.shared.api.context.DominoContext Maven / Gradle / Ivy

Go to download

This artifact provides the API classes that are necessary to implement synchronization configuration Rules on the Memority IM platform.

There is a newer version: 3.43.1
Show newest version
/*
 * Copyright (c) 2016-2023 Memority. All Rights Reserved.
 *
 * This file is part of Memority Domino API , a Memority project.
 *
 * This file is released under the Memority Public Artifacts End-User License Agreement,
 * see 
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 */
package com.memority.domino.shared.api.context;

import com.memority.citadel.shared.api.context.ExternalContext;
import com.memority.citadel.shared.api.im.operation.ObjectPatch;
import com.memority.domino.shared.api.AttributeDelta;
import com.memority.domino.shared.api.AttributeValueConverterUtils;
import com.memority.domino.shared.api.sync.Account;
import com.memority.toolkit.rule.api.context.Context;
import com.memority.toolkit.rule.api.context.StandardContext;
import com.memority.citadel.shared.api.context.AttributeContext;
import com.memority.citadel.shared.api.im.ApiObject;
import com.memority.citadel.shared.api.im.AttributeValue;
import com.memority.domino.shared.api.sync.ShadowKind;
import com.memority.domino.shared.api.sync.SyncSituation;

import java.util.Map;

import static com.memority.domino.shared.api.AttributeValueConverterUtils.convertFromJavaToApi;
import static com.memority.domino.shared.api.context.ShadowContext.ShadowContextConfigurer;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toMap;

/**
 * The parent context made available to all Domino rules.
 * 

* Root Contexts are made available directly to groovy scripts through their corresponding key (see public constants * beginning with KEY_. */ @SuppressWarnings("JavaDoc") public class DominoContext extends StandardContext implements Context { private ShadowContext shadowContext; private ApiObject idmObject; // This is redundant with #shadowContext for the outbound case, but ApiObject is cleaner private Account account; private AttributeContext attributeContext; private SynchronizationContext synchronizationContext; private ProvisioningContext provisioningContext; private Map> patch; private ExternalContext externalContext; /** * The Shadow key, exposed as {@value #KEY_SHADOW}. Meaningful for the inbound case. */ public static final String KEY_SHADOW = "SHADOW"; /** * The Shadow key, exposed as {@value #KEY_ACCOUNT}. Meaningful for the outbound case. */ public static final String KEY_ACCOUNT = "ACCOUNT"; /** * The IM object key, exposed as {@value #KEY_IDM_OBJECT} */ public static final String KEY_IDM_OBJECT = "IDM_OBJECT"; /** * The Synchronization key, exposed as {@value #KEY_SYNC} */ public static final String KEY_SYNC = "SYNC"; /** * The Provisioning key, exposed as {@value #KEY_PROV} */ public static final String KEY_PROV = "PROV"; /** * The attribute context key, exposed as {@value #KEY_ATTRIBUTE} */ public static final String KEY_ATTRIBUTE = "ATTRIBUTE"; /** * The patch applied, exposed as {@value #KEY_PATCH} */ public static final String KEY_PATCH = "PATCH"; /** * The external context key, exposed as {@value #KEY_EXTERNAL} */ public static final String KEY_EXTERNAL = "EXTERNAL"; public ShadowContext getShadowContext() { return shadowContext; } public ApiObject getIdmObject() { return idmObject; } public Account getAccount() { return account; } public AttributeContext getAttributeContext() { return attributeContext; } public Map> getPatch() { return patch; } public SynchronizationContext getSynchronizationContext() { return synchronizationContext; } public ProvisioningContext getProvisioningContext() { return provisioningContext; } public ExternalContext getExternalContext() { return externalContext; } // Builder methods public static DominoContext create() { return new DominoContext(); } @Override public Map getRootContexts() { Map rootContexts = super.getRootContexts(); rootContexts.put(KEY_SHADOW, getShadowContext()); rootContexts.put(KEY_ACCOUNT, getAccount()); rootContexts.put(KEY_IDM_OBJECT, getIdmObject()); rootContexts.put(KEY_ATTRIBUTE, getAttributeContext()); rootContexts.put(KEY_PATCH, getPatch()); rootContexts.put(KEY_SYNC, getSynchronizationContext()); rootContexts.put(KEY_PROV, getProvisioningContext()); rootContexts.put(KEY_EXTERNAL, getExternalContext()); return rootContexts; } public DominoContext withIdmObject(ApiObject idmObject) { this.idmObject = idmObject; return this; } /** * Adds a ShadowContext to the context, with the given kind, returning a builder. * * @param shadowKind the kind of Shadow * @return a configurer that will ultimately return this DominoContext */ public ShadowContextConfigurer withShadow(ShadowKind shadowKind) { this.shadowContext = new ShadowContext(shadowKind); return this.shadowContext.configureFrom(this); } public DominoContext withAccount(Account account) { this.account = account; return this; } /** * Adds an {@link AttributeContext} configured with the given {@link AttributeValue} * * @param attributeValue configuring the {@link AttributeContext} * @return this context enhanced with an {@link AttributeContext} */ public DominoContext withAttribute(AttributeValue attributeValue) { this.attributeContext = new AttributeContext(convertFromJavaToApi(attributeValue)); return this; } public DominoContext withPatch(ObjectPatch patch) { this.patch = patch.getAttributePatches().stream() .map(AttributeDelta.class::cast) .map(AttributeValueConverterUtils::convertFromJavaToApi) .collect(toMap(AttributeValue::getId, attributeDelta -> attributeDelta)); return this; } /** * Adds a {@link SynchronizationContext} configured with the given {@link SyncSituation} * * @param syncSituation configuring the {@link SynchronizationContext} * @return this context enhanced with a {@link SynchronizationContext} */ public DominoContext withSyncSituation(SyncSituation syncSituation) { this.synchronizationContext = new SynchronizationContext(syncSituation); return this; } public DominoContext withExternalContext(Map externalContext) { this.externalContext = new ExternalContext(externalContext == null ? emptyMap() : externalContext); return this; } /** * Enable to build a {@link ProvisioningContext}. * * @return a context configurer */ public ProvisioningContext.ProvisioningContextConfigurer prov() { this.provisioningContext = new ProvisioningContext(); return this.provisioningContext.configureFrom(this); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy