long timeToCacheInMillis = longs.create(timeToExpire.getFirstValue());
defaultCachePolicy = new BasicCachePolicy(timeToCacheInMillis, TimeUnit.MILLISECONDS).getUnmodifiable();
}
// Level 2: The "dna:workspaces" node ...
Node workspacesNode = repositories.getNode(DnaLexicon.WORKSPACES);
if (workspacesNode == null) {
I18n msg = GraphI18n.requiredNodeDoesNotExistRelativeToNode;
throw new RepositorySourceException(msg.text(DnaLexicon.WORKSPACES.getString(registry),
repositories.getLocation().getPath().getString(registry),
repositories.getGraph().getCurrentWorkspaceName(),
repositories.getGraph().getSourceName()));
}
// Level 3: The workspace nodes ...
LinkedList<FederatedWorkspace> workspaces = new LinkedList<FederatedWorkspace>();
for (Location workspace : workspacesNode) {
// Get the name of the workspace ...
String workspaceName = null;
SubgraphNode workspaceNode = repositories.getNode(workspace);
Property workspaceNameProperty = workspaceNode.getProperty(DnaLexicon.WORKSPACE_NAME);
if (workspaceNameProperty != null) {
// Set the name using the property if there is one ...
workspaceName = strings.create(workspaceNameProperty.getFirstValue());
}
if (workspaceName == null) {
// Otherwise, set the name using the local name of the workspace node ...
workspaceName = workspace.getPath().getLastSegment().getName().getLocalName();
}
// Level 4: the "dna:projections" node ...
Node projectionsNode = workspaceNode.getNode(DnaLexicon.PROJECTIONS);
if (projectionsNode == null) {
I18n msg = GraphI18n.requiredNodeDoesNotExistRelativeToNode;
throw new RepositorySourceException(getName(), msg.text(DnaLexicon.PROJECTIONS.getString(registry),
workspaceNode.getLocation()
.getPath()
.getString(registry),
repositories.getGraph().getCurrentWorkspaceName(),
repositories.getGraph().getSourceName()));
}
// Level 5: the projection nodes ...
List<Projection> sourceProjections = new LinkedList<Projection>();
for (Location projection : projectionsNode) {
Node projectionNode = repositories.getNode(projection);
sourceProjections.add(createProjection(executionContext, projectionParser, projectionNode));
}
// Create the federated workspace configuration ...
FederatedWorkspace space = new FederatedWorkspace(repositoryContext, name, workspaceName, sourceProjections,