@Override
public Workspace createWorkspace(Map sessionConfiguration, Object... authenticationContext) throws IOException {
// TODO get data from post body (if no data, assume latest??) -> for now
// always assume latest
final String sessionID;
final Workspace workspace;
final Component component;
synchronized (m_workspaces) {
sessionID = "rest-" + m_sessionID++;
workspace = new WorkspaceImpl(sessionID, m_repositoryURL, m_customerName, m_storeRepositoryName,
m_targetRepositoryName, m_deploymentRepositoryName);
m_workspaces.put(sessionID, workspace);
component = m_dm.createComponent().setImplementation(workspace);
m_workspaceComponents.put(sessionID, component);
}
// any parameters supplied in this call are passed on to the session
// factory, so you can use these to configure your session
m_sessionFactory.createSession(sessionID, sessionConfiguration);
m_dm.add(component);
User user;
if (m_useAuthentication) {
// Use the authentication service to authenticate the given
// request...
user = m_authenticationService.authenticate(authenticationContext);
}
else {
// Use the "hardcoded" user to login with...
user = m_userAdmin.getUser("username", m_serverUser);
}
if (user == null || !workspace.login(user)) {
return null;
}
else {
return workspace;
}