public ResourceBE CreateProperty(uint? parentId, XUri parentUri, ResourceBE.ParentType parentType, string name, ResourceContentBE content, string description, string etag, AbortEnum abort) { //TODO: The parent resource isn't verified when the resource name and the parent info is given ResourceBE prop = _resourceBL.GetResource(parentId, parentType, ResourceBE.Type.PROPERTY, name, DeletionFilter.ACTIVEONLY); if(prop != null) { switch(abort) { case AbortEnum.Exists: throw new PropertyExistsConflictException(name); case AbortEnum.Modified: _resourceBL.ValidateEtag(etag, prop, true); break; } prop = _resourceBL.BuildRevForContentUpdate(prop, content.MimeType, content.Size, description, null, content); prop = _resourceBL.SaveResource(prop); DekiContext.Current.Instance.EventSink.PropertyUpdate(DekiContext.Current.Now, prop, DekiContext.Current.User, parentType, parentUri); } else { if((abort == AbortEnum.Modified) && !string.IsNullOrEmpty(etag)) { throw new PropertyUnexpectedEtagConflictException(); } prop = _resourceBL.BuildRevForNewResource(parentId, parentType, name, content.MimeType, content.Size, description, ResourceBE.Type.PROPERTY, DekiContext.Current.User.ID, content); prop = _resourceBL.SaveResource(prop); DekiContext.Current.Instance.EventSink.PropertyCreate(DekiContext.Current.Now, prop, DekiContext.Current.User, parentType, parentUri); } return prop; }
public ResourceBE UpdatePropertyContent(ResourceBE prop, ResourceContentBE content, string changeDescription, string eTag, AbortEnum abort, XUri parentUri, ResourceBE.ParentType parentType) { if (abort == AbortEnum.Modified) { _resourceBL.ValidateEtag(eTag, prop, true); } prop = _resourceBL.BuildRevForContentUpdate(prop, content.MimeType, content.Size, changeDescription, null, content); prop = _resourceBL.SaveResource(prop); DekiContext.Current.Instance.EventSink.PropertyUpdate(DekiContext.Current.Now, prop, DekiContext.Current.User, parentType, parentUri); return(prop); }
public ResourceBE UpdatePropertyContent(ResourceBE prop, ResourceContentBE content, string changeDescription, string eTag, AbortEnum abort, XUri parentUri, ResourceBE.ParentType parentType) { if(abort == AbortEnum.Modified) { _resourceBL.ValidateEtag(eTag, prop, true); } prop = _resourceBL.BuildRevForContentUpdate(prop, content.MimeType, content.Size, changeDescription, null, content); prop = _resourceBL.SaveResource(prop); DekiContext.Current.Instance.EventSink.PropertyUpdate(DekiContext.Current.Now, prop, DekiContext.Current.User, parentType, parentUri); return prop; }
public ResourceBE CreateProperty(uint?parentId, XUri parentUri, ResourceBE.ParentType parentType, string name, ResourceContentBE content, string description, string etag, AbortEnum abort) { //TODO: The parent resource isn't verified when the resource name and the parent info is given ResourceBE prop = _resourceBL.GetResource(parentId, parentType, ResourceBE.Type.PROPERTY, name, DeletionFilter.ACTIVEONLY); if (prop != null) { switch (abort) { case AbortEnum.Exists: throw new PropertyExistsConflictException(name); case AbortEnum.Modified: _resourceBL.ValidateEtag(etag, prop, true); break; } prop = _resourceBL.BuildRevForContentUpdate(prop, content.MimeType, content.Size, description, null, content); prop = _resourceBL.SaveResource(prop); DekiContext.Current.Instance.EventSink.PropertyUpdate(DekiContext.Current.Now, prop, DekiContext.Current.User, parentType, parentUri); } else { if ((abort == AbortEnum.Modified) && !string.IsNullOrEmpty(etag)) { throw new PropertyUnexpectedEtagConflictException(); } prop = _resourceBL.BuildRevForNewResource(parentId, parentType, name, content.MimeType, content.Size, description, ResourceBE.Type.PROPERTY, DekiContext.Current.User.ID, content); prop = _resourceBL.SaveResource(prop); DekiContext.Current.Instance.EventSink.PropertyCreate(DekiContext.Current.Now, prop, DekiContext.Current.User, parentType, parentUri); } return(prop); }