cancel
Showing results for 
Search instead for 
Did you mean: 

cmis

sunitha
Champ in-the-making
Champ in-the-making
Hi ..

I am new to alfresco.I am trying to connect to the alfresco repository by using cmis api.
My program showing some errors at the atompub line..
could you people help me in regarding this area.
my source code..



import java.util.HashMap;
import java.util.Map;

import javax.xml.ws.BindingType;

import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;


public class Third {
   
   public static void main(String arg[]) throws Exception{
      
      
      Map<String, String> parameter = new HashMap<String, String>();

      // Set the user credentials
      parameter.put(SessionParameter.USER, "admin");
      parameter.put(SessionParameter.PASSWORD, "admin");

      // Specify the connection settings
      parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8070/alfresco/service/cmis");
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

      // Set the alfresco object factory
      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

      // Create a session
      SessionFactory factory = SessionFactoryImpl.newInstance();
      Session session = factory.getRepositories(parameter).get(0).createSession();
       System.out.println("Connected to repository:");
   }

}



Thanks,
Sunitha..
22 REPLIES 22

Your code is not compiling for me ("root cannot be resolved").

I'm getting compilation error in this
 Folder newFolder = root.createFolder(newFolderProps); 
line.


Hi..

for me that code was compiling but doesn't creating the folder..try to use the eclipse ide to run the program,follow the appropriate suggestions according to errors..code is running fine but folder is not creating by the program..


Thanks,
sunitha…

muralidharand
Star Contributor
Star Contributor
Hi Sunitha,

Don't use
 Folder newFolder = root.createFolder(newFolderProps); 


Use 
 Folder newFolder = session.getRootFolder().createFolder(newFolderProps); 


Get the root folder object from the session.getRootFolder();

Hope this helps you.

sunitha
Champ in-the-making
Champ in-the-making
Hi..

I am using alfresco community 4.2..
when i enter this url: http://localhost:8080/alfresco/service/cmis/index.html..
it showing 2 repositories in webscripts cmis browser..one is default and another is cmis…when i run any application using apache chemistry java open cmis api..that application result like creation of document or folder storing in default repository..
now my question is why it is showing 2 repositories information and etc..
how can i access my cmis repository?
could anyone help me in this regard..


Thanks,
Sunitha..

ggoutham
Champ in-the-making
Champ in-the-making
Hi even i got the same question.
Can anybody help me in this regard

Thanks in advance,
Goutham

sunitha
Champ in-the-making
Champ in-the-making
Hi…

I am using alfresco 4.2.c..i want to generate workflow reports for my workflows(may be running or completed)..
could you please help me how to generate the workflow reports for tasks and processes..

Thanks in advance,
Sunitha…

muralidharand
Star Contributor
Star Contributor
Hi Sunitha,
Do you want get these informations by using CMIS or webscript?

To get all the workflow instnaces.

api/workflow-instances?state={active|completed?}&initiator={authority?}&priority={priority?}&dueBefore={isoDate?}&dueAfter={isoDate?}&definitionId={workflow_definition_id?}&
    startedBefore={isoDate?}&startedAfter={isoDate?}&completedBefore={isoDate?}&completedAfter={isoDate?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}
    <= SimpleWorkflowInstanceResponse[]

For more information : http://wiki.alfresco.com/wiki/Workflow_REST_API#Get_Workflow_Instance_Collection

To get all the task instnace.
api/task-instances?authority={authority_id?}&state={in_progress|completed?}&priority={priority?}&pooledTasks={true|false?}&
    dueBefore={isoDate?}&dueAfter={isoDate?}&properties={prop1, prop2, prop3…?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?}
    <= SimpleTaskInstanceResponse[]

http://wiki.alfresco.com/wiki/Workflow_REST_API#Get_Task_Instance_Collection

Hope this helps you.

leonardo_pavone
Champ in-the-making
Champ in-the-making
Hi,

try using
"http://localhost:8070/alfresco/cmisatom" instead of "…/service/cmis" … that was a problem for me.

priyankasoni
Champ in-the-making
Champ in-the-making
hi im geeting error
log4j:WARN No appenders could be found for logger (org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubSpi).
log4j:WARN Please initialize the log4j system properly.
ERROR:  'prefix cannot be null or empty'
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Cannot access http://localhost:8080/alfresco/cmisatom/c1280b5d-5fef-4070-9b41-e2c0713a3ccf/children?id=workspace%3...: null
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:224)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invokePOST(HttpUtils.java:74)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:566)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createFolder(ObjectServiceImpl.java:161)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:786)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:129)
   at newFolderCreate.main(newFolderCreate.java:35)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
javax.xml.transform.TransformerException: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty]
   at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
   at org.apache.chemistry.opencmis.commons.impl.JaxBHelper.marshal(JaxBHelper.java:130)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomEntryWriter.write(AtomEntryWriter.java:164)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl$2.write(ObjectServiceImpl.java:163)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:196)
   … 6 more
Caused by: com.sun.istack.internal.SAXException2: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
javax.xml.transform.TransformerException: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.writeDom(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
   … 12 more
Caused by: javax.xml.transform.TransformerException: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
   … 27 more
Caused by: com.sun.istack.internal.SAXException2: prefix cannot be null or empty
javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.attribute(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.ContentHandlerAdaptor.startElement(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToSAXHandler.flushPending(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(Unknown Source)
   at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
   at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
   … 29 more
Caused by: javax.xml.stream.XMLStreamException: prefix cannot be null or empty
   at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeAttribute(Unknown Source)
   at com.sun.xml.internal.bind.v2.runtime.output.XMLStreamWriterOutput.attribute(Unknown Source)
   … 41 more

thangapandirama
Champ in-the-making
Champ in-the-making
I am aldo getting below exception after getting repository and trying to get createsession
Exception in thread "main" java.lang.IllegalArgumentException: Unable to create object factory: java.lang.ClassNotFoundException: org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createObjectFactory(SessionImpl.java:223)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.<init>(SessionImpl.java:169)
   at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.createSession(SessionFactoryImpl.java:89)
   at org.apache.chemistry.opencmis.client.runtime.repository.RepositoryImpl.createSession(RepositoryImpl.java:62)
   at com.Alfresco_adapter.main(Alfresco_adapter.java:36)
Caused by: java.lang.ClassNotFoundException: org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl
   at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:164)
   at org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:44)
   at org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:35)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createObjectFactory(SessionImpl.java:211)
   … 4 more
Please any one help on this