Skip to content
Snippets Groups Projects
Commit a33008d0 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Solved a problem with multiple session access to the projects list; Added code...

Solved a problem with multiple session access to the projects list; Added code to differ between sessions
parent 29deefe7
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,7 @@ import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.el.ELResolver;
import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;
import javax.faces.bean.ApplicationScoped;
......@@ -37,6 +38,7 @@ import kieker.analysis.AnalysisController;
import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.common.logging.Log;
import kieker.common.logging.LogFactory;
import kieker.webgui.beans.view.CurrentProjectOverviewBean;
import kieker.webgui.common.ACManager;
import kieker.webgui.common.FSManager;
import kieker.webgui.common.exception.ProjectAlreadyExistingException;
......@@ -92,6 +94,11 @@ public final class ProjectsBean {
this.projects.add(project);
// Inform the user
ProjectsBean.showMessage(FacesMessage.SEVERITY_INFO, "Project created.");
// Update the list of the "calling" bean
final ELResolver el = FacesContext.getCurrentInstance().getApplication().getELResolver();
final CurrentProjectOverviewBean bean = (CurrentProjectOverviewBean) el.getValue(FacesContext.getCurrentInstance().getELContext(), null,
"currentProjectOverviewBean");
bean.updateLists();
} catch (final IOException ex) {
ProjectsBean.LOG.error("An error occured while creating the project.", ex);
ProjectsBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project.");
......@@ -159,10 +166,12 @@ public final class ProjectsBean {
/**
* This method delivers all available projects as a list of string.
*
* @return All currently available projects. Do not modify this list with add, remove etc. (It still has to be sortable for Primefaces though)
* @return All currently available projects. The list is just a copy.
*/
public List<String> getProjects() {
return this.projects;
synchronized (this.projects) {
return new ArrayList<String>(this.projects);
}
}
/**
......
......@@ -21,7 +21,9 @@
package kieker.webgui.beans.session;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;
import javax.annotation.PreDestroy;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
......@@ -44,11 +46,19 @@ public final class UserBean implements Serializable {
*/
private final String userName;
private static final AtomicLong guestCounter = new AtomicLong();
/**
* Creates a new instance of this class. The user name is set to "Guest".
*/
public UserBean() {
this.userName = "Guest";
this.userName = "Guest #" + UserBean.guestCounter.getAndIncrement();
}
@Override
@PreDestroy
protected void finalize() {
UserBean.guestCounter.decrementAndGet();
}
/**
......
......@@ -20,8 +20,16 @@
package kieker.webgui.beans.view;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.el.ELResolver;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import kieker.webgui.beans.application.ProjectsBean;
/**
* This bean is used in the context of the project overview page.
......@@ -33,6 +41,10 @@ import javax.faces.bean.ViewScoped;
@ViewScoped
public class CurrentProjectOverviewBean {
/**
* This list contains all available projects by name.
*/
private List<String> projects = new ArrayList<String>();
/**
* The name of the "selected" project.
*/
......@@ -64,4 +76,25 @@ public class CurrentProjectOverviewBean {
this.projectName = projectName;
}
@PostConstruct
protected void init() {
this.updateLists();
}
public void updateLists() {
final ELResolver el = FacesContext.getCurrentInstance().getApplication().getELResolver();
final ProjectsBean bean = (ProjectsBean) el.getValue(FacesContext.getCurrentInstance().getELContext(), null, "projectsBean");
this.projects = bean.getProjects();
}
/**
* This method delivers all available projects as a list of string.
*
* @return All currently available projects. The list is just a copy.
*/
public List<String> getProjects() {
return this.projects;
}
}
......@@ -22,7 +22,7 @@
<p:menuitem value="New Project" onclick="newProjectDialog.show()" ajax="true"/>
<p:menuitem value="Import Project" ajax="true" disabled="true"/>
<p:separator/>
<p:menuitem value="Refresh Projects List" update=":projectsListForm" ajax="true"/>
<p:menuitem value="Refresh Projects List" update=":projectsListForm" action="#{currentProjectOverviewBean.updateLists()}" ajax="true"/>
<p:separator/>
<p:menuitem value="Settings" onclick="settingsDlg.show()" ajax="true"/>
</p:submenu>
......@@ -46,7 +46,7 @@
<p:commandButton icon="ui-icon-plus" value="Project" onclick="newProjectDialog.show()" ajax="true"/>
</p:toolbarGroup>
</p:toolbar>
<p:dataTable rows="15" paginator="true" paginatorPosition="bottom" var="project" rowsPerPageTemplate="5,10,15,25,50" value="#{projectsBean.projects}" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:dataTable rows="15" paginator="true" paginatorPosition="bottom" var="project" rowsPerPageTemplate="5,10,15,25,50" value="#{currentProjectOverviewBean.projects}" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:column headerText="Project Name" id="modelHeader" sortBy="#{project}">
<p:commandLink id="dynaButton" value="#{project}"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment