in src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java [122:175]
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 {
Instant start = Instant.now();
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 sourceReference =
String.format("Configuration PID %s, reference URL %s", componentId, reference);
String msg = String.format(
"Executing %s repoinit operations from \"%s\"", ops.size(), sourceReference);
log.info(msg);
applyOperations(s, ops, msg, sourceReference);
}
}
if (config.scripts() != null) {
int scriptIndex = 0;
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 sourceReference =
String.format("Configuration PID %s, script[%d]", componentId, scriptIndex);
String msg = String.format(
"Executing %s repoinit operations from \"%s\"", ops.size(), sourceReference);
log.info(msg);
applyOperations(s, ops, msg, sourceReference);
scriptIndex++;
}
}
Duration duration = Duration.between(start, Instant.now());
log.info("Total time for successful repoinit execution: {} miliseconds", duration.toMillis());
} finally {
s.logout();
}
}
}