Following up with OpenCMIS bug fixes and enhancements
git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1378495 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMIS/binding/atompub/atompub.cs b/DotCMIS/binding/atompub/atompub.cs
index 35ff66f..4e3cd3d 100644
--- a/DotCMIS/binding/atompub/atompub.cs
+++ b/DotCMIS/binding/atompub/atompub.cs
@@ -1902,8 +1902,21 @@
public IFailedToDeleteData DeleteTree(string repositoryId, string folderId, bool? allVersions, UnfileObject? unfileObjects,
bool? continueOnFailure, ExtensionsData extension)
{
- // find the link
- String link = LoadLink(repositoryId, folderId, AtomPubConstants.RelDown, AtomPubConstants.MediatypeDescendants);
+ // find the down link
+ String link = LoadLink(repositoryId, folderId, AtomPubConstants.RelDown, null);
+
+ if (link != null)
+ {
+ // found only a children link, but no descendants link
+ // -> try folder tree link
+ link = null;
+ }
+ else
+ {
+ // found no or two down links
+ // -> get only the descendants link
+ link = LoadLink(repositoryId, folderId, AtomPubConstants.RelDown, AtomPubConstants.MediatypeDescendants);
+ }
if (link == null)
{
@@ -1912,6 +1925,11 @@
if (link == null)
{
+ link = LoadLink(repositoryId, folderId, AtomPubConstants.RelFolderTree, AtomPubConstants.MediatypeFeed);
+ }
+
+ if (link == null)
+ {
ThrowLinkException(repositoryId, folderId, AtomPubConstants.RelDown, AtomPubConstants.MediatypeDescendants);
}
diff --git a/DotCMIS/client/client-impl.cs b/DotCMIS/client/client-impl.cs
index cd0a89c..e28aa97 100644
--- a/DotCMIS/client/client-impl.cs
+++ b/DotCMIS/client/client-impl.cs
@@ -173,10 +173,14 @@
public class Session : ISession
{
private static HashSet<Updatability> CreateUpdatability = new HashSet<Updatability>();
+ private static HashSet<Updatability> CreateAndCheckoutUpdatability = new HashSet<Updatability>();
static Session()
{
CreateUpdatability.Add(Updatability.OnCreate);
CreateUpdatability.Add(Updatability.ReadWrite);
+ CreateAndCheckoutUpdatability.Add(Updatability.OnCreate);
+ CreateAndCheckoutUpdatability.Add(Updatability.ReadWrite);
+ CreateAndCheckoutUpdatability.Add(Updatability.WhenCheckedOut);
}
protected static IOperationContext FallbackContext = new OperationContext(null, false, true, false, IncludeRelationshipsFlag.None, null, true, null, true, 100);
@@ -678,7 +682,8 @@
throw new ArgumentException("Properties must not be empty!");
}
- string newId = Binding.GetObjectService().CreateDocument(RepositoryId, ObjectFactory.ConvertProperties(properties, null, CreateUpdatability),
+ string newId = Binding.GetObjectService().CreateDocument(RepositoryId, ObjectFactory.ConvertProperties(properties, null,
+ (versioningState == VersioningState.CheckedOut ? CreateAndCheckoutUpdatability : CreateUpdatability)),
(folderId == null ? null : folderId.Id), contentStream, versioningState, ObjectFactory.ConvertPolicies(policies),
ObjectFactory.ConvertAces(addAces), ObjectFactory.ConvertAces(removeAces), null);
@@ -717,7 +722,9 @@
}
string newId = Binding.GetObjectService().CreateDocumentFromSource(RepositoryId, source.Id,
- ObjectFactory.ConvertProperties(properties, type, CreateUpdatability), (folderId == null ? null : folderId.Id),
+ ObjectFactory.ConvertProperties(properties, type,
+ (versioningState == VersioningState.CheckedOut ? CreateAndCheckoutUpdatability : CreateUpdatability)),
+ (folderId == null ? null : folderId.Id),
versioningState, ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
ObjectFactory.ConvertAces(removeAces), null);
@@ -838,6 +845,51 @@
return new CollectionEnumerable<IRelationship>(new PageFetcher<IRelationship>(DefaultContext.MaxItemsPerPage, fetchPageDelegate));
}
+ // delete
+ public void Delete(IObjectId objectId)
+ {
+ Delete(objectId, true);
+ }
+
+ public void Delete(IObjectId objectId, bool allVersions)
+ {
+ if (objectId == null || objectId.Id == null)
+ {
+ throw new ArgumentException("Invalid object id!");
+ }
+
+ Binding.GetObjectService().DeleteObject(RepositoryId, objectId.Id, allVersions, null);
+ RemoveObjectFromCache(objectId);
+ }
+
+ // content stream
+ public IContentStream GetContentStream(IObjectId docId)
+ {
+ return GetContentStream(docId, null, null, null);
+ }
+
+ public IContentStream GetContentStream(IObjectId docId, string streamId, long? offset, long? length)
+ {
+ if (docId == null || docId.Id == null)
+ {
+ throw new ArgumentException("Invalid document id!");
+ }
+
+ // get the content stream
+ IContentStream contentStream = null;
+ try
+ {
+ contentStream = Binding.GetObjectService().GetContentStream(RepositoryId, docId.Id, streamId, offset, length, null);
+ }
+ catch (CmisConstraintException)
+ {
+ // no content stream
+ return null;
+ }
+
+ return contentStream;
+ }
+
// permissions
public IAcl GetAcl(IObjectId objectId, bool onlyBasicPermissions)
diff --git a/DotCMIS/client/client-intf.cs b/DotCMIS/client/client-intf.cs
index 1254b44..7e56dda 100644
--- a/DotCMIS/client/client-intf.cs
+++ b/DotCMIS/client/client-intf.cs
@@ -259,8 +259,15 @@
IItemEnumerable<IRelationship> GetRelationships(IObjectId objectId, bool includeSubRelationshipTypes,
RelationshipDirection? relationshipDirection, IObjectType type, IOperationContext context);
- // permissions
+ // delete
+ void Delete(IObjectId objectId);
+ void Delete(IObjectId objectId, bool allVersions);
+ // content stream
+ IContentStream GetContentStream(IObjectId docId);
+ IContentStream GetContentStream(IObjectId docId, string streamId, long? offset, long? length);
+
+ // permissions
IAcl GetAcl(IObjectId objectId, bool onlyBasicPermissions);
IAcl ApplyAcl(IObjectId objectId, IList<IAce> addAces, IList<IAce> removeAces, AclPropagation? aclPropagation);
void ApplyPolicy(IObjectId objectId, params IObjectId[] policyIds);
@@ -854,6 +861,12 @@
IContentStream GetContentStream(string streamId);
/// <summary>
+ /// Gets the content stream identified by the given stream id with the given offset and length.
+ /// </summary>
+ /// <returns>the content stream or <c>null</c> if the stream id is not associated with content</returns>
+ IContentStream GetContentStream(string streamId, long? offset, long? length);
+
+ /// <summary>
/// Sets a new content stream for this document.
/// </summary>
/// <param name="contentStream">the content stream</param>
diff --git a/DotCMIS/client/client-objects.cs b/DotCMIS/client/client-objects.cs
index 2e9c9c0..53e5d3c 100644
--- a/DotCMIS/client/client-objects.cs
+++ b/DotCMIS/client/client-objects.cs
@@ -200,7 +200,7 @@
Lock();
try
{
- Binding.GetObjectService().DeleteObject(RepositoryId, ObjectId, allVersions, null);
+ Session.Delete(this, allVersions);
}
finally
{
@@ -931,14 +931,15 @@
return GetContentStream(null);
}
- public IContentStream GetContentStream(String streamId)
+ public IContentStream GetContentStream(string streamId)
{
- IContentStream contentStream;
- try
- {
- contentStream = Binding.GetObjectService().GetContentStream(RepositoryId, ObjectId, streamId, null, null, null);
- }
- catch (CmisConstraintException)
+ return GetContentStream(streamId, null, null);
+ }
+
+ public IContentStream GetContentStream(string streamId, long? offset, long? length)
+ {
+ IContentStream contentStream = Session.GetContentStream(this, streamId, offset, length);
+ if (contentStream == null)
{
// no content stream
return null;