Hi Guys We are looking to add 600 datasources fro...
# box-products
c
Hi Guys We are looking to add 600 datasources from ACF's:
Copy code
neo-datasources.xml
Into a format that we can import into Lucee Both application servers are standalone servers, but we are allowed to install commandbox on the boxes I have created a small app that uses Lucee's brilliant import method:
Copy code
variables.config = ConfigImport(
    data=variables.data,
    type='server',
    password=variables.adminpassword
);
So, the idea would be to deserialise data, from a file [I guess JSON would be easiest], into a struct that could then be handled by
ConfigImport()
I have had a look at: https://www.forgebox.io/view/commandbox-cfconfig But I wasn't sure whether it could convert an XML file into JSON, or whether I would have to write the routine to do this from scratch? I cannot have both the ACF and Lucee servers, running on the same box. Only the Lucee standalone server is running. So, I am going to have to work at settings file level.
p
Cfconfig can export all your CF settings and data sources with one simple command and also import them to any environment! That’s what it is for!!
πŸ‘†πŸ» 1
πŸ‘† 1
πŸ‘ 1
r
In CommandBox, you can run
help cfconfig export
and
help cfconfig import
for documentation and examples.
πŸ‘ 1
d
CFConfig works with the xml files directly, providing an API to interact with them. ColdFusion/Lucee doesn't need to be running on either server at all, the whole operation is done by CFConfig running under CommandBox.
πŸ™ 1
r
<3 cfconfig
b
@Charles Robertson While you can use the CFConfig service layer directly in Lucee, I don't know that there's a reason to. Just use the commands like people mentioned above. You can also use the
includeLIst
to export only datasources if you need.
So for the export on the old server, it will be something like
Copy code
cfconfig export from=C:/coldfusion2021/cfusion to=.cfconfig.json
and then you can just drop that JSON file in the webroot of the CommandBox server and it will get picked up when CommandBox start
Or, if you wish, directly import it with
cfconfig import .cfconfig.json
πŸ‘ 1
c
Thanks very much for all the replies. This looks just what we need πŸ™‚
@Dave Merrill I have tried this:
Copy code
cfconfig export from=C:\Users\ADMCharlesr\Desktop\work\xml\neo-datasource.xml to=C:\Users\ADMCharlesr\Desktop\work\xml\.cfconfig-datasource-export.json
And I got this:
Copy code
File is not valid JSON. [C:\Users\ADMCharlesr\Desktop\work\xml\neo-datasource.xml].  Operation aborted.
@bdw429s Hi Brad OK. I have tried this instead:
Copy code
cfconfig export from=C:\Users\ADMCharlesr\.CommandBox\server\02CE1AF3E66B5B8AF1259F8CF863C257-acf11019314546CB5_domains2\adobe-11.0.19.314546\WEB-INF\cfusion to=C:\domains\acf11-0-19_314546-cfconfig\json\.cfconfig-export.json
And I now get a
json
file, full of config? So, this is a great improvement. πŸ™‚ However, there is one big problem, there are no datasources, in the config file? And this is actually the whole reason why I wanted to do the export, in the first place. I have checked the
Copy code
C:\Users\ADMCharlesr\.CommandBox\server\CC852531F91E59BD5E842D9547526422-acf11019314546cfconfig\adobe-11.0.19.314546\WEB-INF\cfusion\lib\neo-datasource.xml
And it contains 44KB worth of datasource information. So, there are plenty of datasources for it to convert. It has successfully converted:
Copy code
C:\Users\ADMCharlesr\.CommandBox\server\CC852531F91E59BD5E842D9547526422-acf11019314546cfconfig\adobe-11.0.19.314546\WEB-INF\cfusion\lib\neo-debug.xml
So, it can't be anything to do with the WDDX tags? It maybe that the neo-datasource.xml, is too big in size. Maybe
cfconfig
cannot place the file contents, into to memory?
I have resolved it @bdw429s I was pointing it to the wrong file πŸ˜΅β€πŸ’« Very embarrassed...
I must say this tool is absolutely amazing. 658 datasources were converted from the XML monstrosity that is
neo-datasource.xml
to JSON, within about a second. That’s 1.2MB config file, in the time it would take you to blink. That has just saved my manager a week’s work, and has put me in his good books. πŸ™‚ Thank you @bdw429s at Ortus. πŸ‘πŸ»
πŸ‘πŸ» 1
πŸ‘ 2
b
Glad you got it sorted
Here's the relevant docs for anyone following allong
The
cfusion
folder that contains the
lib/neo-runtime.xml
file. An example would be:
C:/ColdFusion11/cfusion/
i.e., you point to the server home, not a specific XML file But even that wasn't necessary-- it appears you were trying to copy config from a COmmandBox server. In that, case you could have just used the server name!
Copy code
cfconfig transfer from=acf11019314546cfconfig to=myfile.json
And if you wanted to limit what config was transfered, you can use the include/exclude list https://cfconfig.ortusbooks.com/using-the-cli/command-overview/transfer-settings#includelist-and-excludelist
Copy code
cfconfig transfer from=acf11019314546cfconfig to=myfile.json include=datasources