return minimumStringLengthForBinaryStorage.get();
}
protected void refreshRepositoryMetadata( boolean update ) {
// Read the node document ...
final DocumentTranslator translator = new DocumentTranslator(context, documentStore,
minimumStringLengthForBinaryStorage.get());
final String systemMetadataKeyStr = this.systemMetadataKey.toString();
final boolean accessControlEnabled = this.accessControlEnabled.get();
SchematicEntry entry = documentStore.get(systemMetadataKeyStr);
if (!update && entry != null) {
// We just need to read the metadata from the document, and we don't need a transaction for it ...
Document doc = entry.getContent();
Property accessProp = translator.getProperty(doc, name("accessControl"));
boolean enabled = false;
if (accessProp != null) {
enabled = context.getValueFactories().getBooleanFactory().create(accessProp.getFirstValue());
}
this.accessControlEnabled.set(enabled);
Property prop = translator.getProperty(doc, name("workspaces"));
final Set<String> persistedWorkspaceNames = new HashSet<String>();
ValueFactory<String> strings = context.getValueFactories().getStringFactory();
boolean workspaceNotYetPersisted = false;
for (Object value : prop) {
String workspaceName = strings.create(value);
persistedWorkspaceNames.add(workspaceName);
}
// detect if there are any new workspaces in the configuration which need persisting
for (String configuredWorkspaceName : workspaceNames) {
if (!persistedWorkspaceNames.contains(configuredWorkspaceName)) {
workspaceNotYetPersisted = true;
break;
}
}
this.workspaceNames.addAll(persistedWorkspaceNames);
if (!workspaceNotYetPersisted) {
// only exit if there isn't a new workspace present. Otherwise, the config added a new workspace so we need
// to make sure the meta-information is updated.
return;
}
}
try {
runInTransaction(new Callable<Void>() {
@Override
public Void call() throws Exception {
// Re-read the entry within the transaction ...
SchematicEntry entry = documentStore().get(systemMetadataKeyStr);
if (entry == null) {
// We need to create a new entry ...
EditableDocument newDoc = Schematic.newDocument();
translator.setKey(newDoc, systemMetadataKey);
entry = documentStore().localStore().putIfAbsent(systemMetadataKeyStr, newDoc);
if (entry == null) {
// Read-read the entry that we just put, so we can populate it with the same code that edits it ...
entry = documentStore().localStore().get(systemMetadataKeyStr);
}
}
EditableDocument doc = documentStore().localStore().edit(systemMetadataKeyStr, true);
PropertyFactory propFactory = context().getPropertyFactory();
translator.setProperty(doc, propFactory.create(name("workspaces"), workspaceNames), null, null);
translator.setProperty(doc, propFactory.create(name("accessControl"), accessControlEnabled), null, null);
return null;
}
});
} catch (RuntimeException re) {