net.adamcin.recap icon indicating copy to clipboard operation
net.adamcin.recap copied to clipboard

Call Recap from command line

Open sgu222e opened this issue 10 years ago • 5 comments

Hi Mark,

This might turn into a 2-part question. Could Recap be called from command line with Curl? I'm going to experiment with this myself. Do you think it would be possible to setup an automated task, either in AEM itself or using command line, to copy content from 1 location to another on a scheduled basis? This would be useful for keeping backups or keeping my QA environment up to date with production content.

Thank in advance,

Leigh C

sgu222e avatar Mar 03 '14 15:03 sgu222e

Hi Leigh,

The short answer is "yes, that should work". I designed this application around a fully-functional internal API, plus supporting servlets which accept simple POST commands with consistent parameters to trigger the remote copy action. Also, if you switch the request extension to .txt, the progress log should be written to the response without HTML markup, so you can use it with curl by redirecting the response to a flat file.

You can look at the code for the AddressBook CopyFrom servlet here:

https://github.com/adamcin/net.adamcin.recap/blob/master/addressbook/src/main/java/net/adamcin/recap/addressbook/impl/servlet/CopyFromServlet.java

You can call this servlet by POSTing a list of paths using the ":paths" parameter (either within a single value separated by \n or with multiple :paths values) to an address node within your user's address book, using the "copy" selector, as in:

curl -u admin:admin -F_charset_=utf-8 -F:paths=/content/path1 -F:paths=/content/path2 -o ./recapProgress.txt "http://localhost:4502/home/users/a/admin/recapAddresses/address_10293012908.copy.txt"

Additionally, all the RecapConstants.RP_* parameters are supported (for simple and advanced copy options). Take a look at the JSP for the UI form that triggers a copy to see how they are used:

https://github.com/adamcin/net.adamcin.recap/blob/master/graniteui/src/main/content/jcr_root/components/addressbook/address/html.GET.jsp

I hope that is enough to get you started.

Mark

adamcin avatar Mar 03 '14 16:03 adamcin

And while I have not provided a scheduler UI to support internal scheduling of transfers out-of-the-box, all of the Recap services are exposed to OSGi with public APIs, so it should be fairly easy for you to create a Runnable service in your own custom code which sets up and executes a RecapSession on a regular interval.

Mark

adamcin avatar Mar 03 '14 17:03 adamcin

I know this issue is pretty old now, but for anyone else that happens across this, it works well for us. I ran it from the web gui to figure out exactly which posts i needed. Here is an example of one that we run to bring content from production to dev:

curl -u admin:admin -F_charset_=utf-8 -F:only_newer=false -F:update=true -F:paths=/content "http://author_address:4502/home/users/a/admin/recapAddresses/prod_auth.copy.txt"

chadlnc avatar Jun 24 '15 15:06 chadlnc

Hi Team, I'm new to recap , I have a doubt once we installed the recap in servers by default it will trigger on every 0:00 PST. how it will happens is their any default configuration or we have to run manually????

chanti28 avatar Apr 28 '16 03:04 chanti28

Old issue, but for any who want to create a Recap address from the command line, you can use the following command.

curl -u admin:prod_auth_password -F_charset_=utf-8 -Fjcr:title=prod_auth -Fsling:resourceType=recap/components/addressbook/address -Fhostname=prodauth.example.com -Fport=4502 -Fusername=admin -Fpassword=password -FisHttps=false "http://author_address:4502/home/users/a/admin/recapAddresses/*.txt"

Nightfirecat avatar Dec 20 '16 21:12 Nightfirecat