try {
Set<String> workspaceIds = UIServices.lookup().getWorkspacesManager().getAllWorkspacesIdentifiers();
List<Workspace> workspaces = new ArrayList<Workspace>();
for (String wsId : workspaceIds) {
Workspace workspace = UIServices.lookup().getWorkspacesManager().getWorkspace(wsId);
WorkspacePermission perm = WorkspacePermission.newInstance(workspace, WorkspacePermission.ACTION_LOGIN);
if (UserStatus.lookup().hasPermission(perm)) {
workspaces.add(workspace);
}
}
if (!workspaces.isEmpty()) {
renderFragment("outputStart");
for (Workspace workspace : workspaces) {
setAttribute("workspace", workspace);
setAttribute("workspaceId", workspace.getId());
setAttribute("workspaceName", StringEscapeUtils.escapeHtml(getLocalizedValue(workspace.getTitle())));
Map params = new HashMap();
params.put(NavigationManager.WORKSPACE_ID, workspace.getId());
String workspaceURL = UIServices.lookup().getUrlMarkupGenerator().getPermanentLink("org.jboss.dashboard.ui.NavigationManager", "NavigateToWorkspace", params);
if (workspaceURL.startsWith(request.getContextPath())) {
workspaceURL = workspaceURL.substring((request.getContextPath()).length());
}
while (workspaceURL.startsWith("/")) workspaceURL = workspaceURL.substring(1);