From 8fd2a615b840a8c269b882a4db29771196f6b22b Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Mon, 29 Oct 2012 10:30:50 +0100 Subject: [PATCH] Refactoring --- Kieker.WebGUI/bin/Kieker.WebGUI.bat | 2 +- Kieker.WebGUI/bin/Kieker.WebGUI.sh | 2 +- .../Bookstore-Example/Bookstore-Example.kax | 2 +- Kieker.WebGUI/pom.xml | 3 +- .../application/GlobalPropertiesBean.java | 47 ++- .../beans/application/ProjectsBean.java | 67 ++-- .../beans/application/ThemeSwitcherBean.java | 7 +- .../beans/application/package-info.java | 2 +- .../beans/request/NewUserBean.java | 9 +- .../beans/request/StringBean.java | 7 +- .../beans/request/package-info.java | 2 +- .../beans/session/UserBean.java | 48 ++- .../beans/session/package-info.java | 2 +- .../beans/view/CurrentAnalysisEditorBean.java | 94 ++--- .../view/CurrentAnalysisEditorGraphBean.java | 7 +- .../beans/view/CurrentCockpitBean.java | 50 +-- .../beans/view/CurrentCockpitEditorBean.java | 38 +- .../beans/view/CurrentControllerBean.java | 59 ++- .../view/CurrentProjectOverviewBean.java | 31 +- .../beans/view/CurrentUserManagementBean.java | 60 +-- .../beans/view/package-info.java | 2 +- .../converter/RoleStringConverter.java | 4 +- .../business/converter/package-info.java | 7 + .../kieker/webgui/business/package-info.java | 7 + .../kieker/webgui/common/IProjectManager.java | 348 ------------------ .../main/java/kieker/webgui/common/Role.java | 40 -- .../webgui/common/{util => }/ViewScope.java | 2 +- .../ApplicationInitializationException.java | 55 +++ .../common/exception/DataAccessException.java | 54 +++ .../webgui/common/util/package-info.java | 23 -- .../{common/User.java => domain/Project.java} | 40 +- .../main/java/kieker/webgui/domain/User.java | 133 +++++++ .../converter => domain}/package-info.java | 5 +- .../webgui/persistence/IProjectDAO.java | 101 +++++ .../kieker/webgui/persistence/IUserDAO.java | 55 +++ .../impl/DerbyUserDAO.java} | 140 ++++--- .../impl/FSProjectDAOImpl.java} | 132 ++++--- .../webgui/persistence/impl/package-info.java | 22 ++ .../webgui/persistence/package-info.java | 22 ++ .../webgui/service/IProjectService.java | 124 +++++++ .../IUserService.java} | 22 +- .../impl/ProjectServiceImpl.java} | 156 ++++---- .../webgui/service/impl/UserServiceImpl.java | 97 +++++ .../impl/package-info.java | 5 +- .../impl}/util/ACManager.java | 15 +- .../impl}/util/Analysis.java | 2 +- .../impl}/util/PluginFinder.java | 7 +- .../service/impl/util/package-info.java | 7 + .../kieker/webgui/service/package-info.java | 22 ++ .../src/main/resources/global.properties | 9 + .../lang/AccessDeniedPage_de.properties | 4 +- .../lang/AnalysisEditorPage_de.properties | 4 +- .../lang/CockpitEditorPage_de.properties | 4 +- .../resources/lang/CockpitPage_de.properties | 2 +- .../main/resources/lang/Common_de.properties | 15 +- .../main/resources/lang/Common_en.properties | 3 +- .../lang/ControllerPage_de.properties | 12 +- .../resources/lang/LoginPage_de.properties | 4 +- .../lang/ProjectOverviewPage_de.properties | 6 +- .../lang/UserManagementPage_de.properties | 6 +- .../src/main/webapp/WEB-INF/faces-config.xml | 6 +- .../src/main/webapp/WEB-INF/pretty-config.xml | 19 +- .../webapp/WEB-INF/spring-bean-config.xml | 89 ++--- .../webapp/WEB-INF/spring-common-config.xml | 15 +- .../webapp/WEB-INF/spring-database-config.xml | 11 +- .../webapp/WEB-INF/spring-security-config.xml | 21 +- .../webapp/WEB-INF/spring-security-taglib.xml | 5 +- Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml | 8 +- .../src/main/webapp/css/AccessDeniedPage.css | 5 + .../main/webapp/css/AnalysisEditorPage.css | 5 + .../src/main/webapp/css/CockpitEditorPage.css | 5 + .../src/main/webapp/css/CockpitPage.css | 5 + Kieker.WebGUI/src/main/webapp/css/Common.css | 5 + .../src/main/webapp/css/ControllerPage.css | 7 +- .../src/main/webapp/css/DefaultTemplate.css | 4 +- .../src/main/webapp/css/FlowEditor.css | 5 + Kieker.WebGUI/src/main/webapp/css/Icons.css | 5 + .../src/main/webapp/css/LoginPage.css | 5 + .../main/webapp/css/ProjectOverviewPage.css | 5 + .../src/main/webapp/css/UserManagement.css | 5 +- .../src/main/webapp/dialogs/AboutDialog.xhtml | 5 +- .../dialogs/AnalysisEditorPageDialogs.xhtml | 4 + .../dialogs/CockpitEditorPageDialogs.xhtml | 19 +- .../dialogs/ProjectOverviewPageDialogs.xhtml | 22 +- .../main/webapp/dialogs/SettingsDialog.xhtml | 6 + .../dialogs/UserManagementDialogs.xhtml | 3 + .../main/webapp/templates/PagesTemplate.xhtml | 2 +- 87 files changed, 1520 insertions(+), 1033 deletions(-) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/application/GlobalPropertiesBean.java (92%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/application/ProjectsBean.java (85%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/application/ThemeSwitcherBean.java (91%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/application/package-info.java (94%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/request/NewUserBean.java (92%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/request/StringBean.java (93%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/request/package-info.java (95%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/session/UserBean.java (89%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/session/package-info.java (95%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentAnalysisEditorBean.java (94%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentAnalysisEditorGraphBean.java (99%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentCockpitBean.java (84%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentCockpitEditorBean.java (95%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentControllerBean.java (84%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentProjectOverviewBean.java (81%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/CurrentUserManagementBean.java (70%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{ => business}/beans/view/package-info.java (95%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{common => business}/converter/RoleStringConverter.java (94%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/business/package-info.java delete mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java delete mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java rename Kieker.WebGUI/src/main/java/kieker/webgui/common/{util => }/ViewScope.java (98%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ApplicationInitializationException.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java delete mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/util/package-info.java rename Kieker.WebGUI/src/main/java/kieker/webgui/{common/User.java => domain/Project.java} (56%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java rename Kieker.WebGUI/src/main/java/kieker/webgui/{common/converter => domain}/package-info.java (89%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java rename Kieker.WebGUI/src/main/java/kieker/webgui/{common/impl/UserManagerImpl.java => persistence/impl/DerbyUserDAO.java} (50%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{common/util/FSManager.java => persistence/impl/FSProjectDAOImpl.java} (84%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java rename Kieker.WebGUI/src/main/java/kieker/webgui/{common/IUserManager.java => service/IUserService.java} (61%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{common/impl/ProjectManagerImpl.java => service/impl/ProjectServiceImpl.java} (67%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java rename Kieker.WebGUI/src/main/java/kieker/webgui/{common => service}/impl/package-info.java (89%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{common => service/impl}/util/ACManager.java (96%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{common => service/impl}/util/Analysis.java (99%) rename Kieker.WebGUI/src/main/java/kieker/webgui/{common => service/impl}/util/PluginFinder.java (96%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java diff --git a/Kieker.WebGUI/bin/Kieker.WebGUI.bat b/Kieker.WebGUI/bin/Kieker.WebGUI.bat index 43f71488..de50cb99 100644 --- a/Kieker.WebGUI/bin/Kieker.WebGUI.bat +++ b/Kieker.WebGUI/bin/Kieker.WebGUI.bat @@ -1,6 +1,6 @@ @echo off REM @author Nils Christian Ehmke -java -jar ..\lib\jetty-runner-*.jar --path /Kieker.WebGUI ..\target\Kieker.WebGUI-*.war +java -XX:PermSize=256M -XX:MaxPermSize=512M -Xms128M -Xmx256M -jar ..\lib\jetty-runner-*.jar --path /Kieker.WebGUI ..\target\Kieker.WebGUI-*.war @echo on \ No newline at end of file diff --git a/Kieker.WebGUI/bin/Kieker.WebGUI.sh b/Kieker.WebGUI/bin/Kieker.WebGUI.sh index 82a5cab6..df1ff528 100644 --- a/Kieker.WebGUI/bin/Kieker.WebGUI.sh +++ b/Kieker.WebGUI/bin/Kieker.WebGUI.sh @@ -2,4 +2,4 @@ # @author Nils Christian Ehmke -java -jar ../lib/jetty-runner-*.jar --path /Kieker.WebGUI ../target/Kieker.WebGUI-*.war \ No newline at end of file +java -XX:PermSize=256M -XX:MaxPermSize=512M -Xms128M -Xmx256M -jar ../lib/jetty-runner-*.jar --path /Kieker.WebGUI ../target/Kieker.WebGUI-*.war \ No newline at end of file diff --git a/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax b/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax index 719668e2..c5d6fd62 100644 --- a/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax +++ b/Kieker.WebGUI/bin/data/Bookstore-Example/Bookstore-Example.kax @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<Project xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="platform:/resource/Kieker/model/AnalysisMetaModel.ecore"> +<Project xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="platform:/resource/Kieker/model/AnalysisMetaModel.ecore" name="Bookstore-Example"> <plugins xsi:type="Reader" name="FSReader" classname="kieker.analysis.plugin.reader.filesystem.FSReader"> <properties name="inputDirs" value="data/Bookstore-Example/testdata"/> <properties name="ignoreUnknownRecordTypes" value="false"/> diff --git a/Kieker.WebGUI/pom.xml b/Kieker.WebGUI/pom.xml index b7ad5ff9..f959b1f2 100644 --- a/Kieker.WebGUI/pom.xml +++ b/Kieker.WebGUI/pom.xml @@ -22,6 +22,7 @@ </developer> </developers> + <properties> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -409,7 +410,7 @@ <configuration> <tasks> <copy file="${project.basedir}/lib/${kieker.jar}" - todir="${project.build.directory}/Kieker.WebGUI-${project.version}/WEB-INF/lib" /> + todir="${project.build.directory}/Kieker.WebGUI-${project.version}/WEB-INF/lib" /> </tasks> </configuration> </execution> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/GlobalPropertiesBean.java similarity index 92% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/GlobalPropertiesBean.java index d93a1bdc..06494bb4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/GlobalPropertiesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/GlobalPropertiesBean.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.application; +package kieker.webgui.business.beans.application; import java.io.Serializable; import java.util.ResourceBundle; @@ -23,6 +23,9 @@ import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage.Severity; import javax.faces.context.FacesContext; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + /** * The class {@link GlobalPropertiesBean} is a singleton scoped Spring bean, containing properties, constants and partially localized texts for the application. Some * of the properties are injected via Spring, others are loaded directly from the resource bundle. This makes sure that those constants can be modified without a @@ -32,6 +35,8 @@ import javax.faces.context.FacesContext; * * @author Nils Christian Ehmke */ +@Component +@Scope("singleton") public final class GlobalPropertiesBean implements Serializable { private static final long serialVersionUID = 4253541090603377504L; @@ -58,6 +63,8 @@ public final class GlobalPropertiesBean implements Serializable { private String analysisEditorGridColorCookieName; private String analysisEditorDefaultGridSize; private String analysisEditorDefaultGridColor; + private String version; + private String kiekerUrl; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> @@ -85,6 +92,44 @@ public final class GlobalPropertiesBean implements Serializable { return this.projectOverviewPage; } + /** + * Getter for the property {@link GlobalPropertiesBean#version}. + * + * @return The current value of the property. + */ + public String getVersion() { + return this.version; + } + + /** + * Setter for the property {@link GlobalPropertiesBean#version}. + * + * @param version + * The new value of the property. + */ + public void setVersion(final String version) { + this.version = version; + } + + /** + * Getter for the property {@link GlobalPropertiesBean#kiekerUrl}. + * + * @return The current value of the property. + */ + public String getKiekerUrl() { + return this.kiekerUrl; + } + + /** + * Setter for the property {@link GlobalPropertiesBean#kiekerUrl}. + * + * @param kiekerUrl + * The new value of the property. + */ + public void setKiekerUrl(final String kiekerUrl) { + this.kiekerUrl = kiekerUrl; + } + /** * Setter for the property {@link GlobalPropertiesBean#facesContextThemeKey}. <b>Do not use this method. This property is Spring managed.</b> * diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/ProjectsBean.java similarity index 85% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/ProjectsBean.java index f28ed670..d09ecb32 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/ProjectsBean.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.application; +package kieker.webgui.business.beans.application; import java.io.IOException; import java.util.ArrayList; @@ -24,14 +24,22 @@ import java.util.List; import javax.faces.application.FacesMessage; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; 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.IProjectManager; +import kieker.webgui.business.beans.view.CurrentProjectOverviewBean; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; +import kieker.webgui.service.IProjectService; /** * 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 @@ -42,7 +50,10 @@ import kieker.webgui.common.exception.ProjectNotExistingException; * * @author Nils Christian Ehmke */ -public final class ProjectsBean { +@Component +@Scope("singleton") +@Lazy +public final class ProjectsBean implements InitializingBean { private static final Log LOG = LogFactory.getLog(ProjectsBean.class); private static final String DEFAULT_TIMESTAMP = "N/A"; @@ -50,7 +61,8 @@ public final class ProjectsBean { private final List<String> projects = Collections.synchronizedList(new ArrayList<String>()); - private IProjectManager projectManagerFacade; + @Autowired + private IProjectService projectService; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> @@ -59,24 +71,6 @@ public final class ProjectsBean { // No code necessary } - /** - * The Setter for the property {@link ProjectsBean#projectManagerFacade}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param projectManagerFacade - * The new value for the property. - */ - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; - } - - /** - * This method does some initialization work after construction. <b>Do not call this method. The method is Spring managed.</b> - */ - protected void initialize() { - // Load a list with all available projects on the FS - this.projects.addAll(this.projectManagerFacade.listAllProjects()); - } - /** * This method adds a new project with the given name to the application if this is possible. In either case (this means if the project has been created, if the * project could not be created for any reason) the user will be informed via the growl component. In other words: A message will be delivered within the current @@ -92,8 +86,10 @@ public final class ProjectsBean { */ public void addProject(final String project, final CurrentProjectOverviewBean currentProjectOverviewBean) { try { + final Project emptyProject = new Project(MIAnalysisMetaModelFactory.eINSTANCE.createProject()); + emptyProject.getMiproject().setName(project); // Try and use the FS-Manager to create the project atomically. - this.projectManagerFacade.addProject(project); + this.projectService.addProject(emptyProject); // If there were no exception, everything went well. We can add the project to our list. this.projects.add(project); // Inform the user @@ -126,7 +122,7 @@ public final class ProjectsBean { public void copyProject(final String sourceProject, final String destinationProject, final CurrentProjectOverviewBean currentProjectOverviewBean) { try { // Try and use the FS-Manager to copy the project atomically. - this.projectManagerFacade.copyProject(sourceProject, destinationProject); + this.projectService.copyProject(sourceProject, destinationProject); // If there were no exception, everything went well. We can add the project to our list. this.projects.add(destinationProject); // Inform the user @@ -158,7 +154,7 @@ public final class ProjectsBean { */ public MIProject openProject(final String project) throws ProjectLoadException { try { - return this.projectManagerFacade.openProject(project); + return this.projectService.openProject(project).getMiproject(); } catch (final IOException ex) { ProjectsBean.LOG.error("An error occured while loading the project.", ex); throw new ProjectLoadException("An error occured while loading the project.", ex); @@ -179,13 +175,17 @@ public final class ProjectsBean { public String getCurrTimeStamp(final String project) { try { // Get the current time stamp of the project - final long timeStamp = this.projectManagerFacade.getCurrTimeStamp(project); + final long timeStamp = this.projectService.getCurrTimestamp(project); // Convert the stamp into a human readable string. return new Date(timeStamp).toString(); } catch (final ProjectNotExistingException ex) { ProjectsBean.LOG.info("A project with the given name does not exist.", ex); // We can assume that something went wrong return ProjectsBean.DEFAULT_TIMESTAMP; + } catch (final IOException ex) { + ProjectsBean.LOG.info("An IO Exception occured.", ex); + // We can assume that something went wrong + return ProjectsBean.DEFAULT_TIMESTAMP; } } @@ -211,10 +211,21 @@ public final class ProjectsBean { */ public String getAnalysisControllerState(final String project) { try { - return this.projectManagerFacade.getCurrentState(project).toString(); + return this.projectService.getCurrentState(project).toString(); } catch (final ProjectNotExistingException ex) { ProjectsBean.LOG.info("A project with the given name does not exist.", ex); return ProjectsBean.DEFAULT_ANALYSIS_STATE; } } + + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + // Load a list with all available projects on the FS + this.projects.addAll(this.projectService.listAllProjects()); + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/ThemeSwitcherBean.java similarity index 91% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/ThemeSwitcherBean.java index 91bb4b37..cfbc8ebc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/ThemeSwitcherBean.java @@ -14,11 +14,14 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.application; +package kieker.webgui.business.beans.application; import java.util.Collections; import java.util.Map; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + /** * The {@link ThemeSwitcherBean} is responsible for holding a list with all application wide available themes (look and feels). As this is a static list, it is not * possible to import new themes during the runtime. The initialization is done in the Spring configuration file.<br> @@ -26,6 +29,8 @@ import java.util.Map; * * @author Nils Christian Ehmke */ +@Component +@Scope("singleton") public final class ThemeSwitcherBean { private Map<String, String> themes; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/package-info.java similarity index 94% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/package-info.java index 07aa9a73..527f6e06 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/application/package-info.java @@ -19,5 +19,5 @@ * * @author Nils Christian Ehmke */ -package kieker.webgui.beans.application; +package kieker.webgui.business.beans.application; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/NewUserBean.java similarity index 92% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/NewUserBean.java index 23c42a30..f3742d6e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/NewUserBean.java @@ -14,12 +14,15 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.request; +package kieker.webgui.business.beans.request; import java.util.ArrayList; import java.util.List; -import kieker.webgui.common.Role; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import kieker.webgui.domain.User.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 @@ -27,6 +30,8 @@ import kieker.webgui.common.Role; * * @author Nils Christian Ehmke */ +@Component +@Scope("request") public class NewUserBean { private List<Role> roles; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/StringBean.java similarity index 93% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/StringBean.java index caabc4ae..cdbbf929 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/StringBean.java @@ -14,7 +14,10 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.request; +package kieker.webgui.business.beans.request; + +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; /** * This simple bean can be used to store a string during a request. Furthermore it provides some simple methods to handle strings within the application where a bean @@ -23,6 +26,8 @@ package kieker.webgui.beans.request; * * @author Nils Christian Ehmke */ +@Component +@Scope("request") public final class StringBean { private String string; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/package-info.java similarity index 95% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/package-info.java index 26cfe25c..04b12db2 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/request/package-info.java @@ -19,5 +19,5 @@ * * @author Nils Christian Ehmke */ -package kieker.webgui.beans.request; +package kieker.webgui.business.beans.request; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/session/UserBean.java similarity index 89% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/session/UserBean.java index a9a6025d..e92c7403 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/session/UserBean.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.session; +package kieker.webgui.business.beans.session; import java.io.Serializable; import java.util.Map; @@ -23,10 +23,14 @@ import javax.faces.context.FacesContext; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Component; -import kieker.webgui.beans.application.GlobalPropertiesBean; +import kieker.webgui.business.beans.application.GlobalPropertiesBean; /** * This bean contains information about the user of this session (like the properties and configurations). This class is a Spring managed bean with session scope. @@ -34,7 +38,9 @@ import kieker.webgui.beans.application.GlobalPropertiesBean; * * @author Nils Christian Ehmke */ -public final class UserBean implements Serializable { +@Component +@Scope("session") +public final class UserBean implements Serializable, InitializingBean { private static final long serialVersionUID = 6422563876003638348L; @@ -42,9 +48,7 @@ public final class UserBean implements Serializable { private String gridColor; private int gridSize; - /** - * This property is injected by Spring. - */ + @Autowired private GlobalPropertiesBean globalPropertiesBean; /** @@ -54,15 +58,6 @@ public final class UserBean implements Serializable { // No code necessary } - /** - * This method initializes the bean. In fact it loads the default values before trying to load the values of the user from their cookies. <b>Do not call this - * method. The method is Spring managed.</b> - */ - protected void initialize() { - this.loadDefaultValues(); - this.loadValuesFromCookies(); - } - /** * Returns the name of the user of the current session. If something goes wrong during the search, it returns a human readable 'N/A'. * @@ -85,18 +80,6 @@ public final class UserBean implements Serializable { return username; } - /** - * The setter for the property {@link UserBean#globalPropertiesBean}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param globalPropertiesBean - * The new value for the property. - */ - public void setGlobalPropertiesBean(final GlobalPropertiesBean globalPropertiesBean) { - synchronized (this) { - this.globalPropertiesBean = globalPropertiesBean; - } - } - /** * The getter for the property {@link UserBean#lookAndFeel}. * @@ -227,4 +210,15 @@ public final class UserBean implements Serializable { final HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); response.addCookie(cookie); } + + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + this.loadDefaultValues(); + this.loadValuesFromCookies(); + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/session/package-info.java similarity index 95% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/session/package-info.java index ecc09dce..3afe701f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/session/package-info.java @@ -19,5 +19,5 @@ * * @author Nils Christian Ehmke */ -package kieker.webgui.beans.session; +package kieker.webgui.business.beans.session; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentAnalysisEditorBean.java similarity index 94% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentAnalysisEditorBean.java index 4462c676..3d72c24f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentAnalysisEditorBean.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.io.IOException; import java.lang.annotation.Annotation; @@ -29,6 +29,10 @@ import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.event.ValueChangeEvent; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDisplay; @@ -49,16 +53,17 @@ import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.beans.application.GlobalPropertiesBean; -import kieker.webgui.beans.application.ProjectsBean; -import kieker.webgui.beans.session.UserBean; +import kieker.webgui.business.beans.application.GlobalPropertiesBean; +import kieker.webgui.business.beans.application.ProjectsBean; +import kieker.webgui.business.beans.session.UserBean; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.IProjectManager; import kieker.webgui.common.exception.LibraryAlreadyExistingException; import kieker.webgui.common.exception.LibraryLoadException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; +import kieker.webgui.service.IProjectService; import org.primefaces.context.RequestContext; import org.primefaces.event.FileUploadEvent; @@ -79,6 +84,8 @@ import org.eclipse.emf.ecore.EObject; * * @author Nils Christian Ehmke */ +@Component +@Scope("view") public final class CurrentAnalysisEditorBean { /** * This field contains the log-object for the whole class, which will be used to log all important errors and exceptions which occur. @@ -132,10 +139,15 @@ public final class CurrentAnalysisEditorBean { * This field contains the currently selected component (this can either be a plugin ({@link MIPlugin}) or a repository ({@link MIRepository})). */ private EObject selectedComponent; - private IProjectManager projectManagerFacade; + @Autowired + private IProjectService projectService; + @Autowired private ProjectsBean projectsBean; + @Autowired private CurrentAnalysisEditorGraphBean currentAnalysisEditorGraphBean; + @Autowired private UserBean userBean; + @Autowired private GlobalPropertiesBean globalPropertiesBean; /** @@ -145,54 +157,6 @@ 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 IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; - } - - /** - * Getter for the attribute {@link CurrentAnalysisEditorBean#currentAnalysisEditorGraphBean}. - * - * @return Delivers the value of the attribute. - */ - public CurrentAnalysisEditorGraphBean getCurrentAnalysisEditorGraphBean() { - return this.currentAnalysisEditorGraphBean; - } - - /** - * Setter for the attribute {@link CurrentAnalysisEditorBean#currentAnalysisEditorGraphBean}. - * - * @param currentAnalysisEditorGraphBean - * The new value of the attribute. - */ - public void setCurrentAnalysisEditorGraphBean(final CurrentAnalysisEditorGraphBean currentAnalysisEditorGraphBean) { - this.currentAnalysisEditorGraphBean = currentAnalysisEditorGraphBean; - } - - /** - * Getter for the attribute {@link CurrentAnalysisEditorBean#projectsBean}. - * - * @return Delivers the value of the attribute. - */ - public ProjectsBean getProjectsBean() { - return this.projectsBean; - } - - /** - * Setter for the attribute {@link CurrentAnalysisEditorBean#projectsBean}. - * - * @param projectsBean - * The new value of the attribute. - */ - public void setProjectsBean(final ProjectsBean projectsBean) { - this.projectsBean = projectsBean; - } - /** * This method delivers the project stored in this bean. * @@ -298,8 +262,8 @@ public final class CurrentAnalysisEditorBean { */ private void addContentsToToolPalette(final MIDependency dependency) throws LibraryLoadException { this.addContentsToToolPalette( - this.projectManagerFacade.getAllPluginsWithinLib(dependency, this.projectName, this.classLoader, this.classAndMethodContainer), - this.projectManagerFacade.getAllRepositoriesWithinLib(dependency, this.projectName, this.classLoader, this.classAndMethodContainer)); + this.projectService.getAllPluginsWithinLib(dependency, new Project(this.project), this.classLoader, this.classAndMethodContainer), + this.projectService.getAllRepositoriesWithinLib(dependency, new Project(this.project), this.classLoader, this.classAndMethodContainer)); } /** @@ -310,8 +274,8 @@ public final class CurrentAnalysisEditorBean { */ private void addKiekerContentsToToolPalette() throws LibraryLoadException { this.addContentsToToolPalette( - this.projectManagerFacade.getAllPluginsWithinKiekerLib(this.classLoader, this.classAndMethodContainer), - this.projectManagerFacade.getAllRepositoriesWithinKiekerLib(this.classLoader, this.classAndMethodContainer)); + this.projectService.getAllPluginsWithinKiekerLib(this.classLoader, this.classAndMethodContainer), + this.projectService.getAllRepositoriesWithinKiekerLib(this.classLoader, this.classAndMethodContainer)); } /** @@ -369,7 +333,7 @@ public final class CurrentAnalysisEditorBean { private void initializeModelLibraries() throws ProjectLoadException { synchronized (this) { try { - final List<String> libs = this.projectManagerFacade.listAllLibraries(this.projectName); + final List<String> libs = this.projectService.listAllLibraries(new Project(this.project)); // Add them, but remove all existing dependencies so far to avoid double entries. This also makes sure that the model - after it has been opened - // points // just to valid dependencies (and to all of them). @@ -395,7 +359,7 @@ public final class CurrentAnalysisEditorBean { private void reloadClassLoader() throws ProjectLoadException { synchronized (this) { try { - this.classLoader = this.projectManagerFacade.getClassLoader(this.projectName); // NOPMD (ClassLoader) + this.classLoader = this.projectService.getClassLoader(new Project(this.project)); // NOPMD (ClassLoader) } catch (final NullPointerException ex) { throw new ProjectLoadException("Invalid class loader.", ex); } catch (final IOException ex) { @@ -669,7 +633,7 @@ public final class CurrentAnalysisEditorBean { // Use the file system manager to upload the new file final MIDependency lib; synchronized (this) { - this.projectManagerFacade.uploadLibrary(file, this.projectName); + this.projectService.uploadLibrary(file, new Project(this.project)); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgLibraryUploaded()); // As it seem to have worked, we can add the library to our model. lib = this.factory.createDependency(); @@ -709,7 +673,7 @@ public final class CurrentAnalysisEditorBean { public List<String> getLibraries() { synchronized (this) { try { - final List<String> result = this.projectManagerFacade.listAllLibraries(this.projectName); + final List<String> result = this.projectService.listAllLibraries(new Project(this.project)); result.add(0, "Kieker"); return result; @@ -760,7 +724,11 @@ public final class CurrentAnalysisEditorBean { public void saveProject(final boolean overwriteNewerProject) { synchronized (this) { try { - this.projectManagerFacade.saveProject(this.projectName, this.project, this.timeStamp, overwriteNewerProject); + if (overwriteNewerProject) { + this.projectService.editProject(new Project(this.project)); + } else { + this.projectService.editProject(new Project(this.project), this.timeStamp); + } GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectSaved()); // Update the time stamp! this.resetTimeStamp(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentAnalysisEditorGraphBean.java similarity index 99% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentAnalysisEditorGraphBean.java index ca3f6c43..d601b31a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorGraphBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentAnalysisEditorGraphBean.java @@ -14,12 +14,15 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.util.Map; import javax.faces.context.FacesContext; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.model.analysisMetaModel.MIFilter; import kieker.analysis.model.analysisMetaModel.MIInputPort; import kieker.analysis.model.analysisMetaModel.MIOutputPort; @@ -45,6 +48,8 @@ import org.eclipse.emf.ecore.EObject; * * @author Nils Christian Ehmke */ +@Component +@Scope("view") public final class CurrentAnalysisEditorGraphBean { /** * This is the log for errors, exceptions etc. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentCockpitBean.java similarity index 84% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentCockpitBean.java index 529e1d84..89829074 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentCockpitBean.java @@ -14,23 +14,28 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.io.IOException; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIView; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.beans.application.GlobalPropertiesBean; -import kieker.webgui.beans.application.ProjectsBean; +import kieker.webgui.business.beans.application.GlobalPropertiesBean; +import kieker.webgui.business.beans.application.ProjectsBean; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.IProjectManager; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; +import kieker.webgui.service.IProjectService; /** * The {@link CurrentCockpitBean} contains the necessary data behind an instance of the cockpit. It provides methods to read the state of the currently selected @@ -40,14 +45,18 @@ import kieker.webgui.common.exception.ProjectNotExistingException; * * @author Nils Christian Ehmke */ +@Component +@Scope("view") public final class CurrentCockpitBean { private static final Log LOG = LogFactory.getLog(CurrentCockpitBean.class); - private IProjectManager projectManagerFacade; + @Autowired + private IProjectService projectService; private String projectName; private MIProject project; private MIView activeView; private ClassAndMethodContainer classAndMethodContainer; + @Autowired private ProjectsBean projectsBean; /** @@ -68,33 +77,6 @@ public final class CurrentCockpitBean { } } - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; - } - - /** - * The getter for the {@link #projectsBean}-property. - * - * @return {@link #projectsBean} - */ - public ProjectsBean getProjectsBean() { - synchronized (this) { - return this.projectsBean; - } - } - - /** - * The setter for the {@link #projectsBean}-property. - * - * @param projectsBean - * The new value for {@link #projectsBean}. - */ - public void setProjectsBean(final ProjectsBean projectsBean) { - synchronized (this) { - this.projectsBean = projectsBean; - } - } - /** * This method sets the project stored within this bean. * @@ -122,7 +104,7 @@ public final class CurrentCockpitBean { this.project = this.projectsBean.openProject(this.projectName); if (this.project != null) { - final ClassLoader classLoader = this.projectManagerFacade.getClassLoader(this.projectName); // NOPMD (ClassLoader) + final ClassLoader classLoader = this.projectService.getClassLoader(new Project(this.project)); // NOPMD (ClassLoader) this.classAndMethodContainer = new ClassAndMethodContainer(classLoader); } } @@ -163,7 +145,7 @@ public final class CurrentCockpitBean { synchronized (this) { if ((this.activeView != null) && (this.projectName != null)) { try { - final Object displayObj = this.projectManagerFacade.getDisplay(this.projectName, this.activeView.getName(), displayName); + final Object displayObj = this.projectService.getDisplay(this.projectName, this.activeView.getName(), displayName); final String result = (String) ClassAndMethodContainer.invokeMethod(this.classAndMethodContainer.getPlainTextgetTextMethod(), displayObj, "Error"); return result; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentCockpitEditorBean.java similarity index 95% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentCockpitEditorBean.java index 68fc91eb..1eb383b7 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentCockpitEditorBean.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.io.IOException; import java.lang.annotation.Annotation; @@ -30,6 +30,10 @@ import javax.faces.component.UIInput; import javax.faces.component.html.HtmlOutputText; import javax.faces.context.FacesContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.display.annotation.Display; import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIDisplay; @@ -40,13 +44,14 @@ import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.plugin.AbstractPlugin; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.beans.application.GlobalPropertiesBean; -import kieker.webgui.beans.application.ProjectsBean; +import kieker.webgui.business.beans.application.GlobalPropertiesBean; +import kieker.webgui.business.beans.application.ProjectsBean; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.IProjectManager; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; +import kieker.webgui.service.IProjectService; import org.primefaces.component.dashboard.Dashboard; import org.primefaces.component.panel.Panel; @@ -64,13 +69,16 @@ import org.primefaces.model.DefaultDashboardModel; * * @author Nils Christian Ehmke */ +@Component +@Scope("view") public final class CurrentCockpitEditorBean { private static final int NUMBER_COLUMNS = 2; private static final Log LOG = LogFactory.getLog(CurrentCockpitEditorBean.class); private final MIAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); - private IProjectManager projectManagerFacade; + @Autowired + private IProjectService projectService; private ClassAndMethodContainer classAndMethodContainer; private long timeStamp; @@ -81,7 +89,9 @@ public final class CurrentCockpitEditorBean { private Dashboard dashboard; private DashboardModel dashboardModel; + @Autowired private ProjectsBean projectsBean; + @Autowired private GlobalPropertiesBean globalPropertiesBean; /** @@ -91,16 +101,6 @@ 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 IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; - } - private void createDashboard() { final FacesContext fc = FacesContext.getCurrentInstance(); final Application application = fc.getApplication(); @@ -227,7 +227,7 @@ public final class CurrentCockpitEditorBean { private void reloadClassLoader() throws ProjectLoadException { synchronized (this) { try { - this.classLoader = this.projectManagerFacade.getClassLoader(this.projectName); // NOPMD (ClassLoader) + this.classLoader = this.projectService.getClassLoader(new Project(this.project)); // NOPMD (ClassLoader) } catch (final NullPointerException ex) { throw new ProjectLoadException("Invalid class loader.", ex); } catch (final IOException ex) { @@ -314,7 +314,11 @@ public final class CurrentCockpitEditorBean { public void saveProject(final boolean overwriteNewerProject) { synchronized (this) { try { - this.projectManagerFacade.saveProject(this.projectName, this.project, this.timeStamp, overwriteNewerProject); + if (overwriteNewerProject) { + this.projectService.editProject(new Project(this.project)); + } else { + this.projectService.editProject(new Project(this.project), this.timeStamp); + } GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_INFO, this.globalPropertiesBean.getMsgProjectSaved()); // Update the time stamp! this.resetTimeStamp(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentControllerBean.java similarity index 84% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentControllerBean.java index 5c62d286..d4d093ac 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentControllerBean.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.io.IOException; import java.io.PrintWriter; @@ -25,14 +25,18 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.AnalysisController; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.beans.application.ProjectsBean; -import kieker.webgui.common.IProjectManager; +import kieker.webgui.business.beans.application.ProjectsBean; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.service.IProjectService; /** * /** @@ -41,13 +45,17 @@ import kieker.webgui.common.exception.ProjectNotExistingException; * * @author Nils Christian Ehmke */ +@Component +@Scope("view") public final class CurrentControllerBean { private static final Log LOG = LogFactory.getLog(CurrentControllerBean.class); - private IProjectManager projectManagerFacade; + @Autowired + private IProjectService projectService; private final List<String> logEntries = new ArrayList<String>(); private String projectName; + @Autowired private ProjectsBean projectsBean; /** @@ -57,29 +65,6 @@ public final class CurrentControllerBean { // No code necessary } - /** - * The getter for the {@link #projectsBean}-property. - * - * @return {@link #projectsBean} - */ - public ProjectsBean getProjectsBean() { - return this.projectsBean; - } - - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; - } - - /** - * The setter for the {@link #projectsBean}-property. - * - * @param projectsBean - * The new value for {@link #projectsBean}. - */ - public void setProjectsBean(final ProjectsBean projectsBean) { - this.projectsBean = projectsBean; - } - /** * This method sets the project stored within this bean and returns the new page for the navigation. * @@ -111,7 +96,7 @@ public final class CurrentControllerBean { synchronized (this) { this.addLogEntry("Starting Analysis for project '" + this.projectName + "'"); try { - this.projectManagerFacade.startAnalysis(this.projectName); + this.projectService.startAnalysis(this.projectName); } catch (final AnalysisStateException ex) { CurrentControllerBean.LOG.info("The analysis has already been started.", ex); this.addLogEntry(ex); @@ -129,7 +114,7 @@ public final class CurrentControllerBean { try { this.addLogEntry("Stopping Analysis for project '" + this.projectName + "'"); synchronized (this) { - this.projectManagerFacade.stopAnalysis(this.projectName); + this.projectService.stopAnalysis(this.projectName); } } catch (final AnalysisStateException ex) { CurrentControllerBean.LOG.info("The analysis has not been started yet.", ex); @@ -147,7 +132,7 @@ public final class CurrentControllerBean { synchronized (this) { this.addLogEntry("Instantiating Analysis for project '" + this.projectName + "'"); try { - this.projectManagerFacade.initializeAnalysis(this.projectName, this.projectManagerFacade.getClassLoader(this.projectName)); // NOPMD (ClassLoader) + this.projectService.initializeAnalysis(this.projectName, this.projectService.getClassLoader(this.projectName)); // NOPMD (ClassLoader) } catch (final AnalysisStateException ex) { CurrentControllerBean.LOG.error("The analysis has already been instantiated.", ex); this.addLogEntry(ex); @@ -171,7 +156,7 @@ public final class CurrentControllerBean { synchronized (this) { this.addLogEntry("Cleaning Analysis for project '" + this.projectName + "'"); try { - this.projectManagerFacade.cleanAnalysis(this.projectName); + this.projectService.cleanAnalysis(this.projectName); } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); this.addLogEntry(ex); @@ -190,7 +175,7 @@ public final class CurrentControllerBean { public boolean isAnalysisRunning() { synchronized (this) { try { - return this.projectManagerFacade.getCurrentState(this.projectName) == AnalysisController.STATE.RUNNING; + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.RUNNING; } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); return false; @@ -210,7 +195,7 @@ public final class CurrentControllerBean { public boolean isAnalysisReady() { synchronized (this) { try { - return this.projectManagerFacade.getCurrentState(this.projectName) == AnalysisController.STATE.READY; + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.READY; } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); return false; @@ -230,7 +215,7 @@ public final class CurrentControllerBean { public boolean isAnalysisNotAvailable() { synchronized (this) { try { - return this.projectManagerFacade.getCurrentState(this.projectName) == null; + return this.projectService.getCurrentState(this.projectName) == null; } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); return true; @@ -250,7 +235,7 @@ public final class CurrentControllerBean { public boolean isAnalysisTerminated() { synchronized (this) { try { - return this.projectManagerFacade.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATED; + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATED; } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); return false; @@ -270,7 +255,7 @@ public final class CurrentControllerBean { public boolean isAnalysisFailed() { synchronized (this) { try { - return this.projectManagerFacade.getCurrentState(this.projectName) == AnalysisController.STATE.FAILED; + return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.FAILED; } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); return false; @@ -289,7 +274,7 @@ public final class CurrentControllerBean { */ public Object[] getAnalysisLog() { try { - return this.projectManagerFacade.getLogEntries(this.projectName); + return this.projectService.getLogEntries(this.projectName); } catch (final AnalysisStateException ex) { // Ignore return new Object[0]; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentProjectOverviewBean.java similarity index 81% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentProjectOverviewBean.java index 6ccfb249..4fdb984c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentProjectOverviewBean.java @@ -14,12 +14,17 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.util.ArrayList; import java.util.List; -import kieker.webgui.beans.application.ProjectsBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import kieker.webgui.business.beans.application.ProjectsBean; import org.primefaces.event.SelectEvent; @@ -29,8 +34,11 @@ import org.primefaces.event.SelectEvent; * * @author Nils Christian Ehmke */ -public final class CurrentProjectOverviewBean { +@Component +@Scope("view") +public final class CurrentProjectOverviewBean implements InitializingBean { + @Autowired private ProjectsBean projectsBean; /** * This list contains all available projects by name. @@ -87,13 +95,6 @@ public final class CurrentProjectOverviewBean { this.projectsBean = projectsBean; } - /** - * This method should only be called automatically by Spring to update the projects list. - */ - protected void initialialize() { - this.updateLists(); - } - /** * Updates the list containing the available projects name. */ @@ -110,4 +111,14 @@ public final class CurrentProjectOverviewBean { return this.projects; } + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + this.updateLists(); + } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentUserManagementBean.java similarity index 70% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentUserManagementBean.java index f044ba0a..3325d127 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/CurrentUserManagementBean.java @@ -14,21 +14,30 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import kieker.webgui.common.IUserManager; -import kieker.webgui.common.Role; -import kieker.webgui.common.User; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import kieker.webgui.domain.User; +import kieker.webgui.domain.User.Role; +import kieker.webgui.service.IUserService; /** * @author Nils Christian Ehmke */ -public final class CurrentUserManagementBean { +@Component +@Scope("view") +public final class CurrentUserManagementBean implements InitializingBean { - private IUserManager userManagerFacade; + @Autowired + private IUserService userService; /** * This list contains all available users. */ @@ -41,16 +50,6 @@ 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 IUserManager userManagerFacade) { - this.userManagerFacade = userManagerFacade; - } - /** * This method adds the given user to the database and informs about success via the growl component. * @@ -62,9 +61,9 @@ public final class CurrentUserManagementBean { * 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); + this.userService.addUser(new User(username, password, roles, true)); // TODO Check that the op was successful before adding the user to our list - this.users.add(new User(username, roles, true)); + this.users.add(new User(username, "", roles, true)); } /** @@ -73,8 +72,8 @@ public final class CurrentUserManagementBean { * @param username * The name of the user. */ - public void removeUser(final String username) { - this.userManagerFacade.removeUser(username); + public void deleteUser(final User user) { + this.userService.deleteUser(user); } /** @@ -88,21 +87,14 @@ public final class CurrentUserManagementBean { * 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(); + this.userService.editUserWithPassword(new User(username, password, Arrays.asList(roles), true)); } /** * Updates the list containing the available users. */ public void updateList() { - this.users = this.userManagerFacade.getUsers(); + this.users = this.userService.getUsers(); } /** @@ -113,4 +105,14 @@ public final class CurrentUserManagementBean { public List<User> getUsers() { return this.users; } + + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + this.updateList(); + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/package-info.java similarity index 95% rename from Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/package-info.java index 1294ccfa..4ad020a3 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/beans/view/package-info.java @@ -19,5 +19,5 @@ * * @author Nils Christian Ehmke */ -package kieker.webgui.beans.view; +package kieker.webgui.business.beans.view; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/RoleStringConverter.java similarity index 94% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/RoleStringConverter.java index 2ddb4906..2af8d493 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/RoleStringConverter.java @@ -14,14 +14,14 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.converter; +package kieker.webgui.business.converter; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; -import kieker.webgui.common.Role; +import kieker.webgui.domain.User.Role; @FacesConverter("roleStringConverter") public class RoleStringConverter implements Converter { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/package-info.java new file mode 100644 index 00000000..77315859 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/converter/package-info.java @@ -0,0 +1,7 @@ +/** + * + */ +/** + * @author Nils Christian Ehmke + */ +package kieker.webgui.business.converter; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/business/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/business/package-info.java new file mode 100644 index 00000000..6958f39b --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/business/package-info.java @@ -0,0 +1,7 @@ +/** + * + */ +/** + * @author Nils Christian Ehmke + */ +package kieker.webgui.business; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java deleted file mode 100644 index d7e68c11..00000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java +++ /dev/null @@ -1,348 +0,0 @@ -/*************************************************************************** - * 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.common; - -import java.io.IOException; -import java.util.Collection; -import java.util.List; - -import kieker.analysis.AnalysisController.STATE; -import kieker.analysis.model.analysisMetaModel.MIDependency; -import kieker.analysis.model.analysisMetaModel.MIProject; -import kieker.analysis.plugin.AbstractPlugin; -import kieker.analysis.repository.AbstractRepository; -import kieker.webgui.common.exception.AnalysisInitializationException; -import kieker.webgui.common.exception.AnalysisStateException; -import kieker.webgui.common.exception.DisplayNotFoundException; -import kieker.webgui.common.exception.LibraryAlreadyExistingException; -import kieker.webgui.common.exception.LibraryLoadException; -import kieker.webgui.common.exception.NewerProjectException; -import kieker.webgui.common.exception.ProjectAlreadyExistingException; -import kieker.webgui.common.exception.ProjectNotExistingException; - -import org.primefaces.model.UploadedFile; - -/** - * This is the interface for a component which is responsible for managing all projects. This means that this interface can be used to create, copy, delete projects - * as well as to start and stop the corresponding analyses and similar things. The facade should abstract from details like the (memory) locations and from - * synchronization. Latter should be guaranteed by the facade, which means that multiple requests for the same project do not go wrong. - * - * @author Nils Christian Ehmke - */ -public interface IProjectManager { - - /** - * This method adds a new project to the application. It creates an empty, but nevertheless valid kax-file to the file system. If the method fails due to an - * {@link IOException}, it will make sure that the project-directories will be removed as if the method would never have been called. - * - * @param projectName - * The name of the new project. - * @throws ProjectAlreadyExistingException - * If a project with the same name exists already. - * @throws IOException - * If something went wrong during the creation of the project. - */ - public void addProject(final String projectName) throws ProjectAlreadyExistingException, IOException; - - /** - * This method makes a copy of a project and saves it under another name. If the method fails due to an {@link IOException}, it will make sure that the - * project-directories of the destination-project will be removed as if the method would never have been called. - * - * @param originalProjectName - * The name of the source project. - * @param newProjectName - * The name of the target project. - * @throws ProjectNotExistingException - * If a project with the given (source) name doesn't exist. - * @throws ProjectAlreadyExistingException - * If a project with the same (target) name exists already. - * @throws IOException - * If something went wrong during the creation of the target-project or during the loading of the source-project. - */ - public void copyProject(final String originalProjectName, final String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, - IOException; - - /** - * This method loads the kax-file for the given project name and delivers an initializes instance of {@link MIProject}. - * - * @param projectName - * The name of the project to be loaded. - * @return The model instance as defined by the corresponding kax-file. - * @throws ProjectNotExistingException - * If a project with the given (source) name doesn't exist. - * @throws IOException - * If something went wrong during the opening of the project. - */ - public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException; - - /** - * This method loads the kax-file for the given project name and delivers an initializes instance of {@link MIProject} - but instead of using the "normal" class - * loader, it uses the methods and classes stored in the given instance of {@link ClassAndMethodContainer}. This means that this method <b>does</b> return an - * instance of {@link MIProject}, but the one defined in the container. This is also the reason why this method has to return an {@link Object}-instance. - * - * @param projectName - * The name of the project to be loaded. - * @param classAndMethodContainer - * The container, which will be used to load the project instance. - * @return The model instance as defined by the corresponding kax-file. - * @throws ProjectNotExistingException - * If a project with the given (source) name doesn't exist. - * @throws IOException - * If something went wrong during the opening of the project. This can also mean that the given {@link ClassAndMethodContainer} is somehow invalid. - */ - public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; - - /** - * This method tries to save the given model instance for the given project. The given time stamp will be compared (if the corresponding flag says so) with the - * current time stamp of the project. If the project on the file system has been modified in the meantime, a {@link NewerProjectException} will be thrown. If - * something goes wrong during the storage, it is <b>not</b> guaranteed that the resulting file will be valid. - * - * @param projectName - * The name of the project which has to be saved. - * @param project - * The model instance to be stored in the corresponding kax-file. - * @param timeStamp - * The time stamp which has to be compared with the "real" time stamp of the project. - * @param overwriteNewerProject - * Determines whether a newer project file will be overwritten without further warning or not- - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws IOException - * If something went wrong during the storage of the model instance. - * @throws NewerProjectException - * If the project on the file system is newer and the overwriteNewerProject-flag has not been set. - */ - public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject) throws - ProjectNotExistingException, IOException, NewerProjectException; - - /** - * Delivers the current time stamp of the given project. - * - * @param projectName - * The name of the project whose time stamp will be delivered. - * @return The current time stamp. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - */ - public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException; - - /** - * This method tries to upload a dependency to the given project. - * - * @param file - * The file to be uploaded to the project. - * @param projectName - * The name of the project. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws IOException - * If something went wrong during the uploading. - * @throws LibraryAlreadyExistingException - * If a library with the same name exists already. - */ - public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException; - - /** - * This method delivers a class loader containing the currently available libraries of the given project. - * - * @param projectName - * The name of the project. - * @return A class loader for the given project. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws IOException - * If something went wrong during the initialization of the class loader. - */ - public ClassLoader getClassLoader(final String projectName) throws ProjectNotExistingException, IOException; - - /** - * This method lists all available libraries of the given project. - * - * @param projectName - * The name of the project whose libraries have to be delivered. - * @return A list containing all available library-names of the project. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - */ - public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException; - - /** - * This method delivers the available classes from the type {@link AbstractRepository} within the given dependency for the given project, using the given - * parameters. - * - * @param lib - * The library to be searched. - * @param project - * The project for the given library. - * @param classLoader - * The class loader to be used. - * @param classAndMethodContainer - * The container with classes and methods to be used. - * @return A list with all repository-classes. - * @throws LibraryLoadException - * If something went wrong during the loading of the library. - */ - public List<Class<AbstractRepository>> getAllRepositoriesWithinLib(final MIDependency lib, final String project, final ClassLoader classLoader, - final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; - - /** - * This method delivers the available classes from the type {@link AbstractPlugin} within the given dependency for the given project, using the given - * parameters. - * - * @param lib - * The library to be searched. - * @param project - * The project for the given library. - * @param classLoader - * The class loader to be used. - * @param classAndMethodContainer - * The container with classes and methods to be used. - * @return A list with all plugin-classes. - * @throws LibraryLoadException - * If something went wrong during the loading of the library. - */ - public List<Class<AbstractPlugin>> getAllPluginsWithinLib(final MIDependency lib, final String project, final ClassLoader classLoader, - final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; - - /** - * This method delivers the available classes from the type {@link AbstractRepository} within the kieker dependency using the given parameters. - * - * @param classLoader - * The class loader to be used. - * @param classAndMethodContainer - * The container with classes and methods to be used. - * @return A list with all repository-classes. - * @throws LibraryLoadException - * If something went wrong during the loading of the library. - */ - public List<Class<AbstractRepository>> getAllRepositoriesWithinKiekerLib(final ClassLoader classLoader, - final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; - - /** - * This method delivers the available classes from the type {@link AbstractPlugin} within the kieker dependency using the given parameters. - * - * @param classLoader - * The class loader to be used. - * @param classAndMethodContainer - * The container with classes and methods to be used. - * @return A list with all plugin-classes. - * @throws LibraryLoadException - * If something went wrong during the loading of the library. - */ - public List<Class<AbstractPlugin>> getAllPluginsWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws - LibraryLoadException; - - /** - * This method lists all available projects on the file system. - * - * @return A list containing all available project names. - */ - public Collection<String> listAllProjects(); - - /** - * This method initializes the analysis of the given project. - * - * @param projectName - * The name of the project whose analysis should be initialized. - * @param classLoader - * The class loader to be used during the loading. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws AnalysisStateException - * If the analysis of the given project is in the wrong state to be initialized. This means that it has not been cleaned yet. - * @throws AnalysisInitializationException - * If an error occurred during the initialization of the analysis. - */ - public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException, - AnalysisInitializationException; - - /** - * This method cleans the analysis of the given project. - * - * @param projectName - * The name of the project whose analysis should be cleaned. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws AnalysisStateException - * If the analysis of the given project is in the wrong state to be cleaned. This means that it has not been terminated yet. - */ - public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; - - /** - * This method starts the analysis of the given project. - * - * @param projectName - * The name of the project whose analysis should be started. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws AnalysisStateException - * If the analysis of the given project is in the wrong state to be started. This means that it has not been initialized yet. - */ - public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; - - /** - * This method stops the analysis of the given project. - * - * @param projectName - * The name of the project whose analysis should be stopped. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws AnalysisStateException - * If the analysis of the given project is in the wrong state to be stopped. This means that it has not been started yet or is no longer running. - */ - public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; - - /** - * This method delivers the display object of the (currently running) analysis for the given project and the given parameters. Technically it is an instance of - * {@code AbstractDisplay}, but in fact the project specific class loader has been used. - * - * @param projectName - * The name of the project. - * @param viewName - * The name of the view. - * @param displayName - * The name of the display. - * @return A display object for the given parameters. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - * @throws DisplayNotFoundException - * If a view or a display within the given view does not exist. - */ - public Object getDisplay(final String projectName, final String viewName, final String displayName) throws ProjectNotExistingException, DisplayNotFoundException; - - /** - * This method delivers the current state of the given project. - * - * @param projectName - * The name of the project whose state have to be returned. - * @return The state of the given project, if available. {@code null} otherwise. - * @throws ProjectNotExistingException - * If a project with the given name does not exist. - */ - public STATE getCurrentState(final String projectName) throws ProjectNotExistingException; - - /** - * This method delivers the available log entries of the analysis controller of the given project. - * - * @param projectName - * The name of the project. - * @return An array containing the entries of the log. - * @throws AnalysisStateException - * If the analysis is in an invalid state to deliver the entries. - */ - public Object[] getLogEntries(final String projectName) throws AnalysisStateException; -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java deleted file mode 100644 index 8819d3cb..00000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * 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.common; - -public enum Role { - - ROLE_USER(1), ROLE_ADMIN(2); - - private int id; - - private Role(final int id) { - this.id = id; - } - - public int getID() { - return this.id; - } - - public static Role fromID(final int id) { - if (id == 2) { - return Role.ROLE_ADMIN; - } else { - return Role.ROLE_USER; - } - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ViewScope.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java similarity index 98% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ViewScope.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java index d16f3ce1..652aa84f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ViewScope.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.util; +package kieker.webgui.common; import java.util.Map; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ApplicationInitializationException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ApplicationInitializationException.java new file mode 100644 index 00000000..68dcb579 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ApplicationInitializationException.java @@ -0,0 +1,55 @@ +/*************************************************************************** + * 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.common.exception; + +/** + * + * @author Nils Christian Ehmke + */ +public final class ApplicationInitializationException extends AbstractKiekerWebGUIException { + + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of this class. + */ + public ApplicationInitializationException() { + super(); + } + + /** + * Creates a new instance of this class using the given parameters. + * + * @param msg + * The message used for the exception. + */ + public ApplicationInitializationException(final String msg) { + super(msg); + } + + /** + * Creates a new instance of this class using the given parameters. + * + * @param msg + * The message used for the exception. + * @param cause + * The cause for the exception. + */ + public ApplicationInitializationException(final String msg, final Throwable cause) { + super(msg, cause); + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java new file mode 100644 index 00000000..df28b2e7 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java @@ -0,0 +1,54 @@ +/*************************************************************************** + * 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.common.exception; + +public class DataAccessException extends AbstractKiekerWebGUIException { + + /** + * The UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of this class. + */ + public DataAccessException() { + super(); + } + + /** + * Creates a new instance of this class using the given parameters. + * + * @param msg + * The message used for the exception. + */ + public DataAccessException(final String msg) { + super(msg); + } + + /** + * Creates a new instance of this class using the given parameters. + * + * @param msg + * The message used for the exception. + * @param cause + * The cause for the exception. + */ + public DataAccessException(final String msg, final Throwable cause) { + super(msg, cause); + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/package-info.java deleted file mode 100644 index 06fc0c4f..00000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * 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. - ***************************************************************************/ - -/** - * This package contains utility classes, which are used in the parent-package. The classes within this package are not for public use. They should only be used by - * the classes in {@code kieker.webgui.common}. - * - * @author Nils Christian Ehmke - */ -package kieker.webgui.common.util; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/User.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Project.java similarity index 56% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/User.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/domain/Project.java index 784eaf26..24eeafe6 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/User.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Project.java @@ -14,33 +14,35 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.domain; -import java.util.List; +import kieker.analysis.model.analysisMetaModel.MIProject; -public class User { +public class Project { - private final String name; - private final List<Role> roles; - private final boolean enabled; + private MIProject miproject; - public User(final String name, final List<Role> roles, final boolean enabled) { - this.name = name; - this.roles = roles; - this.enabled = enabled; + public Project(final MIProject project) { + this.miproject = project; } - public String getName() { - return this.name; + /** + * Getter for the property {@link Project#miproject}. + * + * @return The current value of the property. + */ + public MIProject getMiproject() { + return this.miproject; } - public List<Role> getRoles() { - return this.roles; + /** + * Setter for the property {@link Project#miproject}. + * + * @param miproject + * The new value of the property. + */ + public void setMiproject(final MIProject miproject) { + this.miproject = miproject; } - public boolean isEnabled() { - return enabled; - } - - } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java new file mode 100644 index 00000000..93f57f73 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java @@ -0,0 +1,133 @@ +/*************************************************************************** + * 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.domain; + +import java.util.List; + +public class User { + + private String name; + private String password; + private List<Role> roles; + private boolean enabled; + + public User(final String name, final String password, final List<Role> roles, final boolean enabled) { + this.name = name; + this.password = password; + this.roles = roles; + this.enabled = enabled; + } + + /** + * Getter for the property {@link User#name}. + * + * @return The current value of the property. + */ + public String getName() { + return this.name; + } + + /** + * Setter for the property {@link User#name}. + * + * @param name + * The new value of the property. + */ + public void setName(final String name) { + this.name = name; + } + + /** + * Getter for the property {@link User#password}. + * + * @return The current value of the property. + */ + public String getPassword() { + return this.password; + } + + /** + * Setter for the property {@link User#password}. + * + * @param password + * The new value of the property. + */ + public void setPassword(final String password) { + this.password = password; + } + + /** + * Getter for the property {@link User#roles}. + * + * @return The current value of the property. + */ + public List<Role> getRoles() { + return this.roles; + } + + /** + * Setter for the property {@link User#roles}. + * + * @param roles + * The new value of the property. + */ + public void setRoles(final List<Role> roles) { + this.roles = roles; + } + + /** + * Getter for the property {@link User#enabled}. + * + * @return The current value of the property. + */ + public boolean isEnabled() { + return this.enabled; + } + + /** + * Setter for the property {@link User#enabled}. + * + * @param enabled + * The new value of the property. + */ + public void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + public static enum Role { + + ROLE_USER(1), ROLE_ADMIN(2); + + private int id; + + private Role(final int id) { + this.id = id; + } + + public int getID() { + return this.id; + } + + public static Role fromID(final int id) { + if (id == 2) { + return Role.ROLE_ADMIN; + } else { + return Role.ROLE_USER; + } + } + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java similarity index 89% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/package-info.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java index 7d66d449..d9d9d837 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java @@ -15,7 +15,8 @@ ***************************************************************************/ /** + * This package contains the domain objects for the application. + * * @author Nils Christian Ehmke - * */ -package kieker.webgui.common.converter; \ No newline at end of file +package kieker.webgui.domain; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java new file mode 100644 index 00000000..e1e0cd17 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java @@ -0,0 +1,101 @@ +/*************************************************************************** + * 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.persistence; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collection; +import java.util.List; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; + +import kieker.analysis.model.analysisMetaModel.MIDependency; +import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.exception.LibraryAlreadyExistingException; +import kieker.webgui.common.exception.NewerProjectException; +import kieker.webgui.common.exception.ProjectAlreadyExistingException; +import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; + +import org.primefaces.model.UploadedFile; + +/** + * This is the interface for the project data access object. The implementing class will be responsible for managing projects in a transactional way. This interface + * will only be accessible by authenticated users. + * + * @author Nils Christian Ehmke + */ +public interface IProjectDAO { + + @PreAuthorize("isAuthenticated()") + @Transactional + public void addProject(final Project project) throws IOException, ProjectAlreadyExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public void saveProject(final Project project, final long timeStamp, final boolean overwriteNewerProject) throws ProjectNotExistingException, IOException, + NewerProjectException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public void copyProject(final String srcProjectName, final String dstProjectName) throws IOException, ProjectNotExistingException, + ProjectAlreadyExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public Project openProject(final String projectName) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public long getCurrTimestamp(final String projectName) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public void uploadLibrary(final UploadedFile file, final Project project) throws IOException, ProjectNotExistingException, LibraryAlreadyExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public ClassLoader getClassLoader(final Project project) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public Collection<String> listAllProjects(); + + @PreAuthorize("isAuthenticated()") + @Transactional + public File getProjectFile(final String projectName); + + @PreAuthorize("isAuthenticated()") + @Transactional + public URL getKiekerURL(); + + @PreAuthorize("isAuthenticated()") + @Transactional + public URL getURL(final MIDependency lib, final Project project) throws MalformedURLException; + + @PreAuthorize("isAuthenticated()") + @Transactional + public List<String> listAllLibraries(final Project project) throws ProjectNotExistingException; + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java new file mode 100644 index 00000000..c8e14118 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java @@ -0,0 +1,55 @@ +/*************************************************************************** + * 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.persistence; + +import java.util.List; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; + +import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.User; + +/** + * This is the interface for the user data access object. The implementing class will be responsible for managing user in a transactional way. This interface will + * only be accessible by administrators. + * + * @author Nils Christian Ehmke + */ +public interface IUserDAO { + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional() + public void addUser(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void editUserWithoutPassword(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void editUserWithPassword(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void deleteUser(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional(readOnly = true) + public List<User> getUsers(); + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAO.java similarity index 50% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerImpl.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAO.java index 8054f581..b5dfae5b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAO.java @@ -13,8 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ - -package kieker.webgui.common.impl; +package kieker.webgui.persistence.impl; import java.sql.Connection; import java.sql.PreparedStatement; @@ -27,104 +26,155 @@ import java.util.TreeMap; import javax.sql.DataSource; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.IUserManager; -import kieker.webgui.common.Role; -import kieker.webgui.common.User; - -public class UserManagerImpl implements IUserManager { - - private static final Log LOG = LogFactory.getLog(UserManagerImpl.class); - private DataSource dataSource; +import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.User; +import kieker.webgui.domain.User.Role; +import kieker.webgui.persistence.IUserDAO; + +/** + * This is an implementation of the {@link IUserDAO} interface, which uses Apache Derby to store the users. It is a Spring managed singleton bean. + * + * @author Nils Christian Ehmke + */ +// FIXME Transactional annotation don't work yet +@Component +@Scope("singleton") +public class DerbyUserDAO implements IUserDAO, InitializingBean, DisposableBean { + + private static final Log LOG = LogFactory.getLog(DerbyUserDAO.class); + + @Autowired + private DataSource userDataSource; private Connection connection; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ - public UserManagerImpl() { + public DerbyUserDAO() { // No code necessary } - /** - * This method initializes the object.. <b>Do not call this method manually. It will only be accessed by Spring.</b> + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.DisposableBean#destroy() */ - public void initialize() { - try { - this.connection = this.dataSource.getConnection(); - } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not establish database connection.", ex); - } - } - - public void destroy() { - try { - this.connection.close(); - } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not close database connection.", ex); - } + @Override + public void destroy() throws Exception { + this.connection.close(); } - public void setDataSource(final DataSource dataSource) { - this.dataSource = dataSource; + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + this.connection = DataSourceUtils.getConnection(this.userDataSource); } + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IUserDAO#addUser(kieker.webgui.domain.User) + */ @Override @PreAuthorize("hasRole('ROLE_ADMIN')") - public void addUser(final String username, final String password, final List<Role> roles) { + @Transactional + public void addUser(final User user) throws DataAccessException { PreparedStatement userCmd = null; PreparedStatement roleCmd = null; + try { - userCmd = this.connection.prepareStatement("INSERT INTO KIEKERUser (name, password, enabled) VALUES (?, ?, True)"); + // Prepare both statements + userCmd = this.connection.prepareStatement("INSERT INTO KIEKERUser (name, password, enabled) VALUES (?, ?, ?)"); roleCmd = this.connection.prepareStatement("INSERT INTO Userroles (name, role) VALUES (?, ?)"); - userCmd.setString(1, username); - userCmd.setString(2, password); + // Add the user itself to the database + userCmd.setString(1, user.getName()); + userCmd.setString(2, user.getPassword()); + userCmd.setBoolean(3, user.isEnabled()); userCmd.execute(); - roleCmd.setString(1, username); - for (final Role role : roles) { + // Now the roles + roleCmd.setString(1, user.getName()); + for (final Role role : user.getRoles()) { roleCmd.setInt(2, role.getID()); roleCmd.execute(); } } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not add user to the database.", ex); + throw new DataAccessException("Could not add user to the database.", ex); } finally { if (userCmd != null) { try { userCmd.close(); } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not close prepared statement.", ex); + // Log the exception, but don't inform the upper layer about this + DerbyUserDAO.LOG.warn("Could not close prepared statement.", ex); } } if (roleCmd != null) { try { roleCmd.close(); } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not close prepared statement.", ex); + // Log the exception, but don't inform the upper layer about this + DerbyUserDAO.LOG.warn("Could not close prepared statement.", ex); } } } } + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IUserDAO#editUser(kieker.webgui.domain.User) + */ @Override @PreAuthorize("hasRole('ROLE_ADMIN')") - public void removeUser(final String username) { + @Transactional + public void editUserWithPassword(final User user) throws DataAccessException { // TODO Auto-generated method stub - } @Override @PreAuthorize("hasRole('ROLE_ADMIN')") - public void editUser(final String username, final String password, final Role... roles) { + @Transactional + public void editUserWithoutPassword(final User user) throws DataAccessException { // TODO Auto-generated method stub + } + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IUserDAO#deleteUser(kieker.webgui.domain.User) + */ + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void deleteUser(final User user) throws DataAccessException { + // TODO Auto-generated method stub } + /* + * (non-Javadoc) + * + * @see kieker.webgui.persistence.IUserDAO#getUsers() + */ @Override @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional(readOnly = true) public List<User> getUsers() { // FIXME Users without roles final List<User> result = new ArrayList<User>(); @@ -152,24 +202,26 @@ public class UserManagerImpl implements IUserManager { } else { final List<Role> roles = new ArrayList<Role>(); roles.add(role); - tempMap.put(username, new User(username, roles, enabled)); + tempMap.put(username, new User(username, "", roles, enabled)); } } // Now convert the map to the list result.addAll(tempMap.values()); } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not receive user list.", ex); + throw new DataAccessException("Could not receive user list.", ex); } finally { try { if (queryResult != null) { queryResult.close(); } } catch (final SQLException ex) { - UserManagerImpl.LOG.error("Could not close query result.", ex); + // Log the exception, but don't inform the upper layer about this + DerbyUserDAO.LOG.warn("Could not close query result.", ex); } } return result; } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java similarity index 84% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java index d5716a93..df2085ed 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.util; +package kieker.webgui.persistence.impl; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -34,11 +34,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.AnalysisController; -import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; -import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.ClassAndMethodContainer; @@ -46,19 +48,21 @@ import kieker.webgui.common.exception.LibraryAlreadyExistingException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; +import kieker.webgui.persistence.IProjectDAO; import org.primefaces.model.UploadedFile; /** - * This is a singleton class for the access to the file system. It makes sure that the necessary directories for the execution of the application exist. <b>Do - * not</b> remove directories created from this manager during runtime! Directories are created during first access to the class.<br> - * This class <b>does not</b> use any kind of synchronization to handle the access to the projects. + * This is an implementation of the {@link IProjectDAO} interface, which uses the file system to store the projects. * * @author Nils Christian Ehmke */ -public final class FSManager { +@Component +@Scope("singleton") +public class FSProjectDAOImpl implements IProjectDAO, InitializingBean { - private static final Log LOG = LogFactory.getLog(FSManager.class); + private static final Log LOG = LogFactory.getLog(FSProjectDAOImpl.class); private static final String KAX_EXTENSION = "kax"; private static final String LIB_EXTENSION = "jar"; private static final String LIB_DIRECTORY = "lib"; @@ -72,30 +76,13 @@ public final class FSManager { */ private static final int BUF_SIZE_BYTES = 1024 * 1024; - private final MIAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); - /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ - public FSManager() { + public FSProjectDAOImpl() { // no code necessary } - /** - * This method initializes the class. Normally this method should be called via the @PostConstruction annotation, but for unknown reason it does only work for - * beans. - */ - protected void initialize() { - // Check for our root-directory and create it if necessary - final File rootDir = new File(FSManager.ROOT_DIRECTORY); - if (!rootDir.exists()) { - final boolean result = rootDir.mkdir(); - if (!result) { - FSManager.LOG.error("Could not create root directory."); - } - } - } - /** * This method adds a new project to the application. It creates an empty, but nevertheless valid kax-file to the file system. If the method fails due to an * {@link IOException}, it will make sure that the project-directories will be removed as if the method would never have been called. @@ -107,15 +94,14 @@ public final class FSManager { * @throws IOException * If something went wrong during the creation of the project. */ - public void addProject(final String projectName) throws ProjectAlreadyExistingException, IOException { + @Override + public void addProject(final Project project) throws ProjectAlreadyExistingException, IOException { + final String projectName = project.getMiproject().getName(); // Assemble all necessary paths and files for the given project final File projectDir = this.assembleProjectDir(projectName); final File projectFile = this.assembleKaxFile(projectName); final File libDir = this.assembleLibDir(projectName); - // We need an "empty" project in order to save it. - final MIProject emptyProject = this.factory.createProject(); - // Make sure that the project doesn't exist already if (projectDir.exists()) { throw new ProjectAlreadyExistingException("The project with the name '" + projectName + "' exists already."); @@ -125,7 +111,7 @@ public final class FSManager { // Try to create the directories if (projectDir.mkdir() && libDir.mkdir()) { // Try to save the file - AnalysisController.saveToFile(projectFile, emptyProject); + AnalysisController.saveToFile(projectFile, project.getMiproject()); } else { // The directories could not be created throw new IOException("Project-Directories could not be created."); @@ -161,6 +147,7 @@ public final class FSManager { * @throws IOException * If something went wrong during the creation of the target-project or during the loading of the source-project. */ + @Override public void copyProject(final String originalProjectName, final String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, IOException { // Get the necessary paths @@ -216,14 +203,15 @@ public final class FSManager { * @throws IOException * If something went wrong during the opening of the project. */ - public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { + @Override + public Project openProject(final String projectName) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); } try { // Load the project - return AnalysisController.loadFromFile(this.assembleKaxFile(projectName).getAbsoluteFile()); + return new Project(AnalysisController.loadFromFile(this.assembleKaxFile(projectName).getAbsoluteFile())); } catch (final FileNotFoundException ex) { throw new ProjectNotExistingException("A project with the name '" + projectName + "' does not exist.", ex); } @@ -244,6 +232,7 @@ public final class FSManager { * @throws IOException * If something went wrong during the opening of the project. This can also mean that the given {@link ClassAndMethodContainer} is somehow invalid. */ + @Override public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -280,21 +269,23 @@ public final class FSManager { * @throws NewerProjectException * If the project on the file system is newer and the overwriteNewerProject-flag has not been set. */ - public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject) throws - ProjectNotExistingException, IOException, NewerProjectException { + @Override + public void saveProject(final Project project, final long timeStamp, final boolean overwriteNewerProject) throws ProjectNotExistingException, IOException, + NewerProjectException { + final String projectName = project.getMiproject().getName(); // Check whether the project exists if (!this.projectExists(projectName)) { throw new ProjectNotExistingException("A project with the name '" + projectName + "' does not exist."); } // Check for a newer version first - final long currTimeStamp = this.getCurrTimeStamp(projectName); + final long currTimeStamp = this.getCurrTimestamp(projectName); if (!overwriteNewerProject && (currTimeStamp > timeStamp)) { throw new NewerProjectException("The project with the name '" + projectName + "' has a newer version on the FS."); } // Try to save it. - AnalysisController.saveToFile(this.assembleKaxFile(projectName), project); + AnalysisController.saveToFile(this.assembleKaxFile(projectName), project.getMiproject()); } /** @@ -306,7 +297,8 @@ public final class FSManager { * @throws ProjectNotExistingException * If a project with the given name does not exist. */ - public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException { + @Override + public long getCurrTimestamp(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { throw new ProjectNotExistingException("A project with the name '" + projectName + "' does not exist."); @@ -328,7 +320,9 @@ public final class FSManager { * @throws LibraryAlreadyExistingException * If a library with the same name exists already. */ - public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException { + @Override + public void uploadLibrary(final UploadedFile file, final Project project) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException { + final String projectName = project.getMiproject().getName(); // Check whether the project exists if (!this.projectExists(projectName)) { throw new ProjectNotExistingException("A project with the name '" + projectName + "' does not exist."); @@ -350,7 +344,7 @@ public final class FSManager { // Get the streams. in = new BufferedInputStream(file.getInputstream()); out = new BufferedOutputStream(new FileOutputStream(dstFile)); - final byte[] buf = new byte[FSManager.BUF_SIZE_BYTES]; + final byte[] buf = new byte[FSProjectDAOImpl.BUF_SIZE_BYTES]; int count; // Transfer the file. @@ -394,7 +388,9 @@ public final class FSManager { * @throws IOException * If something went wrong during the initialization of the class loader. */ - public ClassLoader getClassLoader(final String projectName) throws ProjectNotExistingException, IOException { + @Override + public ClassLoader getClassLoader(final Project project) throws ProjectNotExistingException, IOException { + final String projectName = project.getMiproject().getName(); // Check whether the project exists if (!this.projectExists(projectName)) { throw new ProjectNotExistingException("A project with the name '" + projectName + "' does not exist."); @@ -405,11 +401,11 @@ public final class FSManager { // Collect all libraries of the project // Run through the libs and put them into our list. - final File libDir = new File(FSManager.ROOT_DIRECTORY + File.separator + projectName + File.separator + FSManager.LIB_DIRECTORY); + final File libDir = new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + projectName + File.separator + FSProjectDAOImpl.LIB_DIRECTORY); final File[] files = libDir.listFiles(); if (files != null) { for (final File file : files) { - if (file.getName().endsWith("." + FSManager.LIB_EXTENSION)) { + if (file.getName().endsWith("." + FSProjectDAOImpl.LIB_EXTENSION)) { try { libs.add(file.toURL()); } catch (final MalformedURLException ex) { @@ -436,7 +432,9 @@ public final class FSManager { * @throws ProjectNotExistingException * If a project with the given name does not exist. */ - public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException { + @Override + public List<String> listAllLibraries(final Project project) throws ProjectNotExistingException { + final String projectName = project.getMiproject().getName(); // Check whether the project exists if (!this.projectExists(projectName)) { throw new ProjectNotExistingException("A project with the name '" + projectName + "' does not exist."); @@ -448,7 +446,7 @@ public final class FSManager { final File[] files = this.assembleLibDir(projectName).listFiles(); if (files != null) { for (final File file : files) { - if (file.getName().endsWith("." + FSManager.LIB_EXTENSION)) { + if (file.getName().endsWith("." + FSProjectDAOImpl.LIB_EXTENSION)) { result.add(file.getName()); } } @@ -462,11 +460,12 @@ public final class FSManager { * * @return A list containing all available project names. */ + @Override public Collection<String> listAllProjects() { final List<String> result = new ArrayList<String>(); // Get all directories within our root-dir - final File[] files = new File(FSManager.ROOT_DIRECTORY).listFiles(); + final File[] files = new File(FSProjectDAOImpl.ROOT_DIRECTORY).listFiles(); for (final File file : files) { if (file.isDirectory()) { result.add(file.getName()); @@ -505,7 +504,7 @@ public final class FSManager { result = dst.setLastModified(src.lastModified()); } catch (final IOException ex) { - FSManager.LOG.error("An IO error occured", ex); + FSProjectDAOImpl.LOG.error("An IO error occured", ex); result = false; } finally { // Try to close the streams @@ -513,7 +512,7 @@ public final class FSManager { try { fileInputStream.close(); } catch (final IOException ex) { - FSManager.LOG.error("An IO error occured", ex); + FSProjectDAOImpl.LOG.error("An IO error occured", ex); result = false; } } @@ -521,7 +520,7 @@ public final class FSManager { try { fileOutputStream.close(); } catch (final IOException ex) { - FSManager.LOG.error("An IO error occured", ex); + FSProjectDAOImpl.LOG.error("An IO error occured", ex); result = false; } } @@ -547,7 +546,7 @@ public final class FSManager { private void transfer(final FileChannel fileChannel, final ByteChannel byteChannel, final long lengthInBytes) throws IOException { long overallBytesTransfered = 0L; while (overallBytesTransfered < lengthInBytes) { - final long count = Math.min(FSManager.BUF_SIZE_BYTES, lengthInBytes - overallBytesTransfered); + final long count = Math.min(FSProjectDAOImpl.BUF_SIZE_BYTES, lengthInBytes - overallBytesTransfered); final long bytesTransfered = fileChannel.transferTo(overallBytesTransfered, count, byteChannel); overallBytesTransfered += bytesTransfered; } @@ -575,8 +574,10 @@ public final class FSManager { * @throws MalformedURLException * If the URL is for some reason invalid. */ - public URL getURL(final MIDependency lib, final String project) throws MalformedURLException { - final File file = new File(FSManager.ROOT_DIRECTORY + File.separator + project + File.separator + FSManager.LIB_DIRECTORY + File.separator + @Override + public URL getURL(final MIDependency lib, final Project project) throws MalformedURLException { + final String projectName = project.getMiproject().getName(); + final File file = new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + projectName + File.separator + FSProjectDAOImpl.LIB_DIRECTORY + File.separator + lib.getFilePath()); return file.toURL(); } @@ -589,7 +590,7 @@ public final class FSManager { * @return The directory of the project. */ private File assembleProjectDir(final String projectName) { - return new File(FSManager.ROOT_DIRECTORY + File.separator + projectName); + return new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + projectName); } /** @@ -600,7 +601,7 @@ public final class FSManager { * @return The kax-file of the project. */ private File assembleKaxFile(final String projectName) { - return new File(FSManager.ROOT_DIRECTORY + File.separator + projectName + File.separator + projectName + "." + FSManager.KAX_EXTENSION); + return new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + projectName + File.separator + projectName + "." + FSProjectDAOImpl.KAX_EXTENSION); } /** @@ -611,7 +612,7 @@ public final class FSManager { * @return The library directory of the project. */ private File assembleLibDir(final String projectName) { - return new File(FSManager.ROOT_DIRECTORY + File.separator + projectName + File.separator + FSManager.LIB_DIRECTORY); + return new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + projectName + File.separator + FSProjectDAOImpl.LIB_DIRECTORY); } /** @@ -619,8 +620,9 @@ public final class FSManager { * * @return The kieker library. */ + @Override public URL getKiekerURL() { - return Thread.currentThread().getContextClassLoader().getResource(FSManager.KIEKER_LIB); + return Thread.currentThread().getContextClassLoader().getResource(FSProjectDAOImpl.KIEKER_LIB); } /** @@ -630,6 +632,7 @@ public final class FSManager { * The name of the project. * @return The kax-file of the project. */ + @Override public File getProjectFile(final String projectName) { return this.assembleKaxFile(projectName); } @@ -668,4 +671,21 @@ public final class FSManager { } } + /* + * (non-Javadoc) + * + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws Exception { + // Check for our root-directory and create it if necessary + final File rootDir = new File(FSProjectDAOImpl.ROOT_DIRECTORY); + if (!rootDir.exists()) { + final boolean result = rootDir.mkdir(); + if (!result) { + FSProjectDAOImpl.LOG.error("Could not create root directory."); + } + } + } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java new file mode 100644 index 00000000..7ab7acc6 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains the implementation of the persistence. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.persistence.impl; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java new file mode 100644 index 00000000..88d0eda3 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains the interfaces of the persistence layer of the web application. It is the undermost layer. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.persistence; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java new file mode 100644 index 00000000..7663c50a --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java @@ -0,0 +1,124 @@ +/*************************************************************************** + * 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.service; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import org.springframework.security.access.prepost.PreAuthorize; + +import kieker.analysis.AnalysisController.STATE; +import kieker.analysis.model.analysisMetaModel.MIDependency; +import kieker.analysis.plugin.AbstractPlugin; +import kieker.analysis.repository.AbstractRepository; +import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.exception.AnalysisInitializationException; +import kieker.webgui.common.exception.AnalysisStateException; +import kieker.webgui.common.exception.DisplayNotFoundException; +import kieker.webgui.common.exception.LibraryAlreadyExistingException; +import kieker.webgui.common.exception.LibraryLoadException; +import kieker.webgui.common.exception.NewerProjectException; +import kieker.webgui.common.exception.ProjectAlreadyExistingException; +import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.Project; + +import org.primefaces.model.UploadedFile; + +/** + * This is the interface for the project service, which is responsible for managing the available projects. This interface will only be accessible by authenticated + * users. + * + * @author Nils Christian Ehmke + */ +public interface IProjectService { + + @PreAuthorize("isAuthenticated()") + public void addProject(final Project project) throws IOException, ProjectAlreadyExistingException; + + @PreAuthorize("isAuthenticated()") + public void editProject(final Project project) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public void editProject(final Project project, final long timestamp) throws IOException, ProjectNotExistingException, NewerProjectException; + + @PreAuthorize("isAuthenticated()") + public void copyProject(final String srcProjectName, final String dstProjectName) throws IOException, ProjectNotExistingException, + ProjectAlreadyExistingException; + + @PreAuthorize("isAuthenticated()") + public Project openProject(final String projectName) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public long getCurrTimestamp(final String projectName) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public void uploadLibrary(final UploadedFile file, final Project project) throws IOException, ProjectNotExistingException, LibraryAlreadyExistingException; + + @PreAuthorize("isAuthenticated()") + public ClassLoader getClassLoader(final Project project) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public ClassLoader getClassLoader(final String projectName) throws IOException, ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public List<Class<AbstractRepository>> getAllRepositoriesWithinLib(final MIDependency lib, final Project project, final ClassLoader classLoader, + final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; + + @PreAuthorize("isAuthenticated()") + public List<Class<AbstractPlugin>> getAllPluginsWithinLib(final MIDependency lib, final Project project, final ClassLoader classLoader, + final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; + + @PreAuthorize("isAuthenticated()") + public List<Class<AbstractRepository>> getAllRepositoriesWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) + throws LibraryLoadException; + + @PreAuthorize("isAuthenticated()") + public List<Class<AbstractPlugin>> getAllPluginsWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) + throws LibraryLoadException; + + @PreAuthorize("isAuthenticated()") + public Collection<String> listAllProjects(); + + @PreAuthorize("isAuthenticated()") + public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException, + AnalysisInitializationException; + + @PreAuthorize("isAuthenticated()") + public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; + + @PreAuthorize("isAuthenticated()") + public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; + + @PreAuthorize("isAuthenticated()") + public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; + + @PreAuthorize("isAuthenticated()") + public Object getDisplay(final String projectName, final String viewName, final String displayName) throws ProjectNotExistingException, DisplayNotFoundException; + + @PreAuthorize("isAuthenticated()") + public STATE getCurrentState(final String projectName) throws ProjectNotExistingException; + + @PreAuthorize("isAuthenticated()") + public Object[] getLogEntries(final String projectName) throws AnalysisStateException; + + @PreAuthorize("isAuthenticated()") + public List<String> listAllLibraries(final Project project) throws ProjectNotExistingException; +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java similarity index 61% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java index c8266c2b..96ecdb6d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java @@ -14,22 +14,34 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.service; import java.util.List; import org.springframework.security.access.prepost.PreAuthorize; -public interface IUserManager { +import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.User; + +/** + * This is the interface for the user service, responsible for managing the available users within the system. This interface will only be accessible by + * administrators. + * + * @author Nils Christian Ehmke + */ +public interface IUserService { + + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void addUser(final User user); @PreAuthorize("hasRole('ROLE_ADMIN')") - public void addUser(final String username, final String password, final List<Role> roles); + public void editUserWithoutPassword(final User user) throws DataAccessException; @PreAuthorize("hasRole('ROLE_ADMIN')") - public void removeUser(final String username); + public void editUserWithPassword(final User user) throws DataAccessException; @PreAuthorize("hasRole('ROLE_ADMIN')") - public void editUser(final String username, final String password, final Role... roles); + public void deleteUser(final User user); @PreAuthorize("hasRole('ROLE_ADMIN')") public List<User> getUsers(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/ProjectManagerImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java similarity index 67% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/ProjectManagerImpl.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java index 497457ca..267db268 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/ProjectManagerImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.impl; +package kieker.webgui.service.impl; import java.io.IOException; import java.net.MalformedURLException; @@ -22,13 +22,18 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Service; + import kieker.analysis.AnalysisController.STATE; +import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.plugin.AbstractPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.IProjectManager; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; @@ -37,65 +42,40 @@ import kieker.webgui.common.exception.LibraryLoadException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; -import kieker.webgui.common.util.ACManager; -import kieker.webgui.common.util.FSManager; -import kieker.webgui.common.util.PluginFinder; +import kieker.webgui.domain.Project; +import kieker.webgui.persistence.IProjectDAO; +import kieker.webgui.service.IProjectService; +import kieker.webgui.service.impl.util.ACManager; +import kieker.webgui.service.impl.util.PluginFinder; import org.primefaces.model.UploadedFile; -/** - * This is an implemented facade for the project management. For technical reasons it is a singleton class. - * - * @author Nils Christian Ehmke - */ -public final class ProjectManagerImpl implements IProjectManager { +@Service +@Scope("singleton") +public class ProjectServiceImpl implements IProjectService { private final ConcurrentHashMap<String, Object> fileSystemLocks = new ConcurrentHashMap<String, Object>(); private final ConcurrentHashMap<String, Object> analysesLocks = new ConcurrentHashMap<String, Object>(); + @Autowired private ACManager acManager; - private FSManager fsManager; + @Autowired private PluginFinder pluginFinder; + @Autowired + private IProjectDAO projectDAO; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ - public ProjectManagerImpl() { + public ProjectServiceImpl() { // No code necessary. } - /** - * The setter for the property {@link ProjectManagerImpl#acManager}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param acManager - */ - public void setAcManager(final ACManager acManager) { - this.acManager = acManager; - } - - /** - * The setter for the property {@link ProjectManagerImpl#fsManager}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param fsManager - */ - public void setFsManager(final FSManager fsManager) { - this.fsManager = fsManager; - } - - /** - * The setter for the property {@link ProjectManagerImpl#pluginFinder}. <b>Do not use this method. This property is Spring managed.</b> - * - * @param pluginFinder - */ - public void setPluginFinder(final PluginFinder pluginFinder) { - this.pluginFinder = pluginFinder; - } - @Override - public void addProject(final String projectName) throws ProjectAlreadyExistingException, IOException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); + public void addProject(final Project project) throws ProjectAlreadyExistingException, IOException { + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); synchronized (projectLock) { - this.fsManager.addProject(projectName); + this.projectDAO.addProject(project); } } @@ -121,17 +101,17 @@ public final class ProjectManagerImpl implements IProjectManager { synchronized (lockFst) { synchronized (lockSnd) { - this.fsManager.copyProject(originalProjectName, newProjectName); + this.projectDAO.copyProject(originalProjectName, newProjectName); } } } @Override - public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { + public Project openProject(final String projectName) throws ProjectNotExistingException, IOException { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.openProject(projectName); + return this.projectDAO.openProject(projectName); } } @@ -140,55 +120,52 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.openProject(projectName, classAndMethodContainer); + return this.projectDAO.openProject(projectName, classAndMethodContainer); } } @Override - public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject) throws - ProjectNotExistingException, IOException, NewerProjectException { + public long getCurrTimestamp(final String projectName) throws ProjectNotExistingException, IOException { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - this.fsManager.saveProject(projectName, project, timeStamp, overwriteNewerProject); + return this.projectDAO.getCurrTimestamp(projectName); } } @Override - public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); + public void uploadLibrary(final UploadedFile file, final Project project) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException { + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.getCurrTimeStamp(projectName); + this.projectDAO.uploadLibrary(file, project); } } @Override - public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); + public ClassLoader getClassLoader(final Project project) throws ProjectNotExistingException, IOException { + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); synchronized (projectLock) { - this.fsManager.uploadLibrary(file, projectName); + return this.projectDAO.getClassLoader(project); // NOPMD (ClassLoader) } } @Override - public ClassLoader getClassLoader(final String projectName) throws ProjectNotExistingException, IOException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); - - synchronized (projectLock) { - return this.fsManager.getClassLoader(projectName); // NOPMD (ClassLoader) - } + public ClassLoader getClassLoader(final String projectName) throws IOException, ProjectNotExistingException { + final MIProject project = MIAnalysisMetaModelFactory.eINSTANCE.createProject(); + project.setName(projectName); + return this.getClassLoader(new Project(project)); } @Override - public List<Class<AbstractRepository>> getAllRepositoriesWithinLib(final MIDependency lib, final String projectName, final ClassLoader classLoader, + public List<Class<AbstractRepository>> getAllRepositoriesWithinLib(final MIDependency lib, final Project project, final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); synchronized (projectLock) { try { - return this.pluginFinder.getAllRepositoriesWithinJar(this.fsManager.getURL(lib, projectName), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllRepositoriesWithinJar(this.projectDAO.getURL(lib, project), classLoader, classAndMethodContainer); } catch (final MalformedURLException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); } @@ -196,13 +173,13 @@ public final class ProjectManagerImpl implements IProjectManager { } @Override - public List<Class<AbstractPlugin>> getAllPluginsWithinLib(final MIDependency lib, final String projectName, final ClassLoader classLoader, + public List<Class<AbstractPlugin>> getAllPluginsWithinLib(final MIDependency lib, final Project project, final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); synchronized (projectLock) { try { - return this.pluginFinder.getAllPluginsWithinJar(this.fsManager.getURL(lib, projectName), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllPluginsWithinJar(this.projectDAO.getURL(lib, project), classLoader, classAndMethodContainer); } catch (final MalformedURLException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); } @@ -213,7 +190,7 @@ public final class ProjectManagerImpl implements IProjectManager { public List<Class<AbstractRepository>> getAllRepositoriesWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException { try { - return this.pluginFinder.getAllRepositoriesWithinJar(this.fsManager.getKiekerURL(), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllRepositoriesWithinJar(this.projectDAO.getKiekerURL(), classLoader, classAndMethodContainer); } catch (final NullPointerException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); @@ -224,7 +201,7 @@ public final class ProjectManagerImpl implements IProjectManager { public List<Class<AbstractPlugin>> getAllPluginsWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException { try { - return this.pluginFinder.getAllPluginsWithinJar(this.fsManager.getKiekerURL(), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllPluginsWithinJar(this.projectDAO.getKiekerURL(), classLoader, classAndMethodContainer); } catch (final NullPointerException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); @@ -232,17 +209,17 @@ public final class ProjectManagerImpl implements IProjectManager { } @Override - public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException { - final Object projectLock = this.getLock(projectName, this.fileSystemLocks); + public List<String> listAllLibraries(final Project project) throws ProjectNotExistingException { + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.listAllLibraries(projectName); + return this.projectDAO.listAllLibraries(project); } } @Override public Collection<String> listAllProjects() { - return this.fsManager.listAllProjects(); + return this.projectDAO.listAllProjects(); } @Override @@ -338,4 +315,35 @@ public final class ProjectManagerImpl implements IProjectManager { return this.acManager.getLogEntries(projectName); } } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IProjectService#editProject(kieker.webgui.domain.Project) + */ + @Override + @PreAuthorize("isAuthenticated()") + public void editProject(final Project project) throws IOException, ProjectNotExistingException { + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); + + synchronized (projectLock) { + this.projectDAO.saveProject(project, 0, true); + } + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IProjectService#editProject(kieker.webgui.domain.Project, long) + */ + @Override + @PreAuthorize("isAuthenticated()") + public void editProject(final Project project, final long timestamp) throws IOException, ProjectNotExistingException, NewerProjectException { + final Object projectLock = this.getLock(project.getMiproject().getName(), this.fileSystemLocks); + + synchronized (projectLock) { + this.projectDAO.saveProject(project, timestamp, false); + } + } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java new file mode 100644 index 00000000..70209205 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java @@ -0,0 +1,97 @@ +/*************************************************************************** + * 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.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Service; + +import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.User; +import kieker.webgui.persistence.IUserDAO; +import kieker.webgui.service.IUserService; + +@Service +@Scope("singleton") +public class UserServiceImpl implements IUserService { + + @Autowired + private IUserDAO userDAO; + + public UserServiceImpl() { + // No code necessary + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IUserService#addUser(kieker.webgui.domain.User) + */ + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void addUser(final User user) { + this.userDAO.addUser(user); + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IUserService#editUserWithoutPassword(kieker.webgui.domain.User) + */ + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void editUserWithoutPassword(final User user) throws DataAccessException { + this.userDAO.editUserWithoutPassword(user); + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IUserService#editUserWithPassword(kieker.webgui.domain.User) + */ + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void editUserWithPassword(final User user) throws DataAccessException { + this.userDAO.editUserWithPassword(user); + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IUserService#deleteUser(kieker.webgui.domain.User) + */ + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void deleteUser(final User user) { + this.userDAO.deleteUser(user); + } + + /* + * (non-Javadoc) + * + * @see kieker.webgui.service.IUserService#getUsers() + */ + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public List<User> getUsers() { + return this.userDAO.getUsers(); + } + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java similarity index 89% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/package-info.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java index 54cf3cb2..4540acaa 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java @@ -15,7 +15,8 @@ ***************************************************************************/ /** + * This package contains the implementation of the services. + * * @author Nils Christian Ehmke - * */ -package kieker.webgui.common.impl; \ No newline at end of file +package kieker.webgui.service.impl; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java similarity index 96% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java index 6d03d916..a5639873 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java @@ -14,17 +14,20 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.util; +package kieker.webgui.service.impl.util; import java.util.concurrent.ConcurrentHashMap; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; import kieker.analysis.AnalysisController.STATE; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.persistence.IProjectDAO; /** * This manager is responsible for the currently used and running instances of {@code AnalysisController}. It supplies methods to check the states of analysis, @@ -32,6 +35,8 @@ import kieker.webgui.common.exception.ProjectNotExistingException; * * @author Nils Christian Ehmke */ +@Component +@Scope("singleton") public final class ACManager { /** * This list contains the current analysis controllers and their corresponding threads. Not every project does have a controller, but every project can have @@ -39,7 +44,7 @@ public final class ACManager { */ private final ConcurrentHashMap<String, Analysis> analyses = new ConcurrentHashMap<String, Analysis>(); @Autowired - private FSManager fsManager; + private IProjectDAO projectDAO; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> @@ -48,10 +53,6 @@ public final class ACManager { // No code necessary. } - public void setFsManager(final FSManager fsManager) { - this.fsManager = fsManager; - } - /** * This method initializes the analysis for the given project. * @@ -73,7 +74,7 @@ public final class ACManager { throw new AnalysisStateException("The analysis has not been cleaned yet."); } - final Analysis analysis = new Analysis(classLoader, this.fsManager.getProjectFile(projectName)); + final Analysis analysis = new Analysis(classLoader, this.projectDAO.getProjectFile(projectName)); this.analyses.put(projectName, analysis); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/Analysis.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java similarity index 99% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/util/Analysis.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java index 74180ef3..bf72d284 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/Analysis.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.util; +package kieker.webgui.service.impl.util; import java.io.File; import java.lang.reflect.InvocationTargetException; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java similarity index 96% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java index 8e414cb1..f1eb7e7b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.util; +package kieker.webgui.service.impl.util; import java.io.IOException; import java.net.URL; @@ -22,6 +22,9 @@ import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + import kieker.analysis.plugin.AbstractPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.webgui.common.ClassAndMethodContainer; @@ -31,6 +34,8 @@ import kieker.webgui.common.ClassAndMethodContainer; * * @author Nils Christian Ehmke */ +@Component +@Scope("singleton") public final class PluginFinder { /** diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java new file mode 100644 index 00000000..c5ce6121 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java @@ -0,0 +1,7 @@ +/** + * + */ +/** + * @author Nils Christian Ehmke + */ +package kieker.webgui.service.impl.util; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java new file mode 100644 index 00000000..03503ece --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains the interfaces of the service layer of the web application. It is directly above the persistence layer. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.service; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/global.properties b/Kieker.WebGUI/src/main/resources/global.properties index 58f3a8d0..dc015ce3 100644 --- a/Kieker.WebGUI/src/main/resources/global.properties +++ b/Kieker.WebGUI/src/main/resources/global.properties @@ -23,3 +23,12 @@ kieker.webgui.config.analysisEditor.defaultGridColor = 0080FF #------------------------------------------------------------------------------ kieker.webgui.page.projectOverview = projectOverview + +#------------------------------------------------------------------------------ +# +# Some common information. +# +#------------------------------------------------------------------------------ + +kieker.url = http://www.kieker-monitoring.net/ +kieker.webgui.version = 1.7-SNAPSHOT \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/AccessDeniedPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/AccessDeniedPage_de.properties index f7f3558b..2fbb56db 100644 --- a/Kieker.WebGUI/src/main/resources/lang/AccessDeniedPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/AccessDeniedPage_de.properties @@ -1,8 +1,8 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Zugriff-Verweigert-Seite benutzt werden. # #------------------------------------------------------------------------------ -accessDenied = Zugriff verweigert! \ No newline at end of file +accessDenied = Zugriff verweigert! \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/AnalysisEditorPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/AnalysisEditorPage_de.properties index 5c386367..08fce9bc 100644 --- a/Kieker.WebGUI/src/main/resources/lang/AnalysisEditorPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/AnalysisEditorPage_de.properties @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Seite des Analyseeditors benutzt werden. # #------------------------------------------------------------------------------ @@ -10,7 +10,7 @@ manageLibraries = Bibliotheken Verwalten graph = Graph analysisEditorScaleToFit = An Fenstergr\u00f6\u00dfe Anpassen grid = Gitter -snap = Einrasten +snap = Einrasten autoLayout = Auto-Layout disable = Deaktivieren diff --git a/Kieker.WebGUI/src/main/resources/lang/CockpitEditorPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/CockpitEditorPage_de.properties index bdab2198..6563bc54 100644 --- a/Kieker.WebGUI/src/main/resources/lang/CockpitEditorPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/CockpitEditorPage_de.properties @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Seite des Cockpiteditors benutzt werden. # #------------------------------------------------------------------------------ @@ -8,4 +8,4 @@ selectView = Ansicht Selektieren copyView = Ansicht Kopieren renameView = Ansicht Umbenennen -deleteView = Ansicht Löschen \ No newline at end of file +deleteView = Ansicht L\u00f6schen \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/CockpitPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/CockpitPage_de.properties index 2e3d90c2..815bdc98 100644 --- a/Kieker.WebGUI/src/main/resources/lang/CockpitPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/CockpitPage_de.properties @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb des Cockpits benutzt werden. # #------------------------------------------------------------------------------ \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/Common_de.properties b/Kieker.WebGUI/src/main/resources/lang/Common_de.properties index edcc9c75..e6225fee 100644 --- a/Kieker.WebGUI/src/main/resources/lang/Common_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/Common_de.properties @@ -14,7 +14,7 @@ choose = Durchsuchen file = Datei settings = Einstellungen -help = Hilfe +help = Hilfe userGuide = User Guide about = \u00dcber... @@ -23,13 +23,14 @@ analysis = Analyse analysisController = Analyse Controller cockpitEditor = Cockpit Editor cockpit = Cockpit +userManagement = User Management saveProject = Projekt Speichern saveProjectAs = Projekt Speichern Unter reloadProject = Projekt Neu Laden closeProject = Projekt schlie\u00dfen -noRecordsFound = Keine Einträge vorhanden. +noRecordsFound = Keine Eintr\u00e4ge vorhanden. properties = Eigenschaften property = Eigenschaft @@ -58,14 +59,14 @@ gridColor = Gitterfarbe # #------------------------------------------------------------------------------ -msgProjectLoadingException = Beim Laden des Projekts ist ein Fehler aufgetreten. Bitte überprüfen Sie den Log für weitere Details. +msgProjectLoadingException = Beim Laden des Projekts ist ein Fehler aufgetreten. Bitte \u00fcberpr\u00fcfen Sie den Log f\u00fcr weitere Details. msgProjectSaved = Das Projekt wurde erfolgreich gespeichert. -msgPluginCreationException = Beim Erzeugen des Plugins ist ein Fehler aufgetreten. Bitte überprüfen Sie die Abhängigkeiten und den Log für weitere Details. -msgRepositoryCreationException = Beim Erzeugen des Repositories ist ein Fehler aufgetreten. Bitte überprüfen Sie die Abhängigkeiten und den Log für weitere Details. +msgPluginCreationException = Beim Erzeugen des Plugins ist ein Fehler aufgetreten. Bitte \u00fcberpr\u00fcfen Sie die Abh\u00e4ngigkeiten und den Log f\u00fcr weitere Details. +msgRepositoryCreationException = Beim Erzeugen des Repositories ist ein Fehler aufgetreten. Bitte \u00fcberpr\u00fcfen Sie die Abh\u00e4ngigkeiten und den Log f\u00fcr weitere Details. msgLibraryUploaded = Die Bibliothek wurde erfolgreich hochgeladen. msgProjectCreated = Das Projekt wurde erfolgreich erstellt. -msgProjectSavingException = Beim Speichern des Projekts ist ein Fehler aufgetreten. Bitte überprüfen Sie den Log für weitere Details. +msgProjectSavingException = Beim Speichern des Projekts ist ein Fehler aufgetreten. Bitte \u00fcberpr\u00fcfen Sie den Log f\u00fcr weitere Details. msgProjectNotExistingException = Das aktuelle Projekt existiert nicht. msgProjectModified = Das Projekt wurde in der Zwischenzeit au\u00dferhalb dieses Editors modifiziert. msgLibraryExistingException = Eine Bibliothek mit dem gleichen Namen existiert bereits. -msgLibraryUploadingException = Beim Hochladen der Bibliothek ist ein Fehler aufgetreten. Bitte überprüfen Sie den Log für weitere Details. \ No newline at end of file +msgLibraryUploadingException = Beim Hochladen der Bibliothek ist ein Fehler aufgetreten. Bitte \u00fcberpr\u00fcfen Sie den Log f\u00fcr weitere Details. \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/Common_en.properties b/Kieker.WebGUI/src/main/resources/lang/Common_en.properties index 8e8211b5..8ba2c5c4 100644 --- a/Kieker.WebGUI/src/main/resources/lang/Common_en.properties +++ b/Kieker.WebGUI/src/main/resources/lang/Common_en.properties @@ -23,7 +23,8 @@ analysis = Analysis analysisController = Analysis Controller cockpitEditor = Cockpit Editor cockpit = Cockpit - +userManagement = User Management + saveProject = Save Project saveProjectAs = Save Project As reloadProject = Reload Project diff --git a/Kieker.WebGUI/src/main/resources/lang/ControllerPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/ControllerPage_de.properties index cec041b9..2c4b72f5 100644 --- a/Kieker.WebGUI/src/main/resources/lang/ControllerPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/ControllerPage_de.properties @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., -# welche innerhalb der Seite für die Analysesteuerung benutzt werden. +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., +# welche innerhalb der Seite f\u00fcr die Analysesteuerung benutzt werden. # #------------------------------------------------------------------------------ @@ -12,10 +12,10 @@ analysisControllerStopAnalysis = Analyse Stoppen analysisControllerMsgNotInstantiated = Zeigt an, dass der AnalysisController noch nicht instanziiert wurde. analysisControllerMsgReady = Zeigt an, dass der AnalysisController zwar instanziiert, jedoch noch nicht gestartet wurde. -analysisControllerMsgRunning = Zeigt an, dass der AnalysisController gestartet wurde und zur Zeit läuft. -analysisControllerMsgFailed = Zeigt an, dass der AnalysisController terminiert oder abgestürzt ist. +analysisControllerMsgRunning = Zeigt an, dass der AnalysisController gestartet wurde und zur Zeit l\u00e4uft. +analysisControllerMsgFailed = Zeigt an, dass der AnalysisController terminiert oder abgest\u00fcrzt ist. -control = Steuerung +control = Steuerung analysisControllerLog = AnalysisController Log -personalLog = Persönlicher Log \ No newline at end of file +personalLog = Pers\u00f6nlicher Log \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties index beef4292..dad9351c 100644 --- a/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/LoginPage_de.properties @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Anmeldeseite benutzt werden. # #------------------------------------------------------------------------------ @@ -12,4 +12,4 @@ password = Passwort login = Anmelden -hint = Hinweis: Die Kieker.WebGUI benötigt Cookies und JavaScript, um korrekt zu funktionieren. Bitte stellen Sie sicher, dass beides aktiviert ist. \ No newline at end of file +hint = Hinweis: Die Kieker.WebGUI ben\u00f6tigt Cookies und JavaScript, um korrekt zu funktionieren. Bitte stellen Sie sicher, dass beides aktiviert ist. \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/resources/lang/ProjectOverviewPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/ProjectOverviewPage_de.properties index dd9d1586..5e43c362 100644 --- a/Kieker.WebGUI/src/main/resources/lang/ProjectOverviewPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/ProjectOverviewPage_de.properties @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., -# welche innerhalb der Projektübersichtsseite benutzt werden. +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., +# welche innerhalb der Projekt\u00fcbersichtsseite benutzt werden. # #------------------------------------------------------------------------------ @@ -13,7 +13,7 @@ projectName = Projektname state = Status lastModification = Letzte \u00c4nderung owner = Besitzer - + copyProject = Projekt Kopieren renameProject = Projekt Umbenennen deleteProject = Projekt L\u00f6schen diff --git a/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties b/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties index f5aadf0c..383c3a34 100644 --- a/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties +++ b/Kieker.WebGUI/src/main/resources/lang/UserManagementPage_de.properties @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc., +# Diese Datei beinhaltet s\u00e4mtliche Nachrichten, Buttonbeschriftungen etc., # welche innerhalb der Benutzerverwaltungsseite benutzt werden. # #------------------------------------------------------------------------------ @@ -12,8 +12,8 @@ updateUserList = Benutzerliste Aktualisieren editUser = Benutzer Bearbeiten disableUser = Benutzer Deaktivieren enableUser = Benutzer Aktivieren -deleteUser = Benutzer Löschen - +deleteUser = Benutzer L\u00f6schen + username = Benutzername userroles = Benutzerrollen enabled = Aktiviert \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/faces-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/faces-config.xml index 5807c106..aac88a49 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/faces-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/faces-config.xml @@ -1,5 +1,8 @@ <?xml version='1.0' encoding='UTF-8'?> - +<!-- + This file contains the configuration for JSF. This means that it contains some localization work, some delegation to the Spring framework and the navigation cases, + which can be used to navigate between the pages. +--> <faces-config version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -75,4 +78,5 @@ <to-view-id>/pages/admin/UserManagementPage.xhtml</to-view-id> </navigation-case> </navigation-rule> + </faces-config> \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/pretty-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/pretty-config.xml index 1301bdbd..0bbeae5b 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/pretty-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/pretty-config.xml @@ -1,19 +1,17 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains the configuration for Prettyfaces. This means we use some mappings to make sure that we have more "pretty" looking urls. Be careful if you + change something in here, as the patterns in the Spring Security configuration has to be modified as well! Otherwise you could destroy the security system. +--> <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.2 http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.2.xsd"> - <!-- The following mappings make sure that we have more "pretty" looking urls. --> <url-mapping id="home"> <pattern value="/pages/" /> <view-id value="/faces/pages/ProjectOverviewPage.xhtml" /> </url-mapping> - <!-- The following mapping is very important! It makes sure that no one can access the root directory of the application. --> - <url-mapping id="home-redirect"> - <pattern value="/" /> - <view-id value="/faces/pages/ProjectOverviewPage.xhtml" /> - </url-mapping> - <url-mapping id="projectOverview"> <pattern value="/pages/projectOverview" /> <view-id value="/faces/pages/ProjectOverviewPage.xhtml" /> @@ -53,4 +51,11 @@ <pattern value="/pages/admin/userManagement" /> <view-id value="/faces/pages/admin/UserManagementPage.xhtml" /> </url-mapping> + + <!-- The following mapping is very important! It makes sure that no one can access the root directory of the application. --> + <url-mapping id="home-redirect"> + <pattern value="/" /> + <view-id value="/faces/pages/ProjectOverviewPage.xhtml" /> + </url-mapping> + </pretty-config> \ No newline at end of file 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 dfe8bd88..dce0d39d 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 @@ -1,25 +1,27 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains the bean configuration for the Spring framework. Technically we initialize only very few beans in here explicitly. Most of the beans and + services will be localized automatically via annotations. You will see them in the source code. +--> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" + xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> + <!-- This is for the properties-files. --> + <bean id="globalPropertiesPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>classpath:global.properties</value> + </list> + </property> + </bean> + <!-- The singleton scoped beans. --> - <bean id="pluginFinder" class="kieker.webgui.common.util.PluginFinder" /> - <bean id="fsManager" class="kieker.webgui.common.util.FSManager" init-method="initialize"/> - <bean id="acManager" class="kieker.webgui.common.util.ACManager"> - <property name="fsManager" ref="fsManager" /> - </bean> - <bean id="projectManager" class="kieker.webgui.common.impl.ProjectManagerImpl"> - <property name="fsManager" ref="fsManager" /> - <property name="acManager" ref="acManager" /> - <property name="pluginFinder" ref="pluginFinder" /> - </bean> - <bean id="projectsBean" class="kieker.webgui.beans.application.ProjectsBean" init-method="initialize"> - <property name="projectManagerFacade" ref="projectManager" /> - </bean> - <bean id="globalPropertiesBean" class="kieker.webgui.beans.application.GlobalPropertiesBean"> + <bean id="globalPropertiesBean" class="kieker.webgui.business.beans.application.GlobalPropertiesBean"> <property name="themeCookieName" value="${kieker.webgui.config.lookAndFeel.cookieName}"/> <property name="projectOverviewPage" value="${kieker.webgui.page.projectOverview}"/> <property name="facesContextThemeKey" value="${kieker.webgui.config.lookAndFeel.facesContextKey}"/> @@ -28,8 +30,11 @@ <property name="analysisEditorGridColorCookieName" value="${kieker.webgui.config.analysisEditor.gridColor.cookieName}"/> <property name="analysisEditorDefaultGridSize" value="${kieker.webgui.config.analysisEditor.defaultGridSize}"/> <property name="analysisEditorDefaultGridColor" value="${kieker.webgui.config.analysisEditor.defaultGridColor}"/> + <property name="version" value="${kieker.webgui.version}"/> + <property name="kiekerUrl" value="${kieker.url}"/> </bean> - <bean id="themeSwitcherBean" class="kieker.webgui.beans.application.ThemeSwitcherBean"> + + <bean id="themeSwitcherBean" class="kieker.webgui.business.beans.application.ThemeSwitcherBean"> <!-- This is the map containing the available themes (look and feels). If one wants to add more themes, this is the correct place to do so. --> <property name="themes"> <map> @@ -66,49 +71,13 @@ </map> </property> </bean> - <bean destroy-method="destroy" init-method="initialize" id="userManager" class="kieker.webgui.common.impl.UserManagerImpl"> - <property name="dataSource" ref="userDataSource" /> - </bean> - - <!-- The session scoped beans. --> - <bean id="userBean" init-method="initialize" class="kieker.webgui.beans.session.UserBean" scope="session"> - <property name="globalPropertiesBean" ref="globalPropertiesBean"/> - </bean> - - <!-- The view scoped beans. --> - <bean id="currentAnalysisEditorBean" class="kieker.webgui.beans.view.CurrentAnalysisEditorBean" scope="view"> - <property name="globalPropertiesBean" ref="globalPropertiesBean"/> - <property name="projectManagerFacade" ref="projectManager" /> - <property name="projectsBean" ref="projectsBean" /> - <property name="currentAnalysisEditorGraphBean" ref="currentAnalysisEditorGraphBean" /> - <property name="userBean" ref="userBean" /> - </bean> - <bean id="currentAnalysisEditorGraphBean" class="kieker.webgui.beans.view.CurrentAnalysisEditorGraphBean" scope="view"/> - <bean id="currentCockpitBean" class="kieker.webgui.beans.view.CurrentCockpitBean" scope="view"> - <property name="projectsBean" ref="projectsBean"/> - <property name="projectManagerFacade" ref="projectManager" /> - </bean> - <bean id="currentCockpitEditorBean" class="kieker.webgui.beans.view.CurrentCockpitEditorBean" scope="view"> - <property name="globalPropertiesBean" ref="globalPropertiesBean"/> - <property name="projectManagerFacade" ref="projectManager" /> - <property name="projectsBean" ref="projectsBean"/> - </bean> - <bean id="currentControllerBean" class="kieker.webgui.beans.view.CurrentControllerBean" scope="view"> - <property name="projectsBean" ref="projectsBean"/> - <property name="projectManagerFacade" ref="projectManager" /> - </bean> - <bean id="currentProjectOverviewBean" class="kieker.webgui.beans.view.CurrentProjectOverviewBean" scope="view" init-method="initialialize"> - <property name="projectsBean" ref="projectsBean"/> - </bean> - <bean id="currentUserManagementBean" class="kieker.webgui.beans.view.CurrentUserManagementBean" init-method="initialialize" scope="view"> - <property name="userManagerFacade" ref="userManager"/> - </bean> - - <!-- The request scoped beans. --> - <bean id="stringBean" class="kieker.webgui.beans.request.StringBean" scope="request"/> - <bean id="newUserBean" class="kieker.webgui.beans.request.NewUserBean" scope="request"/> <!-- The enums. --> - <util:constant id="ROLE_USER" static-field="kieker.webgui.common.Role.ROLE_USER"/> - <util:constant id="ROLE_ADMIN" static-field="kieker.webgui.common.Role.ROLE_ADMIN"/> + <util:constant id="ROLE_USER" static-field="kieker.webgui.domain.User.Role.ROLE_USER"/> + <util:constant id="ROLE_ADMIN" static-field="kieker.webgui.domain.User.Role.ROLE_ADMIN"/> + + <!-- Search the whole(!) project for beans. --> + <context:component-scan base-package="kieker.webgui" /> + <context:annotation-config /> + </beans> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml index b3006a95..50e88767 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml @@ -1,3 +1,7 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains some common configuration for the Spring framework. +--> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> @@ -7,18 +11,11 @@ <property name="scopes"> <map> <entry key="view"> - <bean class="kieker.webgui.common.util.ViewScope"/> + <bean class="kieker.webgui.common.ViewScope"/> </entry> </map> </property> </bean> - <!-- This is for the properties-files. --> - <bean id="globalPropertiesPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> - <property name="locations"> - <list> - <value>classpath:global.properties</value> - </list> - </property> - </bean> + </beans> \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml index 7eb459b5..1f0c7f0c 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml @@ -1,18 +1,23 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains the configuration of the database. +--> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd"> - <!-- The database and the transaction manager. --> + <!-- The database. --> <bean id="userDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" /> <property name="url" value="jdbc:derby:user;create=true" /> </bean> + <!-- This part will try to create the tables and add some test data. This should be removed for the release. --> <jdbc:initialize-database ignore-failures="ALL" data-source="userDataSource"> <jdbc:script location="classpath:sql/tables.sql"/> <jdbc:script location="classpath:sql/test-data.sql"/> - </jdbc:initialize-database> + </jdbc:initialize-database> + </beans> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml index 990ee356..e788440a 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-config.xml @@ -1,11 +1,15 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains the configuration of the security part of Spring. Be very careful if you change something in here. This is critical code! +--> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <http use-expressions="true" access-denied-page="/accessDenied" > + <!-- The following is the part for the login itself. --> <form-login login-page="/login" default-target-url="/pages/" authentication-failure-url="/login?state=fail"/> <intercept-url pattern="/login" access="permitAll"/> <intercept-url pattern="/faces/pages/LoginPage.xhtml" access="permitAll"/> @@ -27,18 +31,15 @@ <logout logout-success-url="/login?state=logout" /> </http> + <!-- Enable the annotations for the security system. --> <global-method-security pre-post-annotations="enabled"/> + <!-- The following part makes sure that the database is used to get the user authentication and authorities. --> <authentication-manager> <authentication-provider> - <jdbc-user-service data-source-ref="userDataSource" - users-by-username-query=" - select name, password, enabled - from KIEKERUser where name=?" - - authorities-by-username-query=" - select u.name, r.Role from KIEKERUser u, Userroles ur, Roles r - where u.name=ur.name and r.ID = ur.role and u.name=?" + <jdbc-user-service data-source-ref="userDataSource" + users-by-username-query="SELECT name, password, enabled FROM KIEKERUser WHERE name=?" + authorities-by-username-query="SELECT u.name, r.Role FROM KIEKERUser u, Userroles ur, Roles r WHERE u.name=ur.name AND r.ID = ur.role AND u.name=?" /> </authentication-provider> </authentication-manager> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-taglib.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-taglib.xml index c6fc52a8..84ccbaef 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-taglib.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-security-taglib.xml @@ -1,4 +1,7 @@ -<?xml version="1.0"?> +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains some manual tagging to make sure that the security part works. +--> <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml index d323eaec..c7e804f5 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml @@ -1,4 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='UTF-8'?> +<!-- + This file contains the core configuration of the whole web application. Be careful if you change something in here. An exchange of codeparts could destroy the + security system for example. +--> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -22,11 +26,13 @@ <param-value>#{userBean.lookAndFeel}</param-value> </context-param> + <!-- This is for the security system. --> <context-param> <param-name>javax.faces.FACELETS_LIBRARIES</param-name> <param-value>/WEB-INF/spring-security-taglib.xml</param-value> </context-param> + <!-- This is for the security system. It has to be the first filter in order to work correctly. --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> diff --git a/Kieker.WebGUI/src/main/webapp/css/AccessDeniedPage.css b/Kieker.WebGUI/src/main/webapp/css/AccessDeniedPage.css index 7eac351d..7f324f8f 100644 --- a/Kieker.WebGUI/src/main/webapp/css/AccessDeniedPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/AccessDeniedPage.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the access denied page. +*/ .hint-label { font-size: 25px; diff --git a/Kieker.WebGUI/src/main/webapp/css/AnalysisEditorPage.css b/Kieker.WebGUI/src/main/webapp/css/AnalysisEditorPage.css index 1889c5a7..facc9e83 100644 --- a/Kieker.WebGUI/src/main/webapp/css/AnalysisEditorPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/AnalysisEditorPage.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the analysis editor page. +*/ /* This is necessary to remove the border from the datalist */ .ui-datalist * { diff --git a/Kieker.WebGUI/src/main/webapp/css/CockpitEditorPage.css b/Kieker.WebGUI/src/main/webapp/css/CockpitEditorPage.css index b8ba3d16..8cb1a77f 100644 --- a/Kieker.WebGUI/src/main/webapp/css/CockpitEditorPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/CockpitEditorPage.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the cockpit editor page. +*/ /* This is necessary to remove the border from the datalist */ .ui-datalist * { diff --git a/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css b/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css index f76427d5..11c5dfa7 100644 --- a/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/CockpitPage.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the cockpit page. +*/ ui-dashboard-column { width: 50% diff --git a/Kieker.WebGUI/src/main/webapp/css/Common.css b/Kieker.WebGUI/src/main/webapp/css/Common.css index 6cf1da11..a3e897c4 100644 --- a/Kieker.WebGUI/src/main/webapp/css/Common.css +++ b/Kieker.WebGUI/src/main/webapp/css/Common.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the common template. +*/ .ui-growl { width: 500px diff --git a/Kieker.WebGUI/src/main/webapp/css/ControllerPage.css b/Kieker.WebGUI/src/main/webapp/css/ControllerPage.css index 03bb3631..73439da3 100644 --- a/Kieker.WebGUI/src/main/webapp/css/ControllerPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/ControllerPage.css @@ -1 +1,6 @@ -@charset "UTF-8"; \ No newline at end of file +@charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the controller page. +*/ \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/css/DefaultTemplate.css b/Kieker.WebGUI/src/main/webapp/css/DefaultTemplate.css index e1616250..fb85f101 100644 --- a/Kieker.WebGUI/src/main/webapp/css/DefaultTemplate.css +++ b/Kieker.WebGUI/src/main/webapp/css/DefaultTemplate.css @@ -1,10 +1,8 @@ @charset "UTF-8"; /* - Document : DefaultTemplate - Created on : 24.10.2012, 15:14:21 Author : Nils Christian Ehmke Description: - Purpose of the stylesheet follows. + This file contains the css parts for the default template. */ root { diff --git a/Kieker.WebGUI/src/main/webapp/css/FlowEditor.css b/Kieker.WebGUI/src/main/webapp/css/FlowEditor.css index eb0b8e77..478a35f4 100644 --- a/Kieker.WebGUI/src/main/webapp/css/FlowEditor.css +++ b/Kieker.WebGUI/src/main/webapp/css/FlowEditor.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the flow editor within the analysis editor page. +*/ #inner-details { font-size:12px; diff --git a/Kieker.WebGUI/src/main/webapp/css/Icons.css b/Kieker.WebGUI/src/main/webapp/css/Icons.css index 88818fe7..020bb58f 100644 --- a/Kieker.WebGUI/src/main/webapp/css/Icons.css +++ b/Kieker.WebGUI/src/main/webapp/css/Icons.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for icons. +*/ .ui-icon-close { background: url('../img/icons/Close.png') no-repeat !important; diff --git a/Kieker.WebGUI/src/main/webapp/css/LoginPage.css b/Kieker.WebGUI/src/main/webapp/css/LoginPage.css index ad91576c..fbb42cc7 100644 --- a/Kieker.WebGUI/src/main/webapp/css/LoginPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/LoginPage.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the login page. +*/ .ui-panel { font-size: 12px; diff --git a/Kieker.WebGUI/src/main/webapp/css/ProjectOverviewPage.css b/Kieker.WebGUI/src/main/webapp/css/ProjectOverviewPage.css index f506fa16..36f5ee7f 100644 --- a/Kieker.WebGUI/src/main/webapp/css/ProjectOverviewPage.css +++ b/Kieker.WebGUI/src/main/webapp/css/ProjectOverviewPage.css @@ -1,4 +1,9 @@ @charset "UTF-8"; +/* + Author : Nils Christian Ehmke + Description: + This file contains the css parts for the project overview page. +*/ .ui-datatable-header { font-size: 12px; diff --git a/Kieker.WebGUI/src/main/webapp/css/UserManagement.css b/Kieker.WebGUI/src/main/webapp/css/UserManagement.css index 5b51f2ee..3f6c34fd 100644 --- a/Kieker.WebGUI/src/main/webapp/css/UserManagement.css +++ b/Kieker.WebGUI/src/main/webapp/css/UserManagement.css @@ -1,9 +1,8 @@ +@charset "UTF-8"; /* - Document : UserManagement - Created on : 24.10.2012, 21:58:57 Author : Nils Christian Ehmke Description: - Purpose of the stylesheet follows. + This file contains the css parts for the user management page. */ .col1 { diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/AboutDialog.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/AboutDialog.xhtml index c37c126e..04e21cbc 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/AboutDialog.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/AboutDialog.xhtml @@ -6,6 +6,7 @@ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> + <!-- This is the dialog showing some information about the web application. --> <p:dialog header="#{localizedMessages.about}" resizable="false" modal="true" widgetVar="aboutDlg"> <h:form> <img src="#{root}/img/kieker-logo-transparent.png" alt="Kieker-Logo" width="491" height="150" /> @@ -13,12 +14,12 @@ <h:outputText value="Kieker.WebGUI" /> <br /> <br /> - <h:outputText value="Version: 1.7-SNAPSHOT" /> + <h:outputText value="Version: #{globalPropertiesBean.version}" /> <br /> <h:outputText value="Copyright (c) 2012 Kieker Project" /> <br /> <br /> - <a href="http://www.kieker-monitoring.net/">http://www.kieker-monitoring.net/</a> + <a href="#{globalPropertiesBean.kiekerUrl}">#{globalPropertiesBean.kiekerUrl}</a> <hr/> <div style="text-align: right"> <p:commandButton value="Ok" oncomplete="aboutDlg.hide()" /> diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml index 3bb92495..fb7d6d13 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/AnalysisEditorPageDialogs.xhtml @@ -1,9 +1,12 @@ +<?xml version='1.0' encoding='UTF-8' ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> + <!-- This is the dialog to upload and manage libraries for the current project. --> <p:dialog id="manageLibrariesDlg" header="#{localizedMessages.libraries}" resizable="false" modal="true" widgetVar="manageLibrariesDialog"> <h:form id="dependenciesForm"> <p:dataTable id="currentDependencies" value="#{currentAnalysisEditorBean.libraries}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" > @@ -41,6 +44,7 @@ </div> </p:dialog> + <!-- This is the dialog to ask the user in case that the project has been modified in the meantime. --> <p:dialog header="#{localizedMessages.saveProject}" resizable="false" modal="true" widgetVar="forceSaveDlg"> <h:form> <div style="text-align: center"> diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/CockpitEditorPageDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/CockpitEditorPageDialogs.xhtml index 7e8beecc..c9d09eac 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/CockpitEditorPageDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/CockpitEditorPageDialogs.xhtml @@ -1,10 +1,11 @@ +<?xml version='1.0' encoding='UTF-8' ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - <!-- ******************************************************************************** --> <!-- This is the dialog to create a new view. --> <p:dialog id="newViewDlg" header="New View" resizable="false" modal="true" widgetVar="newViewDialog"> <!-- Make sure that closing the dialog also clears the input field. --> @@ -24,5 +25,19 @@ </div> </h:form> </p:dialog> - + + <!-- This is the dialog to ask the user in case that the project has been modified in the meantime. --> + <p:dialog header="Save Project" resizable="false" modal="true" widgetVar="forceSaveDlg"> + <h:form> + <div style="text-align: center"> + <h:outputText value="The project has been modified externally in the meanwhile. Do you want to overwrite the changes?" /> + </div> + <hr/> + <div style="text-align: right"> + <p:commandButton value="Yes" action="#{currentCockpitEditorBean.saveProject(true)}" oncomplete="forceSaveDlg.hide()" update=":messages" /> + <p:spacer width="10px" height="10" /> + <p:commandButton value="Cancel" onclick="forceSaveDlg.hide()" /> + </div> + </h:form> + </p:dialog> </ui:composition> \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/ProjectOverviewPageDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/ProjectOverviewPageDialogs.xhtml index 25ae3ba6..f5b44705 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/ProjectOverviewPageDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/ProjectOverviewPageDialogs.xhtml @@ -1,10 +1,11 @@ +<?xml version='1.0' encoding='UTF-8' ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> - <!-- ******************************************************************************** --> <!-- This is the dialog to create a new project. --> <p:dialog id="newProjectDlg" header="#{localizedProjectOverviewMessages.newProject}" resizable="false" modal="true" widgetVar="newProjectDialog"> <!-- Make sure that closing of the dialog also clears the input field. --> @@ -22,8 +23,8 @@ </div> </h:form> </p:dialog> - <!-- ******************************************************************************** --> + <!-- This is the dialog to rename an existing project. --> <p:dialog id="renameProjectDlg" header="#{localizedProjectOverviewMessages.renameProject}" resizable="false" modal="true" widgetVar="renameProjectDialog"> <!-- Make sure that closing of the dialog also clears the input field. --> <p:ajax event="close" update="renameProjectDialogForm:renameProjectInputText" /> @@ -41,8 +42,8 @@ </h:form> </p:dialog> + <!-- This is the dialog to delete an existing project. --> <p:dialog id="deleteProjectDlg" header="#{localizedProjectOverviewMessages.deleteProject}" resizable="false" modal="true" widgetVar="deleteProjectDialog"> - <h:form id="deleteProjectDialogForm"> <div style="text-align: center"> <h:outputText value="#{localizedProjectOverviewMessages.msgReallyDeleteProject}" /> @@ -55,6 +56,7 @@ </h:form> </p:dialog> + <!-- This is the dialog to copy an existing project. --> <p:dialog id="copyProjectDlg" header="#{localizedProjectOverviewMessages.copyProject}" resizable="false" modal="true" widgetVar="copyProjectDialog"> <!-- Make sure that closing of the dialog also clears the input field. --> <p:ajax event="close" update="copyProjectDialogForm:copyProjectDialogInputText" /> @@ -72,17 +74,5 @@ </h:form> </p:dialog> - <p:dialog header="Save Project" resizable="false" modal="true" widgetVar="forceSaveDlg"> - <h:form> - <div style="text-align: center"> - <h:outputText value="The project has been modified externally in the meanwhile. Do you want to overwrite the changes?" /> - </div> - <hr/> - <div style="text-align: right"> - <p:commandButton value="Yes" action="#{currentCockpitEditorBean.saveProject(true)}" oncomplete="forceSaveDlg.hide()" update=":messages" /> - <p:spacer width="10px" height="10" /> - <p:commandButton value="Cancel" onclick="forceSaveDlg.hide()" /> - </div> - </h:form> - </p:dialog> + </ui:composition> \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/SettingsDialog.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/SettingsDialog.xhtml index bc4bdcdf..0229f2a7 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/SettingsDialog.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/SettingsDialog.xhtml @@ -1,3 +1,6 @@ +<?xml version='1.0' encoding='UTF-8' ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" @@ -5,6 +8,7 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> + <!-- This is the dialog for the configuration. --> <p:dialog id="settingsDialog" header="#{localizedMessages.settings}" resizable="false" modal="true" widgetVar="settingsDlg"> <h:form> <p:tabView> @@ -43,6 +47,8 @@ </p:tab> <p:tab title="#{localizedMessages.cockpit}" disabled="true"> </p:tab> + <p:tab title="#{localizedMessages.userManagement}" disabled="true"> + </p:tab> </p:tabView> <hr/> <div style="text-align: right"> diff --git a/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml index 2106604a..6d2e6648 100644 --- a/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml +++ b/Kieker.WebGUI/src/main/webapp/dialogs/UserManagementDialogs.xhtml @@ -1,3 +1,5 @@ +<?xml version='1.0' encoding='UTF-8' ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" @@ -5,6 +7,7 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> + <!-- This is the dialog for a new user. --> <p:dialog id="newUserDialog" header="Neuer Benutzer" resizable="false" modal="true" widgetVar="newUserDlg"> <!-- Make sure that closing of the dialog also clears the input field. --> <p:ajax event="close" update=":newUserDialogForm" /> diff --git a/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml b/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml index 1c09d653..36868c32 100644 --- a/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml +++ b/Kieker.WebGUI/src/main/webapp/templates/PagesTemplate.xhtml @@ -42,7 +42,7 @@ </p:button> <c:if test="#{sec:areAnyGranted('ROLE_ADMIN')}"> <p:separator/> - <p:button styleClass="perspective-button" icon="ui-icon-userManagement" value="User Management" outcome="userManagement" disabled="#{pagename == 'userManagement'}" /> + <p:button styleClass="perspective-button" icon="ui-icon-userManagement" value="#{localizedMessages.userManagement}" outcome="userManagement" disabled="#{pagename == 'userManagement'}" /> </c:if> </p:toolbarGroup> </p:toolbar> -- GitLab