Search in sources :

Example 1 with WorkspaceCreatedEvent

use of org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent in project che by eclipse.

the class WorkspaceManager method doCreateWorkspace.

private WorkspaceImpl doCreateWorkspace(WorkspaceConfig config, Account account, Map<String, String> attributes, boolean isTemporary) throws NotFoundException, ServerException, ConflictException {
    final WorkspaceImpl workspace = WorkspaceImpl.builder().generateId().setConfig(config).setAccount(account).setAttributes(attributes).setTemporary(isTemporary).build();
    workspace.getAttributes().put(CREATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis()));
    workspaceDao.create(workspace);
    LOG.info("Workspace '{}/{}' with id '{}' created by user '{}'", account.getName(), workspace.getConfig().getName(), workspace.getId(), sessionUserNameOr("undefined"));
    eventService.publish(new WorkspaceCreatedEvent(workspace));
    return workspace;
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceCreatedEvent(org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent)

Example 2 with WorkspaceCreatedEvent

use of org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent in project che by eclipse.

the class WorkspaceSshKeysTest method shouldGenerateSshKeyPairWhenWorkspaceIsCreated.

/**
     * Ensure that when a new workspace is created, a new default ssh keypair is generated by asking sshManager
     */
@Test
public void shouldGenerateSshKeyPairWhenWorkspaceIsCreated() throws Exception {
    // given
    workspaceCreatedEventEventSubscriber.onEvent(new WorkspaceCreatedEvent(this.workspace));
    // then
    verify(sshManager).generatePair(eq(USER_ID), eq("workspace"), eq(WORKSPACE_ID));
}
Also used : WorkspaceCreatedEvent(org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent) Test(org.testng.annotations.Test)

Aggregations

WorkspaceCreatedEvent (org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent)2 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)1 Test (org.testng.annotations.Test)1