public static void ValidateStreamIfApplicable(long streamLength, PropertyDefinition propertyDefinition, StoreObjectPropertyBag propertyBag) { if (ExtendedRuleConditionConstraint.propertyDefinition.Equals(propertyDefinition) && propertyBag != null && propertyBag.MapiPropertyBag != null && propertyBag.MapiPropertyBag.StoreSession != null) { int extendedRuleSizeLimit = ExtendedRuleConditionConstraint.GetExtendedRuleSizeLimit(propertyBag.MapiPropertyBag.StoreSession); if (streamLength > (long)extendedRuleSizeLimit) { throw new StoragePermanentException(ServerStrings.ExConstraintViolationByteArrayLengthTooLong(propertyDefinition.Name, (long)extendedRuleSizeLimit, streamLength)); } } }
public override void SetLength(long length) { this.CheckDisposed(); this.CheckNotReadOnly(); Util.ThrowOnArgumentOutOfRangeOnLessThan(length, 0L, "length"); ExtendedRuleConditionConstraint.ValidateStreamIfApplicable(length, this.property, this.storePropertyBag); if (this.NeedToSwitchToMapiStream(length)) { this.OpenMapiStream(false); } this.dataChanged = true; this.ActiveStream.SetLength(length); }
internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag) { if (validatablePropertyBag is PropertyBag && validatablePropertyBag.IsPropertyDirty(ExtendedRuleConditionConstraint.propertyDefinition)) { byte[] array = validatablePropertyBag.TryGetProperty(ExtendedRuleConditionConstraint.propertyDefinition) as byte[]; StoreSession session = ((PropertyBag)validatablePropertyBag).Context.Session; if (array != null && session != null && array.Length > ExtendedRuleConditionConstraint.GetExtendedRuleSizeLimit(session)) { return(new StoreObjectValidationError(context, ExtendedRuleConditionConstraint.propertyDefinition, array, this)); } } return(null); }
public override void Write(byte[] buffer, int offset, int count) { this.CheckDisposed(); Util.ThrowOnNullArgument(buffer, "buffer"); Util.ThrowOnArgumentOutOfRangeOnLessThan(offset, 0, "offset"); Util.ThrowOnArgumentInvalidOnGreaterThan(offset, buffer.Length, "offset"); Util.ThrowOnArgumentOutOfRangeOnLessThan(count, 0, "count"); Util.ThrowOnArgumentInvalidOnGreaterThan(offset + count, buffer.Length, "offset + count exceeds buffer size"); this.CheckNotReadOnly(); if (count == 0) { return; } ExtendedRuleConditionConstraint.ValidateStreamIfApplicable(this.ActiveStream.Position + (long)count, this.property, this.storePropertyBag); this.dataChanged = true; if (this.cache != null && this.NeedToSwitchToMapiStream(this.cache.Position + (long)count)) { this.OpenMapiStream(true); } this.ActiveStream.Write(buffer, offset, count); }