cancel
Showing results for 
Search instead for 
Did you mean: 

Exceptions adding custom aspect

rmangi
Champ in-the-making
Champ in-the-making
Hello all. I'm trying to create a custom aspect and apply it to content and I'm getting exceptions.

It's a very simple aspect, just really trying to create a stub so I can play. Following are the steps I've taken:

XML for the aspect:
repository/config/alfresco/extension/projectModel.xml

<?xml version='1.0' encoding='UTF-8'?>
<model name="gto:projectModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Model of a project in GTO-space</description>
   <author>Rick Mangi</author>
   <version>1.0</version>

  <imports>
         <!– Import Alfresco Dictionary Definitions –>
         <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
         <!– Import Alfresco Content Domain Model Definitions –>
         <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>
   <namespaces>
      <!– Define a Namespace for my new definitions –>
      <namespace uri="gto.project.model" prefix="gto"/>
   </namespaces>

   <!– Type and Aspect definitions go here –>
      <aspects>
      <aspect name="gto:project">
         <title>GTO Project Specification</title>
         <properties>
            <property name="gto:projectName">
               <type>d:text</type>
            </property>
            <property name="gto:clientName">
                  <type>d:text</type>
               </property>
            <property name="gto:entryDate">
               <type>d:datetime</type>
            </property>
         </properties>
      </aspect>
    </aspects>
</model>

added to extension-context.xml:


    <bean id="extension.dictionaryBootstrap" class="org.alfresco.repo.dictionary.DictionaryBootstrap" init-method="bootstrap" depends-on="dictionaryBootstrap">
        <property name="dictionaryDAO"><ref bean="dictionaryDAO"/></property>
        <property name="models">
            <list>
                <value>alfresco/extension/projectModel.xml</value>
                <value>alfresco/extension/exampleModel.xml</value>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>
     

Added to web-client-config.xml


     <config evaluator="aspect-name" condition="gto:projectModel">
      <property-sheet>
         <show-property name="gto:projectName"/>
         <show-property name="gto:clientName"/>
         <show-property name="gto:entryDate"/>
      </property-sheet>
   </config>
  

and


   <config evaluator="string-compare" condition="Action Wizards">
      <types>
         <type name="folder" displayLabelId="space"/>
         <type name="content"/>
      </types>
      <aspects>
         …
         <aspect name="gto:projectModel" displayLabel="GTO Project Model"/>
      </aspects>

in web-client-config-edit-properties.xml


    <config evaluator="aspect-name" condition="gto:projectModel">
      <property-sheet>
         <show-property name="gto:projectName"/>
         <show-property name="gto:clientName"/>
         <show-property name="gto:entryDate"/>
      </property-sheet>
   </config>




I created a rule in the webclient for a space to try to apply the aspect. I've tried adding it to spaces and content but every time I add a type which would trigger the aspect to be added I get the following error:

Error  Please correct the errors below then click Finish.

    * A system error happened during the operation: The aspect is invalid: {gto.project.model}projectModel

and this exception:


11:58:24,897 ERROR [repo.action.ActionServiceImpl] An error was encountered whilst executing the action 'composite-action'.
org.alfresco.service.cmr.dictionary.InvalidAspectException: The aspect is invalid: {gto.project.model}projectModel
        at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspect(DbNodeServiceImpl.java:490)

Does anybody have any ideas where to go from here?

Thanks,

Rick
11 REPLIES 11

rmangi
Champ in-the-making
Champ in-the-making
i did run the test program to validate the xml before deploying it… passed fine.

rmangi
Champ in-the-making
Champ in-the-making
Bump… anybody have any advice? Anything else I should post here?

gavinc
Champ in-the-making
Champ in-the-making
Hi,

Apologies for missing your previous post.

The problem is that you are referencing the model name and not the aspect name. In your model you have the following snippet:

<aspect name="gto:project">
   <title>GTO Project Specification</title>

The aspect name is gtoSmiley Tongueroject so in the web client config files you should be using this and not "gtoSmiley TonguerojectModel".

So for example in web-client-config.xml and web-client-config-edit-properties.xml you should use the following evaluator expression:

<config evaluator="aspect-name" condition="gto:project">


