Class ModelArchiveWriter
- java.lang.Object
-
- org.apache.sling.provisioning.model.io.ModelArchiveWriter
-
public class ModelArchiveWriter extends Object
The model archive writer can be used to create an archive based on a model The archive contains the model file and all artifacts.- Since:
- 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceModelArchiveWriter.ArtifactProvider
-
Field Summary
Fields Modifier and Type Field Description static intARCHIVE_VERSIONCurrent support version of the model archive.static StringARTIFACTS_PREFIXArtifacts prefix.static StringDEFAULT_EXTENSIONDefault extension for model archives.static StringMANIFEST_HEADERThe manifest header marking an archive as a model archive.static StringMODEL_NAMEModel name.
-
Constructor Summary
Constructors Constructor Description ModelArchiveWriter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JarOutputStreamwrite(OutputStream out, Model model, Manifest baseManifest, ModelArchiveWriter.ArtifactProvider provider)Create a model archive.
-
-
-
Field Detail
-
MANIFEST_HEADER
public static final String MANIFEST_HEADER
The manifest header marking an archive as a model archive.- See Also:
- Constant Field Values
-
ARCHIVE_VERSION
public static final int ARCHIVE_VERSION
Current support version of the model archive.- See Also:
- Constant Field Values
-
DEFAULT_EXTENSION
public static final String DEFAULT_EXTENSION
Default extension for model archives.- See Also:
- Constant Field Values
-
MODEL_NAME
public static final String MODEL_NAME
Model name.- See Also:
- Constant Field Values
-
ARTIFACTS_PREFIX
public static final String ARTIFACTS_PREFIX
Artifacts prefix.- See Also:
- Constant Field Values
-
-
Method Detail
-
write
public static JarOutputStream write(OutputStream out, Model model, Manifest baseManifest, ModelArchiveWriter.ArtifactProvider provider) throws IOException
Create a model archive. The output stream will not be closed by this method. The caller must callZipOutputStream.close()orZipOutputStream.finish()on the return output stream. The caller can add additional files through the return stream. In order to create an archive for a model, each feature in the model must have a name and a version and the model must be valid, thereforeModelUtility.validateIncludingVersion(Model)is called first. If the model is invalid anIOExceptionis thrown.- Parameters:
out- The output stream to write tomodel- The model to writebaseManifest- Optional base manifest used for creating the manifest.provider- The artifact provider- Returns:
- The jar output stream.
- Throws:
IOException- If anything goes wrong
-
-