in src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java [102:144]
public void processRepository(final SlingRepository repo) throws Exception {
if ( (config.references() != null && config.references().length > 0)
|| (config.scripts() != null && config.scripts().length > 0 )) {
// loginAdministrative is ok here, definitely an admin operation
@SuppressWarnings("deprecation")
final Session s = repo.loginAdministrative(null);
try {
if ( config.references() != null ) {
final RepoinitTextProvider p = new RepoinitTextProvider();
for(final String reference : config.references()) {
if(reference == null || reference.trim().length() == 0) {
continue;
}
final String repoinitText = p.getRepoinitText("raw:" + reference);
final List<Operation> ops;
try (StringReader sr = new StringReader(repoinitText)) {
ops = parser.parse(sr);
}
String msg = String.format("Executing %s repoinit operations", ops.size());
log.info(msg);
applyOperations(s,ops,msg);
}
}
if ( config.scripts() != null ) {
for(final String script : config.scripts()) {
if(script == null || script.trim().length() == 0) {
continue;
}
final List<Operation> ops;
try (StringReader sr = new StringReader(script)) {
ops = parser.parse(sr);
}
String msg = String.format("Executing %s repoinit operations", ops.size());
log.info(msg);
applyOperations(s,ops,msg);
}
}
} finally {
s.logout();
}
}
}