Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Evolveum/midpoint
- Loading branch information
Showing
10 changed files
with
315 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
|
||
<!-- | ||
~ Copyright (c) 2010-2017 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. | ||
--> | ||
<xsd:schema elementFormDefault="qualified" | ||
targetNamespace="http://midpoint.evolveum.com/xml/ns/samples/resource" | ||
xmlns:tns="http://midpoint.evolveum.com/xml/ns/samples/resource" | ||
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" | ||
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<xsd:complexType name="ResourceTypeExtensionType"> | ||
<xsd:annotation> | ||
<xsd:appinfo> | ||
<a:extension ref="c:ResourceType"/> | ||
</xsd:appinfo> | ||
</xsd:annotation> | ||
<xsd:sequence> | ||
<xsd:element name="provisioning" type="xsd:string"> | ||
<xsd:annotation> | ||
<xsd:appinfo> | ||
<a:indexed>true</a:indexed> | ||
</xsd:appinfo> | ||
</xsd:annotation> | ||
</xsd:element> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
|
||
</xsd:schema> |
89 changes: 89 additions & 0 deletions
89
...main/java/com/evolveum/midpoint/provisioning/impl/task/MultiPropagationResultHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* Copyright (c) 2018 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.provisioning.impl.task; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.query.ObjectFilter; | ||
import com.evolveum.midpoint.prism.query.ObjectQuery; | ||
import com.evolveum.midpoint.prism.query.builder.QueryBuilder; | ||
import com.evolveum.midpoint.provisioning.impl.ShadowCache; | ||
import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException; | ||
import com.evolveum.midpoint.repo.api.PreconditionViolationException; | ||
import com.evolveum.midpoint.repo.api.RepositoryService; | ||
import com.evolveum.midpoint.repo.common.task.AbstractSearchIterativeResultHandler; | ||
import com.evolveum.midpoint.schema.ResultHandler; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.task.api.TaskManager; | ||
import com.evolveum.midpoint.util.exception.CommonException; | ||
import com.evolveum.midpoint.util.exception.SystemException; | ||
import com.evolveum.midpoint.util.logging.Trace; | ||
import com.evolveum.midpoint.util.logging.TraceManager; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; | ||
|
||
/** | ||
* @author semancik | ||
* | ||
*/ | ||
public class MultiPropagationResultHandler extends AbstractSearchIterativeResultHandler<ResourceType> { | ||
|
||
private static final transient Trace LOGGER = TraceManager.getTrace(MultiPropagationResultHandler.class); | ||
|
||
private final RepositoryService repositoryService; | ||
private final ShadowCache shadowCache; | ||
|
||
public MultiPropagationResultHandler(Task coordinatorTask, String taskOperationPrefix, TaskManager taskManager, RepositoryService repositoryService, ShadowCache shadowCache) { | ||
super(coordinatorTask, taskOperationPrefix, "propagation", "multipropagation", taskManager); | ||
this.repositoryService = repositoryService; | ||
this.shadowCache = shadowCache; | ||
} | ||
|
||
@Override | ||
protected boolean handleObject(PrismObject<ResourceType> resource, Task workerTask, OperationResult taskResult) | ||
throws CommonException, PreconditionViolationException { | ||
|
||
LOGGER.trace("Propagating provisioning operations on {}", resource); | ||
ObjectQuery query = new ObjectQuery(); | ||
ObjectFilter filter = QueryBuilder.queryFor(ShadowType.class, resource.getPrismContext()) | ||
.item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()) | ||
.and() | ||
.exists(ShadowType.F_PENDING_OPERATION) | ||
.buildFilter(); | ||
query.setFilter(filter); | ||
|
||
ResultHandler<ShadowType> handler = | ||
(shadow, result) -> { | ||
propagateShadowOperations(resource, shadow, workerTask, result); | ||
return true; | ||
}; | ||
|
||
repositoryService.searchObjectsIterative(ShadowType.class, query, handler, null, false, taskResult); | ||
|
||
LOGGER.trace("Propagation of {} done", resource); | ||
|
||
return true; | ||
} | ||
|
||
protected void propagateShadowOperations(PrismObject<ResourceType> resource, PrismObject<ShadowType> shadow, Task workerTask, OperationResult result) { | ||
try { | ||
shadowCache.propagateOperations(resource, shadow, workerTask, result); | ||
} catch (CommonException | GenericFrameworkException e) { | ||
throw new SystemException("Generic provisioning framework error: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
} |
125 changes: 125 additions & 0 deletions
125
...c/main/java/com/evolveum/midpoint/provisioning/impl/task/MultiPropagationTaskHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* Copyright (c) 2018 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.provisioning.impl.task; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.query.ObjectFilter; | ||
import com.evolveum.midpoint.prism.query.ObjectQuery; | ||
import com.evolveum.midpoint.prism.query.builder.QueryBuilder; | ||
import com.evolveum.midpoint.provisioning.api.ProvisioningService; | ||
import com.evolveum.midpoint.provisioning.impl.ShadowCache; | ||
import com.evolveum.midpoint.provisioning.impl.ShadowCacheFactory; | ||
import com.evolveum.midpoint.repo.common.task.AbstractSearchIterativeTaskHandler; | ||
import com.evolveum.midpoint.schema.constants.SchemaConstants; | ||
import com.evolveum.midpoint.schema.result.OperationConstants; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.task.api.TaskCategory; | ||
import com.evolveum.midpoint.task.api.TaskManager; | ||
import com.evolveum.midpoint.task.api.TaskRunResult; | ||
import com.evolveum.midpoint.task.api.TaskRunResult.TaskRunResultStatus; | ||
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.ObjectNotFoundException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
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.ResourceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; | ||
|
||
/** | ||
* Task handler for provisioning propagation of many resources. | ||
* | ||
* The search in this task handler is somehow reversed. The task is searching for resources | ||
* and then the task internally looks for pending changes. | ||
* | ||
* Here we assume that there will be large number of resources, but there will be much smaller | ||
* number of changes. | ||
* | ||
* @author Radovan Semancik | ||
* | ||
*/ | ||
@Component | ||
public class MultiPropagationTaskHandler extends AbstractSearchIterativeTaskHandler<ResourceType, MultiPropagationResultHandler> { | ||
|
||
public static final String HANDLER_URI = SchemaConstants.NS_PROVISIONING_TASK + "/propagation/multi-handler-3"; | ||
|
||
// WARNING! This task handler is efficiently singleton! | ||
// It is a spring bean and it is supposed to handle all search task instances | ||
// Therefore it must not have task-specific fields. It can only contain fields specific to | ||
// all tasks of a specified type | ||
|
||
@Autowired private TaskManager taskManager; | ||
@Autowired private ShadowCacheFactory shadowCacheFactory; | ||
|
||
private static final Trace LOGGER = TraceManager.getTrace(MultiPropagationTaskHandler.class); | ||
|
||
public MultiPropagationTaskHandler() { | ||
super("Provisioning propagation (multi)", OperationConstants.PROVISIONING_PROPAGATION); | ||
setLogFinishInfo(true); | ||
setPreserveStatistics(false); | ||
setEnableSynchronizationStatistics(false); | ||
} | ||
|
||
@PostConstruct | ||
private void initialize() { | ||
taskManager.registerHandler(HANDLER_URI, this); | ||
} | ||
|
||
@Override | ||
protected MultiPropagationResultHandler createHandler(TaskRunResult runResult, Task coordinatorTask, | ||
OperationResult opResult) { | ||
|
||
ShadowCache shadowCache = shadowCacheFactory.getShadowCache(ShadowCacheFactory.Mode.STANDARD); | ||
MultiPropagationResultHandler handler = new MultiPropagationResultHandler(coordinatorTask, getTaskOperationPrefix(), taskManager, repositoryService, shadowCache); | ||
return handler; | ||
} | ||
|
||
@Override | ||
public String getCategoryName(Task task) { | ||
return TaskCategory.SYSTEM; | ||
} | ||
|
||
@Override | ||
public List<String> getCategoryNames() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected ObjectQuery createQuery(MultiPropagationResultHandler handler, TaskRunResult runResult, Task coordinatorTask, | ||
OperationResult opResult) throws SchemaException { | ||
ObjectQuery objectQuery = createQueryFromTask(handler, runResult, coordinatorTask, opResult); | ||
LOGGER.trace("Resource query: {}", objectQuery); | ||
return objectQuery; | ||
|
||
} | ||
|
||
@Override | ||
protected Class<? extends ObjectType> getType(Task task) { | ||
return ResourceType.class; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.