cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to add aspect to a node in 2.0

doblek
Champ in-the-making
Champ in-the-making
Hi all,

I had this method working in version 1.3:

private Reference createFolder (Store inStore, Reference inNode, String folder_name, String str_prepend, String description)
   throws Exception{
      ParentReference parent_folder_ref;
      parent_folder_ref = new ParentReference(inStore, inNode.getUuid(), null, Constants.ASSOC_CONTAINS, str_prepend+folder_name);
      
      NamedValue[] folder_properties = new NamedValue[]{new NamedValue(Constants.PROP_NAME, false, folder_name, null)};
      //CMLCreate create_folder = new CMLCreate(folder_name, parent_folder_ref, Constants.TYPE_FOLDER, folder_properties);
      CMLCreate create_folder = new CMLCreate(folder_name, parent_folder_ref, null, null, null, Constants.TYPE_FOLDER, folder_properties);
      
      CML cml = new CML();
      cml.setCreate(new CMLCreate[]{create_folder});

      UpdateResult[] upd_result = WebServiceFactory.getRepositoryService().update(cml);
      
      Reference folder_ref = upd_result[0].getDestination();
      
      NamedValue[] aspect_properties = new NamedValue[]{new NamedValue(Constants.PROP_DESCRIPTION, false, description, null)};
      CMLAddAspect addAspect2Folder = new CMLAddAspect(
                                    "{http://www.alfresco.org/model/application/1.0}uifacets",
                                    aspect_properties,
                                    new Predicate(new Reference[]{folder_ref}, inStore, null),
                                    null);

      cml.setAddAspect(new CMLAddAspect[]{addAspect2Folder});
      WebServiceFactory.getRepositoryService().update(cml);

      
      return folder_ref;
   }

which creates a new folder in Alfresco and fills 'description' field and adds aspect 'uifacets'.

But now, with version 2.0, it crashes at:


cml.setAddAspect(new CMLAddAspect[]{addAspect2Folder});
WebServiceFactory.getRepositoryService().update(cml);         //This is the command that crashes


It creates the folder, but the aspect and the property are not added…

From the error stack trace it seems to be related to some axis, xerces. But sorry, i can't find the stack trace in any log (Tomcat or Alfresco), it's only on the console… =(

Any help appreciated.

Regards,
Enrique
5 REPLIES 5

jonas
Champ in-the-making
Champ in-the-making
Hi,

It is in need to add the aspect in content model first. Then you can use it.

Normally, aspects were not added to the new types directly.

Here is an example, there is a new type called cd:document, which inherited from cm:content. The aspect titled is not added to cd:document directly.

The suitable specification should look like

<!– Base Document Type –>
     <type name="cd:cddocument">
         <title>CD_Document</title>
         <parent>cm:content</parent>
         <properties>
           <property name="cd:cdComments">
                 <title>User Comments</title>
                <type>d:text</type>
           </property>
           <property name="cd:cdSize">
                 <title>Content Size</title>
                <type>d:long</type>
           </property>
         </properties>
         <mandatory-aspects>
            <aspect>cm:titled</aspect>
            <aspect>cmSmiley Surprisedwnable</aspect>
            <aspect>cm:author</aspect>
            <aspect>cm:versionable</aspect>
            <aspect>cm:lockable</aspect>
            <aspect>cd:keywordable</aspect>
            <aspect>cd:versionLabel</aspect>
            <aspect>cm:complianceable</aspect>
            <aspect>cm:subscribable</aspect>
            <aspect>cd:lifecyclable</aspect>
         <aspect>cd:subjectable</aspect>           
         </mandatory-aspects>
     </type>

doblek
Champ in-the-making
Champ in-the-making
Hi Jonas,

and thanks for your quick response 😃

But I think I don't understand you well  Smiley Surprisedops:

This aspect is defined in the Alfresco's applicationModel… so I guess I could use it without problems, right?

From your point of view, what I should do?

Thanks,
Enrique

doblek
Champ in-the-making
Champ in-the-making
Hi again,

These are the error traces that appear in the console:

sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
java.lang.Class.newInstance0(Class.java:350)
java.lang.Class.newInstance(Class.java:303)
org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
org.alfresco.webservice.repository.RepositoryFault.getDeserializer(RepositoryFault.java:146)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
org.apache.axis.client.Call.invokeEngine(Call.java:2784)
org.apache.axis.client.Call.invoke(Call.java:2767)
org.apache.axis.client.Call.invoke(Call.java:2443)
org.apache.axis.client.Call.invoke(Call.java:2366)
org.apache.axis.client.Call.invoke(Call.java:1812)
org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.update(RepositoryServiceSoapBindingStub.java:986)
es.upm.dit.portlet.Alfresco.AlfrescoRegistrationPortlet.createFolder(AlfrescoRegistrationPortlet.java:590)
es.upm.dit.portlet.Alfresco.AlfrescoRegistrationPortlet.registerUserInAlfresco(AlfrescoRegistrationPortlet.java:380)
es.upm.dit.portlet.Alfresco.AlfrescoRegistrationPortlet.processAction(AlfrescoRegistrationPortlet.java:272)
org.apache.jetspeed.factory.JetspeedPortletInstance.processAction(JetspeedPortletInstance.java:96)
org.apache.jetspeed.container.JetspeedContainerServlet.doGet(JetspeedContainerServlet.java:221)
org.apache.jetspeed.container.JetspeedContainerServlet.doPost(JetspeedContainerServlet.java:344)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:215)
org.apache.jetspeed.container.invoker.ServletPortletInvoker.action(ServletPortletInvoker.java:134)
org.apache.pluto.PortletContainerImpl.processPortletAction(PortletContainerImpl.java:164)
org.apache.jetspeed.container.JetspeedPortletContainerWrapper.processPortletAction(JetspeedPortletContainerWrapper.java:132)
org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl.invoke(ActionValveImpl.java:95)
org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:166)
org.apache.jetspeed.container.ContainerValve.invoke(ContainerValve.java:76)

