ItemData storage = session.getTransientNodesManager().getItemData(AUDIT_STORAGE_ID);
if (storage == null)
{
SessionChangesLog changesLog = new SessionChangesLog(session);
// here should be added to TransactionalDataManager (i.e. saved
// immediatelly!
// nodeData: /exo:audit with UUID = AUDIT_STORAGE_ID
// its primaryType exo:auditStorage
List<AccessControlEntry> access = new ArrayList<AccessControlEntry>();
access.add(new AccessControlEntry(IdentityConstants.ANY, PermissionType.ADD_NODE));
for (String identity : adminIdentitys)
{
access.add(new AccessControlEntry(identity, PermissionType.READ));
}
access.add(new AccessControlEntry(IdentityConstants.ANY, PermissionType.REMOVE));
AccessControlList exoAuditAccessControlList = new AccessControlList(IdentityConstants.SYSTEM, access);
InternalQName[] mixins = new InternalQName[]{Constants.EXO_PRIVILEGEABLE, Constants.MIX_REFERENCEABLE};
TransientNodeData exoAuditNode =
new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, AuditService.EXO_AUDIT),
AuditService.AUDIT_STORAGE_ID, -1, AuditService.EXO_AUDITSTORAGE, mixins, 0, Constants.ROOT_UUID,
exoAuditAccessControlList);
// jcr:primaryType
TransientPropertyData exoAuditPrType =
TransientPropertyData.createPropertyData(exoAuditNode, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
false, new TransientValueData(exoAuditNode.getPrimaryTypeName()));
// jcr:uuid
TransientPropertyData exoAuditUuid =
TransientPropertyData.createPropertyData(exoAuditNode, Constants.JCR_UUID, PropertyType.STRING, false,
new TransientValueData(exoAuditNode.getIdentifier()));
// jcr:mixinTypes
List<ValueData> mixValues = new ArrayList<ValueData>();
mixValues.add(new TransientValueData(Constants.MIX_REFERENCEABLE));
mixValues.add(new TransientValueData(Constants.EXO_PRIVILEGEABLE));
TransientPropertyData exoAuditMixinTypes =
TransientPropertyData.createPropertyData(exoAuditNode, Constants.JCR_MIXINTYPES, PropertyType.NAME,
true, mixValues);
// EXO_PERMISSIONS
List<ValueData> permsValues = new ArrayList<ValueData>();
for (int i = 0; i < exoAuditNode.getACL().getPermissionEntries().size(); i++)
{
AccessControlEntry entry = exoAuditNode.getACL().getPermissionEntries().get(i);
permsValues.add(new TransientValueData(entry));
}
TransientPropertyData exoAuditPerms =
TransientPropertyData.createPropertyData(exoAuditNode, Constants.EXO_PERMISSIONS,
ExtendedPropertyType.PERMISSION, true, permsValues);
changesLog.add(ItemState.createAddedState(exoAuditNode));
changesLog.add(ItemState.createAddedState(exoAuditPrType));
changesLog.add(ItemState.createAddedState(exoAuditUuid));
changesLog.add(ItemState.createAddedState(exoAuditMixinTypes));
changesLog.add(ItemState.createAddedState(exoAuditPerms));
session.getTransientNodesManager().getTransactManager().save(changesLog);
storage = session.getTransientNodesManager().getItemData(AUDIT_STORAGE_ID);
}
if (!storage.isNode())