Class ContentPackage
- java.lang.Object
-
- io.wcm.tooling.commons.contentpackagebuilder.ContentPackage
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class ContentPackage extends java.lang.Object implements java.io.Closeable
Represents an AEM content package. Content like structured JCR data and binary files can be added. This class is not thread-safe.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContent(java.lang.String path, ContentElement content)
Add some JCR content structure directly to the package.void
addContent(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> content)
Add some JCR content structure directly to the package.void
addContentForFile(java.lang.String path, ContentElement content)
Add some JCR content structure directly to the package.void
addContentForFile(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> content)
Add some JCR content structure directly to the package.void
addFile(java.lang.String path, java.io.File file)
Adds a binary file.void
addFile(java.lang.String path, java.io.File file, java.lang.String contentType)
Adds a binary file with explicit mime type.void
addFile(java.lang.String path, java.io.InputStream inputStream)
Adds a binary file.void
addFile(java.lang.String path, java.io.InputStream inputStream, java.lang.String contentType)
Adds a binary file with explicit mime type.void
addPage(java.lang.String path, ContentElement content)
Adds a page with given content.void
addPage(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> content)
Adds a page with given content.void
close()
Close the underlying ZIP stream of the package.java.util.List<PackageFilter>
getFilters()
Get filters defined for this package.java.lang.String
getRootPath()
Get root path of the package.
-
-
-
Method Detail
-
addPage
public void addPage(java.lang.String path, ContentElement content) throws java.io.IOException
Adds a page with given content. The "cq:Page/cq:PageContent envelope" is added automatically.- Parameters:
path
- Full content path of page.content
- Hierarchy of content elements.- Throws:
java.io.IOException
- I/O exception
-
addPage
public void addPage(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> content) throws java.io.IOException
Adds a page with given content. The "cq:Page/cq:PageContent envelope" is added automatically.- Parameters:
path
- Full content path of page.content
- Map with page properties. If the map contains nested maps this builds a tree of JCR nodes. The key of the nested map in its parent map is the node name, the nested map contain the properties of the child node.- Throws:
java.io.IOException
- I/O exception
-
addContent
public void addContent(java.lang.String path, ContentElement content) throws java.io.IOException
Add some JCR content structure directly to the package.- Parameters:
path
- Full content path of content root node.content
- Hierarchy of content elements.- Throws:
java.io.IOException
- I/O exception
-
addContent
public void addContent(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> content) throws java.io.IOException
Add some JCR content structure directly to the package.- Parameters:
path
- Full content path of content root node.content
- Map with node properties. If the map contains nested maps this builds a tree of JCR nodes. The key of the nested map in its parent map is the node name, the nested map contain the properties of the child node.- Throws:
java.io.IOException
- I/O exception
-
addContentForFile
public void addContentForFile(java.lang.String path, ContentElement content) throws java.io.IOException
Add some JCR content structure directly to the package.This method is used to provide additional properties for a path that is already used by a binary file, using a special
<node-name>.dir/.content.xml
syntax.- Parameters:
path
- Full content path of content root/file node.content
- Hierarchy of content elements.- Throws:
java.io.IOException
- I/O exception
-
addContentForFile
public void addContentForFile(java.lang.String path, java.util.Map<java.lang.String,java.lang.Object> content) throws java.io.IOException
Add some JCR content structure directly to the package.This method is used to provide additional properties for a path that is already used by a binary file, using a special
<node-name>.dir/.content.xml
syntax.- Parameters:
path
- Full content path of content root/file node.content
- Map with node properties. If the map contains nested maps this builds a tree of JCR nodes. The key of the nested map in its parent map is the node name, the nested map contain the properties of the child node.- Throws:
java.io.IOException
- I/O exception
-
addFile
public void addFile(java.lang.String path, java.io.InputStream inputStream) throws java.io.IOException
Adds a binary file.- Parameters:
path
- Full content path and file name of fileinputStream
- Input stream with binary dta- Throws:
java.io.IOException
- I/O exception
-
addFile
public void addFile(java.lang.String path, java.io.InputStream inputStream, java.lang.String contentType) throws java.io.IOException
Adds a binary file with explicit mime type.- Parameters:
path
- Full content path and file name of fileinputStream
- Input stream with binary datacontentType
- Mime type, optionally with ";charset=XYZ" extension- Throws:
java.io.IOException
- I/O exception
-
addFile
public void addFile(java.lang.String path, java.io.File file) throws java.io.IOException
Adds a binary file.- Parameters:
path
- Full content path and file name of filefile
- File with binary data- Throws:
java.io.IOException
- I/O exception
-
addFile
public void addFile(java.lang.String path, java.io.File file, java.lang.String contentType) throws java.io.IOException
Adds a binary file with explicit mime type.- Parameters:
path
- Full content path and file name of filefile
- File with binary datacontentType
- Mime type, optionally with ";charset=XYZ" extension- Throws:
java.io.IOException
- I/O exception
-
close
public void close() throws java.io.IOException
Close the underlying ZIP stream of the package.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- I/O exception
-
getRootPath
public java.lang.String getRootPath()
Get root path of the package. This does only work if there is only one filter of the package. If they are more filters usegetFilters()
instead.- Returns:
- Root path of package
-
getFilters
public java.util.List<PackageFilter> getFilters()
Get filters defined for this package.- Returns:
- List of package filters, optionally with include/exclude rules.
-
-