if (workspaceName == null)
{
workspaceName = config.getDefaultWorkspaceName();
if (workspaceName == null)
throw new NoSuchWorkspaceException("Both workspace and default-workspace name are null! ");
}
if (!isWorkspaceInitialized(workspaceName))
throw new NoSuchWorkspaceException("Workspace '" + workspaceName + "' not found. "
+ "Probably is not initialized. If so either Initialize it manually or turn on the RepositoryInitializer");
SessionFactory sessionFactory = repositoryContainer.getWorkspaceContainer(workspaceName).getSessionFactory();
return sessionFactory.createSession(state);
}