ExecutionContext context) throws ActionException {
identity.checkLoggedIn();
Person person = retrievePerson();
WorkspaceId workspaceId = action.getWorkspaceId();
TranslationWorkspace workspace =
translationWorkspaceManager.getOrRegisterWorkspace(workspaceId);
String httpSessionId = getHttpSessionId();
EditorClientId editorClientId =
new EditorClientId(httpSessionId, generateEditorClientNum());
workspace
.addEditorClient(httpSessionId, editorClientId, person.getId());
// Send EnterWorkspace event to clients
EnterWorkspace event = new EnterWorkspace(editorClientId, person);
workspace.publish(event);
HLocale locale =
localeServiceImpl.getByLocaleId(workspaceId.getLocaleId());
HProject project =
projectDAO.getBySlug(workspaceId.getProjectIterationId()
.getProjectSlug());
HProjectIteration projectIteration =
projectIterationDAO.getBySlug(workspaceId
.getProjectIterationId().getProjectSlug(), workspaceId
.getProjectIterationId().getIterationSlug());
boolean isProjectActive =
isProjectIterationActive(project.getStatus(),
projectIteration.getStatus());
boolean hasWriteAccess = hasWritePermission(project, locale);
boolean hasGlossaryUpdateAccess = hasGlossaryUpdatePermission();
boolean requireReview = projectIteration.getRequireTranslationReview();
boolean hasReviewAccess = hasReviewerPermission(locale, project);
WorkspaceRestrictions workspaceRestrictions =
new WorkspaceRestrictions(isProjectActive, hasWriteAccess,
hasGlossaryUpdateAccess, hasReviewAccess, requireReview);
log.debug("workspace restrictions: {}", workspaceRestrictions);
LoadOptionsResult loadOptsRes =
loadOptionsHandler
.execute(new LoadOptionsAction(null), context);
GetValidationRulesResult validationRulesResult =
getValidationRulesHandler.execute(new GetValidationRulesAction(
workspaceId), context);
Identity identity = new Identity(editorClientId, person);
workspace.getWorkspaceContext().getWorkspaceId()
.getProjectIterationId()
.setProjectType(projectIteration.getProjectType());
UserWorkspaceContext userWorkspaceContext =
new UserWorkspaceContext(workspace.getWorkspaceContext(),
workspaceRestrictions);
return new ActivateWorkspaceResult(userWorkspaceContext, identity,
loadOptsRes.getConfiguration(),
validationRulesResult.getValidationRules());
}