String externalKeyStr = projection.getExternalNodeKey(); // contains the source & workspace keys ...
final NodeKey externalKey = new NodeKey(externalKeyStr);
final String externalDocId = externalKey.getIdentifier();
// Find the connector that serves up this external key ...
Connector conn = getConnectorForSourceKey(externalKey.getSourceKey());
if (conn == null) {
// should never happen
throw new IllegalStateException("External source key: " + externalKey.getSourceKey()
+ " has no matching connector");
}
if (conn != connector) {
// since projections are stored in bulk (not on a per-connector basis), we only care about the
// projection
// if it belongs to this connector
continue;
}
// Find the path mappings ...
BasicPathMappings mappings = mappingsByConnectorSourceName.get(connectorSourceName);
if (mappings == null) {
mappings = new BasicPathMappings(connectorSourceName, pathFactory);
mappingsByConnectorSourceName.put(connectorSourceName, mappings);
}
// Now add the path mapping for this projection. First, find the path of the one projected node ...
String projectedKeyStr = projection.getProjectedNodeKey();
NodeKey projectedKey = new NodeKey(projectedKeyStr);
String workspaceName = workspaceNamesByKey.get(projectedKey.getWorkspaceKey());
if (workspaceName == null) continue;
try {
WorkspaceCache cache = repository.repositoryCache().getWorkspaceCache(workspaceName);
AllPathsCache allPathsCache = new AllPathsCache(cache, null, pathFactory);
CachedNode node = cache.getNode(projectedKey);
for (Path nodePath : allPathsCache.getPaths(node)) {
Path internalPath = pathFactory.create(nodePath, alias);
// Then find the path(s) for the external node with the aforementioned key ...
for (String externalPathStr : conn.getDocumentPathsById(externalDocId)) {
Path externalPath = pathFactory.create(externalPathStr);
mappings.add(externalPath, internalPath, workspaceName);
}
}
} catch (WorkspaceNotFoundException e) {