Skip to content

Commit

Permalink
Add empty AsyncUpdateConnector
Browse files Browse the repository at this point in the history
It will receive asynchronous updates from a resource (via messaging
or REST or whatever) and pass them to midPoint.
  • Loading branch information
mederly committed Mar 7, 2019
1 parent 5fad9be commit 19837d9
Show file tree
Hide file tree
Showing 16 changed files with 434 additions and 127 deletions.
Expand Up @@ -250,6 +250,8 @@ public abstract class SchemaConstants {
public static final String NS_PROVISIONING_CHANNEL = NS_PROVISIONING + "/channels-3";
public static final QName CHANGE_CHANNEL_LIVE_SYNC = new QName(NS_PROVISIONING_CHANNEL, "liveSync");
public static final String CHANGE_CHANNEL_LIVE_SYNC_URI = QNameUtil.qNameToUri(CHANGE_CHANNEL_LIVE_SYNC);
public static final QName CHANGE_CHANNEL_ASYNC_UPDATE = new QName(NS_PROVISIONING_CHANNEL, "asyncUpdate");
public static final String CHANGE_CHANNEL_ASYNC_UPDATE_URI = QNameUtil.qNameToUri(CHANGE_CHANNEL_ASYNC_UPDATE);
public static final QName CHANGE_CHANNEL_RECON = new QName(NS_PROVISIONING_CHANNEL, "reconciliation");
public static final String CHANGE_CHANNEL_RECON_URI = QNameUtil.qNameToUri(CHANGE_CHANNEL_RECON);
public static final QName CHANGE_CHANNEL_RECOMPUTE = new QName(NS_PROVISIONING_CHANNEL, "recompute");
Expand Down
Expand Up @@ -329,7 +329,21 @@

<xsd:element name="liveSync" type="tns:LiveSyncCapabilityType"/>


<xsd:complexType name="AsyncUpdateCapabilityType">
<xsd:annotation>
<xsd:documentation>
Describes capability to process asynchronous updates. Note that this is currently supported only
by the built-in AsyncUpdateConnector.
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:CapabilityType">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:element name="asyncUpdate" type="tns:AsyncUpdateCapabilityType"/>

<xsd:complexType name="AbstractWriteCapabilityType" abstract="true">
<xsd:annotation>
<xsd:documentation>
Expand Down
Expand Up @@ -15,62 +15,37 @@
*/
package com.evolveum.midpoint.model.impl;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.model.api.TaskService;
import com.evolveum.midpoint.prism.ConsistencyCheckScope;
import com.evolveum.midpoint.prism.crypto.Protector;

import com.evolveum.midpoint.prism.delta.*;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
import com.evolveum.midpoint.prism.ConsistencyCheckScope;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.provisioning.api.ChangeNotificationDispatcher;
import com.evolveum.midpoint.provisioning.api.GenericConnectorException;
import com.evolveum.midpoint.provisioning.api.ResourceEventDescription;
import com.evolveum.midpoint.repo.api.PreconditionViolationException;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.repo.cache.RepositoryCache;
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ObjectDeltaOperation;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.PolicyViolationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;

/**
* Simple version of model service exposing CRUD-like operations. This is common facade for webservice and REST services.
Expand Down
Expand Up @@ -45,11 +45,11 @@
import java.io.File;

/**
* Tests model.notifyChange using artificially constructed ResourceObjectShadowChangeDescriptionType objects.
* Tests model.notifyChange using manually constructed ResourceObjectShadowChangeDescriptionType objects.
*/
@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestMessagingUsingShadows extends AbstractInitializedModelIntegrationTest {
public class TestNotifyChange extends AbstractInitializedModelIntegrationTest {

public static final File TEST_DIR = new File(MidPointTestConstants.TEST_RESOURCES_DIR, "messaging");

Expand Down Expand Up @@ -97,7 +97,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
public void test000Sanity() throws Exception {
final String TEST_NAME = "test000Sanity";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);

OperationResult testResultGrouper = modelService.testResource(RESOURCE_GROUPER_OID, task);
TestUtil.assertSuccess(testResultGrouper);
Expand All @@ -110,7 +110,7 @@ public void test000Sanity() throws Exception {
public void test100AddAnderson() throws Exception {
final String TEST_NAME = "test100AddAnderson";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// GIVEN
Expand All @@ -135,10 +135,10 @@ public void test100AddAnderson() throws Exception {
.links()
.single()
.resolveTarget()
.display()
.assertKind(ShadowKindType.ACCOUNT)
.assertIntent(GROUPER_USER_INTENT)
.assertResource(RESOURCE_GROUPER_OID)
.display();
.assertResource(RESOURCE_GROUPER_OID);
}

/**
Expand All @@ -148,7 +148,7 @@ public void test100AddAnderson() throws Exception {
public void test105AddLewis() throws Exception {
final String TEST_NAME = "test105AddLewis";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// GIVEN
Expand Down Expand Up @@ -189,7 +189,7 @@ public void test105AddLewis() throws Exception {
public void test110AddAlumni() throws Exception {
final String TEST_NAME = "test110AddAlumni";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// GIVEN
Expand Down Expand Up @@ -227,7 +227,7 @@ public void test110AddAlumni() throws Exception {
public void test120AddStaff() throws Exception {
final String TEST_NAME = "test120AddStaff";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// GIVEN
Expand Down Expand Up @@ -265,7 +265,7 @@ public void test120AddStaff() throws Exception {
public void test200AddGroupsForAnderson() throws Exception {
final String TEST_NAME = "test200AddGroupsForAnderson";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// GIVEN
Expand Down Expand Up @@ -303,7 +303,7 @@ public void test200AddGroupsForAnderson() throws Exception {
public void test210AddGroupsForLewis() throws Exception {
final String TEST_NAME = "test210AddGroupsForLewis";
TestUtil.displayTestTitle(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestMessagingUsingShadows.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TestNotifyChange.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

// GIVEN
Expand Down
@@ -0,0 +1,37 @@
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<resourceObjectShadowChangeDescription
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<objectDelta>
<t:changeType>add</t:changeType>
<t:objectType>c:ShadowType</t:objectType>
<t:objectToAdd xsi:type="ShadowType">
<resourceRef oid="bbb9900a-b53d-4453-b60b-908725e3950e"/>
<objectClass>ri:AccountObjectClass</objectClass>
<attributes>
<icfs:name>banderson</icfs:name>
<icfs:uid>banderson</icfs:uid>
</attributes>
</t:objectToAdd>
</objectDelta>
<channel>http://midpoint.evolveum.com/xml/ns/public/provisioning/channels-3#asyncUpdate</channel>
</resourceObjectShadowChangeDescription>
Expand Up @@ -30,8 +30,7 @@
public interface ResourceEventListener extends ProvisioningListener {

void notifyEvent(ResourceEventDescription eventDescription, Task task, OperationResult parentResult) throws SchemaException,
CommunicationException, ConfigurationException,
SecurityViolationException, ObjectNotFoundException,
GenericConnectorException, ObjectAlreadyExistsException,
ExpressionEvaluationException, PolicyViolationException, PreconditionViolationException;
CommunicationException, ConfigurationException, SecurityViolationException, ObjectNotFoundException,
GenericConnectorException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException,
PreconditionViolationException;
}

0 comments on commit 19837d9

Please sign in to comment.