The same also goes for the reference in the Action Wizards section.

Hope that helps.

hsp
Champ in-the-making
Champ in-the-making
I did what you wrote, but after try to apply an aspect in a rule, when it will show the aspect list available, in fact show the errors in UI:
javax.faces.FacesException: Error calling action method of component with id new-rule-condition:set-add-button

caused by:
javax.faces.el.EvaluationException: Exception while invoking expression #{NewRuleWizard.promptForConditionValues}

caused by:
java.lang.NullPointerException

Hide Details

javax.faces.FacesException: Error calling action method of component with id new-rule-condition:set-add-button at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74) at javax.faces.component.UICommand.broadcast(UICommand.java:106) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164) at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106) at org.alfresco.web.app.servlet.AlfrescoFacesServlet.service(AlfrescoFacesServlet.java:49) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) at java.lang.Thread.run(Thread.java:595) Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{NewRuleWizard.promptForConditionValues} at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) … 29 more Caused by: java.lang.NullPointerException at org.alfresco.web.bean.wizard.NewRuleWizard.promptForConditionValues(NewRuleWizard.java:266) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129) … 30 more

If needed I can post the changes in the files for your inspection.

hsp
Champ in-the-making
Champ in-the-making
Well, forget about it. At the moment it is working, after I logged out and in again. Thank's

rmangi
Champ in-the-making
Champ in-the-making
Hi Gavin,

That worked! Thanks. Ok, but now I have another question on this same topic. So I added the aspect to a space using a rule based on the name "Project*". I created a new space and it adds the aspect. When I go to edit the properties of this space it shows the fields I've added, but they are greyed out and I can't change them, just blank values. How do I edit these values?

What I'm trying to do is to add some custom properties to certain spaces which represent Projects in our firm. This data should be attached to the Project (space) not to the documents in the space, things such as client name, project code, create date, that sort of meta data.

Thanks,

Rick

hsp
Champ in-the-making
Champ in-the-making
Besides this case above, I have a doubt eigther. After create the aspect, I changed the name of a propertie,
It was "nomeCLiente"
I changed to "nomeCliente".
But Before I change it, I'd already assigned the aspect to one document, and after I change it (redeployed it). So, the propertie "nomeCliente" doesn't appears now. How could it be, neigther that already assigned ("nomeCLiente")?
(I wait by the answer of rmangi question too)
Tks
Helio

gavinc
Champ in-the-making
Champ in-the-making
I presume you are talking about the 'View Details' page for the space where the the properties are shown but grayed out.

The list of properties that appear here are driven from the configuration file (web-client-config.xml). The list is built from all the property-sheet config found for each applicable type and/or aspect. rmangi has an example of this at the beginning of this topic. hsp, have you updated your config to show "nomeCliente" instead of "nomeCLiente"?

To edit the properties you can click on the small icon in the title bar of the Properties panel (on the right hand side). This should take you to the edit properties page for the space. If you don't see this icon it means you do not have the permissions to edit.

However, unfortunately, the edit space details page is not dynamic at the moment (unlike the edit content properties page) meaning that despite what you have configured in web-client-config-edit-properties.xml none of the properties will show up.

We will be fixing this in the release after 1.2, so in the meantime you will have to create your own details page. You could use the same technique the forums use to dispatch to your own page instead of the standard one. To do this you would need the following config:

<config evaluator="aspect-name" condition="gto:project">
   <property-sheet>
      <show-property name="gto:projectName"/>
      <show-property name="gto:clientName"/>
      <show-property name="gto:entryDate"/>
   </property-sheet>

   <navigation>
      <override from-outcome="showSpaceDetails" to-view-id="/jsp/your/aspect-details-page.jsp" />
   </navigation>
</config>

You will then also need to create a backing bean for your new page to take the properties entered by the user and update the node in the repository.

If you want to use this approach you will need to get the latest source from SVN or the nightly build.

Hope this helps.

gavinc
Champ in-the-making
Champ in-the-making
The issues i mentioned in the previous post are covered by the following JIRA issues:

http://www.alfresco.org/jira/browse/AWC-447
http://www.alfresco.org/jira/browse/AWC-99