cancel
Showing results for 
Search instead for 
Did you mean: 

adding content to space in executeImpl()

pxavier76
Champ in-the-making
Champ in-the-making
I am trying to insert content  to the "CompanyHome" space within the
executeImpl() method of a custom action.

My current attempt  is to copy/paste sections of code from the FirstFoundationClient example to do this work. However, an exception is
thrown everytime

ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();

is called, indicating that Application cache is not initialized. I have tried using code from the FirstWebServiceClient as well but getting no success in doing this.

Does anyone have any alternatives ?
1 REPLY 1

frederick
Champ in-the-making
Champ in-the-making
Hi,

The FirstFoundationClient example uses the 'embedded repository' mechanism, which means it launches an embedded Alfresco during the execution of the example class (using the ApplicationContext approach).
A custom action does not need to do this, as it runs inside the repository already. All you have to do is use Spring to inject the services you need into your ActionExecuter:

<bean id="prepare-image" class="com.jnj.ice.is.action.PrepareImageActionExecuter"
      parent="action-executer">
      <property name="nodeService">
         <ref bean="nodeService"/>
      </property>
      <property name="dictionaryService">
         <ref bean="dictionaryService"/>
      </property>
      <property name="actionService">
         <ref bean="actionService"/>
      </property>
      <property name="mimetypeService">
         <ref bean="mimetypeService"/>
      </property>
      <property name="permissionService">
         <ref bean="permissionService"/>
      </property>
      <property name="publicAction">
         <value>false</value>
      </property>
      <property name="mimetypes">
         <list>
            <value>image/bmp</value>
            <value>image/jpeg</value>
            <value>image/ppm</value>
            <value>image/pgx</value>
            <value>image/tga</value>
            <value>image/tiff</value>
            <value>image/lsm</value>
            <value>image/jp2</value>
            <value>image/j2k</value>
            <value>image/dicom</value>
         </list>
      </property>
   </bean>

Regards,