cancel
Showing results for 
Search instead for 
Did you mean: 

[solved]read alfresco configuration file in a java class

ethan
Champ in-the-making
Champ in-the-making
Hi Smiley Happy

I would like to know if there's a class in the alfresco API which could allow me to read one of the xml configuration files that exists or access one of the alfresco folder (like the install folder). My goal is to ask the user to set a parameter (an ip adress) in an xml configuration file and then I could refer to it in a java class.
I know I could force the user to install alfresco in a specified directory and hard code the path in my class but I don't like to do this way.

Thank you Smiley Happy
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
Why not use spring to inject the value into your class.   Its how the rest of Alfresco works.

ethan
Champ in-the-making
Champ in-the-making
Thank you for the advice. Actually, I'm trying to create a new action called download-action which will get the file from a distant server instead of retrieving its content from the cm:content property. I started writing the java class and I also wrote a download-action-context.xml file which is :

<beans>
     
    <!– Download Action Bean –>
    <bean id="download-action" class="com.alfresco.customUI.actions.DownloadActionExecuter" parent="action-executer">
       <property name="nodeService">
         <ref bean="NodeService" />
      </property>
      <property name="exchangeServer">
         <value>192.168.20.241</value>
      </property>
      <property name="fileServer">
         <value>192.168.20.221</value>
      </property>
   </bean>
  
      <!– Action properties –>
   <bean id="extension.actionResourceBundles" parent="actionResourceBundles">
      <property name="resourceBundles">
         <list>
            <value>alfresco.extension.download-action-messages</value>
         </list>
      </property>
   </bean>
     
</beans>

I added my ip addresses as properties. But now, I don't know how to access theses properties in my class  :?:
Do get and set for each properties in my class are enought? Is this the right way to proceed ?

Thank you Smiley Happy

ps: post edited

ethan
Champ in-the-making
Champ in-the-making
Hi again Smiley Happy

Could someone tell me if I did well please?

mrogers
Star Contributor
Star Contributor
Yes that's O.K.

ethan
Champ in-the-making
Champ in-the-making
Thank you for your help Smiley Happy