diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java index f28ed6708a28be0dcaea7e56cee9d7f15d9b7627..49bbe49271fa77b98117e941a9c7e7e8f705dd43 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java @@ -28,10 +28,10 @@ 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.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; +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 @@ -50,7 +50,7 @@ public final class ProjectsBean { private final List<String> projects = Collections.synchronizedList(new ArrayList<String>()); - private IProjectManager projectManagerFacade; + private IProjectService projectService; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> @@ -60,13 +60,13 @@ public final class ProjectsBean { } /** - * The Setter for the property {@link ProjectsBean#projectManagerFacade}. <b>Do not use this method. This property is Spring managed.</b> + * The Setter for the property {@link ProjectsBean#projectService}. <b>Do not use this method. This property is Spring managed.</b> * - * @param projectManagerFacade + * @param projectService * The new value for the property. */ - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; + public void setProjectService(final IProjectService projectService) { + this.projectService = projectService; } /** @@ -74,7 +74,7 @@ public final class ProjectsBean { */ protected void initialize() { // Load a list with all available projects on the FS - this.projects.addAll(this.projectManagerFacade.listAllProjects()); + this.projects.addAll(this.projectService.listAllProjects()); } /** @@ -93,7 +93,7 @@ public final class ProjectsBean { public void addProject(final String project, final CurrentProjectOverviewBean currentProjectOverviewBean) { try { // Try and use the FS-Manager to create the project atomically. - this.projectManagerFacade.addProject(project); + this.projectService.addProject(project); // 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 +126,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 +158,7 @@ public final class ProjectsBean { */ public MIProject openProject(final String project) throws ProjectLoadException { try { - return this.projectManagerFacade.openProject(project); + return this.projectService.openProject(project); } 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,7 +179,7 @@ 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) { @@ -211,7 +211,7 @@ 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; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java index 23c42a308deadb77bed3eabf9abe7cbb5d354f54..d86ed59fcd0486838829028844d2a182c8e05762 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/NewUserBean.java @@ -19,7 +19,7 @@ package kieker.webgui.beans.request; import java.util.ArrayList; import java.util.List; -import kieker.webgui.common.Role; +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 diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java index 4462c676781c60972e7853fbbe6837aab0904fc4..b438bf9431f4c06973757c4ff04406cf2fed1bb9 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java @@ -53,12 +53,12 @@ import kieker.webgui.beans.application.GlobalPropertiesBean; import kieker.webgui.beans.application.ProjectsBean; import kieker.webgui.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.service.IProjectService; import org.primefaces.context.RequestContext; import org.primefaces.event.FileUploadEvent; @@ -132,7 +132,7 @@ 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; + private IProjectService projectService; private ProjectsBean projectsBean; private CurrentAnalysisEditorGraphBean currentAnalysisEditorGraphBean; private UserBean userBean; @@ -146,13 +146,13 @@ public final class CurrentAnalysisEditorBean { } /** - * Setter for the attribute {@link CurrentAnalysisEditorBean#projectManagerFacade}. + * Setter for the attribute {@link CurrentAnalysisEditorBean#projectService}. * - * @param projectManagerFacade + * @param projectService * The new value of the attribute. */ - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; + public void setProjectService(final IProjectService projectService) { + this.projectService = projectService; } /** @@ -298,8 +298,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, this.projectName, this.classLoader, this.classAndMethodContainer), + this.projectService.getAllRepositoriesWithinLib(dependency, this.projectName, this.classLoader, this.classAndMethodContainer)); } /** @@ -310,8 +310,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 +369,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(this.projectName); // 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 +395,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(this.projectName); // NOPMD (ClassLoader) } catch (final NullPointerException ex) { throw new ProjectLoadException("Invalid class loader.", ex); } catch (final IOException ex) { @@ -669,7 +669,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, this.projectName); 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 +709,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(this.projectName); result.add(0, "Kieker"); return result; @@ -760,7 +760,7 @@ public final class CurrentAnalysisEditorBean { public void saveProject(final boolean overwriteNewerProject) { synchronized (this) { try { - this.projectManagerFacade.saveProject(this.projectName, this.project, this.timeStamp, overwriteNewerProject); + this.projectService.saveProject(this.projectName, this.project, this.timeStamp, overwriteNewerProject); 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/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java index 529e1d84566348ec07903c811ee4908796fe548c..9367932e9dd0324381362cdb343134f1f1141517 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java @@ -28,9 +28,9 @@ import kieker.common.logging.LogFactory; import kieker.webgui.beans.application.GlobalPropertiesBean; import kieker.webgui.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.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 @@ -43,7 +43,7 @@ import kieker.webgui.common.exception.ProjectNotExistingException; public final class CurrentCockpitBean { private static final Log LOG = LogFactory.getLog(CurrentCockpitBean.class); - private IProjectManager projectManagerFacade; + private IProjectService projectService; private String projectName; private MIProject project; private MIView activeView; @@ -68,8 +68,8 @@ public final class CurrentCockpitBean { } } - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; + public void setProjectService(final IProjectService projectService) { + this.projectService = projectService; } /** @@ -122,7 +122,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(this.projectName); // NOPMD (ClassLoader) this.classAndMethodContainer = new ClassAndMethodContainer(classLoader); } } @@ -163,7 +163,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/beans/view/CurrentCockpitEditorBean.java index 68fc91ebf3a247e6a203ba1bc8a6cca400c27d9d..18b5fee8d5be0c686cbbe009e97f9dcf84ca9308 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java @@ -43,10 +43,10 @@ import kieker.common.logging.LogFactory; import kieker.webgui.beans.application.GlobalPropertiesBean; import kieker.webgui.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.service.IProjectService; import org.primefaces.component.dashboard.Dashboard; import org.primefaces.component.panel.Panel; @@ -70,7 +70,7 @@ public final class CurrentCockpitEditorBean { private static final Log LOG = LogFactory.getLog(CurrentCockpitEditorBean.class); private final MIAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); - private IProjectManager projectManagerFacade; + private IProjectService projectService; private ClassAndMethodContainer classAndMethodContainer; private long timeStamp; @@ -92,13 +92,13 @@ public final class CurrentCockpitEditorBean { } /** - * Setter for the property {@link CurrentCockpitEditorBean#projectManagerFacade}. + * Setter for the property {@link CurrentCockpitEditorBean#projectService}. * - * @param projectManagerFacade + * @param projectService * The new value of the property. */ - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; + public void setProjectService(final IProjectService projectService) { + this.projectService = projectService; } private void createDashboard() { @@ -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(this.projectName); // NOPMD (ClassLoader) } catch (final NullPointerException ex) { throw new ProjectLoadException("Invalid class loader.", ex); } catch (final IOException ex) { @@ -314,7 +314,7 @@ public final class CurrentCockpitEditorBean { public void saveProject(final boolean overwriteNewerProject) { synchronized (this) { try { - this.projectManagerFacade.saveProject(this.projectName, this.project, this.timeStamp, overwriteNewerProject); + this.projectService.saveProject(this.projectName, this.project, this.timeStamp, overwriteNewerProject); 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/beans/view/CurrentControllerBean.java index 5c62d286d25a5ab59f6fc8d3c453e45c9a8fa710..b9301ad137a20fbb2247809bd28109b62acaee0c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java @@ -29,10 +29,10 @@ 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.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.service.IProjectService; /** * /** @@ -45,7 +45,7 @@ public final class CurrentControllerBean { private static final Log LOG = LogFactory.getLog(CurrentControllerBean.class); - private IProjectManager projectManagerFacade; + private IProjectService projectService; private final List<String> logEntries = new ArrayList<String>(); private String projectName; private ProjectsBean projectsBean; @@ -66,8 +66,8 @@ public final class CurrentControllerBean { return this.projectsBean; } - public void setProjectManagerFacade(final IProjectManager projectManagerFacade) { - this.projectManagerFacade = projectManagerFacade; + public void setProjectService(final IProjectService projectService) { + this.projectService = projectService; } /** @@ -111,7 +111,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 +129,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 +147,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 +171,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 +190,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 +210,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 +230,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 +250,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 +270,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 +289,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/CurrentUserManagementBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java index f044ba0a8c135f6292fbecd95a8c2b0260d1b6ed..44cff58d35d152a4873063a9bad494467bbf95da 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentUserManagementBean.java @@ -20,8 +20,8 @@ import java.util.ArrayList; import java.util.List; import kieker.webgui.common.IUserManager; -import kieker.webgui.common.Role; -import kieker.webgui.common.User; +import kieker.webgui.domain.User; +import kieker.webgui.domain.User.Role; /** * @author Nils Christian Ehmke @@ -64,7 +64,7 @@ public final class CurrentUserManagementBean { public void addUser(final String username, final String password, final List<Role> roles) { this.userManagerFacade.addUser(username, password, roles); // TODO Check that the op was successful before adding the user to our list - this.users.add(new User(username, roles, true)); + this.users.add(new User(username, null, roles, true)); } /** diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java index c8266c2b5596321638cdc6468ac09efa16cbc888..827e68580e90ff9628d55d5debb18de8f4db21c4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/IUserManager.java @@ -20,6 +20,9 @@ import java.util.List; import org.springframework.security.access.prepost.PreAuthorize; +import kieker.webgui.domain.User; +import kieker.webgui.domain.User.Role; + public interface IUserManager { @PreAuthorize("hasRole('ROLE_ADMIN')") diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java index 2ddb4906432cea409f9faa3a5fa4c0bb80948b0c..2168bc317864ca3974e485cccaadaf097caa3ade 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/converter/RoleStringConverter.java @@ -21,7 +21,7 @@ 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/common/exception/DataAccessException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java new file mode 100644 index 0000000000000000000000000000000000000000..5905cd560489fb7339e052e6da77de4e981212bc --- /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; + +/** + * @author Nils Christian Ehmke + */ +public final class DataAccessException extends AbstractKiekerWebGUIException { + + 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/impl/UserManagerImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerImpl.java index 8054f581de48033851ad62fa9243860caec6cce8..d737a4b39948d8dd5b841f440bed651612e9171d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/impl/UserManagerImpl.java @@ -32,8 +32,8 @@ import org.springframework.security.access.prepost.PreAuthorize; 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; +import kieker.webgui.domain.User; +import kieker.webgui.domain.User.Role; public class UserManagerImpl implements IUserManager { @@ -152,7 +152,7 @@ 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, null, roles, enabled)); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java index 6d03d91604565f28818a7c880cf38a53f2f2277d..11c315314cb410e3da824647ffc154ed5effa20a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java @@ -25,6 +25,7 @@ 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, @@ -39,7 +40,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,8 +49,13 @@ public final class ACManager { // No code necessary. } - public void setFsManager(final FSManager fsManager) { - this.fsManager = fsManager; + /** + * The setter for the property {@link ACManager#projectDAO}. <b>Do not use this method. This property is Spring managed.</b> + * + * @param projectDAO + */ + public void setProjectDAO(final IProjectDAO projectDAO) { + this.projectDAO = projectDAO; } /** @@ -73,7 +79,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/domain/User.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java new file mode 100644 index 0000000000000000000000000000000000000000..5056f1c20e996647ac7b32f97e58caa16c3959d5 --- /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.roles = roles; + this.enabled = enabled; + this.password = password; + } + + /** + * 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/domain/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..3931eafb0ca213a61d8263c05774ad757a5ece35 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java @@ -0,0 +1,20 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * @author Nils Christian Ehmke + */ +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 0000000000000000000000000000000000000000..0453da31f092c68766448f9bd4104d7e8e63a448 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java @@ -0,0 +1,242 @@ +/*************************************************************************** + * 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.analysis.model.analysisMetaModel.MIProject; +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 org.primefaces.model.UploadedFile; + +/** + * @author Nils Christian Ehmke + */ +// FIXME @Transactional doesn't work yet +public interface IProjectDAO { + + /** + * 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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract void addProject(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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract void copyProject(String originalProjectName, 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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract MIProject openProject(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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract Object openProject(String projectName, 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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract void saveProject(String projectName, MIProject project, long timeStamp, 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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract long getCurrTimeStamp(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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract void uploadLibrary(UploadedFile file, 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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract ClassLoader getClassLoader(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. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract List<String> listAllLibraries(String projectName) throws ProjectNotExistingException; + + /** + * This method lists all available projects on the file system. + * + * @return A list containing all available project names. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract Collection<String> listAllProjects(); + + /** + * This method can be used to deliver the fully qualified URL of a given dependency for a given project. + * + * @param lib + * The library whose URL should be delivered. + * @param project + * The corresponding project of the library. + * @return The URL to the given library if everything went well. + * @throws MalformedURLException + * If the URL is for some reason invalid. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract URL getURL(MIDependency lib, String project) throws MalformedURLException; + + /** + * Delivers the {@link URL}-element pointing to the kieker library. + * + * @return The kieker library. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract URL getKiekerURL(); + + /** + * Delivers the kax-file for the given project. + * + * @param projectName + * The name of the project. + * @return The kax-file of the project. + */ + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public abstract File getProjectFile(String projectName); + +} 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 0000000000000000000000000000000000000000..f4d6748e8545dbdf1796c3dade51d23b2f74c9cd --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java @@ -0,0 +1,50 @@ +/*************************************************************************** + * 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.domain.User; +import kieker.webgui.common.exception.DataAccessException; + +/** + * + * @author Nils Christian Ehmke + */ +// FIXME @Transactional doesn't work yet +public interface IUserDAO { + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void addUser(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void editUser(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public void deleteUser(final User user) throws DataAccessException; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @Transactional + public List<User> getUsers() throws DataAccessException; + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..6c49c87dc67fa8262abb6b727e4e8f616f6c9d80 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java @@ -0,0 +1,170 @@ +/*************************************************************************** + * 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.impl; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import javax.sql.DataSource; + +import org.springframework.security.access.prepost.PreAuthorize; + +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; +import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.User; +import kieker.webgui.domain.User.Role; +import kieker.webgui.persistence.IUserDAO; + +/** + * + * @author Nils Christian Ehmke + */ +public class DerbyUserDAOImpl implements IUserDAO { + + private static final Log LOG = LogFactory.getLog(DerbyUserDAOImpl.class); + private DataSource dataSource; + private Connection connection; + + public void initialize() throws Exception { + this.connection = this.dataSource.getConnection(); + } + + public void destroy() throws Exception { + this.connection.close(); + } + + /** + * Setter for the property {@link DerbyUserDAO#dataSource}. + * + * @param dataSource + * The new value of the property. + */ + public void setDataSource(final DataSource dataSource) { + this.dataSource = dataSource; + } + + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + 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 (?, ?, ?)"); + roleCmd = this.connection.prepareStatement("INSERT INTO Userroles (name, role) VALUES (?, ?)"); + + userCmd.setString(1, user.getName()); + userCmd.setString(2, user.getPassword()); + userCmd.setBoolean(3, user.isEnabled()); + userCmd.execute(); + + roleCmd.setString(1, user.getName()); + for (final Role role : user.getRoles()) { + roleCmd.setInt(2, role.getID()); + roleCmd.execute(); + } + } catch (final SQLException ex) { + throw new DataAccessException("Could not add user to the database.", ex); + } finally { + if (userCmd != null) { + try { + userCmd.close(); + } catch (final SQLException ex) { + // No need to inform the calling method + DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); + } + } + if (roleCmd != null) { + try { + roleCmd.close(); + } catch (final SQLException ex) { + // No need to inform the calling method + DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); + } + } + } + } + + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void deleteUser(final User user) throws DataAccessException { + // TODO Auto-generated method stub + } + + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public void editUser(final User user) throws DataAccessException { + // TODO Auto-generated method stub + } + + @Override + @PreAuthorize("hasRole('ROLE_ADMIN')") + public List<User> getUsers() throws DataAccessException { + // FIXME Users without roles + final List<User> result = new ArrayList<User>(); + ResultSet queryResult = null; + + try { + final Map<String, User> tempMap = new TreeMap<String, User>(); + + final PreparedStatement getQuery = this.connection + .prepareStatement("select u.name, ur.role, u.enabled from KIEKERUser u, Userroles ur where u.name=ur.name"); + + // Run through all results + queryResult = getQuery.executeQuery(); + while (queryResult.next()) { + // Get both the username and the role from the current entry + final String username = queryResult.getString(1); + final int roleID = queryResult.getInt(2); + final Role role = Role.fromID(roleID); + final boolean enabled = queryResult.getBoolean(3); + + // If the user doesn't exist in our map yet, add him. + // In each case we add the role to the user + if (tempMap.containsKey(username)) { + tempMap.get(username).getRoles().add(role); + } else { + final List<Role> roles = new ArrayList<Role>(); + roles.add(role); + tempMap.put(username, new User(username, null, roles, enabled)); + } + } + + // Now convert the map to the list + result.addAll(tempMap.values()); + } catch (final SQLException ex) { + throw new DataAccessException("Could not receive user list.", ex); + } finally { + try { + if (queryResult != null) { + queryResult.close(); + } + } catch (final SQLException ex) { + // No need to inform the calling method + DerbyUserDAOImpl.LOG.error("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 67% 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 d5716a93c928c82251a11ec714552e74104e9442..c7a475743dd43c919e28b4c28d996bde9cdee5f9 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; @@ -46,19 +46,16 @@ 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.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. - * * @author Nils Christian Ehmke */ -public final class FSManager { +public class FSProjectDAOImpl implements IProjectDAO { - 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"; @@ -77,7 +74,7 @@ public final class FSManager { /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ - public FSManager() { + public FSProjectDAOImpl() { // no code necessary } @@ -85,28 +82,23 @@ public final class FSManager { * 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() { + public void initialize() { // Check for our root-directory and create it if necessary - final File rootDir = new File(FSManager.ROOT_DIRECTORY); + final File rootDir = new File(FSProjectDAOImpl.ROOT_DIRECTORY); if (!rootDir.exists()) { final boolean result = rootDir.mkdir(); if (!result) { - FSManager.LOG.error("Could not create root directory."); + FSProjectDAOImpl.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. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#addProject(java.lang.String) */ + @Override public void addProject(final String projectName) throws ProjectAlreadyExistingException, IOException { // Assemble all necessary paths and files for the given project final File projectDir = this.assembleProjectDir(projectName); @@ -146,21 +138,12 @@ public final class FSManager { } } - /** - * 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. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#copyProject(java.lang.String, java.lang.String) */ + @Override public void copyProject(final String originalProjectName, final String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, IOException { // Get the necessary paths @@ -205,17 +188,12 @@ public final class FSManager { } } - /** - * This method loads the kax-file for the given project name and delivers an initializes instance of {@link MIProject}. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#openProject(java.lang.String) */ + @Override public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -229,21 +207,12 @@ public final class FSManager { } } - /** - * 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. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#openProject(java.lang.String, kieker.webgui.common.ClassAndMethodContainer) */ + @Override public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -260,26 +229,12 @@ public final class FSManager { } } - /** - * 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. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#saveProject(java.lang.String, kieker.analysis.model.analysisMetaModel.MIProject, long, boolean) */ + @Override public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject) throws ProjectNotExistingException, IOException, NewerProjectException { // Check whether the project exists @@ -297,15 +252,12 @@ public final class FSManager { AnalysisController.saveToFile(this.assembleKaxFile(projectName), project); } - /** - * Delivers the current time stamp of the given project. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#getCurrTimeStamp(java.lang.String) */ + @Override public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -314,20 +266,12 @@ public final class FSManager { return this.assembleKaxFile(projectName).lastModified(); } - /** - * This method tries to upload a dependency to the given project. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#uploadLibrary(org.primefaces.model.UploadedFile, java.lang.String) */ + @Override public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException, LibraryAlreadyExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -350,7 +294,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. @@ -383,17 +327,12 @@ public final class FSManager { } } - /** - * This method delivers a class loader containing the currently available libraries of the given project. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#getClassLoader(java.lang.String) */ + @Override public ClassLoader getClassLoader(final String projectName) throws ProjectNotExistingException, IOException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -405,11 +344,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) { @@ -427,15 +366,12 @@ public final class FSManager { return AccessController.doPrivileged(action); } - /** - * This method lists all available libraries of the given project. + /* + * (non-Javadoc) * - * @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. + * @see kieker.webgui.persistence.IProjectDAO#listAllLibraries(java.lang.String) */ + @Override public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -448,7 +384,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()); } } @@ -457,16 +393,17 @@ public final class FSManager { return result; } - /** - * This method lists all available projects on the file system. + /* + * (non-Javadoc) * - * @return A list containing all available project names. + * @see kieker.webgui.persistence.IProjectDAO#listAllProjects() */ + @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 +442,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 +450,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 +458,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 +484,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; } @@ -564,19 +501,14 @@ public final class FSManager { return this.assembleKaxFile(projectName).exists(); } - /** - * This method can be used to deliver the fully qualified URL of a given dependency for a given project. + /* + * (non-Javadoc) * - * @param lib - * The library whose URL should be delivered. - * @param project - * The corresponding project of the library. - * @return The URL to the given library if everything went well. - * @throws MalformedURLException - * If the URL is for some reason invalid. + * @see kieker.webgui.persistence.IProjectDAO#getURL(kieker.analysis.model.analysisMetaModel.MIDependency, java.lang.String) */ + @Override 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 + final File file = new File(FSProjectDAOImpl.ROOT_DIRECTORY + File.separator + project + File.separator + FSProjectDAOImpl.LIB_DIRECTORY + File.separator + lib.getFilePath()); return file.toURL(); } @@ -589,7 +521,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 +532,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,25 +543,25 @@ 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); } - /** - * Delivers the {@link URL}-element pointing to the kieker library. + /* + * (non-Javadoc) * - * @return The kieker library. + * @see kieker.webgui.persistence.IProjectDAO#getKiekerURL() */ + @Override public URL getKiekerURL() { - return Thread.currentThread().getContextClassLoader().getResource(FSManager.KIEKER_LIB); + return Thread.currentThread().getContextClassLoader().getResource(FSProjectDAOImpl.KIEKER_LIB); } - /** - * Delivers the kax-file for the given project. + /* + * (non-Javadoc) * - * @param projectName - * The name of the project. - * @return The kax-file of the project. + * @see kieker.webgui.persistence.IProjectDAO#getProjectFile(java.lang.String) */ + @Override public File getProjectFile(final String projectName) { return this.assembleKaxFile(projectName); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java similarity index 99% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java index d7e68c1172ce855721d4d038407797198987a1fa..92ca6832c3913d5a03a9096ef755412e49fb9add 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IProjectManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.service; import java.io.IOException; import java.util.Collection; @@ -25,6 +25,7 @@ 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.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; @@ -43,7 +44,7 @@ import org.primefaces.model.UploadedFile; * * @author Nils Christian Ehmke */ -public interface IProjectManager { +public interface IProjectService { /** * 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 diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/User.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/User.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java index 784eaf26d3a0c875e8a42af2952ad7b6305c571f..82f4dbf94b75612526cdd284fefdd4522ac0ecdb 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/User.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java @@ -13,34 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ +package kieker.webgui.service; -package kieker.webgui.common; +/** + * @author Nils Christian Ehmke + */ +public interface IUserService { -import java.util.List; - -public class User { - - private final String name; - private final List<Role> roles; - private final boolean enabled; - - public User(final String name, final List<Role> roles, final boolean enabled) { - this.name = name; - this.roles = roles; - this.enabled = enabled; - } - - public String getName() { - return this.name; - } - - public List<Role> getRoles() { - return this.roles; - } - - public boolean isEnabled() { - return enabled; - } - - } 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 84% 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 497457ca84fb6f4a3dfb4f5d54933483d9c48345..9b3b79470afe5df7297637fb3dd8786514da4930 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; @@ -28,7 +28,6 @@ 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; @@ -38,8 +37,9 @@ 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.persistence.IProjectDAO; +import kieker.webgui.service.IProjectService; import org.primefaces.model.UploadedFile; @@ -48,23 +48,23 @@ import org.primefaces.model.UploadedFile; * * @author Nils Christian Ehmke */ -public final class ProjectManagerImpl implements IProjectManager { +public final class ProjectServiceImpl implements IProjectService { private final ConcurrentHashMap<String, Object> fileSystemLocks = new ConcurrentHashMap<String, Object>(); private final ConcurrentHashMap<String, Object> analysesLocks = new ConcurrentHashMap<String, Object>(); private ACManager acManager; - private FSManager fsManager; + private IProjectDAO projectDAO; private PluginFinder pluginFinder; /** * 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> + * The setter for the property {@link ProjectServiceImplImpl#acManager}. <b>Do not use this method. This property is Spring managed.</b> * * @param acManager */ @@ -73,16 +73,16 @@ public final class ProjectManagerImpl implements IProjectManager { } /** - * The setter for the property {@link ProjectManagerImpl#fsManager}. <b>Do not use this method. This property is Spring managed.</b> + * The setter for the property {@link ProjectServiceImplImpl#projectDAO}. <b>Do not use this method. This property is Spring managed.</b> * - * @param fsManager + * @param projectDAO */ - public void setFsManager(final FSManager fsManager) { - this.fsManager = fsManager; + public void setProjectDAO(final IProjectDAO projectDAO) { + this.projectDAO = projectDAO; } /** - * The setter for the property {@link ProjectManagerImpl#pluginFinder}. <b>Do not use this method. This property is Spring managed.</b> + * The setter for the property {@link ProjectServiceImplImpl#pluginFinder}. <b>Do not use this method. This property is Spring managed.</b> * * @param pluginFinder */ @@ -95,7 +95,7 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - this.fsManager.addProject(projectName); + this.projectDAO.addProject(projectName); } } @@ -121,7 +121,7 @@ public final class ProjectManagerImpl implements IProjectManager { synchronized (lockFst) { synchronized (lockSnd) { - this.fsManager.copyProject(originalProjectName, newProjectName); + this.projectDAO.copyProject(originalProjectName, newProjectName); } } } @@ -131,7 +131,7 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.openProject(projectName); + return this.projectDAO.openProject(projectName); } } @@ -140,7 +140,7 @@ 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); } } @@ -150,7 +150,7 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - this.fsManager.saveProject(projectName, project, timeStamp, overwriteNewerProject); + this.projectDAO.saveProject(projectName, project, timeStamp, overwriteNewerProject); } } @@ -159,7 +159,7 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.getCurrTimeStamp(projectName); + return this.projectDAO.getCurrTimeStamp(projectName); } } @@ -168,7 +168,7 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - this.fsManager.uploadLibrary(file, projectName); + this.projectDAO.uploadLibrary(file, projectName); } } @@ -177,7 +177,7 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.getClassLoader(projectName); // NOPMD (ClassLoader) + return this.projectDAO.getClassLoader(projectName); // NOPMD (ClassLoader) } } @@ -188,7 +188,7 @@ public final class ProjectManagerImpl implements IProjectManager { synchronized (projectLock) { try { - return this.pluginFinder.getAllRepositoriesWithinJar(this.fsManager.getURL(lib, projectName), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllRepositoriesWithinJar(this.projectDAO.getURL(lib, projectName), classLoader, classAndMethodContainer); } catch (final MalformedURLException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); } @@ -202,7 +202,7 @@ public final class ProjectManagerImpl implements IProjectManager { synchronized (projectLock) { try { - return this.pluginFinder.getAllPluginsWithinJar(this.fsManager.getURL(lib, projectName), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllPluginsWithinJar(this.projectDAO.getURL(lib, projectName), classLoader, classAndMethodContainer); } catch (final MalformedURLException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); } @@ -213,7 +213,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 +224,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); @@ -236,13 +236,13 @@ public final class ProjectManagerImpl implements IProjectManager { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.fsManager.listAllLibraries(projectName); + return this.projectDAO.listAllLibraries(projectName); } } @Override public Collection<String> listAllProjects() { - return this.fsManager.listAllProjects(); + return this.projectDAO.listAllProjects(); } @Override diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java similarity index 71% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java index 8819d3cb098432988fcc1fcfee2ee2a4d7a5eec3..a50db3035582d9d0e4c50a79f4d9d2f80fb38693 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Role.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java @@ -13,28 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ +package kieker.webgui.service.impl; -package kieker.webgui.common; +import kieker.webgui.service.IUserService; -public enum Role { +/** + * @author Nils Christian Ehmke + */ +public class UserServiceImpl implements IUserService { - ROLE_USER(1), ROLE_ADMIN(2); - - private int id; - - private Role(final int id) { - this.id = id; + /** + * + */ + public UserServiceImpl() { + // TODO Auto-generated constructor stub } - 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/service/impl/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..87c267d4af0b95ceab05df8d051e82f9b424fc5f --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java @@ -0,0 +1,20 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * @author Nils Christian Ehmke + */ +package kieker.webgui.service.impl; \ 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 0000000000000000000000000000000000000000..ee1129d260b3fc85d5b1b02ee6301e07f60c41f6 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java @@ -0,0 +1,20 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * @author Nils Christian Ehmke + */ +package kieker.webgui.service; \ 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 dfe8bd88d5c9bc511342610cf966233d809a6012..a612d99579f2e316bce4fb2e1a5d10d93f032d21 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 @@ -6,18 +6,18 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> <!-- The singleton scoped beans. --> + <bean id="projectDAO" class="kieker.webgui.persistence.impl.FSProjectDAOImpl" init-method="initialize"/> <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" /> + <bean id="projectService" class="kieker.webgui.service.impl.ProjectServiceImpl"> + <property name="projectDAO" ref="projectDAO" /> <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 id="acManager" class="kieker.webgui.common.util.ACManager"> + <property name="projectDAO" ref="projectDAO" /> + </bean> + <bean id="projectsBean" lazy-init="true" class="kieker.webgui.beans.application.ProjectsBean" init-method="initialize"> + <property name="projectService" ref="projectService" /> </bean> <bean id="globalPropertiesBean" class="kieker.webgui.beans.application.GlobalPropertiesBean"> <property name="themeCookieName" value="${kieker.webgui.config.lookAndFeel.cookieName}"/> @@ -69,6 +69,9 @@ <bean destroy-method="destroy" init-method="initialize" id="userManager" class="kieker.webgui.common.impl.UserManagerImpl"> <property name="dataSource" ref="userDataSource" /> </bean> + <bean id="userDAO" class="kieker.webgui.persistence.impl.DerbyUserDAOImpl" init-method="initialize" destroy-method="destroy"> + <property name="dataSource" ref="userDataSource"/> + </bean> <!-- The session scoped beans. --> <bean id="userBean" init-method="initialize" class="kieker.webgui.beans.session.UserBean" scope="session"> @@ -78,7 +81,7 @@ <!-- 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="projectService" ref="projectService" /> <property name="projectsBean" ref="projectsBean" /> <property name="currentAnalysisEditorGraphBean" ref="currentAnalysisEditorGraphBean" /> <property name="userBean" ref="userBean" /> @@ -86,22 +89,22 @@ <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" /> + <property name="projectService" ref="projectService" /> </bean> <bean id="currentCockpitEditorBean" class="kieker.webgui.beans.view.CurrentCockpitEditorBean" scope="view"> <property name="globalPropertiesBean" ref="globalPropertiesBean"/> - <property name="projectManagerFacade" ref="projectManager" /> + <property name="projectService" ref="projectService" /> <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" /> + <property name="projectService" ref="projectService" /> </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"/> + <property name="userManagerFacade" ref="userManager"/> </bean> <!-- The request scoped beans. --> @@ -109,6 +112,6 @@ <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"/> </beans>