in src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultContentSerializer.java [130:180]
public void importFromStream(ResourceResolver resourceResolver, InputStream inputStream) throws DistributionException {
Session session = null;
Archive archive = null;
try {
session = getSession(resourceResolver);
ImportOptions importOptions = VltUtils.getImportOptions(importSettings);
ErrorListener errorListener = new ErrorListener();
importOptions.setListener(errorListener);
Importer importer = new Importer(importOptions);
archive = new ZipStreamArchive(inputStream);
archive.open(false);
// retrieve the mapping
MetaInf metaInf = archive.getMetaInf();
if (metaInf != null) {
Properties metaInfProperties = metaInf.getProperties();
if (metaInfProperties != null) {
String pathsMappingProperty = metaInfProperties.getProperty(PATH_MAPPING_PROPERTY);
if (pathsMappingProperty != null && !pathsMappingProperty.isEmpty()) {
RegexpPathMapping pathMapping = new RegexpPathMapping();
StringTokenizer pathsMappingTokenizer = new StringTokenizer(pathsMappingProperty, MAPPING_DELIMITER);
while (pathsMappingTokenizer.hasMoreTokens()) {
String[] pathMappingHeader = pathsMappingTokenizer.nextToken().split(MAPPING_SEPARATOR);
pathMapping.addMapping(pathMappingHeader[0], pathMappingHeader[1]);
}
importOptions.setPathMapping(pathMapping);
}
}
}
// now import the content
importer.run(archive, session, "/");
if (importer.hasErrors() && importOptions.isStrict()) {
throw errorListener.getLastError();
}
if (session.hasPendingChanges()) {
session.save();
}
} catch (Exception e) {
throw new DistributionException(e);
} finally {
ungetSession(session);
if (archive != null) {
archive.close();
}
}
}