// The correct way of using session is to clone it first.
private Credentials systemCredentials = new SimpleCredentials("system", new char[]{});
//...
Session clonedSession = null;
try {
clonedSession = session.impersonate(SYSTEM_CREDENTIALS);
Node subject = clonedSession.getNodeByIdentifier(event.subjectId());
clonedSession.save();
} catch (UnsupportedRepositoryOperationException e) {
// we're trying to get something from a deleted node. Ignore
} catch (Exception e) {
log.error("Unsupported error occurred during document translation event: ", e);
} finally {
if (clonedSession != null) {
clonedSession.logout();
}
}