MonkeyWrench
MonkeyWrench

Reputation: 1839

Alfresco scoped webscript configuration, can it be loaded into an E4X object?

I'm looking to use a scoped configuration file in an Alfresco javascript webscript. I started with this wiki page, and it got me mostly there.

This jira page told me I needed to create a file spring-webscripts-config-custom.xml and place it in a META-INF folder i.e. in /shared/classes/META-INF/spring-webscripts-config-custom.xml. Fine. Got that working. I can load the file, and browse the configuration using the methods listed in the Jira page.

But those methods are a pain to use (childrenMap and getChild), and I'd rather use E4X to parse and query the XML configuration file. To do so, I'd need to get the configuration file as a string and pass it to

var conf = new XML( configStr );

Any ideas on how I can do this?

And a good E4X tutorial page

Upvotes: 3

Views: 584

Answers (1)

skuro
skuro

Reputation: 13514

There's IMHO no way to achieve what you describe with a JS backed webscript. You would need to implement a Java controller to get access to the configuration file and send it back to the client.

That said, exposing their content to the outside world it's not really what the Alfresco configuration files are designed for. If you could disclose more details of you are trying to achieve it would be easier to suggest some proper ways to expose configuration data to the client.


EDIT

After the scope has been clarified, my suggestion is to provide your web script with a dedicated XML configuration file containing all the mapping between error codes and messages. As explained in the docs, let's suppose your web script is defined in myscript.get.desc.xml. Then you can create a file named myscript.get.config.xml that contains e.g.:

<messages>
  <message>
    <id>1</id>
    <desc>A long description here</desc>
  </message>
</messages>

You can then parse such configuration in the JS controller myscript.get.js:

var myconfig = new XML(config.script);

Upvotes: 2

Related Questions