cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS resources, tutorials, and examples

jpotts
World-Class Innovator
World-Class Innovator
If you are new to CMIS, there are several resources you need to be aware of:
<ul><li><a href="http://cmis.alfresco.com/">Alfresco CMIS Page</a> Includes links to the specification and a live server for testing.</li>
<li><a href="http://ecmarchitect.com/images/articles/cmis/cmis-article.pdf">Getting Started with CMIS</a> Provides a brief introduction and shows how to use the ATOM Pub binding directly.</li>
<li><a href="http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html">Custom Content Types Tutorial</a> Includes several CMIS examples, including CMIS queries and how to query aspects.</li>
<li><a href="http://chemistry.apache.org/">Apache Chemistry</a> Includes client-side API's for working with CMIS in several languages, example code, and how-to's.</li>
<li><a href="http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/">Alfresco OpenCMIS Extension</a> Used for adding aspect support to Apache Chemistry OpenCMIS.</li></ul>

Also, please note that when you are using the CMIS ATOM Pub binding against Alfresco 4, you should use the new OpenCMIS-based URL (http://localhost:8080/alfresco/cmisatom) instead of the old web script-based URL (http://localhost:8080/alfresco/s/api/cmis). The old URL should be considered deprecated. This is not just a URL change–these are two different implementations, so you will see differences in how they behave.

If you are using Alfresco 4.2.x the URL has changed again. You should use one of these URLs:
* http://localhost:8080/alfresco/api/-default-/cmis/versions/1.0/atom
* http://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/atom
* http://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/browser

Jeff
15 REPLIES 15

billydoe
Champ in-the-making
Champ in-the-making
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;
            parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:80/alfresco/service/cmis";
            parameters[DotCMIS.SessionParameter.User] = "username";
            parameters[DotCMIS.SessionParameter.Password] = "password";
       
            SessionFactory factory = SessionFactory.NewInstance();
            ISession session = factory.GetRepositories(parameters)[0].CreateSession();
       

            IOperationContext oc = session.CreateOperationContext();
            oc.IncludeAcls = true;
            IFolder folder = (IFolder)session.GetObjectByPath("/Upload/");

            IDictionary<string, object> properties = new Dictionary<string, object>();
            string id = PropertyIds.ObjectTypeId;
            properties[PropertyIds.Name] = "Mytest.jpg";
            properties[PropertyIds.ObjectTypeId] = "cmis:document";

            Image img = Image.FromFile(@"D:\temp\Test.jpg");
            byte[] arr;
            using (MemoryStream ms = new MemoryStream())
            {
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                arr = ms.ToArray();
            }
            Encoding u8 = Encoding.UTF8;
            ContentStream contentStream = new ContentStream
            {
                // FileName = formattedName,
                MimeType = "image/jpeg",
                Length = arr.Length,
                Stream = new MemoryStream(arr)
            };
            // this statment would create document in default repository

            folder.CreateDocument(properties, contentStream, null);

billydoe
Champ in-the-making
Champ in-the-making
Is there any Thumbnail create/retrive features in DotCMIS?

deathangel908
Champ in-the-making
Champ in-the-making
Hi, I'm new to Alfresco. I need to get inbound emails from Alfresco. Unfortunately I didn't found a better way than just crawl the emailable directory for files. So to get all users' emails I use:

import org.apache.chemistry.opencmis.client.util.FileUtils;
AfrescoDocumentImpl doc = FileUtils.getObject("emailDir/userEmail/", session);
List<CmisObject> allEmails = doc.getChilder()

Every single object has email properties, for example "cm:sentdate" or "cm:subjectline".
Now I stuck with the issue when an email has attachments and I need to get them as well. I can't find a property in AlfrescoDocumentImpl that matches my needs. I also note that if an email has attachments it would also have "attachable" aspect. I even can fetch all document that have attachments with a query: "SELECT * FROM cm:attachable" but they don't refer to the attached files. The query should be something like "Select* from cm:attachments" but attachments table isn't quaryable.
I found that /share application shows emails attachments. And furthermore a table alf_node_assoc is used to connect them. If I had access to database I would select alf_node with join on alf_node_assoc but I don't have it.

I apologize to post here, I can't create new topic because I'm a new user. Could you please suggest me where to look for functionality I need, or if it's an inappropriate topic to write where I should post my message. Thanks in advance!

I also created a topic on stackoverflow, you can see some images there. Maybe this would give you a clue what I mean.

http://stackoverflow.com/questions/34090937/get-documents-attachments-via-alfresco-opencmis

shivakumar_lank
Champ in-the-making
Champ in-the-making
Hi Jeff,

We are trying to remove local permissions to all folders but in some folders file are locked by users. When i try to run the Java Script in folder rules it's got failed, script is below

document.setInheritsPermissions(false);
document.save();
var perms = document.getPermissions();
var arrayLength = perms.length;
for (var i = 0; i < arrayLength; i++) {
   var permArry = perms.split(';');   
   document.removePermission(permArry[2],permArry[1]);
}
document.save();
document.setInheritsPermissions(true);
document.save();

Can you please suggestion me a script to run

Thanks,
Shiva

qsdmv
Champ in-the-making
Champ in-the-making
I am using alfresco SDK's fileFolderService to create file content. After program finishes, I checked from alfresco explore but didn't find content there. I actually run program to batch to create files. Sometimes files are created and sometimes they are not. I have no idea what could go wrong. The API is really simple, just not work consistently. I have no problem to create other types of contents.

FileInfo contentFile = fileFolderService.create(contentPrimaryParentNodeRef, contentName, FILE);
contentNodeRef = contentFile.getNodeRef();


I also use nodeService as replacement. It is also not consistent. It seems having issues with image files etc.

Any thoughts. Thank you in advance.

nandini
Champ in-the-making
Champ in-the-making

How can i upload an document or file using PHP Rest api ??