if (log.isDebugEnabled()) {
log.debug("workspaceCandidate=" + workspaceCandidate);
log.debug("sectionCandidate=" + sectionCandidate);
}
WorkspaceImpl workspace = null;
Section section = null;
if (workspaceCandidate != null) {
boolean canbeWorkspaceId = canBeWorkspaceId(workspaceCandidate);
if (canbeWorkspaceId) workspace = (WorkspaceImpl) UIServices.lookup().getWorkspacesManager().getWorkspace(workspaceCandidate);
if (workspace == null) workspace = (WorkspaceImpl) UIServices.lookup().getWorkspacesManager().getWorkspaceByUrl(workspaceCandidate);
}
if (workspace != null && sectionCandidate != null) {
try {
section = workspace.getSection(Long.decode(sectionCandidate));
} catch (NumberFormatException nfe) {
section = workspace.getSectionByUrl(sectionCandidate);
}
}
// Check the user has access permissions to the target workspace.
if (workspace != null && section == null) {
try {
Workspace currentWorkspace = navigationManager.getCurrentWorkspace();
log.debug("currentWorkspace = " + (currentWorkspace == null ? "null" : currentWorkspace.getId()) + " workspaceCandidate = " + workspaceCandidate);
if (!workspace.equals(currentWorkspace)) {
WorkspacePermission workspacePerm = WorkspacePermission.newInstance(workspace, WorkspacePermission.ACTION_LOGIN);
if (userStatus.hasPermission(workspacePerm)) {
navigationManager.setCurrentWorkspace(workspace);
log.debug("SessionManager.setWorkspace(" + workspace.getId() + ")");
} else {
if (log.isDebugEnabled()) log.debug("User has no " + WorkspacePermission.ACTION_LOGIN + " permission in workspace " + workspaceCandidate);
if (isShowLoginBackDoorOnPermissionDenied()) {
navigationManager.setUserRequiresLoginBackdoor(true);
navigationManager.setCurrentWorkspace(workspace);
}
}
}
requestContext.consumeURIPart("/" + workspaceCandidate);
} catch (Exception e) {
log.error("Cannot set current workspace.", e);
}
}
// Check the user has access permissions to the target section.
else if (section != null) {
try {
if (!section.equals(navigationManager.getCurrentSection())) {
WorkspacePermission workspacePerm = WorkspacePermission.newInstance(section.getWorkspace(), WorkspacePermission.ACTION_LOGIN);
SectionPermission sectionPerm = SectionPermission.newInstance(section, SectionPermission.ACTION_VIEW);
if (userStatus.hasPermission(workspacePerm) && userStatus.hasPermission(sectionPerm)) {
if (log.isDebugEnabled()) log.debug("SessionManager.setSection(" + section.getId() + ")");
navigationManager.setCurrentSection(section);
}
else {
if (log.isDebugEnabled()) log.debug("User has no " + WorkspacePermission.ACTION_LOGIN + " permission in workspace " + workspaceCandidate);
if (isShowLoginBackDoorOnPermissionDenied()) {