@@ -4662,6 +4662,7 @@ public sealed class SyncDelta
4662
4662
private readonly SyncToken _token ;
4663
4663
private readonly SyncDeltaType _deltaType ;
4664
4664
private readonly Uid _previousUid ;
4665
+ private readonly ObjectClass _objectClass ;
4665
4666
private readonly Uid _uid ;
4666
4667
private readonly ConnectorObject _object ;
4667
4668
@@ -4670,20 +4671,22 @@ public sealed class SyncDelta
4670
4671
/// </summary>
4671
4672
/// <param name="token">The token. Must not be null.</param>
4672
4673
/// <param name="deltaType">The delta. Must not be null.</param>
4674
+ /// <param name="previousUid">The previousUid. Can be null.</param>
4675
+ /// <param name="objectClass">The objectClass. Can be null.</param>
4673
4676
/// <param name="uid">The uid. Must not be null.</param>
4674
- /// <param name="object ">The object that has changed. May be null for delete.</param>
4677
+ /// <param name="obj ">The object that has changed. May be null for delete.</param>
4675
4678
internal SyncDelta ( SyncToken token , SyncDeltaType deltaType ,
4676
- Uid previousUid , Uid uid ,
4679
+ Uid previousUid , ObjectClass objectClass , Uid uid ,
4677
4680
ConnectorObject obj )
4678
4681
{
4679
4682
Assertions . NullCheck ( token , "token" ) ;
4680
4683
Assertions . NullCheck ( deltaType , "deltaType" ) ;
4681
4684
Assertions . NullCheck ( uid , "uid" ) ;
4682
4685
4683
4686
//do not allow previous Uid for anything else than create or update
4684
- if ( previousUid != null && deltaType == SyncDeltaType . DELETE )
4687
+ if ( previousUid != null && ( deltaType == SyncDeltaType . DELETE || deltaType == SyncDeltaType . CREATE ) )
4685
4688
{
4686
- throw new ArgumentException ( "The previous Uid can only be specified for create or update ." ) ;
4689
+ throw new ArgumentException ( "The previous Uid can only be specified for create_or_update or udate ." ) ;
4687
4690
}
4688
4691
4689
4692
//only allow null object for delete
@@ -4701,11 +4704,16 @@ internal SyncDelta(SyncToken token, SyncDeltaType deltaType,
4701
4704
{
4702
4705
throw new ArgumentException ( "Uid does not match that of the object." ) ;
4703
4706
}
4707
+ if ( ! objectClass . Equals ( obj . ObjectClass ) )
4708
+ {
4709
+ throw new ArgumentException ( "ObjectClass does not match that of the object." ) ;
4710
+ }
4704
4711
}
4705
4712
4706
4713
_token = token ;
4707
4714
_deltaType = deltaType ;
4708
4715
_previousUid = previousUid ;
4716
+ _objectClass = objectClass ;
4709
4717
_uid = uid ;
4710
4718
_object = obj ;
4711
4719
@@ -4730,6 +4738,22 @@ public Uid PreviousUid
4730
4738
}
4731
4739
}
4732
4740
4741
+ /// <summary>
4742
+ /// If the change described by this <code>SyncDelta.DELETE</code> and the
4743
+ /// deleted object value is <code>null</code>, this method returns the
4744
+ /// ObjectClass of the deleted object. If operation syncs
4745
+ /// <seealso cref="Org.IdentityConnectors.Framework.Common.Objects.ObjectClass#ALL"/>
4746
+ /// this must be set, otherwise this method can return <code>null</code>.
4747
+ /// </summary>
4748
+ /// <returns> the ObjectClass of the deleted object. </returns>
4749
+ public ObjectClass ObjectClass
4750
+ {
4751
+ get
4752
+ {
4753
+ return _objectClass ;
4754
+ }
4755
+ }
4756
+
4733
4757
/// <summary>
4734
4758
/// Returns the <code>Uid</code> of the object that changed.
4735
4759
/// </summary>
@@ -4790,14 +4814,29 @@ public override String ToString()
4790
4814
values [ "Token" ] = _token ;
4791
4815
values [ "DeltaType" ] = _deltaType ;
4792
4816
values [ "PreviousUid" ] = _previousUid ;
4817
+ values [ "ObjectClass" ] = _objectClass ;
4793
4818
values [ "Uid" ] = _uid ;
4794
4819
values [ "Object" ] = _object ;
4795
4820
return values . ToString ( ) ;
4796
4821
}
4797
4822
4798
4823
public override int GetHashCode ( )
4799
4824
{
4800
- return _uid . GetHashCode ( ) ;
4825
+ unchecked
4826
+ {
4827
+ int hashCode = ( _token != null ? _token . GetHashCode ( ) : 0 ) ;
4828
+ hashCode = ( hashCode * 397 ) ^ ( int ) _deltaType ;
4829
+ hashCode = ( hashCode * 397 ) ^ ( _previousUid != null ? _previousUid . GetHashCode ( ) : 0 ) ;
4830
+ hashCode = ( hashCode * 397 ) ^ ( _objectClass != null ? _objectClass . GetHashCode ( ) : 0 ) ;
4831
+ hashCode = ( hashCode * 397 ) ^ ( _uid != null ? _uid . GetHashCode ( ) : 0 ) ;
4832
+ hashCode = ( hashCode * 397 ) ^ ( _object != null ? _object . GetHashCode ( ) : 0 ) ;
4833
+ return hashCode ;
4834
+ }
4835
+ }
4836
+
4837
+ private bool Equals ( SyncDelta other )
4838
+ {
4839
+ return Equals ( _token , other . _token ) && _deltaType == other . _deltaType && Equals ( _previousUid , other . _previousUid ) && Equals ( _objectClass , other . _objectClass ) && Equals ( _uid , other . _uid ) && Equals ( _object , other . _object ) ;
4801
4840
}
4802
4841
4803
4842
public override bool Equals ( Object o )
@@ -4824,6 +4863,17 @@ public override bool Equals(Object o)
4824
4863
{
4825
4864
return false ;
4826
4865
}
4866
+ if ( _objectClass == null )
4867
+ {
4868
+ if ( other . _objectClass != null )
4869
+ {
4870
+ return false ;
4871
+ }
4872
+ }
4873
+ else if ( ! _objectClass . Equals ( other . _objectClass ) )
4874
+ {
4875
+ return false ;
4876
+ }
4827
4877
if ( ! _uid . Equals ( other . _uid ) )
4828
4878
{
4829
4879
return false ;
@@ -4855,6 +4905,7 @@ public sealed class SyncDeltaBuilder
4855
4905
private SyncToken _token ;
4856
4906
private SyncDeltaType _deltaType ;
4857
4907
private Uid _previousUid ;
4908
+ private ObjectClass _objectClass ;
4858
4909
private Uid _uid ;
4859
4910
private ConnectorObject _object ;
4860
4911
@@ -4876,6 +4927,7 @@ public SyncDeltaBuilder(SyncDelta delta)
4876
4927
_token = delta . Token ;
4877
4928
_deltaType = delta . DeltaType ;
4878
4929
_previousUid = delta . PreviousUid ;
4930
+ _objectClass = delta . ObjectClass ;
4879
4931
_uid = delta . Uid ;
4880
4932
_object = delta . Object ;
4881
4933
}
@@ -4928,6 +4980,23 @@ public Uid PreviousUid
4928
4980
}
4929
4981
}
4930
4982
4983
+ /// <summary>
4984
+ /// Returns the <code>ObjectClass</code> of Deleted object.
4985
+ /// </summary>
4986
+ /// <returns>the <code>ObjectClass</code> of Deleted object.</returns>
4987
+ public ObjectClass ObjectClass
4988
+ {
4989
+ get
4990
+ {
4991
+ return _objectClass ;
4992
+ }
4993
+ set
4994
+ {
4995
+ _objectClass = value ;
4996
+ }
4997
+ }
4998
+
4999
+
4931
5000
/// <summary>
4932
5001
/// Returns the <code>Uid</code> of the object that changed.
4933
5002
/// </summary>
@@ -4969,6 +5038,7 @@ public ConnectorObject Object
4969
5038
if ( value != null )
4970
5039
{
4971
5040
_uid = value . Uid ;
5041
+ _objectClass = value . ObjectClass ;
4972
5042
}
4973
5043
}
4974
5044
}
@@ -4999,7 +5069,7 @@ public ConnectorObject Object
4999
5069
/// </remarks>
5000
5070
public SyncDelta Build ( )
5001
5071
{
5002
- return new SyncDelta ( _token , _deltaType , _previousUid , _uid , _object ) ;
5072
+ return new SyncDelta ( _token , _deltaType , _previousUid , _objectClass , _uid , _object ) ;
5003
5073
}
5004
5074
}
5005
5075
#endregion
0 commit comments