diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java index def85fb2b9abb58be6d89563568f35c6156f9454..f5e4514ec292c0d9626b7cc0535a9ff38949db7d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java @@ -136,7 +136,7 @@ public final class GlobalPropertiesBean implements Serializable { /** * Setter for the property {@link GlobalPropertiesBean#analysisEditorGridSizeCookieName}. <b>Do not use this method. This property is Spring managed.</b> * - * @param projectOverviewPage + * @param analysisEditorGridSizeCookieName * The new value for the property. */ public void setAnalysisEditorGridSizeCookieName(final String analysisEditorGridSizeCookieName) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java index 5094db99b1645843c0abe346d5550819d6a2a698..716c6d8e78152b6eaaf81ab269caaeaa56be410e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java @@ -34,7 +34,6 @@ import kieker.webgui.common.IProjectManagerFacade; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; -import kieker.webgui.common.impl.ProjectManagerFacadeImpl; /** * The {@link ProjectsBean} is a Spring managed bean to manage a list with all application wide available projects. It provides methods to receive this list as well @@ -91,6 +90,8 @@ public final class ProjectsBean { * * @param project * The name for the new project which should be added to the application. + * @param currentProjectOverviewBean + * The current instance of {@link CurrentProjectOverviewBean} which will be used to update the list of projects. */ public void addProject(final String project, final CurrentProjectOverviewBean currentProjectOverviewBean) { try { @@ -122,6 +123,8 @@ public final class ProjectsBean { * The name of the source project. * @param destinationProject * The name of the new (copied) project. + * @param currentProjectOverviewBean + * The current instance of {@link CurrentProjectOverviewBean} which will be used to update the list of projects. */ public void copyProject(final String sourceProject, final String destinationProject, final CurrentProjectOverviewBean currentProjectOverviewBean) { try { @@ -148,7 +151,7 @@ public final class ProjectsBean { /** * This method can be used to open an already existing project. This means that the current state of the project on the file system is loaded into an instance of - * {@link MIProject}. This instance can be modified at will and for example later saved by the {@link ProjectManagerFacadeImpl}. + * {@link MIProject}. This instance can be modified at will and for example later saved by the {@link IProjectManagerFacade}. * * @param project * The name of the project to be opened. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java index f260734306d6d933025be3056ad789134e075d0e..91bb4b3775e1887360876b130fe7ad191396790a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java @@ -50,6 +50,7 @@ public final class ThemeSwitcherBean { * The setter for the property {@link ThemeSwitcherBean#themes}. <b>Do not use this method. This property is Spring managed.</b> * * @param themes + * The value for the property. */ public void setThemes(final Map<String, String> themes) { this.themes = themes; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java index 886efc57d0d22a19c75d366e5c3f6b8ddd4fc97c..23c42a308deadb77bed3eabf9abe7cbb5d354f54 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java @@ -1,3 +1,19 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + package kieker.webgui.beans.request; import java.util.ArrayList; @@ -5,6 +21,12 @@ import java.util.List; import kieker.webgui.common.Role; +/** + * This simple bean is request scoped and can be used to store the necessary data for a new user during a request. It is not to be used to deliver a list of users + * for example, as there is a field for a password. + * + * @author Nils Christian Ehmke + */ public class NewUserBean { private List<Role> roles; @@ -20,26 +42,59 @@ public class NewUserBean { this.password = ""; } + /** + * Delivers the current value of the property {@link NewUserBean#roles}. + * + * @return The current value of the property. + */ public List<Role> getRoles() { return this.roles; } + /** + * Setter for the property {@link NewUserBean#roles}. + * + * @param roles + * The new value for the property. + */ public void setRoles(final List<Role> roles) { this.roles = roles; } + /** + * Delivers the current value of the property {@link NewUserBean#username}. + * + * @return The current value of the property. + */ public String getUsername() { return this.username; } + /** + * Setter for the property {@link NewUserBean#username}. + * + * @param username + * The new value for the property. + */ public void setUsername(final String username) { this.username = username; } + /** + * Delivers the current value of the property {@link NewUserBean#password}. + * + * @return The current value of the property. + */ public String getPassword() { return this.password; } + /** + * Setter for the property {@link NewUserBean#password}. + * + * @param password + * The new value for the property. + */ public void setPassword(final String password) { this.password = password; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java index 2d26fd227a879e6d6c246bee89554342887ef82e..c5d61c95aec319a1e09d5ae2318217b36e29aaed 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java @@ -50,7 +50,7 @@ public final class UserBean implements Serializable { * * @return The user name. */ - public String getUserName() { + public String getUsername() { final String username; final Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java index 27a5fe2b84bd0bbfd5486a6f96e4eb42fd166f92..a228a20e4c44bfbb6cbf644bc63af9a55e64edae 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java @@ -156,6 +156,12 @@ public final class CurrentAnalysisEditorBean { // No code necessary } + /** + * Setter for the attribute {@link CurrentAnalysisEditorBean#projectManagerFacade}. + * + * @param projectManagerFacade + * The new value of the attribute. + */ public void setProjectManagerFacade(final IProjectManagerFacade projectManagerFacade) { this.projectManagerFacade = projectManagerFacade; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java index 9b0faed787fde73f61245ead42a7ebf2bb6e7ad9..41252700bcaa3927f703a788394744daa1ad0097 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java @@ -97,6 +97,12 @@ public final class CurrentCockpitEditorBean { this.createDashboard(); } + /** + * Setter for the property {@link CurrentCockpitEditorBean#projectManagerFacade}. + * + * @param projectManagerFacade + * The new value of the property. + */ public void setProjectManagerFacade(final IProjectManagerFacade projectManagerFacade) { this.projectManagerFacade = projectManagerFacade; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java index 1b31c8f8acf8269007271802ab8a537e749f5b2a..81fbe74b8cf919a40b49db307d580742d6de78d4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java @@ -80,12 +80,18 @@ public final class CurrentProjectOverviewBean { this.setProjectName((String) event.getObject()); } + /** + * Setter for the property {@link CurrentProjectOverviewBean#projectsBean}. + * + * @param projectsBean + * The new value for the property. + */ public void setProjectsBean(final ProjectsBean projectsBean) { this.projectsBean = projectsBean; } /** - * This method should only be called automatically by the JVM to update the projects list. + * This method should only be called automatically by Spring to update the projects list. */ protected void initialialize() { this.updateLists(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java index fa2beaf1b00644dc2de34ddabe39880893f3bf5f..6321488c773291c83fd440a90399692731709327 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java @@ -44,24 +44,59 @@ public final class CurrentUserManagementBean { // No code necessary } + /** + * Setter for the property {@link CurrentUserManagementBean#userManagerFacade}. + * + * @param userManagerFacade + * The new value for the property. + */ public void setUserManagerFacade(final IUserManagerFacade userManagerFacade) { this.userManagerFacade = userManagerFacade; } + /** + * This method adds the given user to the database and informs about success via the growl component. + * + * @param username + * The name of the new user. + * @param password + * The password of the new user. + * @param roles + * The roles of the new user. + */ public void addUser(final String username, final String password, final List<Role> roles) { this.userManagerFacade.addUser(username, password, roles); // TODO Check that the op was successful before adding the user to our list this.users.add(new User(username, roles, true)); } + /** + * This method removed the given user from the database and informs about success via the growl component. + * + * @param username + * The name of the user. + */ public void removeUser(final String username) { this.userManagerFacade.removeUser(username); } + /** + * This method edits the given user within the database and informs about success via the growl component. + * + * @param username + * The name of the user. + * @param password + * The (new) password of the user. + * @param roles + * The (new) roles of the user. + */ public void editUser(final String username, final String password, final Role... roles) { this.userManagerFacade.editUser(username, password, roles); } + /** + * This method initializes the bean. <b>Do not call this method manually. It will only be accessed by Spring.</b> + */ protected void initialialize() { this.updateList(); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerFacadeImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerFacadeImpl.java index 7e744a2235c3cfa4da4d1b05f8bc7665325bd017..eb7e7e4ed0fa74fbeed6d85f0f8055d3d1685610 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerFacadeImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerFacadeImpl.java @@ -61,6 +61,14 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { } } + public void destroy() { + try { + this.connection.close(); + } catch (final SQLException ex) { + UserManagerFacadeImpl.LOG.error("Could not close database connection.", ex); + } + } + public void setDataSource(final DataSource dataSource) { this.dataSource = dataSource; } @@ -68,9 +76,11 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { @Override @PreAuthorize("hasRole('ROLE_ADMIN')") public void addUser(final String username, final String password, final List<Role> roles) { + PreparedStatement userCmd = null; + PreparedStatement roleCmd = null; try { - final PreparedStatement userCmd = this.connection.prepareStatement("INSERT INTO KIEKERUser (name, password, enabled) VALUES (?, ?, True)"); - final PreparedStatement roleCmd = this.connection.prepareStatement("INSERT INTO Userroles (name, role) VALUES (?, ?)"); + userCmd = this.connection.prepareStatement("INSERT INTO KIEKERUser (name, password, enabled) VALUES (?, ?, True)"); + roleCmd = this.connection.prepareStatement("INSERT INTO Userroles (name, role) VALUES (?, ?)"); userCmd.setString(1, username); userCmd.setString(2, password); @@ -83,6 +93,21 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { } } catch (final SQLException ex) { UserManagerFacadeImpl.LOG.error("Could not add user to the database.", ex); + } finally { + if (userCmd != null) { + try { + userCmd.close(); + } catch (final SQLException ex) { + UserManagerFacadeImpl.LOG.error("Could not close prepared statement.", ex); + } + } + if (roleCmd != null) { + try { + roleCmd.close(); + } catch (final SQLException ex) { + UserManagerFacadeImpl.LOG.error("Could not close prepared statement.", ex); + } + } } } diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml index e8da97f1024e8e4ca3d1b8e1dc3e99db91fbf4bb..e6e0029cd03b2f28ca03e751cb74d84520d536ad 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-bean-config.xml @@ -66,7 +66,7 @@ </map> </property> </bean> - <bean init-method="initialize" id="userManagerFacade" class="kieker.webgui.common.impl.UserManagerFacadeImpl"> + <bean destroy-method="destroy" init-method="initialize" id="userManagerFacade" class="kieker.webgui.common.impl.UserManagerFacadeImpl"> <property name="dataSource" ref="userDataSource" /> </bean> diff --git a/Kieker.WebGUI/src/main/webapp/pages/CockpitEditorPage.xhtml b/Kieker.WebGUI/src/main/webapp/pages/CockpitEditorPage.xhtml index a201c9f874c8064638e212a9687a2cbf0bf8f6ef..c7f1e6e011b1e6c076d7374a2b475d19b243b2ee 100644 --- a/Kieker.WebGUI/src/main/webapp/pages/CockpitEditorPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/pages/CockpitEditorPage.xhtml @@ -68,7 +68,7 @@ <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-about" value=" #{localizedMessages.about}" onclick="aboutDlg.show()" ajax="true"/> </p:submenu> - <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.userName}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> + <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> </p:menubar> </h:form> </p:layoutUnit> diff --git a/Kieker.WebGUI/src/main/webapp/pages/ControllerPage.xhtml b/Kieker.WebGUI/src/main/webapp/pages/ControllerPage.xhtml index 30c45b94e999b4e6a2bbd4a88bfdf7964ce2bcc5..623647308973d2b3be3c0206afde6f7c8b71e1a9 100644 --- a/Kieker.WebGUI/src/main/webapp/pages/ControllerPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/pages/ControllerPage.xhtml @@ -61,7 +61,7 @@ <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-about" value=" #{localizedMessages.about}" onclick="aboutDlg.show()" ajax="true"/> </p:submenu> - <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.userName}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> + <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> </p:menubar> </h:form> diff --git a/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml b/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml index c70d4e2bb0358f80f8ba7359b58bb45901995ca9..1c09d653f4d0a7ea9e3cad989a6270688c389f21 100644 --- a/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml +++ b/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml @@ -57,7 +57,7 @@ <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-about" value=" #{localizedMessages.about}" onclick="aboutDlg.show()" ajax="true"/> </p:submenu> - <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.userName}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> + <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username}" ajax="true" url="#{request.contextPath}/j_spring_security_logout"/> </p:menubar> <ui:insert name="furtherMenuBar"/> </h:form>