String serverUrl = "http://" + path + "/" + repositoryName;
String workspaceName = info.getWorkspaceName();
if (workspaceName == null) {
// there is no WS info, so try to figure out a default one...
ModeShapeRestClient client = new ModeShapeRestClient(serverUrl, username, String.valueOf(password));
List<String> allWorkspaces = client.getWorkspaces(repositoryName).getWorkspaces();
if (allWorkspaces.isEmpty()) {
throw new SQLException("No workspaces found for the " + repositoryName + " repository");
}
// TODO author=Horia Chiorean date=19-Aug-14 description=There is no way to get the "default" ws so we'll choose one
workspaceName = allWorkspaces.get(0);
}
serverUrl = serverUrl + "/" + workspaceName;
logger.debug("Using server url: {0}", serverUrl);
// this is only a connection test to confirm a connection can be made and results can be obtained.
try {
this.restClient = new ModeShapeRestClient(serverUrl, username, String.valueOf(password));
Repositories repositories = this.restClient.getRepositories();
this.setRepositoryNames(repositories.getRepositoryNames());
Repositories.Repository repository = repositories.getRepository(repositoryName);
if (repository == null) {
throw new SQLException(JdbcLocalI18n.unableToFindNamedRepository.text(path, repositoryName));