Background: I've been thinking about adopting a service mix including Apache Sling, Jackrabbit, and Jetty, for purposes of content management within web site designs. At this point, I'd like to imagine that it would be possible to create a mobile content creation platform using DAV to access a JCR content repository. The matter of Versioning in JCR 2.0 (JSR-283) it leaves me wondering, how would one conduct JCR versioning operations via HTTP?
In more detail: I'm looking at what I presume would be section 15 of JSR-283, served up in HTML format from Adobe. In that section, JSR-283 presents a concept of versioning for JCR nodes.
I understand, then, that there's a VersionManager API in JSR-283 compatible releases of Jackrabbit. That serves to explain how one would conduct JCR (JSR-283) versioning operations via the API. So, but how can a user agent conduct a versioning operation via DAV?
I'd like to answer that one for myself, but I don't even know where to start.
Is there another part of JSR-283 explaining how the version checkin/checkout operations translate into HTTP requests? Is it a matter of simple DAV properties? Am I even close to the mark, at that?
/Peer review needed, lol
There is a document (JCR_Webdav_Protocol.doc - Apache Jackrabbit) describing the mapping between WebDAV method calls and Jackrabbit JCR API calls on the Jackrabbit website:
http://jackrabbit.apache.org/JCR_Webdav_Protocol.doc
Though this document is last updated 29.March 2006 I found it quite helpful to make my first steps.
I have traced a session with Microsoft Office 2010 against my Jackrabbit default repository using Word and Wireshark. The following shell script kind of executes the same actions using curl and libreoffice on *nix.
As you can see the DELETE, UPLOAD, VERSION-CONTROL Document WebDAV calls are executed upfront to the actions in Word.
The Browse Directory opens the URL in your Internet Explorer instance.
Microsoft Word retrieves Document Properties (PROPFIND) and then opens (GET) and LOCKs the Document.
It also requests the Properties on %EE%B3%B0 for unknown reasons (UTF-8 (hex) 0xEE 0xB3 0xB0 (eeb3b0) or UTF-16 "\uECF0" a.k.a. "" from the Private Use Range of Unicode Character Set).
Once you Save the Document in Microsoft Word it will upload (PUT) and update the properties (PROPPATCH) of your Document node to include Win32CreationTime, Win32LastModifiedTime and Win32LastAccessTime stamps.
Closing the Document in Word will release the aquired lock using UNLOCK.
CHECKIN Document is again executed manually to make the Version lifecycle complete.
The Version-Tree REPORT can be gained from WebDAV too.
#!/bin/sh
# Delete document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X DELETE -v http://localhost:7001/repository/default/test.docx
# Upload document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PUT -v http://localhost:7001/repository/default/test.docx --data-binary "#test.docx"
# Version-Control document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X VERSION-CONTROL -v http://localhost:7001/repository/default/test.docx
# Checkout document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X CHECKOUT -v http://localhost:7001/repository/default/test.docx
# Browse directory
curl -A "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" -X GET -v http://localhost:7001/repository/default/
# Open document in Word
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPFIND -v http://localhost:7001/repository/default/test.docx | xmllint --format -
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X GET -v http://localhost:7001/repository/default/test.docx -O
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPFIND -v http://localhost:7001/repository/default/test.docx%EE%B3%B0
cat > LOCK_document.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:lockinfo xmlns:D="DAV:">
<D:lockscope>
<D:exclusive/>
</D:lockscope>
<D:locktype>
<D:write/>
</D:locktype>
<D:owner>
<D:href>WINDOWSDOMAIN\USER</D:href>
</D:owner>
</D:lockinfo>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X LOCK -v http://localhost:7001/repository/default/test.docx --data "#LOCK_document.xml" | xmllint --format - | tee LOCK_document.txt
export LOCK_token=$(grep opaquelocktoken LOCK_document.txt | sed 's/^.*opaquelocktoken:/<opaquelocktoken:/' | sed 's/<\/D:href>.*$/>/')
curl -A "Microsoft Office Existence Discovery" -X HEAD -v http://localhost:7001/repository/default/test.docx
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X OPTIONS -v http://localhost:7001/ -H "translate: f"
# Edit document in Word
libreoffice test.docx
# Save document in Word
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X HEAD -v http://localhost:7001/repository/default/test.docx
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PUT -v http://localhost:7001/repository/default/test.docx -H "If: (${LOCK_token})" --data-binary "#test.docx"
cat > PROPPATCH_document.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:" xmlns:Z="urn:schemas-microsoft-com:">
<D:set>
<D:prop>
<Z:Win32CreationTime>Mon, 09 Mar 2015 15:24:36 GMT</Z:Win32CreationTime>
<Z:Win32LastAccessTime>Mon, 16 Mar 2015 13:22:40 GMT</Z:Win32LastAccessTime>
<Z:Win32LastModifiedTime>Mon, 16 Mar 2015 13:22:40 GMT</Z:Win32LastModifiedTime>
</D:prop>
</D:set>
</D:propertyupdate>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPPATCH -v http://localhost:7001/repository/default/test.docx -H "If: (${LOCK_token})" --data "#PROPPATCH_document.xml" | xmllint --format -
# Close document in Word
curl -A "Microsoft Office Existence Discovery" -X HEAD -v http://localhost:7001/repository/default/test.docx
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X UNLOCK -v http://localhost:7001/repository/default/test.docx -H "Lock-Token: ${LOCK_token}"
# Checkin document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X CHECKIN -v http://localhost:7001/repository/default/test.docx
# Version tree report on document
cat > REPORT_version-tree.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:version-tree xmlns:D="DAV:">
<D:prop>
<D:version-name/>
</D:prop>
</D:version-tree>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X REPORT -v http://localhost:7001/repository/default/test.docx --data "#REPORT_version-tree.xml" | xmllint --format -
I only had problems with the auto-version capabilities of Jackrabbit, which are obviously not implemented yet.
https://issues.apache.org/jira/browse/JCR-1348
#<!--
# see http://www.webdav.org/specs/rfc3253.html#PROPERTY_auto-version
# <D:auto-version>checkout-checkin</D:auto-version>
# <D:auto-version>checkout-unlocked-checkin</D:auto-version>
# <D:auto-version>checkout</D:auto-version>
# <D:auto-version>locked-checkout</D:auto-version>
#-->
cat > PROPPATCH_auto-version.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:">
<D:set>
<D:prop>
<D:auto-version>checkout-checkin</D:auto-version>
</D:prop>
</D:set>
</D:propertyupdate>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPPATCH -v http://localhost:7001/repository/default/test.docx -H "If: (${LOCK_token})" --data "#PROPPATCH_auto-version.xml" | xmllint --format -
I understand that the JCR versioning framework effectively pivots around the mix:versionable JCR mixin node type (Jackrabbit Wiki). So, if a node is created as being of type mix:versionable, then I presume that the conventional WebDAV checkin and checkout operations - as could be encapsulated with a WebDAV API - that those would probably be how one would conduct JCR checkin/checkout operations on versionable nodes. That, I presume, would answer that much of the question
I don't see any exact DAV compliment to the JCR checkpoint operation, but if that's just checkin followed with checkout, as the documentation explains, then it would be easy enough to emulate via DAV - thus making a compliment to that JCR operation.
Related
I’m trying to fill out web forms using curl via a bash script to a website that uses AngularJS. Can’t find any documentation on how to do this. Is it even possible to use curl to POST data to webforms that use AngularJS? I’m not even sure I’m asking the right question or if there’s a better method?
In most cases AngularJS uses ajax calls with JSON payload instead of old-school multipart POSTs.
You can use browser to send test post and save request information "as cURL".
Most likely you will have ready-to-use command to add to your bash file.
But quite often such posts are associated with authenticated person so you will need to fill in up-to-date session cookie into your request.
First things to check will be whether your command works with cleaned cookies.
If it works then your task is done.
Just call such API with something like this:
curl -X POST -H "Content-Type:application/json" \
http://some-server/handle-form \
-d '{"parameter1":["41","34"],"another_parameter":"val1"}'
But if your curl request is rejected by server with cookies absent then you need to setup proper cookie before invocation of API request.
This call will authenticate you against server and will store session cookie in a jar file:
curl -b ./jar -c ./jar -i -X POST -H "Content-Type:application/json" \
http://some-server/login \
-d '{"login":"my-user-name", "password":"my-password"}'
And such save session cookies would be reused for subsequent API calls:
curl -b ./jar -c ./jar -i -X POST -H "Content-Type:application/json" \
http://some-server/handle-form \
-d '{"parameter1":["41","34"],"another_parameter":"val1"}'
I have a few versions of my code in JFROG, which are provided to the clients. How do I specify a generic way to pull latest version(Artifact)? It is not Maven code. I looked up on the Jfrog page:
'''
GET http://localhost:8081/artifactory/ivy-local/org/acme/[RELEASE]/acme-[RELEASE].jar
'''
How do I get [RELEASE] ?
Please help ?
the [RELEASE] in this case is the version number you want to download the latest artifact for. To get that number you can use the REST API call for Artifact Latest Version Search Based on Layout. For example
GET /api/search/latestVersion?g=org.acme&a=artifact&repos=libs-snapshot-local
This would return a string of the latest release version you have.
You can follow the documentation at jfrog
#!/bin/bash
# Note that we don't enable the 'e' option, which would cause the script to
# immediately exit
set -uo pipefail
HOST=myartcloud.jfrog.io
USER=thisIsMyUser
PASS=thisismypass
SNAPSHOT_LAST_VERSION=$(curl --silent --show-error --fail \
-u$USER:"$PASS" \
-X POST https://$HOST/artifactory/api/search/aql \
-H "content-type: text/plain" \
-d 'items.find({ "repo": {"$eq":"my-repo-snapshot"}, "name": {"$match" : "my-project-package-name*"}})'\
| grep -E -o -e 'my-project-package-name-[[:digit:]].[[:digit:]].[[:digit:]]+'| uniq | sort | tail -1 \
| grep -E -o -e '[[:digit:]].[[:digit:]].[[:digit:]]+')
Explanation. Making usage of curl with option
--fail (HTTP) Fail silently (no output at all) on server errors. This is mostly done to better enable scripts etc to better deal with failed attempts.
--silent Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute.
--show-error When used with -s it makes curl show an error message if it fails.
Then a post request -X POST is made using basic authentication to the api path. The content type of the request is -H "content-type: text/plain".
-d, --data (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML.
The data sent, is using a filter query to find an repository and also the content.
After the api results, using grep command line utility where it searches for PATTERNS and return only the version number.
Example: 0.1.1
I am following a tutorial and (just like in the official tutorial) when you execute a command with Solr if outputs the commands that were sent to, and received from, the Solr server to perform the action like so:
$ bin/solr create_core -c films
WARNING: Using _default configset. Data driven schema functionality is enabled
by default, which is NOT RECOMMENDED for production use.
To turn it off:
curl http://localhost:8983/solr/films/config -d
'{"set-user-property": {"update.autoCreateFields":"false"}}'
Copying configuration to new core instance directory:
/home/paul/solr-7.0.0/server/solr/films
Creating new core 'films' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=films&instanceDire=films
{
"responseHeader":{
"status":0,
"QTime:1222},
"core":"films"}
When I run the same command I get
bin/solr create_core -c films
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
To turn off: bin/solr config -c films -p 8983 -action set-user-property -property update.autoCreateFields -value false
INFO - 2018-12-07 10:00:10.021; org.apache.solr.util.configuration.SSLCredentialProviderFactory; Processing SSL Credential Provider chain: env;sysprop
Created new core 'films'
How Do I get my Solr commancds to output the extra information?
Append the -V argument when invoking bin/solr:
-V Enable more verbose output.
.. making the end command be bin/solr create_core -c films -V.
Is there anyway to use the curl command to update the solr with all the files under a directory? For example like update all the XML files:
curl "http://localhost:8983/solr/xml/update?commit=true&tr=add.xsl" -H "Content-Type: text/xml" --data-binary #*.xml
Using the post.jar, I was able to run these updates, but I am not looking the same function on using CURL ?
Thanks in advance.
I don't think CURL supports making wildcard posts through --data-binary. It does support some globbing in its -T parameter, but that issues a PUT (as it uses the baseurl + filename). You'll also have to expand the list yourself, as I couldn't get * to work as globbing pattern.
The easiest way is probably to wrap it in a for-loop instead, which will depend on how you're running curl (and what OS or shell you're using).
#!/usr/bin/env bash
for FILE in *.xml
do
curl "http://localhost:8983/solr/xml/update?commit=true&tr=add.xsl" -H "Content-Type: text/xml" --data-binary #$FILE
done
I'm trying to make dump with next command:
mysqldump -v -u root -p -h 127.0.0.1 -P 3308 -x --add-drop-table
--add-locks --create-options -K -e -q -A > database.sql
The result (after password input) is message "Connecting to 127.0.0.1...". After this is nothing (no any errors, just waiting).
database.sql is empty file.
Why I see no any activity? Is it bug?
From http://linuxcommand.org/man_pages/mysqldump1.html
The password to use when connecting to the server. If you use the
short option form (-p), you cannot have a space between the option and
the password. If you omit the password value following the --password
or -p option on the command line, you are prompted for one.
The system may be waiting for you to input a password.
If you want to avoid that just add the password in the command. Assuming your password is "FLOWER":
mysqldump -v -u root -pFLOWER -h 127.0.0.1 -P 3308 -x --add-drop-table --add-locks --create-options -K -e -q -A > database.sql
This problem, as you describe it, can be caused by the mysql server not running or not being available on the host (in your case, localhost), or it is running but not on that port.
What kind of a system is it? If it is a flavor of linux/unix, you can run
ps -ef|egrep mysql
to see if the mysql server is running. Check the equivalent command on Windows or whatever else you may be running. Also, you can verify that this is the problem by seeing if this works:
mysql -u root -p -h 127.0.0.1 -P 3308
The solution is to start the server:
/etc/init.d/mysqld start
or the equivalent on your system.
Note: if it is running, determine what port it is on - it is possible that you are not specifying the right port number. The default is 3306 - it is unusual that you are using a non-standard port.