Skip to content

Commit

Permalink
new model execute option - limitPropagation
Browse files Browse the repository at this point in the history
* improved compensation mechanism for already exits situation - propagate changes related only to the conflicting shadow
* configurable changes propagation - can be propagated only to the source resource
* skipping some steps while computing changes - if specified to propagate changes only for source resource
  • Loading branch information
katkav committed Oct 5, 2014
1 parent 51e280e commit fd5b9f9
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 181 deletions.
21 changes: 21 additions & 0 deletions infra/schema/src/main/resources/xml/ns/public/common/common-3.xsd
Expand Up @@ -5204,6 +5204,19 @@
No additional read will be executed.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="limitPropagation" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true, applicable synchronization reactions will propagate changes only form/to source
resource. In the case focus cotains links to another resource this will be not recomputed
and after reaction execution there may be small inconsistencies.

It can improve performance for example for initial import.

Default value is false.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="opportunistic" type="xsd:boolean" minOccurs="0" default="true">
<xsd:annotation>
Expand Down Expand Up @@ -5324,6 +5337,7 @@
<xsd:element name="channel" type="xsd:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="synchronize" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element name="reconcile" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element name="limitPropagation" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element name="objectTemplateRef" type="tns:ObjectReferenceType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -8550,6 +8564,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="limitPropagation" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Option to limit change computation and execution only for the source resource.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down
Expand Up @@ -65,6 +65,11 @@ public class ModelExecuteOptions implements Serializable, Cloneable {

Boolean isImport;

/**
* Option to limit propagation only for the source resource
*/
Boolean limitPropagation;


public Boolean getForce() {
return force;
Expand Down Expand Up @@ -224,6 +229,27 @@ public static boolean isExecuteImmediatelyAfterApproval(ModelExecuteOptions opti
}
return options.executeImmediatelyAfterApproval;
}

public static ModelExecuteOptions createIsLimitPropagation() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setLimitPropagation(true);
return opts;

}

public void setLimitPropagation(Boolean limitPropagation) {
this.limitPropagation = limitPropagation;
}

public static boolean isLimitPropagation(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.limitPropagation == null){
return false;
}
return options.limitPropagation;
}

public static ModelExecuteOptions createExecuteImmediatelyAfterApproval(){
ModelExecuteOptions opts = new ModelExecuteOptions();
Expand All @@ -240,6 +266,7 @@ public ModelExecuteOptionsType toModelExecutionOptionsType() {
retval.setExecuteImmediatelyAfterApproval(executeImmediatelyAfterApproval);
retval.setOverwrite(overwrite);
retval.setIsImport(isImport);
retval.setLimitPropagation(limitPropagation);
return retval;
}

Expand All @@ -255,6 +282,7 @@ public static ModelExecuteOptions fromModelExecutionOptionsType(ModelExecuteOpti
retval.setExecuteImmediatelyAfterApproval(type.isExecuteImmediatelyAfterApproval());
retval.setOverwrite(type.isOverwrite());
retval.setIsImport(type.isIsImport());
retval.setLimitPropagation(type.isLimitPropagation());
return retval;
}

Expand Down Expand Up @@ -286,6 +314,9 @@ public static ModelExecuteOptions fromRestOptions(List<String> options){
if (ModelExecuteOptionsType.F_IS_IMPORT.getLocalPart().equals(option)){
retVal.setIsImport(true);;
}
if (ModelExecuteOptionsType.F_LIMIT_PROPAGATION.getLocalPart().equals(option)){
retVal.setIsImport(true);;
}
}

return retVal;
Expand All @@ -297,7 +328,7 @@ public String toString(){
+ ",reconcile=" + reconcile
+ ",executeImmediatelyAfterApproval="
+ executeImmediatelyAfterApproval + ",overwrite=" + overwrite
+ "]";
+ "limitPropagation="+limitPropagation+"]";
}

public ModelExecuteOptions clone() {
Expand Down
Expand Up @@ -169,7 +169,7 @@ public <O extends ObjectType> void executeChanges(LensContext<O> syncContext, Ta
throw e;
} catch (ObjectAlreadyExistsException e) {
subResult.computeStatus();
if (!subResult.isSuccess()) {
if (!subResult.isSuccess() && !subResult.isHandledError()) {
subResult.recordFatalError(e);
}
result.computeStatusComposite();
Expand Down Expand Up @@ -205,6 +205,11 @@ public <O extends ObjectType> void executeChanges(LensContext<O> syncContext, Ta
if (accCtx.getWave() != syncContext.getExecutionWave()) {
continue;
}

if (!accCtx.isCanProject()){
continue;
}

OperationResult subResult = result.createSubresult(OPERATION_EXECUTE_PROJECTION+"."+accCtx.getObjectTypeClass().getSimpleName());
subResult.addContext("discriminator", accCtx.getResourceShadowDiscriminator());
if (accCtx.getResource() != null) {
Expand Down Expand Up @@ -290,7 +295,8 @@ public <O extends ObjectType> void executeChanges(LensContext<O> syncContext, Ta
// and also do not set fatal error to the operation result, this is a special case
// if it is fatal, it will be set later
// but we need to set some result
subResult.recordHandledError(e);
subResult.recordSuccess();
subResult.muteLastSubresultError();
continue;
} catch (CommunicationException e) {
recordProjectionExecutionException(e, accCtx, subResult, SynchronizationPolicyDecision.BROKEN);
Expand Down
Expand Up @@ -98,6 +98,8 @@ public class LensContext<F extends ObjectType> implements ModelContext<F> {
* Current wave of execution.
*/
int executionWave = 0;

private String triggeredResourceOid;

transient private boolean isFresh = false;
transient private boolean isRequestAuthorized = false;
Expand Down Expand Up @@ -149,6 +151,21 @@ protected PrismContext getNotNullPrismContext() {
public ProvisioningService getProvisioningService() {
return provisioningService;
}

public void setTriggeredResource(String triggeredResourceOid) {
this.triggeredResourceOid = triggeredResourceOid;
}

public void setTriggeredResource(ResourceType triggeredResource) {
if (triggeredResource != null){
this.triggeredResourceOid = triggeredResource.getOid();
}
}

public String getTriggeredResourceOid() {
return triggeredResourceOid;
}


@Override
public ModelState getState() {
Expand Down
Expand Up @@ -132,6 +132,11 @@ public class LensProjectionContext extends LensElementContext<ShadowType> implem
*/
private boolean doReconciliation;

/**
* false if the context should be not taken into the account while synchronizing changes from other resource
*/
private boolean canProject = true;



/**
Expand Down Expand Up @@ -510,6 +515,14 @@ public ValuePolicyType getAccountPasswordPolicy() {
return accountPasswordPolicy;
}

public void setCanProject(boolean canProject) {
this.canProject = canProject;
}

public boolean isCanProject() {
return canProject;
}

public void setAccountPasswordPolicy(ValuePolicyType accountPasswordPolicy) {
this.accountPasswordPolicy = accountPasswordPolicy;
}
Expand Down

0 comments on commit fd5b9f9

Please sign in to comment.