Hope that helps… =/
Is it related to axis or xerces version?

Thanks,
Enrique

jonas
Champ in-the-making
Champ in-the-making
Hi

Here is applicationModel.xml.

When you use aspect, such as "app:uifacets", you need to add the aspect to your content type first as follows

<!– Base Document Type –>
     <type name="cd:cddocument">
         <title>CD_Document</title>
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>app:uifacets</aspect>
         </mandatory-aspects>
     </type>

Then you can use it as much as you can in Web services or other applciations.


———————————
<model name="app:applicationmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Alfresco Application Model</description>
   <author>Alfresco</author>
   <published>2005-09-29</published>
   <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="http://www.alfresco.org/model/application/1.0" prefix="app"/>
   </namespaces>

  
   <types>
  
      <!– TODO: Glossary will be revisited when implementation is better understood –>
      <type name="app:glossary">
         <parent>cm:folder</parent>
         <!–
         <mandatory-aspects>
            <aspect>CategoryContainable</aspect>
         </mandatory-aspects>
         <associations>
            <association name="app:namespace">
               <target-type>Category</target-type>
               <target-multiplicity>0..*</target-multiplicity>
               <source-mulitplicity>0..1<source-multiplicity>
               <duplicates-allowed>false</duplicates-allowed>
            </association>
         </associations>
         –>
      </type>

      <type name="app:configurations">
         <title>Configurations</title>
         <parent>cm:systemfolder</parent>
      </type>
     
      <type name="app:filelink">
         <title>File Link Object</title>
         <parent>cm:link</parent>
      </type>
     
      <type name="app:folderlink">
         <title>Folder Link Object</title>
         <parent>cm:link</parent>
      </type>

   </types>

   <aspects>
  
      <aspect name="app:uifacets">
         <title>UI Facets</title>
         <parent>cm:titled</parent>
         <properties>
            <property name="app:icon">
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
  
      <aspect name="app:inlineeditable">
         <title>Inline Editable</title>
         <properties>
            <property name="app:editInline">
               <title>Edit Inline</title>
               <type>d:boolean</type>
            </property>
         </properties>
      </aspect>
  
      <!–  TODO: Is this needed - should simpleworkflow ? –>
      <aspect name="app:workflow">
         <title>Workflow</title>
      </aspect>
  
      <aspect name="app:simpleworkflow">
         <parent>app:workflow</parent>
         <properties>
            <property name="app:approveStep">
               <type>d:text</type>
               <protected>true</protected>
            </property>
            <property name="app:approveFolder">
               <type>d:noderef</type>
               <protected>true</protected>
            </property>
            <property name="app:approveMove">
               <type>d:boolean</type>
            </property>
            <property name="app:rejectStep">
               <type>d:text</type>
               <protected>true</protected>
            </property>
            <property name="app:rejectFolder">
               <type>d:noderef</type>
               <protected>true</protected>
            </property>
            <property name="app:rejectMove">
               <type>d:boolean</type>
            </property>
         </properties>
      </aspect>

      <aspect name="app:configurable">
         <title>Configurable</title>
         <associations>
            <child-association name="app:configurations">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>app:configurations</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </child-association>
         </associations>
      </aspect>
     
      <aspect name="app:feedsource">
         <title>Feed Source</title>
         <properties>
            <property name="app:template">
               <title>Feed Template</title>
               <type>d:noderef</type>
               <mandatory>false</mandatory>
            </property>
         </properties>
      </aspect>

   </aspects>
   
</model>

doblek
Champ in-the-making
Champ in-the-making
Hi Jonas,

and thanks again for your help 😃

Now, I've realized I've got a problem with aspects (due to instalation I think…). After solving that trouble, I'll try your suggestion…

Regards,
Enrique