Custom code development using CMIS

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2013 10:27 AM
Hello All,
I am developing a custom .NET based application which needs to interact with the Alfresco system in place. I want to retrieve all the versions of a particular document along with all their metadata and pass them to my custom application.
I have written following code, but its giving me "Bad Request" error. I think I am getting error where there is some mismatch in the RepositoryId and ObjectId that is getting passed. I need your kind help to fix the same.
private IItemEnumerable<ICmisObject> GetChildren(IOperationContext context)
{
string objectId = "1a8fefd8-d99c-4df2-9a44-e66e2cadea2d";
INavigationService service = session.Binding.GetNavigationService();
IObjectFactory of = session.ObjectFactory;
IOperationContext ctxt = new OperationContext(context);
String folderId = session.GetObject("workspace://SpacesStore/0270f45a-b41a-41af-bab8-4951234817b9").Name;
service.GetFolderTree(session.RepositoryInfo.Id,"0270f45a-b41a-41af-bab8-4951234817b9",1000,context.FilterString,context.IncludeAllowableActions,context.IncludeRelationships,context.RenditionFilterString,context.IncludePathSegments
IObjectInFolderList children1 = service.GetChildren(session.RepositoryInfo.Id, objectId, context.FilterString, context.OrderBy, context.IncludeAllowableActions, context.IncludeRelationships, context.RenditionFilterString, context.IncludePathSegments, 10, 0, null);
PageFetcher<ICmisObject>.FetchPage fetchPageDelegate = delegate(long maxNumItems, long skipCount)
{
IObjectInFolderList children = service.GetChildren(session.RepositoryInfo.Id, objectId, context.FilterString, context.OrderBy, context.IncludeAllowableActions, context.IncludeRelationships, context.RenditionFilterString, context.IncludePathSegments, maxNumItems, skipCount, null);
// convert objects
IList<ICmisObject> page = new List<ICmisObject>();
if (children.Objects != null)
{
foreach (IObjectInFolderData objectData in children.Objects)
{
if (objectData.Object != null)
{
page.Add(of.ConvertObject(objectData.Object, ctxt));
}
}
}
return new PageFetcher<ICmisObject>.Page<ICmisObject>(page, children.NumItems, children.HasMoreItems);
};
return new CollectionEnumerable<ICmisObject>(new PageFetcher<ICmisObject>(context.MaxItemsPerPage, fetchPageDelegate));
}
I am developing a custom .NET based application which needs to interact with the Alfresco system in place. I want to retrieve all the versions of a particular document along with all their metadata and pass them to my custom application.
I have written following code, but its giving me "Bad Request" error. I think I am getting error where there is some mismatch in the RepositoryId and ObjectId that is getting passed. I need your kind help to fix the same.
private IItemEnumerable<ICmisObject> GetChildren(IOperationContext context)
{
string objectId = "1a8fefd8-d99c-4df2-9a44-e66e2cadea2d";
INavigationService service = session.Binding.GetNavigationService();
IObjectFactory of = session.ObjectFactory;
IOperationContext ctxt = new OperationContext(context);
String folderId = session.GetObject("workspace://SpacesStore/0270f45a-b41a-41af-bab8-4951234817b9").Name;
service.GetFolderTree(session.RepositoryInfo.Id,"0270f45a-b41a-41af-bab8-4951234817b9",1000,context.FilterString,context.IncludeAllowableActions,context.IncludeRelationships,context.RenditionFilterString,context.IncludePathSegments
IObjectInFolderList children1 = service.GetChildren(session.RepositoryInfo.Id, objectId, context.FilterString, context.OrderBy, context.IncludeAllowableActions, context.IncludeRelationships, context.RenditionFilterString, context.IncludePathSegments, 10, 0, null);
PageFetcher<ICmisObject>.FetchPage fetchPageDelegate = delegate(long maxNumItems, long skipCount)
{
IObjectInFolderList children = service.GetChildren(session.RepositoryInfo.Id, objectId, context.FilterString, context.OrderBy, context.IncludeAllowableActions, context.IncludeRelationships, context.RenditionFilterString, context.IncludePathSegments, maxNumItems, skipCount, null);
// convert objects
IList<ICmisObject> page = new List<ICmisObject>();
if (children.Objects != null)
{
foreach (IObjectInFolderData objectData in children.Objects)
{
if (objectData.Object != null)
{
page.Add(of.ConvertObject(objectData.Object, ctxt));
}
}
}
return new PageFetcher<ICmisObject>.Page<ICmisObject>(page, children.NumItems, children.HasMoreItems);
};
return new CollectionEnumerable<ICmisObject>(new PageFetcher<ICmisObject>(context.MaxItemsPerPage, fetchPageDelegate));
}
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2013 05:00 AM
Hi Amit,
What is your DOTCMIS version? If possible, please post your complete class file.
What is your DOTCMIS version? If possible, please post your complete class file.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2013 05:43 AM
Hi Amit,
Please try this and let me know.
To retrieve all the versions of a particular document.
Please try this and let me know.
To retrieve all the versions of a particular document.
Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub; parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/service/cmis"; parameters[DotCMIS.SessionParameter.User] = "admin"; parameters[DotCMIS.SessionParameter.Password] = "admin"; SessionFactory factory = SessionFactory.NewInstance(); ISession session = factory.GetRepositories(parameters)[0].CreateSession(); // get the document using its noderef Document document = ((Document)session.GetObject("workspace://SpacesStore/b49fb618-76a1-4f19-91ac-37c8c39a2412")); IList<IDocument> documents = document.GetAllVersions(); foreach(Document doc in documents ) { Console.WriteLine("Document name : " + doc.Name + " and its version " + doc.VersionLabel); }

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2013 11:32 PM
Hello Murali,
This really worked and I could get my code going with this. Many Thanks again for your extended support..
This really worked and I could get my code going with this. Many Thanks again for your extended support..

