Class DownloadJcrTreeAsPackageServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class DownloadJcrTreeAsPackageServlet
    extends org.apache.sling.api.servlets.SlingSafeMethodsServlet
    This is a servlet that enables to download a package of a JCR subtree without having to create a package in the package manager. The package is created on the fly, and not saved to disk / the repository, so this is better suited to large content trees, but valuable also for quickly downloading a page.

    CAUTION: not suitable for production, only for internal testing systems!

    Usage with curl e.g. curl -s -S -o tmp.zip -u admin:admin http://localhost:6502/somepath.html/{path to download}
    where somepath is a path to a resource with sling:resourceType cpm/nodes/debug/downloadjcr .

    Example Creates a package of /some/path: http://localhost:6502/somepath.html/some/path

    Fragment of a bash script to download a path from another AEM system and install it locally on AEM: path=$1 TMPFIL=`mktemp -u`.zip trap "{ rm -f $TMPFIL; }" EXIT PKG=$(basename $TMPFIL) curl -S -o $TMPFIL -u ${OTHER_USER}:${OTHER_PWD} http://${OTHERIP}:4502/somepath.html${path}?packageName=$PKG curl -u admin:admin -F file=@"$TMPFIL" -F name="tmp $path" -F force=true -F install=true http://localhost:6502/crx/packmgr/service.jsp curl -u admin:admin -F cmd=delete http://localhost:6502/crx/packmgr/service/.json/etc/packages/my_packages/${PKG%%.zip}-1.zip

    See Also:
    "https://gist.github.com/stoerr/a54c58b4b05770c6a7ee39654ea84305", Serialized Form
    • Constructor Detail

      • DownloadJcrTreeAsPackageServlet

        public DownloadJcrTreeAsPackageServlet()
    • Method Detail

      • doGet

        protected void doGet​(org.apache.sling.api.SlingHttpServletRequest request,
                             org.apache.sling.api.SlingHttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
        Overrides:
        doGet in class org.apache.sling.api.servlets.SlingSafeMethodsServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • deactivate

        protected void deactivate()