@Service(value=DesignPackageImporter.class) public class DesignPackageImporter extends java.lang.Object
A design package is an archived HTML project containing an HTML file along with several (optional) referenced scripts and styles. This class provides API for importing that design package under a CQ page or component.
CanvasBuilder
Constructor and Description |
---|
DesignPackageImporter() |
Modifier and Type | Method and Description |
---|---|
DesignImportResult |
importDesignPackage(Page importerPage,
java.lang.String designPackagePath,
CanvasBuildOptions buildOptions)
Imports a design package, similarly to
importDesignPackage(org.apache.sling.api.SlingHttpServletRequest, com.day.cq.wcm.designimporter.CanvasBuildOptions) , but with a different set of parameters. |
DesignImportResult |
importDesignPackage(SlingHttpServletRequest slingHttpServletRequest)
Imports a design package from a sling request.
|
DesignImportResult |
importDesignPackage(SlingHttpServletRequest slingHttpServletRequest,
CanvasBuildOptions buildOptions)
Imports a design package from a sling request similar to how
importDesignPackage(org.apache.sling.api.SlingHttpServletRequest) imports, the difference being
the amount of control you've over various building options. |
public DesignImportResult importDesignPackage(SlingHttpServletRequest slingHttpServletRequest) throws DesignImportException
A design package is typically imported by dropping a design package onto the designimporter component, which in turn POSTs the file to CQ server. This API serves as the starting point for import of the design package from the POST sling request. The POST request contains the uploaded file stream as a request parameter named "designfile".
The design package is expected to be a conforming HTML project with a "defined" structure. At the minimum, the project must contain
the HTML file with the name index.html or index.htm at the root (This rule is configurable via CanvasBuilder
OSGi component configuration).
This is the only conformance required. Authors are free to choose any project structure or file/directory naming conventions as per their wishes. The
importer works by fully parsing the HTML document and not by relying upon certain naming conventions.
The import process involves the following steps:
CanvasBuilder
service implementation that is registered to handle the HTML of that name pattern is executedCanvasBuilder
builds the CQ page by parsing the HTML file as following:
importDesignPackage(org.apache.sling.api.SlingHttpServletRequest, CanvasBuildOptions)
API instead.
slingHttpServletRequest
- The sling request for importing the design package. A design package is an archived HTML project containing the main HTML file
along with all the referenced scripts, styles and assets. By default, the main HTML file should be named
index.html and appear at the root level of the zip archive. The rule can however be modified via CanvasBuilder
configuration. *MalformedArchiveException
- if there is an error reading the input archive streamMissingHTMLException
- if there is no index.html or index.htm entry in the zip archiveUnsupportedTagContentException
- if unsupported content is encountered within a tagMissingCanvasException
- if the input HTML stream is missing the canvas boundaryDesignImportException
- if there is an exception writing to the CRX repositorypublic DesignImportResult importDesignPackage(SlingHttpServletRequest slingHttpServletRequest, CanvasBuildOptions buildOptions) throws DesignImportException
importDesignPackage(org.apache.sling.api.SlingHttpServletRequest)
imports, the difference being
the amount of control you've over various building options.
This api lets you have control over what you want to build by providing build flags specified via CanvasBuildOptions
. You can choose to switch on or off,
the building of canvas nodes, canvas component and clientlibs. With clientlibs, you can further choose to switch on or off, the building of head scripts, head styles,
body scripts, body styles or a combination of some of those
slingHttpServletRequest
- Contains http request and input stream of the design package. Design package is a zipped HTML project containing the main HTML file
along with all the referenced scripts, styles and assets. By default, the main HTML file should be named
index.html and appear at the root level of the zip archive. The rule can however be modified via CanvasBuilder
OSGi configuration.buildOptions
- The CanvasBuildOptions
object that contains build flags for switching on or off certain build optionsMalformedArchiveException
- if there is an error reading the input archive streamMissingHTMLException
- if there is no index.html or index.htm entry in the zip archiveUnsupportedTagContentException
- if unsupported content is encountered within a tagMissingCanvasException
- if the input HTML stream is missing the canvas boundaryDesignImportException
- if there is an exception writing to the CRX repositorypublic DesignImportResult importDesignPackage(Page importerPage, java.lang.String designPackagePath, CanvasBuildOptions buildOptions) throws DesignImportException
importDesignPackage(org.apache.sling.api.SlingHttpServletRequest, com.day.cq.wcm.designimporter.CanvasBuildOptions)
, but with a different set of parameters.importerPage
- An existing page of template type "wcm/designimporter/templates/importerpage"designPackagePath
- The absolute path to a design package zip file in the repositorybuildOptions
- The CanvasBuildOptions
object that contains build flags for switching on or off certain build optionsMalformedArchiveException
- if there is an error reading the input archive streamMissingHTMLException
- if there is no index.html or index.htm entry in the zip archiveUnsupportedTagContentException
- if unsupported content is encountered within a tagMissingCanvasException
- if the input HTML stream is missing the canvas boundaryDesignImportException
- if there is an exception writing to the CRX repositoryCopyright © 2010 - 2020 Adobe. All Rights Reserved