cancel
Showing results for 
Search instead for 
Did you mean: 

Aspect doesn't work

fabernate
Champ in-the-making
Champ in-the-making
Hello

this is my tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml

very simple

<alfresco-config>
  
   <!– Repository Library config section –>
   <config evaluator="string-compare" condition="RepositoryLibrary" replace="true">
      <aspect name="zz:attributes">
         <title>More Attributes</title>
         <properties>
            <property name="zz:docType">
               <type>d:text</type>
            </property>
         
            <property name="zz:refId">
               <type>d:text</type>
            </property>
         </properties>
         <addable></addable>
         <visible>true</visible>
      </aspect>
   </config>
  
</alfresco-config>

and this is the code lines

public Document upload(File f, String mimeType, Folder folder) throws FileNotFoundException {
      ContentStream contentStream = new ContentStreamImpl(f.getName(), null, mimeType, new FileInputStream(f));
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put(PropertyIds.NAME, contentStream.getFileName());
      properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document, P:zz:attributes");
      properties.put("zz:docType", "CIAO");
      
      return folder.createDocument(properties, contentStream , VersioningState.MAJOR);
   }

I get the floowing exceptions:

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Type 'cmis:document, P:zz:attributes' is unknown!
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:432)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:554)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getTypeDefinitionInternal(AbstractAtomPubService.java:821)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:80)
   at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:137)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getTypeDefinition(SessionImpl.java:508)
   at org.apache.chemistry.opencmis.client.runtime.repository.ObjectFactoryImpl.convertProperties(ObjectFactoryImpl.java:294)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:716)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:88)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:443)
   at com.lynxspa.util.alfresco.AFRepo.upload(AFRepo.java:107)
   at main.Main.main(Main.java:21)

Obviousely if I remove the code regarding the Aspect it works

Where am I wrong ?

Thanks
6 REPLIES 6

afaust
Legendary Innovator
Legendary Innovator
Hello,

please see the Wiki concerning extending the types and aspects.
Your error lies in the fact that you have mixed up data model and UI configuration. The share-config-custom.xml is NOT the right place for your aspect definition - this needs to be deployed on the Alfresco Repository tier via a dictionary bootstrap. The share-config-custom.xml ONLY contains UI configuration for the Share client, e.g. how nodes with the aspect are displayed in structured forms or which aspects are available in the "Manage Aspects" action.

Regards
Axel

fabernate
Champ in-the-making
Champ in-the-making
Hi

so this is my new \tomcat\shared\classes\alfresco\extension\myModel.xml

<model name="zz:lynxModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Example custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
   
    <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
   
    <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
  </imports>
 
   <namespaces>
   
      <namespace uri="my.new.model" prefix="zz"/>
   </namespaces>

   <aspects>
      <aspect name="zz:attributes">
         <title>More Attributes</title>
         <properties>
            <property name="zz:docType">
               <type>d:text</type>
            </property>
         
            <property name="zz:refId">
               <type>d:text</type>
            </property>
         </properties>         
      </aspect>
   </aspects>
</model>

and Alfresco load it succesfully (at the beginning cause errors Alfresco log was full of Exception, anyway now it works)

these are the code lines

public Document upload(File f, String mimeType, Folder folder) throws FileNotFoundException {
ContentStream contentStream = new ContentStreamImpl(f.getName(), null, mimeType, new FileInputStream(f));
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, contentStream.getFileName());
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document, P:zz:attributes");
properties.put("zz:docType", "CIAO");

SAME ERROR
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Type 'cmis:document, P:zz:attributes' is unknown!

afaust
Legendary Innovator
Legendary Innovator
Hello,

is the Alfresco OpenCMIS extension correctly installed / referenced in your project? If not, then this is most likely the cause for your exception.

Regards
Axel

fabernate
Champ in-the-making
Champ in-the-making
Thank god errors change

So I changed the method in

public AlfrescoDocument upload(File f, String mimeType, AlfrescoFolder folder) throws FileNotFoundException {
      ContentStream contentStream = new ContentStreamImpl(f.getName(), null, mimeType, new FileInputStream(f));
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put(PropertyIds.NAME, contentStream.getFileName());
      properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:zz:attributes");
      properties.put("zz:docType", "CIAO");
      properties.put("zz:refId", "CIAO");
      
      return (AlfrescoDocument) folder.createDocument(properties, contentStream , null);
   }

and now the exceptions is


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/1359f0c0-fc71-4b64-85ec-937e440825ce/children?id=workspace%3...: null
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:208)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invokePOST(HttpUtils.java:70)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:566)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:127)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:716)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:88)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:443)
   at com.lynxspa.util.alfresco.AFRepo.upload(AFRepo.java:110)
   at main.Main.main(Main.java:21)
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:146)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl$1.write(ObjectServiceImpl.java:129)
   at org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils.invoke(HttpUtils.java:180)
   … 8 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)
   … 14 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)
   … 29 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)
   … 31 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)
   … 43 more

fabernate
Champ in-the-making
Champ in-the-making
OK

Solved with the download of the most recent library

Thanks

juxxo
Champ in-the-making
Champ in-the-making
I had that same problem: "ERROR:  'prefix cannot be null or empty' ", when implementing one solution with Eclipse and Java and OpenCMIS (0.7.0 and 0.8.0).  The solution in my case was to insert library wstx-asl-3.2.3.jar in Java build path (class path) in Eclipse. (wstx-asl-3.2.3.jar library comes with OpenCMIS zip packet)