> deltas = new ArrayList<>();
- deltas.add(delta);
- ModelImplUtils.encrypt(deltas, protector, null, parentResult);
- eventDescription.setDelta(delta);
-
- eventDescription.setSourceChannel(changeDescription.getChannel());
-
- dispatcher.notifyEvent(eventDescription, task, parentResult);
- parentResult.computeStatus();
- task.setResult(parentResult);
- }
-
-
/**
*
* Add new object.
@@ -447,82 +339,4 @@ public void modifyObject(Class type, String oid,
RepositoryCache.exit();
}
}
-
- public PrismObject findShadowOwner(String accountOid, Task task, OperationResult parentResult)
- throws ObjectNotFoundException, SecurityViolationException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException {
- return modelService.findShadowOwner(accountOid, task, parentResult);
- }
-
- public List> listResourceObjects(String resourceOid, QName objectClass,
- ObjectPaging paging, Task task, OperationResult parentResult) throws SchemaException,
- ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
- return modelService.listResourceObjects(resourceOid, objectClass, paging, task, parentResult);
- }
-
- public void importFromResource(String resourceOid, QName objectClass, Task task, OperationResult parentResult)
- throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
- modelService.importFromResource(resourceOid, objectClass, task, parentResult);
- }
-
- public OperationResult testResource(String resourceOid, Task task) throws ObjectNotFoundException {
- return modelService.testResource(resourceOid, task);
- }
-
-
- //TASK AREA
- public boolean suspendTask(String taskOid, long waitForStop, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- return taskService.suspendTask(taskOid, waitForStop, operationTask, parentResult);
- }
-
- public void suspendAndDeleteTask(String taskOid, long waitForStop, boolean alsoSubtasks, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.suspendAndDeleteTask(taskOid, waitForStop, alsoSubtasks, operationTask, parentResult);
- }
-
- public void resumeTask(String taskOid, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.resumeTask(taskOid, operationTask, parentResult);
- }
-
- public void scheduleTaskNow(String taskOid, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.scheduleTaskNow(taskOid, operationTask, parentResult);
- }
-
- @SuppressWarnings("unused")
- public PrismObject getTaskByIdentifier(String identifier, Collection> options, Task operationTask, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException, CommunicationException {
- return taskService.getTaskByIdentifier(identifier, options, operationTask, parentResult);
- }
-
- public boolean deactivateServiceThreads(long timeToWait, Task operationTask, OperationResult parentResult) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- return taskService.deactivateServiceThreads(timeToWait, operationTask, parentResult);
- }
-
- public void reactivateServiceThreads(Task operationTask, OperationResult parentResult) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.reactivateServiceThreads(operationTask, parentResult);
- }
-
- @SuppressWarnings("unused")
- public boolean getServiceThreadsActivationState() {
- return taskService.getServiceThreadsActivationState();
- }
-
- public void stopSchedulers(Collection nodeIdentifiers, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.stopSchedulers(nodeIdentifiers, operationTask, parentResult);
- }
-
- public boolean stopSchedulersAndTasks(Collection nodeIdentifiers, long waitTime, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- return taskService.stopSchedulersAndTasks(nodeIdentifiers, waitTime, operationTask, parentResult);
- }
-
- public void startSchedulers(Collection nodeIdentifiers, Task operationTask, OperationResult parentResult) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.startSchedulers(nodeIdentifiers, operationTask, parentResult);
- }
-
- public void synchronizeTasks(Task operationTask, OperationResult parentResult) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
- taskService.synchronizeTasks(operationTask, parentResult);
- }
-
- @SuppressWarnings("unused")
- public List getAllTaskCategories() {
- return taskService.getAllTaskCategories();
- }
-
}
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java
index b66899a8141..27a2c9c3094 100644
--- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelRestService.java
@@ -575,7 +575,7 @@ public Response deleteObject(@PathParam("type") String type, @PathParam("id") St
Response response;
try {
if (clazz.isAssignableFrom(TaskType.class)) {
- model.suspendAndDeleteTask(id, WAIT_FOR_TASK_STOP, true, task, parentResult);
+ taskService.suspendAndDeleteTask(id, WAIT_FOR_TASK_STOP, true, task, parentResult);
parentResult.computeStatus();
finishRequest(task);
if (parentResult.isSuccess()) {
@@ -647,7 +647,7 @@ public Response notifyChange(ResourceObjectShadowChangeDescriptionType changeDes
Response response;
try {
- model.notifyChange(changeDescription, parentResult, task);
+ modelService.notifyChange(changeDescription, task, parentResult);
response = RestServiceUtil.createResponse(Response.Status.OK, parentResult);
// return Response.ok().build();
// String oldShadowOid = changeDescription.getOldShadowOid();
@@ -679,7 +679,7 @@ public Response findShadowOwner(@PathParam("oid") String shadowOid, @Context Mes
Response response;
try {
- PrismObject user = model.findShadowOwner(shadowOid, task, parentResult);
+ PrismObject user = modelService.findShadowOwner(shadowOid, task, parentResult);
// response = Response.ok().entity(user).build();
response = RestServiceUtil.createResponse(Response.Status.OK, user, parentResult);
} catch (Exception ex) {
@@ -769,7 +769,7 @@ public Response importFromResource(@PathParam("resourceOid") String resourceOid,
QName objClass = new QName(MidPointConstants.NS_RI, objectClass);
Response response;
try {
- model.importFromResource(resourceOid, objClass, task, parentResult);
+ modelService.importFromResource(resourceOid, objClass, task, parentResult);
response = RestServiceUtil.createResponse(Response.Status.SEE_OTHER, (uriInfo.getBaseUriBuilder().path(this.getClass(), "getObject")
.build(ObjectTypes.TASK.getRestType(), task.getOid())), parentResult);
// response = Response.seeOther((uriInfo.getBaseUriBuilder().path(this.getClass(), "getObject")
@@ -795,7 +795,7 @@ public Response testResource(@PathParam("resourceOid") String resourceOid, @Cont
Response response;
OperationResult testResult = null;
try {
- testResult = model.testResource(resourceOid, task);
+ testResult = modelService.testResource(resourceOid, task);
response = RestServiceUtil.createResponse(Response.Status.OK, testResult, parentResult);
// response = Response.ok(testResult).build();
} catch (Exception ex) {
@@ -819,7 +819,7 @@ public Response suspendTask(@PathParam("oid") String taskOid, @Context MessageCo
Response response;
try {
- model.suspendTask(taskOid, WAIT_FOR_TASK_STOP, task, parentResult);
+ taskService.suspendTask(taskOid, WAIT_FOR_TASK_STOP, task, parentResult);
parentResult.computeStatus();
response = RestServiceUtil.createResponse(Response.Status.NO_CONTENT, task, parentResult);
} catch (Exception ex) {
@@ -865,7 +865,7 @@ public Response resumeTask(@PathParam("oid") String taskOid, @Context MessageCon
Response response;
try {
- model.resumeTask(taskOid, task, parentResult);
+ taskService.resumeTask(taskOid, task, parentResult);
parentResult.computeStatus();
response = RestServiceUtil.createResponse(Response.Status.ACCEPTED, parentResult);
} catch (Exception ex) {
@@ -886,7 +886,7 @@ public Response scheduleTaskNow(@PathParam("oid") String taskOid, @Context Messa
Response response;
try {
- model.scheduleTaskNow(taskOid, task, parentResult);
+ taskService.scheduleTaskNow(taskOid, task, parentResult);
parentResult.computeStatus();
response = RestServiceUtil.createResponse(Response.Status.NO_CONTENT, parentResult);
} catch (Exception ex) {
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelWebService.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelWebService.java
index ca6ef979338..11bd24b1885 100644
--- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelWebService.java
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/ModelWebService.java
@@ -170,7 +170,7 @@ public void findShadowOwner(String accountOid, Holder userHolder, Hold
auditLogin(task);
OperationResult operationResult = task.getResult();
try {
- PrismObject user = model.findShadowOwner(accountOid, task, operationResult);
+ PrismObject user = modelService.findShadowOwner(accountOid, task, operationResult);
handleOperationResult(operationResult, result);
if (user != null) {
userHolder.value = user.asObjectable();
@@ -191,7 +191,7 @@ public OperationResultType testResource(String resourceOid) throws FaultMessage
Task task = createTaskInstance(TEST_RESOURCE);
auditLogin(task);
try {
- OperationResult testResult = model.testResource(resourceOid, task);
+ OperationResult testResult = modelService.testResource(resourceOid, task);
return handleOperationResult(testResult);
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "# MODEL testResource() failed", ex);
@@ -403,7 +403,7 @@ public TaskType importFromResource(String resourceOid, QName objectClass)
OperationResult operationResult = task.getResult();
try {
- model.importFromResource(resourceOid, objectClass, task, operationResult);
+ modelService.importFromResource(resourceOid, objectClass, task, operationResult);
operationResult.computeStatus();
return handleTaskResult(task);
} catch (Exception ex) {
@@ -426,12 +426,14 @@ public TaskType notifyChange(ResourceObjectShadowChangeDescriptionType changeDes
OperationResult parentResult = task.getResult();
try {
- model.notifyChange(changeDescription, parentResult, task);
- } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ObjectAlreadyExistsException | ExpressionEvaluationException | RuntimeException | Error | PolicyViolationException | PreconditionViolationException ex) {
- LoggingUtils.logException(LOGGER, "# MODEL notifyChange() failed", ex);
- auditLogout(task);
- throwFault(ex, parentResult);
- }
+ modelService.notifyChange(changeDescription, task, parentResult);
+ } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException |
+ SecurityViolationException | ObjectAlreadyExistsException | ExpressionEvaluationException |
+ RuntimeException | Error | PolicyViolationException ex) {
+ LoggingUtils.logException(LOGGER, "# MODEL notifyChange() failed", ex);
+ auditLogout(task);
+ throwFault(ex, parentResult);
+ }
LOGGER.info("notify change ended.");
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java
index c7f88a0fa95..55ceee82c64 100644
--- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java
@@ -29,22 +29,22 @@
import com.evolveum.midpoint.model.impl.importer.ImportAccountsFromResourceTaskHandler;
import com.evolveum.midpoint.model.impl.importer.ObjectImporter;
import com.evolveum.midpoint.model.impl.lens.*;
+import com.evolveum.midpoint.model.impl.messaging.MessageProcessor;
import com.evolveum.midpoint.model.impl.scripting.ExecutionContext;
import com.evolveum.midpoint.model.impl.scripting.ScriptingExpressionEvaluator;
-import com.evolveum.midpoint.model.impl.security.NodeAuthenticationToken;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.DiffUtil;
+import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.*;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.query.*;
import com.evolveum.midpoint.prism.util.CloneUtil;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
-import com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions;
-import com.evolveum.midpoint.provisioning.api.ProvisioningService;
+import com.evolveum.midpoint.provisioning.api.*;
import com.evolveum.midpoint.repo.api.PreconditionViolationException;
import com.evolveum.midpoint.repo.api.RepoAddOptions;
import com.evolveum.midpoint.repo.api.RepositoryService;
@@ -80,13 +80,13 @@
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ScriptingExpressionType;
import com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType;
+import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import javax.xml.datatype.XMLGregorianCalendar;
@@ -156,7 +156,8 @@ public class ModelController implements ModelService, TaskService, WorkflowServi
@Autowired private EmulatedSearchProvider emulatedSearchProvider;
@Autowired private CacheRegistry cacheRegistry;
@Autowired private ClockworkMedic clockworkMedic;
-
+ @Autowired private ChangeNotificationDispatcher dispatcher;
+ @Autowired private MessageProcessor messageProcessor;
@Autowired
@Qualifier("cacheRepositoryService")
private transient RepositoryService cacheRepositoryService;
@@ -2323,4 +2324,69 @@ public String getTaskThreadsDump(@NotNull String taskOid, @NotNull Task task, @N
//endregion
+ public void notifyChange(ResourceObjectShadowChangeDescriptionType changeDescription, Task task, OperationResult parentResult)
+ throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException,
+ ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, PolicyViolationException {
+
+ String oldShadowOid = changeDescription.getOldShadowOid();
+ ResourceEventDescription eventDescription = new ResourceEventDescription();
+
+ PrismObject oldShadow;
+ LOGGER.trace("resolving old object");
+ if (!StringUtils.isEmpty(oldShadowOid)) {
+ oldShadow = getObject(ShadowType.class, oldShadowOid, SelectorOptions.createCollection(GetOperationOptions.createDoNotDiscovery()), task, parentResult);
+ eventDescription.setOldShadow(oldShadow);
+ LOGGER.trace("old object resolved to: {}", oldShadow.debugDumpLazily());
+ } else {
+ LOGGER.trace("Old shadow null");
+ }
+
+ PrismObject currentShadow = null;
+ ShadowType currentShadowType = changeDescription.getCurrentShadow();
+ LOGGER.trace("resolving current shadow");
+ if (currentShadowType != null) {
+ prismContext.adopt(currentShadowType);
+ currentShadow = currentShadowType.asPrismObject();
+ LOGGER.trace("current shadow resolved to {}", currentShadow.debugDumpLazily());
+ }
+
+ eventDescription.setCurrentShadow(currentShadow);
+
+ ObjectDeltaType deltaType = changeDescription.getObjectDelta();
+
+ if (deltaType != null) {
+
+ PrismObject shadowToAdd;
+ ObjectDelta delta = prismContext.deltaFactory().object().createEmptyDelta(ShadowType.class, deltaType.getOid(),
+ ChangeType.toChangeType(deltaType.getChangeType()));
+
+ if (delta.getChangeType() == ChangeType.ADD) {
+ if (deltaType.getObjectToAdd() == null) {
+ LOGGER.trace("No object to add specified. Check your delta. Add delta must contain object to add");
+ throw new IllegalArgumentException("No object to add specified. Check your delta. Add delta must contain object to add");
+ }
+ Object objToAdd = deltaType.getObjectToAdd();
+ if (!(objToAdd instanceof ShadowType)) {
+ LOGGER.trace("Wrong object specified in change description. Expected on the the shadow type, but got " + objToAdd.getClass().getSimpleName());
+ throw new IllegalArgumentException("Wrong object specified in change description. Expected on the the shadow type, but got " + objToAdd.getClass().getSimpleName());
+ }
+ prismContext.adopt((ShadowType)objToAdd);
+
+ shadowToAdd = ((ShadowType) objToAdd).asPrismObject();
+ LOGGER.trace("object to add: {}", shadowToAdd.debugDump());
+ delta.setObjectToAdd(shadowToAdd);
+ } else {
+ Collection extends ItemDelta> modifications = DeltaConvertor.toModifications(deltaType.getItemDelta(), prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class));
+ delta.addModifications(modifications);
+ }
+ ModelImplUtils.encrypt(Collections.singletonList(delta), protector, null, parentResult);
+ eventDescription.setDelta(delta);
+ }
+
+ eventDescription.setSourceChannel(changeDescription.getChannel());
+
+ dispatcher.notifyEvent(eventDescription, task, parentResult);
+ parentResult.computeStatus();
+ task.setResult(parentResult);
+ }
}
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java
index 5538190966f..25ebdfb5978 100644
--- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java
@@ -36,6 +36,7 @@
import com.evolveum.midpoint.model.impl.lens.LensFocusContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.SynchronizationIntent;
+import com.evolveum.midpoint.model.impl.messaging.MessageWrapper;
import com.evolveum.midpoint.model.impl.sync.CorrelationConfirmationEvaluator;
import com.evolveum.midpoint.model.impl.sync.SynchronizationContext;
import com.evolveum.midpoint.model.impl.sync.SynchronizationServiceUtils;
@@ -52,6 +53,10 @@
import com.evolveum.midpoint.repo.common.expression.ExpressionFactory;
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
+import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
+import com.evolveum.midpoint.schema.processor.ResourceAttribute;
+import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
+import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.schema.util.*;
@@ -88,6 +93,7 @@
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.*;
@@ -1815,4 +1821,14 @@ public void applyDefinition(T object)
public S_ItemEntry deltaFor(Class objectClass) throws SchemaException {
return prismContext.deltaFor(objectClass);
}
+
+ // temporary
+ public MessageWrapper wrap(AsyncUpdateMessageType message) {
+ return new MessageWrapper(message);
+ }
+
+ // temporary
+ public Map getMessageBodyAsMap(AsyncUpdateMessageType message) throws IOException {
+ return wrap(message).getBodyAsMap();
+ }
}
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/i2/MessageProcessingTaskHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/i2/MessageProcessingTaskHandler.java
new file mode 100644
index 00000000000..9c7884c4146
--- /dev/null
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/i2/MessageProcessingTaskHandler.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package com.evolveum.midpoint.model.impl.i2;
+
+import com.evolveum.midpoint.model.impl.ModelConstants;
+import com.evolveum.midpoint.task.api.*;
+import com.evolveum.midpoint.util.logging.LoggingUtils;
+import com.evolveum.midpoint.util.logging.Trace;
+import com.evolveum.midpoint.util.logging.TraceManager;
+import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskPartitionDefinitionType;
+import com.rabbitmq.client.Channel;
+import com.rabbitmq.client.Connection;
+import com.rabbitmq.client.ConnectionFactory;
+import com.rabbitmq.client.DeliverCallback;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+/**
+ *
+ */
+@Component
+public class MessageProcessingTaskHandler implements TaskHandler {
+
+ private static final transient Trace LOGGER = TraceManager.getTrace(MessageProcessingTaskHandler.class);
+
+ public static final String HANDLER_URI = ModelConstants.NS_SYNCHRONIZATION_TASK_PREFIX + "/message-processing/handler-3";
+
+ @Autowired private TaskManager taskManager;
+
+ @PostConstruct
+ private void initialize() {
+ taskManager.registerHandler(HANDLER_URI, this);
+ System.out.println("URI = " + HANDLER_URI);
+ }
+
+ @Override
+ public TaskRunResult run(RunningTask task, TaskPartitionDefinitionType partitionDefinition) {
+
+ ConnectionFactory connectionFactory = new ConnectionFactory();
+
+// connectionFactory.setU
+// connectionFactory.setHost("192.168.56.101");
+// factory.setUsername("guest");
+// factory.setPassword("guest");
+// factory.setVirtualHost("/");
+// String queueName = "sampleQueue";
+//
+// try (Connection connection = factory.newConnection();
+// Channel channel = connection.createChannel()) {
+//
+// DeliverCallback deliverCallback = (consumerTag, message) -> {
+// byte[] body = message.getBody();
+//
+// System.out.println("Body: " + new String(body));
+// channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
+// task.incrementProgressAndStoreStatsIfNeeded();
+// };
+// channel.basicConsume(queueName, false, deliverCallback, consumerTag -> {});
+//
+// while (task.canRun()) {
+// Thread.sleep(1000L);
+// }
+// } catch (Throwable t) {
+// LoggingUtils.logUnexpectedException(LOGGER, "Exception on RabbitMQ", t);
+// }
+
+ TaskRunResult rv = new TaskRunResult();
+ rv.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED);
+ rv.setOperationResult(task.getResult());
+ return rv;
+ }
+
+ @Override
+ public String getCategoryName(Task task) {
+ return TaskCategory.LIVE_SYNCHRONIZATION;
+ }
+}
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java
index 919feca1d65..cd6d51450f2 100644
--- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/Projector.java
@@ -19,38 +19,26 @@
import static com.evolveum.midpoint.model.api.ProgressInformation.StateType.ENTERING;
import static com.evolveum.midpoint.schema.internals.InternalsConfig.consistencyChecks;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import javax.xml.datatype.XMLGregorianCalendar;
-import com.evolveum.midpoint.model.api.ProgressInformation;
-
-import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.evolveum.midpoint.common.Clock;
-import com.evolveum.midpoint.model.api.context.EvaluatedAssignment;
-import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule;
+import com.evolveum.midpoint.model.api.ProgressInformation;
import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision;
import com.evolveum.midpoint.model.impl.lens.ClockworkMedic;
-import com.evolveum.midpoint.model.impl.lens.EvaluatedAssignmentImpl;
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.model.impl.lens.LensProjectionContext;
import com.evolveum.midpoint.model.impl.lens.LensUtil;
import com.evolveum.midpoint.model.impl.lens.projector.credentials.ProjectionCredentialsProcessor;
-import com.evolveum.midpoint.model.impl.lens.projector.focus.AssignmentProcessor;
-import com.evolveum.midpoint.model.impl.lens.projector.focus.AssignmentTripleEvaluator;
import com.evolveum.midpoint.model.impl.lens.projector.focus.AssignmentHolderProcessor;
+import com.evolveum.midpoint.model.impl.lens.projector.focus.AssignmentProcessor;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
-import com.evolveum.midpoint.prism.PrismContext;
-import com.evolveum.midpoint.prism.delta.DeltaSetTriple;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.repo.api.PreconditionViolationException;
-import com.evolveum.midpoint.repo.common.CounterManager;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.internals.InternalCounters;
import com.evolveum.midpoint.schema.internals.InternalMonitor;
@@ -67,6 +55,9 @@
import com.evolveum.midpoint.util.exception.SecurityViolationException;
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.PartialProcessingOptionsType;
+import com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingTypeType;
/**
* Projector recomputes the context. It takes the context with a few basic data as input. It uses all the policies
@@ -99,9 +90,7 @@ public class Projector {
@Autowired private Clock clock;
@Autowired private ClockworkMedic medic;
- @Autowired private CounterManager counterManager;
-
- private static final Trace LOGGER = TraceManager.getTrace(Projector.class);
+ private static final Trace LOGGER = TraceManager.getTrace(Projector.class);
/**
* Runs one projection wave, starting at current execution wave.
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/policy/PolicyRuleSuspendTaskExecutor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/policy/PolicyRuleSuspendTaskExecutor.java
index a29e8462733..d3ec4c2a4f7 100644
--- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/policy/PolicyRuleSuspendTaskExecutor.java
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/projector/policy/PolicyRuleSuspendTaskExecutor.java
@@ -22,8 +22,9 @@
import com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule;
import com.evolveum.midpoint.model.api.context.ModelContext;
import com.evolveum.midpoint.model.api.context.ModelElementContext;
-import com.evolveum.midpoint.repo.common.CounterManager;
-import com.evolveum.midpoint.repo.common.CounterSepcification;
+import com.evolveum.midpoint.repo.api.CounterManager;
+import com.evolveum.midpoint.repo.api.CounterSepcification;
+import com.evolveum.midpoint.repo.cache.CacheCounterManager;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DebugDumpable;
@@ -48,7 +49,6 @@ public class PolicyRuleSuspendTaskExecutor {
private static final Trace LOGGER = TraceManager.getTrace(PolicyRuleSuspendTaskExecutor.class);
@Autowired private CounterManager counterManager;
-// @Autowired private TaskManager taskManager;
public void execute(@NotNull ModelContext context, Task task, OperationResult result) throws ThresholdPolicyViolationException, ObjectNotFoundException, SchemaException {
ModelElementContext focusCtx = context.getFocusContext();
@@ -58,7 +58,7 @@ public void execute(@NotNull ModelContext context, Tas
}
for (EvaluatedPolicyRule policyRule : focusCtx.getPolicyRules()) {
- CounterSepcification counterSpec = counterManager.getCounterSpec(task, policyRule.getPolicyRuleIdentifier(), policyRule.getPolicyRule());
+ CounterSepcification counterSpec = counterManager.getCounterSpec(task.getTaskType(), policyRule.getPolicyRuleIdentifier(), policyRule.getPolicyRule());
LOGGER.trace("Found counter specification {} for {}", counterSpec, DebugUtil.debugDumpLazily(policyRule));
int counter = 1;
@@ -72,20 +72,7 @@ public void execute(@NotNull ModelContext context, Tas
counterSpec.setCount(counter);
}
}
-
- //TODO : not supported yet
-// Collection extends ModelProjectionContext> projectionCtxs = context.getProjectionContexts();
-// for (ModelProjectionContext projectionCtx : projectionCtxs) {
-// Collection evaluatedPolicyRules = projectionCtx.getPolicyRules();
-// for (EvaluatedPolicyRule policyRule : evaluatedPolicyRules) {
-// LOGGER.info("projction policy rules: {}", policyRule);
-// counter = checkEvaluatedPolicyRule(task, policyRule, counter, result);
-// }
-//
-// }
-
-
-
+
}
private synchronized int checkEvaluatedPolicyRule(Task task, EvaluatedPolicyRule policyRule, int counter, OperationResult result) throws ThresholdPolicyViolationException, ObjectNotFoundException, SchemaException {
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/messaging/MessageProcessor.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/messaging/MessageProcessor.java
new file mode 100644
index 00000000000..f27b31f5b24
--- /dev/null
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/messaging/MessageProcessor.java
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+package com.evolveum.midpoint.model.impl.messaging;
+
+import com.evolveum.midpoint.model.api.ModelService;
+import com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder;
+import com.evolveum.midpoint.prism.*;
+import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple;
+import com.evolveum.midpoint.repo.api.PreconditionViolationException;
+import com.evolveum.midpoint.repo.common.expression.*;
+import com.evolveum.midpoint.schema.SchemaConstantsGenerated;
+import com.evolveum.midpoint.schema.constants.ExpressionConstants;
+import com.evolveum.midpoint.schema.result.OperationResult;
+import com.evolveum.midpoint.security.api.SecurityContextManager;
+import com.evolveum.midpoint.task.api.Task;
+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.*;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ */
+@Component
+public class MessageProcessor {
+
+ private static final Trace LOGGER = TraceManager.getTrace(MessageProcessor.class);
+
+ public static final String DOT_CLASS = MessageProcessor.class.getName() + ".";
+
+ @Autowired ModelService modelService;
+ @Autowired ExpressionFactory expressionFactory;
+ @Autowired PrismContext prismContext;
+ @Autowired SecurityContextManager securityContextManager;
+
+// public void processMessage(DataMessageType message, MessageProcessingConfigurationType processing,
+// ResourceType resource, Task task, OperationResult parentResult)
+// throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException,
+// ConfigurationException, ExpressionEvaluationException, PreconditionViolationException, PolicyViolationException,
+// ObjectAlreadyExistsException {
+// OperationResult result = parentResult.createSubresult(DOT_CLASS + "processMessage");
+// try {
+// ExpressionVariables variables = createVariables(message, resource);
+// if (processing.getConsumerExpression() != null && processing.getTransformerExpression() != null) {
+// throw new IllegalStateException("Both consumerExpression and transformerExpression cannot be specified at once");
+// }
+// if (processing.getConsumerExpression() != null) {
+// evaluateExpression(processing.getConsumerExpression(), variables, "consumer expression", task, result);
+// } else {
+// List descriptions = evaluateExpression(processing.getTransformerExpression(),
+// variables, "transformer expression", task, result);
+// LOGGER.trace("Change description computation returned {} description(s)", descriptions.size());
+// for (ResourceObjectShadowChangeDescriptionType description : descriptions) {
+// modelService.notifyChange(description, task, result);
+// }
+// }
+// result.computeStatusIfUnknown();
+// } catch (Throwable t) {
+// result.recordFatalError("Couldn't process message: " + t.getMessage(), t);
+// throw t;
+// }
+// }
+//
+// @NotNull
+// private List evaluateExpression(ExpressionType expressionBean, ExpressionVariables variables, String contextDescription,
+// Task task, OperationResult result)
+// throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException,
+// ConfigurationException, SecurityViolationException {
+// Expression, PrismPropertyDefinition> expression = expressionFactory.makePropertyExpression(expressionBean,
+// SchemaConstantsGenerated.C_RESOURCE_OBJECT_SHADOW_CHANGE_DESCRIPTION, contextDescription, task, result);
+// ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDescription, task, result);
+// PrismValueDeltaSetTriple> exprResultTriple =
+// ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, context, task, result);
+// List list = new ArrayList<>();
+// for (PrismPropertyValue pv : exprResultTriple.getZeroSet()) {
+// list.add(pv.getRealValue());
+// }
+// return list;
+// }
+//
+// @NotNull
+// private ExpressionVariables createVariables(DataMessageType message,
+// ResourceType resource) {
+// ExpressionVariables variables = new ExpressionVariables();
+// variables.addVariableDefinition(ExpressionConstants.VAR_MESSAGE, new MessageWrapper(message));
+// variables.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, resource);
+// return variables;
+// }
+}
diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/messaging/MessageWrapper.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/messaging/MessageWrapper.java
new file mode 100644
index 00000000000..755a20c38ca
--- /dev/null
+++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/messaging/MessageWrapper.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+package com.evolveum.midpoint.model.impl.messaging;
+
+import com.evolveum.midpoint.xml.ns._public.common.common_3.Amqp091MessageAttributesType;
+import com.evolveum.midpoint.xml.ns._public.common.common_3.Amqp091MessageType;
+import com.evolveum.midpoint.xml.ns._public.common.common_3.AsyncUpdateMessageType;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+/**
+ *
+ */
+public class MessageWrapper {
+
+ @NotNull private final AsyncUpdateMessageType message;
+
+ private static final TypeReference> MAP_TYPE = new MapTypeReference();
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private static class MapTypeReference extends TypeReference