/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
using System;
using System.Collections.Generic;
using System.IO;
using DotCMIS.Binding;
using DotCMIS.Data;
using DotCMIS.Data.Extensions;
using DotCMIS.Enums;
namespace DotCMIS.Client
{
///
/// Session factory interface.
///
public interface ISessionFactory
{
///
/// Creates a new session with the given parameters and connects to the repository.
///
/// the session parameters
/// the newly created session
///
/// Connect to an AtomPub CMIS endpoint:
///
/// Dictionary<string, string> parameters = new Dictionary<string, string>();
///
/// parameters[SessionParameter.BindingType] = BindingType.AtomPub;
/// parameters[SessionParameter.AtomPubUrl] = "http://localhost/cmis/atom";
/// parameters[SessionParameter.Password] = "admin";
/// parameters[SessionParameter.User] = "admin";
/// parameters[SessionParameter.RepositoryId] = "1234-abcd-5678";
///
/// SessionFactory factory = SessionFactory.NewInstance();
/// ISession session = factory.CreateSession(parameters);
///
///
/// Connect to a Web Services CMIS endpoint:
///
/// Dictionary<string, string> parameters = new Dictionary<string, string>();
///
/// string baseUrlWS = "https://localhost:443/cmis/ws";
///
/// parameters[SessionParameter.BindingType] = BindingType.WebServices;
/// parameters[SessionParameter.WebServicesRepositoryService] = baseUrlWS + "/RepositoryService?wsdl";
/// parameters[SessionParameter.WebServicesAclService] = baseUrlWS + "/AclService?wsdl";
/// parameters[SessionParameter.WebServicesDiscoveryService] = baseUrlWS + "/DiscoveryService?wsdl";
/// parameters[SessionParameter.WebServicesMultifilingService] = baseUrlWS + "/MultifilingService?wsdl";
/// parameters[SessionParameter.WebServicesNavigationService] = baseUrlWS + "/NavigationService?wsdl";
/// parameters[SessionParameter.WebServicesObjectService] = baseUrlWS + "/ObjectService?wsdl";
/// parameters[SessionParameter.WebServicesPolicyService] = baseUrlWS + "/PolicyService?wsdl";
/// parameters[SessionParameter.WebServicesRelationshipService] = baseUrlWS + "/RelationshipService?wsdl";
/// parameters[SessionParameter.WebServicesVersioningService] = baseUrlWS + "/VersioningService?wsdl";
/// parameters[SessionParameter.RepositoryId] = "1234-abcd-5678"
/// parameters[SessionParameter.User] = "admin";
/// parameters[SessionParameter.Password] = "admin";
///
/// SessionFactory factory = SessionFactory.NewInstance();
/// ISession session = factory.CreateSession(parameters);
///
///
///
ISession CreateSession(IDictionary parameters);
///
/// Gets all repository available at the specified endpoint.
///
/// the session parameters
/// a list of all available repositories
///
IList GetRepositories(IDictionary parameters);
}
///
/// Repository interface.
///
public interface IRepository : IRepositoryInfo
{
///
/// Creates a session for this repository.
///
ISession CreateSession();
}
///
/// A session is a connection to a CMIS repository with a specific user.
///
///
///
/// Not all operations might be supported by the connected repository. Either DotCMIS or the repository will
/// throw an exception if an unsupported operation is called.
/// The capabilities of the repository can be discovered by evaluating the repository info
/// (see ).
///
///
/// Almost all methods might throw exceptions derived from !
///
///
/// (Please refer to the CMIS specification
/// for details about the domain model, terms, concepts, base types, properties, IDs and query names,
/// query language, etc.)
///
///
public interface ISession
{
///
/// Clears all caches.
///
void Clear();
///
/// Gets the CMIS binding object.
///
ICmisBinding Binding { get; }
///
/// Gets the default operation context.
///
IOperationContext DefaultContext { get; set; }
///
/// Creates a new operation context object.
///
IOperationContext CreateOperationContext();
///
/// Creates a new operation context object with the given parameters.
///
IOperationContext CreateOperationContext(HashSet filter, bool includeAcls, bool includeAllowableActions, bool includePolicies,
IncludeRelationshipsFlag includeRelationships, HashSet renditionFilter, bool includePathSegments, string orderBy,
bool cacheEnabled, int maxItemsPerPage);
///
/// Creates a new with the given ID.
///
IObjectId CreateObjectId(string id);
///
/// Gets the CMIS repositoy info.
///
IRepositoryInfo RepositoryInfo { get; }
///
/// Gets the internal object factory.
///
IObjectFactory ObjectFactory { get; }
// types
IObjectType GetTypeDefinition(string typeId);
IItemEnumerable GetTypeChildren(string typeId, bool includePropertyDefinitions);
IList> GetTypeDescendants(string typeId, int depth, bool includePropertyDefinitions);
// navigation
IFolder GetRootFolder();
IFolder GetRootFolder(IOperationContext context);
IItemEnumerable GetCheckedOutDocs();
IItemEnumerable GetCheckedOutDocs(IOperationContext context);
///
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
/// turned off per default , it will load the object
/// from the repository and puts it into the cache.
///
/// the object ID
ICmisObject GetObject(IObjectId objectId);
ICmisObject GetObject(IObjectId objectId, IOperationContext context);
///
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
/// turned off per default , it will load the object
/// from the repository and puts it into the cache.
///
/// the object ID
ICmisObject GetObject(string objectId);
ICmisObject GetObject(string objectId, IOperationContext context);
///
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
/// turned off per default , it will load the object
/// from the repository and puts it into the cache.
///
/// the path to the object
ICmisObject GetObjectByPath(string path);
ICmisObject GetObjectByPath(string path, IOperationContext context);
///
/// Gets the latest version in a version series.
///
/// the document ID of an arbitrary version in the version series
IDocument GetLatestDocumentVersion(String objectId);
IDocument GetLatestDocumentVersion(String objectId, IOperationContext context);
IDocument GetLatestDocumentVersion(IObjectId objectId);
IDocument GetLatestDocumentVersion(IObjectId objectId, IOperationContext context);
IDocument GetLatestDocumentVersion(IObjectId objectId, bool major, IOperationContext context);
///
/// Removes the given object from the cache.
///
/// the object ID
void RemoveObjectFromCache(IObjectId objectId);
///
/// Removes the given object from the cache.
///
/// the object ID
void RemoveObjectFromCache(string objectId);
// discovery
///
/// Performs a query.
///
/// the CMIS QL statement
/// indicates if all versions or only latest version should be searched
/// query results
IItemEnumerable Query(string statement, bool searchAllVersions);
///
/// Performs a query using the given .
///
/// the CMIS QL statement
/// indicates if all versions or only latest version should be searched
/// the
/// query results
IItemEnumerable Query(string statement, bool searchAllVersions, IOperationContext context);
IChangeEvents GetContentChanges(string changeLogToken, bool includeProperties, long maxNumItems);
IChangeEvents GetContentChanges(string changeLogToken, bool includeProperties, long maxNumItems,
IOperationContext context);
// create
IObjectId CreateDocument(IDictionary properties, IObjectId folderId, IContentStream contentStream,
VersioningState? versioningState, IList policies, IList addAces, IList removeAces);
IObjectId CreateDocument(IDictionary properties, IObjectId folderId, IContentStream contentStream,
VersioningState? versioningState);
IObjectId CreateDocumentFromSource(IObjectId source, IDictionary properties, IObjectId folderId,
VersioningState? versioningState, IList policies, IList addAces, IList removeAces);
IObjectId CreateDocumentFromSource(IObjectId source, IDictionary properties, IObjectId folderId,
VersioningState? versioningState);
IObjectId CreateFolder(IDictionary properties, IObjectId folderId, IList policies, IList addAces,
IList removeAces);
IObjectId CreateFolder(IDictionary properties, IObjectId folderId);
IObjectId CreatePolicy(IDictionary properties, IObjectId folderId, IList policies, IList addAces,
IList removeAces);
IObjectId CreatePolicy(IDictionary properties, IObjectId folderId);
IObjectId CreateRelationship(IDictionary properties, IList policies, IList addAces,
IList removeAces);
IObjectId CreateRelationship(IDictionary properties);
IItemEnumerable GetRelationships(IObjectId objectId, bool includeSubRelationshipTypes,
RelationshipDirection? relationshipDirection, IObjectType type, IOperationContext context);
// 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 addAces, IList removeAces, AclPropagation? aclPropagation);
void ApplyPolicy(IObjectId objectId, params IObjectId[] policyIds);
void RemovePolicy(IObjectId objectId, params IObjectId[] policyIds);
}
public interface IObjectFactory
{
void Initialize(ISession session, IDictionary parameters);
// ACL and ACE
IAcl ConvertAces(IList aces);
IAcl CreateAcl(IList aces);
IAce CreateAce(string principal, IList permissions);
// policies
IList ConvertPolicies(IList policies);
// renditions
IRendition ConvertRendition(string objectId, IRenditionData rendition);
// content stream
IContentStream CreateContentStream(string filename, long length, string mimetype, Stream stream);
// types
IObjectType ConvertTypeDefinition(ITypeDefinition typeDefinition);
IObjectType GetTypeFromObjectData(IObjectData objectData);
// properties
IProperty CreateProperty(IPropertyDefinition type, IList values);
IDictionary ConvertProperties(IObjectType objectType, IProperties properties);
IProperties ConvertProperties(IDictionary properties, IObjectType type, HashSet updatabilityFilter);
IList ConvertQueryProperties(IProperties properties);
// objects
ICmisObject ConvertObject(IObjectData objectData, IOperationContext context);
IQueryResult ConvertQueryResult(IObjectData objectData);
IChangeEvent ConvertChangeEvent(IObjectData objectData);
IChangeEvents ConvertChangeEvents(string changeLogToken, IObjectList objectList);
}
///
/// Operation context interface.
///
public interface IOperationContext
{
///
/// Gets and sets the property filter.
///
///
/// This is a set of query names.
///
HashSet Filter { get; set; }
///
/// Gets and sets the property filter.
///
///
/// This is a comma-separated list of query names.
///
string FilterString { get; set; }
///
/// Gets and sets if allowable actions should be retrieved.
///
bool IncludeAllowableActions { get; set; }
///
/// Gets and sets if ACLs should be retrieved.
///
bool IncludeAcls { get; set; }
///
/// Gets and sets if relationships should be retrieved.
///
IncludeRelationshipsFlag? IncludeRelationships { get; set; }
///
/// Gets and sets if policies should be retrieved.
///
bool IncludePolicies { get; set; }
///
/// Gets and sets the rendition filter.
///
///
/// This is a set of rendition kinds or MIME types.
///
HashSet RenditionFilter { get; set; }
///
/// Gets and sets the rendition filter.
///
///
/// This is a comma-separated list of rendition kinds or MIME types.
///
string RenditionFilterString { get; set; }
///
/// Gets and sets if path segements should be retrieved.
///
bool IncludePathSegments { get; set; }
///
/// Gets and sets order by list.
///
///
/// This is a comma-separated list of query names.
///
string OrderBy { get; set; }
///
/// Gets and sets if object fetched with this
/// should be cached or not.
///
bool CacheEnabled { get; set; }
///
/// Gets the cache key. (For internal use.)
///
string CacheKey { get; }
///
/// Gets and sets how many items should be fetched per page.
///
int MaxItemsPerPage { get; set; }
}
public interface ITree
{
T Item { get; }
IList> Children { get; }
}
///
/// Base interface for all CMIS types.
///
public interface IObjectType : ITypeDefinition
{
bool IsBaseType { get; }
IObjectType GetBaseType();
IObjectType GetParentType();
IItemEnumerable GetChildren();
IList> GetDescendants(int depth);
}
///
/// Document type interface.
///
public interface IDocumentType : IObjectType
{
bool? IsVersionable { get; }
ContentStreamAllowed? ContentStreamAllowed { get; }
}
///
/// Folder type interface.
///
public interface IFolderType : IObjectType
{
}
///
/// Relationship type interface.
///
public interface IRelationshipType : IObjectType
{
IList GetAllowedSourceTypes { get; }
IList GetAllowedTargetTypes { get; }
}
///
/// Policy type interface.
///
public interface IPolicyType : IObjectType
{
}
public interface IItemEnumerable : IEnumerable
{
IItemEnumerable SkipTo(long position);
IItemEnumerable GetPage();
IItemEnumerable GetPage(int maxNumItems);
long PageNumItems { get; }
bool HasMoreItems { get; }
long TotalNumItems { get; }
}
public interface IObjectId
{
///
/// Gets the object ID.
///
string Id { get; }
}
public interface IRendition : IRenditionData
{
IDocument GetRenditionDocument();
IDocument GetRenditionDocument(IOperationContext context);
IContentStream GetContentStream();
}
///
/// Property interface.
///
public interface IProperty
{
///
/// Gets the property ID.
///
string Id { get; }
///
/// Gets the property local name.
///
string LocalName { get; }
///
/// Gets the property display name.
///
string DisplayName { get; }
///
/// Gets the property query name.
///
string QueryName { get; }
///
/// Gets if the property is a multi-value proprty.
///
bool IsMultiValued { get; }
///
/// Gets the proprty type.
///
PropertyType? PropertyType { get; }
///
/// Gets the property defintion.
///
IPropertyDefinition PropertyDefinition { get; }
///
/// Gets the value of the property.
///
///
/// If the property is a single-value property the single value is returned.
/// If the property is a multi-value property a IList<object> is returned.
///
object Value { get; }
///
/// Gets the value list of the property.
///
///
/// If the property is a single-value property a list with one or no items is returend.
///
IList