diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java index f92ed7efb3d360eb8b2b0ef6d269f06bdd5a8963..3566d8eb556f9de2977a234dc61750c667d79ebb 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java @@ -16,9 +16,6 @@ package kieker.webgui.common; import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import kieker.analysis.AnalysisController; import kieker.analysis.AnalysisController.AnalysisControllerWithMapping; @@ -37,10 +34,8 @@ import kieker.analysis.plugin.filter.AbstractFilterPlugin; import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.analysis.repository.annotation.Repository; -import kieker.common.logging.Log; -import kieker.common.logging.LogFactory; import kieker.common.logging.LogImplWebguiLogging; -import kieker.webgui.common.exception.ProjectLoadException; +import kieker.webgui.common.exception.ReflectionException; /** * The {@link ClassAndMethodContainer} is a container which contains - as the name already tells - various classes and methods. To be more precisely, it uses a @@ -56,9 +51,6 @@ import kieker.webgui.common.exception.ProjectLoadException; */ public class ClassAndMethodContainer { - private static final Log LOG = LogFactory.getLog(ClassAndMethodContainer.class); - private static final String MSG_LOAD_EXCEPTION = "An error occured while loading the classes and methods."; - private Class<?> logImplWebguiLoggingClass; private Class<?> analysisControllerWithMappingClass; private Class<?> analysisControllerClass; @@ -67,6 +59,10 @@ public class ClassAndMethodContainer { private Class<?> abstractPluginClass; private Class<?> abstractFilterPluginClass; private Class<?> abstractReaderPluginClass; + private Class<?> imageClass; + private Class<?> plainTextClass; + private Class<?> htmlTextClass; + private Class<? extends Annotation> pluginAnnotationClass; private Class<? extends Annotation> repositoryAnnotationClass; private Class<? extends Annotation> propertyAnnotationClass; @@ -74,88 +70,56 @@ public class ClassAndMethodContainer { private Class<? extends Annotation> inputPortAnnotationClass; private Class<? extends Annotation> repositoryPortAnnotationClass; private Class<? extends Annotation> displayAnnotationClass; - private Class<?> imageClass; - private Class<?> plainTextClass; - private Class<?> htmlTextClass; - private Method repositoryConfigurationMethod; - private Method analysisControllerGetState; - private Method logImplWebguiLoggingClassGetEntriesMethod; - - private Constructor<?> analysisControllerThreadConstructor; /** * Creates a new instance of this class, using the given class loader. * * @param classLoader * The class loader which will be used to load all classes and determine their methods. - * @throws ProjectLoadException + * + * @throws ReflectionException * If one or more of the classes or methods for this container could not be found. */ - public ClassAndMethodContainer(final ClassLoader classLoader) throws ProjectLoadException { + @SuppressWarnings("unchecked") + public ClassAndMethodContainer(final ClassLoader classLoader) throws ReflectionException { try { - this.loadClasses(classLoader); - this.loadMethods(); - this.loadConstructors(); + // For the first: Use the classloader the load all classes we will need. + this.logImplWebguiLoggingClass = classLoader.loadClass(LogImplWebguiLogging.class.getName()); + + this.analysisControllerWithMappingClass = classLoader.loadClass(AnalysisControllerWithMapping.class.getName()); + + this.analysisControllerClass = classLoader.loadClass(AnalysisController.class.getName()); + this.analysisControllerThreadClass = classLoader.loadClass(AnalysisControllerThread.class.getName()); + this.abstractFilterPluginClass = classLoader.loadClass(AbstractFilterPlugin.class.getName()); + this.abstractReaderPluginClass = classLoader.loadClass(AbstractReaderPlugin.class.getName()); + this.abstractRepositoryClass = classLoader.loadClass(AbstractRepository.class.getName()); + this.abstractPluginClass = classLoader.loadClass(AbstractPlugin.class.getName()); + this.htmlTextClass = classLoader.loadClass(HtmlText.class.getName()); + this.plainTextClass = classLoader.loadClass(PlainText.class.getName()); + this.imageClass = classLoader.loadClass(Image.class.getName()); + + // Now we load the more specific annotation classes + this.pluginAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Plugin.class.getName()); + this.repositoryAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Repository.class.getName()); + this.propertyAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Property.class.getName()); + this.outputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(OutputPort.class.getName()); + this.inputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(InputPort.class.getName()); + this.repositoryPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(RepositoryPort.class.getName()); + this.displayAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Display.class.getName()); } catch (final ClassNotFoundException ex) { // Something went wrong. We can do nothing except throwing an exception - ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); - throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); - } catch (final NoSuchMethodException ex) { - // Something went wrong. We can do nothing except throwing an exception - ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); - throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); + throw new ReflectionException("An error occured while loading the classes and methods.", ex); } catch (final SecurityException ex) { // Something went wrong. We can do nothing except throwing an exception - ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); - throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); + throw new ReflectionException("An error occured while loading the classes and methods.", ex); } catch (final ClassCastException ex) { // Something went wrong. We can do nothing except throwing an exception - ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); - throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); + throw new ReflectionException("An error occured while loading the classes and methods.", ex); } } - private void loadConstructors() throws SecurityException, NoSuchMethodException { - // Now the constructors - this.analysisControllerThreadConstructor = this.analysisControllerThreadClass.getConstructor(this.analysisControllerClass); - } - - private void loadMethods() throws SecurityException, NoSuchMethodException { - // The following part has to be done carefully: The methods will be loaded via the name - this.repositoryConfigurationMethod = this.repositoryAnnotationClass.getMethod("configuration", new Class<?>[0]); - this.analysisControllerGetState = this.analysisControllerClass.getMethod("getState", new Class<?>[0]); - this.logImplWebguiLoggingClassGetEntriesMethod = this.logImplWebguiLoggingClass.getMethod("getEntries", String.class); - } - - @SuppressWarnings("unchecked") - private void loadClasses(final ClassLoader classLoader) throws ClassNotFoundException { - // For the first: Use the classloader the load all classes we will need. - this.logImplWebguiLoggingClass = classLoader.loadClass(LogImplWebguiLogging.class.getName()); - - this.analysisControllerWithMappingClass = classLoader.loadClass(AnalysisControllerWithMapping.class.getName()); - - this.analysisControllerClass = classLoader.loadClass(AnalysisController.class.getName()); - this.analysisControllerThreadClass = classLoader.loadClass(AnalysisControllerThread.class.getName()); - this.abstractFilterPluginClass = classLoader.loadClass(AbstractFilterPlugin.class.getName()); - this.abstractReaderPluginClass = classLoader.loadClass(AbstractReaderPlugin.class.getName()); - this.abstractRepositoryClass = classLoader.loadClass(AbstractRepository.class.getName()); - this.abstractPluginClass = classLoader.loadClass(AbstractPlugin.class.getName()); - this.htmlTextClass = classLoader.loadClass(HtmlText.class.getName()); - this.plainTextClass = classLoader.loadClass(PlainText.class.getName()); - this.imageClass = classLoader.loadClass(Image.class.getName()); - - // Now we load the more specific annotation classes - this.pluginAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Plugin.class.getName()); - this.repositoryAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Repository.class.getName()); - this.propertyAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Property.class.getName()); - this.outputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(OutputPort.class.getName()); - this.inputPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(InputPort.class.getName()); - this.repositoryPortAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(RepositoryPort.class.getName()); - this.displayAnnotationClass = (Class<? extends Annotation>) classLoader.loadClass(Display.class.getName()); - } - public Class<?> getAbstractFilterPluginClass() { return this.abstractFilterPluginClass; } @@ -192,10 +156,6 @@ public class ClassAndMethodContainer { return this.displayAnnotationClass; } - public Method getRepositoryConfigurationMethod() { - return this.repositoryConfigurationMethod; - } - public Class<?> getAbstractRepositoryClass() { return this.abstractRepositoryClass; } @@ -228,89 +188,8 @@ public class ClassAndMethodContainer { return this.analysisControllerThreadClass; } - public Method getAnalysisControllerGetState() { - return this.analysisControllerGetState; - } - - public Constructor<?> getAnalysisControllerThreadConstructor() { - return this.analysisControllerThreadConstructor; - } - public Class<?> getLogImplWebguiLoggingClass() { return this.logImplWebguiLoggingClass; } - public Method getLogImplWebguiLoggingClassGetEntriesMethod() { - return this.logImplWebguiLoggingClassGetEntriesMethod; - } - - /** - * This method can be used to invoke a given method with given parameters, without having to mind about the exceptions. If an exception occurs, the given default - * value will be returned. - * - * @param method - * The method to be invoked. - * @param obj - * The object on which the method will be invoked. - * @param defaultReturn - * The default return value in case of an exception. - * @param values - * The parameters for the method. - * @return The result of the invoked method if everything went well, the default value otherwise. - */ - public static Object invokeMethod(final Method method, final Object obj, final Object defaultReturn, final Object... values) { - try { - return method.invoke(obj, values); - } catch (final IllegalAccessException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection method call.", ex); - } catch (final IllegalArgumentException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection method call.", ex); - } catch (final InvocationTargetException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection method call.", ex); - } - return defaultReturn; - } - - /** - * This method can be used to invoke a given constructor with given parameters, without having to mind about the exceptions. If an exception occurs, null will be - * returned. - * - * @param constructor - * The constructor to be invoked. - * @param values - * The parameters for the method. - * @return The result of the invoked method if everything went well, null otherwise. - */ - public static Object invokeConstructor(final Constructor<?> constructor, final Object... values) { - try { - return constructor.newInstance(values); - } catch (final InstantiationException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection constructor call.", ex); - } catch (final IllegalAccessException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection constructor call.", ex); - } catch (final IllegalArgumentException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection constructor call.", ex); - } catch (final InvocationTargetException ex) { - ClassAndMethodContainer.LOG.error("An error occured during a reflection constructor call.", ex); - } - return null; - } - - /** - * This method can be used to invoke a given <b>class</b>-method with no parameters, without having to mind about the exceptions. If an exception occurs, the - * given default value will be returned. A call to this method is the same as {@link ClassAndMethodContainer#invokeMethod(Method, Object, Object, Object...)} - * with null as object. - * - * @param method - * The method to be invoked. - * @param defaultReturn - * The default return value in case of an exception. - * @param values - * The parameters for the method. - * @return The result of the invoked method if everything went well, the default value otherwise. - */ - public static Object invokeClassMethod(final Method method, final Object defaultReturn, final Object... values) { - return ClassAndMethodContainer.invokeMethod(method, null, defaultReturn, values); - } - } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java index a5799f9b26e97afd749c1acfc85b87fcfb8b21bf..28f72895daeff2459790b2e5d741d3f3f4361539 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java @@ -23,8 +23,8 @@ import kieker.common.logging.Log; import kieker.common.logging.LogFactory; /** - * The {@link EnvironmentLoaderListener} is a context listener, which will be activated during the initialization of the application. It is used to initialize some - * environment properties for the WebGUI. + * This class is a context listener, which will be activated during the initialization of the application. It is used to initialize some environment properties for + * the WebGUI. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java index c6d7014492dae6df3cdfb139465c94bf90b9c3fa..2d8b64919c086f849880d826a06062e9305e7b94 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java @@ -21,7 +21,7 @@ package kieker.webgui.common.exception; * * @author Nils Christian Ehmke */ -public abstract class AbstractKiekerWebGUIException extends RuntimeException { +public abstract class AbstractKiekerWebGUIException extends Exception { private static final long serialVersionUID = 1L; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java new file mode 100644 index 0000000000000000000000000000000000000000..00689c9edac88a31bf7617b38f5c22cca7079e55 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright 2013 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; + +/** + * This exception occurs when something goes wrong during reflection calls. + * + * @author Nils Christian Ehmke + */ +public class ReflectionException extends AbstractKiekerWebGUIException { + + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance of this class. + */ + public ReflectionException() { + super(); + } + + /** + * Creates a new instance of this class using the given parameters. + * + * @param msg + * The message used for the exception. + */ + public ReflectionException(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 ReflectionException(final String msg, final Throwable cause) { + super(msg, cause); + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java index 2b0aaa86e52e085bd7a4312f589f957d9e7cb7b3..67a550787a469084f49e7fab21b3aa05e4fb5e9c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java @@ -25,7 +25,7 @@ import kieker.webgui.domain.pluginDecorators.RepositoryDecorator; /** * This class is a container for multiple {@link ReaderDecorator}, {@link FilterDecorator} or {@link RepositoryDecorator} instances. For each of the component type * (reader, filter, repository) there is exactly one list available. This class will mostly be used to deliver a set of available components for a project. A bean - * can, for example, use the components as a prototype to copy new model instances. + * can use the components as a prototype to copy new model instances. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java new file mode 100644 index 0000000000000000000000000000000000000000..b5efd3adaeb27a5b662197d94b116ed45dd43040 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright 2013 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; + +/** + * This enum represents the available roles within the system. + * + * @author Nils Christian Ehmke + */ +public enum Role { + + /** Represents a guest within the system. */ + ROLE_GUEST(0), + /** Represents an user within the system. */ + ROLE_USER(1), + /** Represents an administrator within the system. */ + ROLE_ADMIN(2); + + private int id; + + private Role(final int id) { + this.id = id; + } + + public int getID() { + return this.id; + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java index 0e105a5d2b86117e203f6e8de5b4ba61fd058217..3c222558e7270c7ccff17e2edc78fd077fc34fdc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java @@ -78,35 +78,4 @@ public class User { public void setEnabled(final boolean enabled) { this.enabled = enabled; } - - /** - * This enum represents the available roles within this system. - * - * @author Nils Christian Ehmke - */ - public static enum Role { - - /** - * Represents a guest within the system. - */ - ROLE_GUEST(0), - /** - * Represents an user within the system. - */ - ROLE_USER(1), - /** - * Represents an admin within the system. - */ - ROLE_ADMIN(2); - - private int id; - - private Role(final int id) { - this.id = id; - } - - public int getID() { - return this.id; - } - } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java index 831ec8be711deadcffa2fd3b8a6061db629efd72..34a9e927ea5ba4b3e00211dda550ee1c7b985181 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java @@ -33,7 +33,8 @@ import org.primefaces.model.UploadedFile; import org.springframework.security.access.prepost.PreAuthorize; /** - * This is the interface for the data access object(s) which will access for example the file system to manage the available projects. + * This is the interface for the data access object(s) which will access for example the file system to manage the available projects. The implementing classes are + * responsible for suitable synchronization. * * @author Nils Christian Ehmke */ @@ -47,6 +48,7 @@ public interface IProjectDAO { * The name of the new project. * @param username * The name of the user who created the project. + * * @throws ProjectAlreadyExistingException * If a project with the same name exists already. * @throws IOException @@ -64,9 +66,11 @@ public interface IProjectDAO { * * @throws IOException * If something went wrong during the removing. + * @throws ProjectNotExistingException + * If a project with the given name does not exist. */ @PreAuthorize("hasAnyRole('User', 'Administrator')") - public abstract void removeProject(String projectName) throws IOException; + public abstract void removeProject(String projectName) throws IOException, ProjectNotExistingException; /** * This method imports an existing kax-file into the application. If the given project name does already exist, the application will not try to upload it in the @@ -78,6 +82,7 @@ public interface IProjectDAO { * The name of the user who imported the project. * @param file * The kax file to be uploaded. + * * @throws ProjectAlreadyExistingException * If a project with the same name exists already. * @throws IOException @@ -94,6 +99,7 @@ public interface IProjectDAO { * 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 @@ -110,7 +116,9 @@ public interface IProjectDAO { * * @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 @@ -128,7 +136,9 @@ public interface IProjectDAO { * 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 @@ -173,7 +183,9 @@ public interface IProjectDAO { * * @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. */ @@ -187,6 +199,7 @@ public interface IProjectDAO { * 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 @@ -202,7 +215,9 @@ public interface IProjectDAO { * The name of the project. * @param requester * The requester of the classloader. + * * @return A class loader for the given project. + * * @throws ProjectNotExistingException * If a project with the given name does not exist. * @throws IOException @@ -216,7 +231,9 @@ public interface IProjectDAO { * * @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. */ @@ -236,6 +253,7 @@ public interface IProjectDAO { * * @param projectName * The name of the project. + * * @return The kax-file of the project. */ @PreAuthorize("isAuthenticated()") @@ -248,7 +266,9 @@ public interface IProjectDAO { * The name of the project. * @param libName * The name of the library. + * * @return true if and only if the given library has been removed. + * * @throws IOException * If something went wrong during the reloading of the components. */ @@ -260,6 +280,7 @@ public interface IProjectDAO { * * @param project * The project whose components should be loaded. + * * @return An object containing the available components as model instances. */ @PreAuthorize("isAuthenticated()") diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java index 35fd8b1aaf2f4da8447b257316cdc56ff5e7aeb3..5c0e50de749e391ce9dd57c272c4ee6d1379f0f9 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IUserDAO.java @@ -25,7 +25,7 @@ import org.springframework.security.access.prepost.PreAuthorize; /** * This is the interface for the data access object(s) which will access for example a database to manage the available users. The methods within this interface are - * only accessible by administrators. + * only accessible by administrators. The implementing classes are responsible for a suitable transaction management. * * @author Nils Christian Ehmke */ @@ -35,7 +35,8 @@ public interface IUserDAO { * Adds a user to the system. * * @param user - * The domain object used to extract the necessary data to create the user. + * The domain object used to extract the necessary data to create the user. It is assumed that all fields are filled. + * * @throws DataAccessException * If it was not possible to add the user to the system. Either because a constraint was violated or because the connection to the database has * somehow been damaged. @@ -47,7 +48,8 @@ public interface IUserDAO { * Deletes a user from the system. * * @param user - * The domain object used to extract the necessary data to delete the user. + * The domain object used to extract the necessary data to delete the user. It is only necessary that the name field is filled. + * * @throws DataAccessException * If it was not possible to delete the user. Either because a constraint was violated or because the connection to the database has somehow been * damaged. @@ -59,7 +61,9 @@ public interface IUserDAO { * Edits a given user. If the password field of the given domain object is empty, the password won't be changed. If it is filled, it will be changed. * * @param user - * The domain object used to extract the necessary data to edit the user. + * The domain object used to extract the necessary data to edit the user. It is assumed that all fields are filled (except for the password field + * which is optional). + * * @throws DataAccessException * If it was not possible to edit the user. Either because a constraint was violated or because the connection to the database has somehow been * damaged. @@ -68,10 +72,11 @@ public interface IUserDAO { public void editUser(final User user) throws DataAccessException; /** - * Delivers a list containing the available users within the system. The password fields of the returned domain objects will be empty. The list is always a copy - * and can be modified at will. + * Delivers a list containing the available users within the system. The password fields of the returned domain objects will be empty. The list is always a fresh + * copy and can be modified at will. * * @return A list with the available users. + * * @throws DataAccessException * If something went wrong during the reading. This happens probably if the connection to the database has somehow been damaged. */ 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 index eb041455b39e3097e946f0cf12eed19d6296249d..ad968f9a9b0746e45919af8f98649c3f537b6d96 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java @@ -28,17 +28,18 @@ import javax.sql.DataSource; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.Role; import kieker.webgui.domain.User; -import kieker.webgui.domain.User.Role; import kieker.webgui.persistence.IUserDAO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** - * An implementation of the {@link IUserDAO} interface, which uses Apache Derby to store and manage the available users. A transaction manager is not necessary, as - * all of the used commands are atomic (except for the getUsers() method, which is read only though). + * An implementation of the {@link IUserDAO} interface, which uses Apache Derby to store and manage the available users. A transaction manager makes sure that all + * operations are atomically. * * @author Nils Christian Ehmke */ @@ -57,193 +58,145 @@ public class DerbyUserDAOImpl implements IUserDAO { // No code necessary } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IserDAO#addUser(user) - */ @Override + @Transactional public void addUser(final User user) throws DataAccessException { - final Connection connection = DataSourceUtils.getConnection(this.dataSource); - PreparedStatement userCmd = null; + final Connection connection = DataSourceUtils.getConnection(this.dataSource); // NOPMD (Auto Close) + PreparedStatement statement = null; + try { - userCmd = connection.prepareStatement("INSERT INTO Users (name, password, isGuest, isUser, isAdministrator, isEnabled) VALUES (?, ?, ?, ?, ?, ?)"); + statement = connection.prepareStatement("INSERT INTO Users (name, password, isGuest, isUser, isAdministrator, isEnabled) VALUES (?, ?, ?, ?, ?, ?)"); // Use all properties of the given object - userCmd.setString(1, user.getName()); - userCmd.setString(2, user.getPassword()); - userCmd.setBoolean(3, user.getRole() == Role.ROLE_GUEST); - userCmd.setBoolean(4, user.getRole() == Role.ROLE_USER); - userCmd.setBoolean(5, user.getRole() == Role.ROLE_ADMIN); - userCmd.setBoolean(6, user.isEnabled()); - - // Run the command - userCmd.execute(); + statement.setString(1, user.getName()); + statement.setString(2, user.getPassword()); + statement.setBoolean(3, user.getRole() == Role.ROLE_GUEST); + statement.setBoolean(4, user.getRole() == Role.ROLE_USER); + statement.setBoolean(5, user.getRole() == Role.ROLE_ADMIN); + statement.setBoolean(6, user.isEnabled()); + + statement.execute(); } catch (final SQLException ex) { - // Something went wrong. Inform the calling method. + // Something went wrong. throw new DataAccessException("Could not add user to the database.", ex); } finally { - // Try to close the statement. If that doesn't work then log it, but it is not necessary to inform the calling method. - if (userCmd != null) { + // Try to close the statement. If this is not possible then log the problem. It is not necessary to inform the calling method about a fail though. + if (statement != null) { try { - userCmd.close(); + statement.close(); } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); } } - - try { - connection.close(); - } catch (final SQLException ex) { - DerbyUserDAOImpl.LOG.error("Could not close connection.", ex); - } } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IserDAO#deleteUser(user) - */ @Override + @Transactional public void deleteUser(final User user) throws DataAccessException { - final Connection connection = DataSourceUtils.getConnection(this.dataSource); - PreparedStatement delCmd = null; + final Connection connection = DataSourceUtils.getConnection(this.dataSource); // NOPMD (Auto Close) + PreparedStatement statement = null; + try { - delCmd = connection.prepareStatement("DELETE FROM Users WHERE name=?"); + statement = connection.prepareStatement("DELETE FROM Users WHERE name=?"); - delCmd.setString(1, user.getName()); + statement.setString(1, user.getName()); - delCmd.execute(); + statement.execute(); } catch (final SQLException ex) { // Something went wrong. Inform the calling method. throw new DataAccessException("Could not delete user from the database.", ex); } finally { - // Try to close the statement. If that doesn't work then log it, but it is not necessary to inform the calling method. - if (delCmd != null) { + // Try to close the statement. If this is not possible then log the problem. It is not necessary to inform the calling method about a fail though. + if (statement != null) { try { - delCmd.close(); + statement.close(); } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); } } - - try { - connection.close(); - } catch (final SQLException ex) { - DerbyUserDAOImpl.LOG.error("Could not close connection.", ex); - } } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IserDAO#editUser(user) - */ @Override + @Transactional public void editUser(final User user) throws DataAccessException { - final Connection connection = DataSourceUtils.getConnection(this.dataSource); - PreparedStatement updateCmd = null; + final Connection connection = DataSourceUtils.getConnection(this.dataSource); // NOPMD (Auto Close) + PreparedStatement statement = null; + try { // Choose the right update command, depending on whether the password has to be changed or not if (user.getPassword() == null) { - updateCmd = connection.prepareStatement("UPDATE Users SET name=?, isGuest=?, isUser=?, isAdministrator=?, isEnabled=? WHERE name=?"); - updateCmd.setString(6, user.getName()); + statement = connection.prepareStatement("UPDATE Users SET name=?, isGuest=?, isUser=?, isAdministrator=?, isEnabled=? WHERE name=?"); + statement.setString(6, user.getName()); } else { // In this case we have to set the password as well - updateCmd = connection.prepareStatement("UPDATE Users SET name=?, isGuest=?, isUser=?, isAdministrator=?, isEnabled=?, password=? WHERE name=?"); - updateCmd.setString(6, user.getPassword()); - updateCmd.setString(7, user.getName()); + statement = connection.prepareStatement("UPDATE Users SET name=?, isGuest=?, isUser=?, isAdministrator=?, isEnabled=?, password=? WHERE name=?"); + statement.setString(6, user.getPassword()); + statement.setString(7, user.getName()); } // Set the other values - updateCmd.setString(1, user.getName()); - updateCmd.setBoolean(2, user.getRole() == Role.ROLE_GUEST); - updateCmd.setBoolean(3, user.getRole() == Role.ROLE_USER); - updateCmd.setBoolean(4, user.getRole() == Role.ROLE_ADMIN); - updateCmd.setBoolean(5, user.isEnabled()); + statement.setString(1, user.getName()); + statement.setBoolean(2, user.getRole() == Role.ROLE_GUEST); + statement.setBoolean(3, user.getRole() == Role.ROLE_USER); + statement.setBoolean(4, user.getRole() == Role.ROLE_ADMIN); + statement.setBoolean(5, user.isEnabled()); - // Run the command - updateCmd.execute(); + statement.execute(); } catch (final SQLException ex) { throw new DataAccessException("Could not update user within the database.", ex); } finally { - // Try to close the statement. If that doesn't work then log it, but it is not necessary to inform the calling method. - if (updateCmd != null) { + // Try to close the statement. If this is not possible then log the problem. It is not necessary to inform the calling method about a fail though. + if (statement != null) { try { - updateCmd.close(); + statement.close(); } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); } } - - try { - connection.close(); - } catch (final SQLException ex) { - DerbyUserDAOImpl.LOG.error("Could not close connection.", ex); - } } } - /* - * (non-Javadoc) - * - * @see List<User> kieker.webgui.persistence.getUsers() - */ @Override + @Transactional(readOnly = true) public List<User> getUsers() throws DataAccessException { - final Connection connection = DataSourceUtils.getConnection(this.dataSource); + final Connection connection = DataSourceUtils.getConnection(this.dataSource); // NOPMD (Auto Close) final List<User> result = new ArrayList<User>(); ResultSet queryResult = null; - PreparedStatement getQuery = null; + PreparedStatement statement = null; try { - getQuery = connection.prepareStatement("SELECT name, isGuest, isUser, isAdministrator, isEnabled FROM Users"); + // Get all properties from all users - except the password + statement = connection.prepareStatement("SELECT name, isGuest, isUser, isAdministrator, isEnabled FROM Users"); - queryResult = getQuery.executeQuery(); - this.queryToUsers(queryResult, result); + queryResult = statement.executeQuery(); + DerbyUserDAOImpl.queryToUsers(queryResult, result); } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not receive user list.", ex); } finally { - // Try to close the everything. If that doesn't work then log it, but it is not necessary to inform the calling method. - try { - if (queryResult != null) { + // Try to close everything. If this is not possible then log the problem. It is not necessary to inform the calling method about a fail though. + if (queryResult != null) { + try { queryResult.close(); + } catch (final SQLException ex) { + DerbyUserDAOImpl.LOG.error("Could not close query result.", ex); } - } catch (final SQLException ex) { - DerbyUserDAOImpl.LOG.error("Could not close query result.", ex); } - if (getQuery != null) { + if (statement != null) { try { - getQuery.close(); + statement.close(); } catch (final SQLException ex) { DerbyUserDAOImpl.LOG.error("Could not close prepared statement.", ex); } } - - try { - connection.close(); - } catch (final SQLException ex) { - DerbyUserDAOImpl.LOG.error("Could not close connection.", ex); - } } return result; } - /** - * Transforms the given query result into the single users. - * - * @param queryResult - * The query result. - * @param result - * The list which will be filled with users. - * @throws SQLException - * If something went wrong. - */ - private void queryToUsers(final ResultSet queryResult, final List<User> result) throws SQLException { + private static void queryToUsers(final ResultSet queryResult, final List<User> result) throws SQLException { // Run through all results while (queryResult.next()) { final String username = queryResult.getString(1); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java index 4f91e0d49699f4d22a55727c5c0a897f230d3609..5cd525e1ba180e7feaab2dd00a99e77c9646294c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java @@ -58,6 +58,7 @@ import kieker.webgui.common.ClassAndMethodContainer; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.common.exception.ReflectionException; import kieker.webgui.domain.ComponentListContainer; import kieker.webgui.domain.pluginDecorators.FilterDecorator; import kieker.webgui.domain.pluginDecorators.ReaderDecorator; @@ -74,7 +75,6 @@ import net.vidageek.mirror.dsl.Mirror; import net.vidageek.mirror.exception.MirrorException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.util.FileCopyUtils; import org.springframework.util.FileSystemUtils; @@ -104,15 +104,15 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { private static final String PROPERTY_KEY_ANALYSIS_LAYOUT = "analysis layout"; private static final String PROPERTY_KEY_COCKPIT_LAYOUT = "cockpit layout"; + private final Map<CloseableURLClassLoader, WeakReference<Object>> classLoaders = new ConcurrentHashMap<CloseableURLClassLoader, WeakReference<Object>>(); + private final Map<File, WeakReference<Object>> tempDirs = new ConcurrentHashMap<File, WeakReference<Object>>(); + private final Map<String, ComponentListContainer> availableComponents = new ConcurrentHashMap<String, ComponentListContainer>(); + @Autowired private PluginFinder pluginFinder; @Autowired private Class2ModelInstanceConverter class2ModelInstanceConverter; - private final Map<CloseableURLClassLoader, WeakReference<Object>> classLoaders = new ConcurrentHashMap<CloseableURLClassLoader, WeakReference<Object>>(); - private final Map<File, WeakReference<Object>> tempDirs = new ConcurrentHashMap<File, WeakReference<Object>>(); - private final Map<String, ComponentListContainer> availableComponents = new ConcurrentHashMap<String, ComponentListContainer>(); - /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ @@ -164,6 +164,8 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { this.availableComponents.put(project, componentList); classLoader.close(); + } catch (final ReflectionException ex) { + FSProjectDAOImpl.LOG.warn("An error occured while initializing the project '" + project + "'.", ex); } catch (final ProjectNotExistingException ex) { // Technically this should not happen. Log but ignore this exception. FSProjectDAOImpl.LOG.warn("An error occured while initializing the project '" + project + "'.", ex); @@ -206,14 +208,8 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#removeProject(java.lang.String) - */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") - public void removeProject(final String projectName) throws IOException { + public void removeProject(final String projectName) throws IOException, ProjectNotExistingException { this.checkProjectExistence(projectName); // Simply try to remove the project directory @@ -225,13 +221,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#addProject(java.lang.String) - */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") public void addProject(final String projectName, final String username) throws ProjectAlreadyExistingException, IOException { // Assemble all necessary paths and files for the given project final File projectDir = FSProjectDAOImpl.assembleProjectDir(projectName); @@ -279,13 +269,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#importProject(java.lang.String, java.lang.String, org.primefaces.model.UploadedFile) - */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") public void importProject(final String projectName, final String username, final UploadedFile file) throws ProjectAlreadyExistingException, IOException { // Add an empty project. this.addProject(projectName, username); @@ -301,16 +285,18 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { // Now load the kax file and use the resulting MIProject to overwrite the existing (newly created) kax file final MIProject project = AnalysisController.loadFromFile(tempFile); - this.saveProject(projectName, project, 0, true, username, null, null); + try { + this.saveProject(projectName, project, 0, true, username, null, null); + } catch (final ProjectNotExistingException ex) { + // This should not happen! + LOG.error("Could not save project.", ex); + } catch (final NewerProjectException ex) { + // This should not happen! + LOG.error("Could not save project.", ex); + } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#copyProject(java.lang.String, java.lang.String) - */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") public void copyProject(final String originalProjectName, final String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, IOException { final File dstProjDir = FSProjectDAOImpl.assembleProjectDir(newProjectName); @@ -346,13 +332,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#openProject(java.lang.String) - */ @Override - @PreAuthorize("isAuthenticated()") public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -366,13 +346,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#openProject(java.lang.String, kieker.webgui.common.ClassAndMethodContainer) - */ @Override - @PreAuthorize("isAuthenticated()") public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new IOException("Project is null"); @@ -388,13 +362,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#saveProject(java.lang.String, kieker.analysis.model.analysisMetaModel.MIProject, long, boolean, String) - */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject, final String username, final String analysisLayout, final String cockpitLayout) throws ProjectNotExistingException, IOException, NewerProjectException { // Check whether the project exists @@ -453,13 +421,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#getCurrTimeStamp(java.lang.String) - */ @Override - @PreAuthorize("isAuthenticated()") public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -468,13 +430,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { return FSProjectDAOImpl.assembleKaxFile(projectName).lastModified(); } - /* - * (non-Javadoc) - * - * @see kieker.webgui.persistence.IProjectDAO#uploadLibrary(org.primefaces.model.UploadedFile, java.lang.String) - */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -502,7 +458,6 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getClassLoader(java.lang.String) */ @Override - @PreAuthorize("isAuthenticated()") public ClassLoader getClassLoader(final String projectName, final Object requester) throws ProjectNotExistingException, IOException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -561,7 +516,6 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#listAllLibraries(java.lang.String) */ @Override - @PreAuthorize("isAuthenticated()") public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException { // Check whether the project exists if (!this.projectExists(projectName)) { @@ -589,7 +543,6 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#listAllProjects() */ @Override - @PreAuthorize("isAuthenticated()") public Collection<String> listAllProjects() { final List<String> result = new ArrayList<String>(); @@ -610,7 +563,6 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getAvailableComponents(java.lang.String) */ @Override - @PreAuthorize("isAuthenticated()") public ComponentListContainer getAvailableComponents(final String project) { return this.availableComponents.get(project); } @@ -701,7 +653,6 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#deleteLibrary(java.lang.String, java.lang.String) */ @Override - @PreAuthorize("hasAnyRole('User', 'Administrator')") public boolean deleteLibrary(final String projectName, final String libName) throws IOException { final File libDir = this.assembleLibDir(projectName); final File libFile = new File(libDir, libName); @@ -727,7 +678,6 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { * @see kieker.webgui.persistence.IProjectDAO#getProjectFile(java.lang.String) */ @Override - @PreAuthorize("isAuthenticated()") public File getProjectFile(final String projectName) { return FSProjectDAOImpl.assembleKaxFile(projectName); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java index 321fc3665f04b2681ecdef737dc1d75808f74be2..a962ffd9b45b6d671da99e50130223bdc51b44bc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java @@ -28,7 +28,7 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface IGraphLayoutService { /** - * This method takes two Strings, describing some basic graph information, and constructs a KGraph, which is then layouted by a Kieler algorithm. + * This method takes two Strings, describing some basic graph information, and constructs a KGraph. The KGraph is then layouted by the Kieler algorithms. * * @param nodes * A String containing node dimensions. @@ -37,7 +37,7 @@ public interface IGraphLayoutService { * @return A String of space separated node positions. * * @throws GraphLayoutException - * If the autolayout failed. + * If the auto layout failed. */ @PreAuthorize("isAuthenticated()") public String layoutGraph(String nodes, String edges) throws GraphLayoutException; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java index 56353e74aafc30839fbf10d8022cd1087baceee1..bb335f918c17b89c8b2a5bf3d60fde4053696e0c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IUserService.java @@ -34,7 +34,8 @@ public interface IUserService { * Adds a user to the system. * * @param user - * The domain object used to extract the necessary data to create the user. + * The domain object used to extract the necessary data to create the user. It is assumed that all fields are filled. + * * @throws DataAccessException * If it was not possible to add the user to the system. Either because a constraint was violated or because the connection to the database has * somehow been damaged. @@ -46,7 +47,8 @@ public interface IUserService { * Deletes a user from the system. * * @param user - * The domain object used to extract the necessary data to delete the user. + * The domain object used to extract the necessary data to delete the user. It is only necessary that the name field is filled. + * * @throws DataAccessException * If it was not possible to delete the user. Either because a constraint was violated or because the connection to the database has somehow been * damaged. @@ -58,7 +60,9 @@ public interface IUserService { * Edits a given user. If the password field of the given domain object is empty, the password won't be changed. If it is filled, it will be changed. * * @param user - * The domain object used to extract the necessary data to edit the user. + * The domain object used to extract the necessary data to edit the user. It is assumed that all fields are filled (except for the password field + * which is optional). + * * @throws DataAccessException * If it was not possible to edit the user. Either because a constraint was violated or because the connection to the database has somehow been * damaged. @@ -67,10 +71,11 @@ public interface IUserService { public void editUser(final User user) throws DataAccessException; /** - * Delivers a list containing the available users within the system. The password fields of the returned domain objects will be empty. The list is always a copy - * and can be modified at will. + * Delivers a list containing the available users within the system. The password fields of the returned domain objects will be empty. The list is always a fresh + * copy and can be modified at will. * * @return A list with the available users. + * * @throws DataAccessException * If something went wrong during the reading. This happens probably if the connection to the database has somehow been damaged. */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java index 5e5332bfd28a198d1901887ecaa3fd03069f7379..f4265dea7fd0b386d6aae72dfc384bb70224cd93 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java @@ -61,11 +61,6 @@ public class GraphLayoutServiceImpl implements IGraphLayoutService { // No code necessary } - /* - * (non-Javadoc) - * - * @see kieker.webgui.service.impl.IGraphLayoutService#layoutGraph(java.lang.String, java.lang.String) - */ @Override public String layoutGraph(final String nodes, final String edges) throws GraphLayoutException { try { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java index 05436e4a38c4eb5adcb628b2e0c1e6b155e4186b..c592fdae2998d1ac1d3a92ec4145808d4d97c391 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java @@ -43,41 +43,21 @@ public class UserServiceImpl implements IUserService { // No code necessary } - /* - * (non-Javadoc) - * - * @see kieker.webgui.service.IUserService#addUser(kieker.webgui.domain.User) - */ @Override public void addUser(final User user) throws DataAccessException { this.userDAO.addUser(user); } - /* - * (non-Javadoc) - * - * @see kieker.webgui.service.IUserService#getUsers() - */ @Override public List<User> getUsers() throws DataAccessException { return this.userDAO.getUsers(); } - /* - * (non-Javadoc) - * - * @see kieker.webgui.service.IUserService#deleteUser(kieker.webgui.domain.User) - */ @Override public void deleteUser(final User user) throws DataAccessException { this.userDAO.deleteUser(user); } - /* - * (non-Javadoc) - * - * @see kieker.webgui.service.IUserService#editUser(kieker.webgui.domain.User) - */ @Override public void editUser(final User user) throws DataAccessException { this.userDAO.editUser(user); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java index ba36402a8bfd70d9bea5b12b3d7baec53b9c60d4..f145c5dc27a40ef2c3bcf763aef3168f6ef4bd9d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java @@ -23,13 +23,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import kieker.analysis.AnalysisController; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.ClassAndMethodContainer; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.InvalidAnalysisStateException; -import kieker.webgui.common.exception.ProjectLoadException; +import kieker.webgui.common.exception.ReflectionException; import net.vidageek.mirror.dsl.Mirror; import net.vidageek.mirror.exception.MirrorException; @@ -123,7 +122,7 @@ public class Analysis { } } - } catch (final ProjectLoadException ex) { + } catch (final ReflectionException ex) { throw new AnalysisInitializationException("An error occured while instantiating the analysis.", ex); } catch (final NullPointerException ex) { throw new AnalysisInitializationException("An error occured while instantiating the analysis.", ex); @@ -197,8 +196,11 @@ public class Analysis { * @return An array containing the log entries (if available). */ public Object[] getLogEntries() { - return (Object[]) ClassAndMethodContainer.invokeClassMethod(Analysis.this.classAndMethodContainer.getLogImplWebguiLoggingClassGetEntriesMethod(), null, - AnalysisController.class.getName()); + try { + return (Object[]) new Mirror().on(this.classAndMethodContainer.getLogImplWebguiLoggingClass()).invoke().method("getEntries").withoutArgs(); + } catch (final MirrorException ex) { + return new Object[0]; + } } public void updateDisplays() { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java index 5cafd10013436ec6b8599a5e0357244d58aa5cd9..307cc46b67cb167b9350a15b82a9b52bf16e433a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java @@ -133,9 +133,9 @@ public class ProjectsBean { } catch (final IOException ex) { ProjectsBean.LOG.error("An error occured while removing the project.", ex); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while removing the project."); - } catch (final ProjectAlreadyExistingException ex) { - ProjectsBean.LOG.info("A project with the same name exists already.", ex); - GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_WARN, "A project with the same name exists already."); + } catch (final ProjectNotExistingException ex) { + ProjectsBean.LOG.error("An error occured while removing the project.", ex); + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while removing the project."); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java index 5425a517baafca8ff6d65a3d45ef317f65e50580..4d12d78c51d076008296987489a7e499d488e141 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/NewUserBean.java @@ -16,7 +16,7 @@ package kieker.webgui.web.beans.request; -import kieker.webgui.domain.User.Role; +import kieker.webgui.domain.Role; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java index a534a26d71cbb74dd2b1492d1348f3c050948722..f1127958151fbcb7ef81087cf7085b52af5a7bfd 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java @@ -46,7 +46,6 @@ import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.plugin.annotation.Property; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.exception.LibraryLoadException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; @@ -55,6 +54,7 @@ import kieker.webgui.domain.pluginDecorators.AbstractAnalysisComponentDecorator; import kieker.webgui.domain.pluginDecorators.FilterDecorator; import kieker.webgui.domain.pluginDecorators.ReaderDecorator; import kieker.webgui.domain.pluginDecorators.RepositoryDecorator; +import kieker.webgui.persistence.IUserDAO; import kieker.webgui.service.IProjectService; import kieker.webgui.web.beans.application.GlobalPropertiesBean; import kieker.webgui.web.beans.application.ProjectsBean; @@ -110,6 +110,8 @@ public class CurrentAnalysisEditorBean { private ProjectsBean projectsBean; @Autowired private UserBean userBean; + @Autowired + private IUserDAO userDAO; /** * Creates a new instance of this class. <b>Do not call this constructor manually. It will only be accessed by Spring.</b> @@ -240,15 +242,9 @@ public class CurrentAnalysisEditorBean { } catch (final IOException ex) { CurrentAnalysisEditorBean.LOG.error("An error occured while uploading the library.", ex); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgLibraryUploadingException()); - } catch (final ProjectLoadException ex) { - CurrentAnalysisEditorBean.LOG.error("An error occured while uploading the library.", ex); - GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgLibraryUploadingException()); } catch (final ProjectNotExistingException ex) { CurrentAnalysisEditorBean.LOG.error("Project does not exist.", ex); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgProjectNotExistingException()); - } catch (final LibraryLoadException ex) { - CurrentAnalysisEditorBean.LOG.error("An error occured while uploading the library.", ex); - GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgLibraryUploadingException()); } } @@ -629,7 +625,7 @@ public class CurrentAnalysisEditorBean { this.availableComponents = this.projectService.getAvailableComponents(this.projectName); } - private void loadProject() { + private void loadProject() throws ProjectLoadException { this.project = this.projectsBean.openProject(this.projectName); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java index 60c2cf79c36082b641551912fe5ae32b1b7c7a11..8e570c91f7e3d7e50fe4fc2480801f7b9ff12268 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java @@ -29,6 +29,7 @@ import kieker.analysis.model.analysisMetaModel.MIView; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.exception.DisplayNotFoundException; +import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; import kieker.webgui.service.IProjectService; import kieker.webgui.web.beans.application.GlobalPropertiesBean; @@ -175,7 +176,7 @@ public class CurrentCockpitBean { this.fillDashboard(); } } - } catch (final ProjectNotExistingException ex) { + } catch (final ProjectLoadException ex) { CurrentCockpitBean.LOG.error("An error occured while loading the project.", ex); GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgProjectLoadingException()); } catch (final NullPointerException ex) { @@ -207,6 +208,8 @@ public class CurrentCockpitBean { CurrentCockpitBean.LOG.warn("Display not found.", ex); } catch (final MirrorException ex) { return "N/A"; + } catch (final ProjectNotExistingException ex) { + return "N/A"; } } return "N/A"; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java index 75a198e479b1172e66e28aa943aa81362b6f1226..b1054eaaa5262649216d332a0e4e619282e6f7cc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java @@ -155,8 +155,6 @@ public class CurrentControllerBean { public boolean isAnalysisRunning() { try { return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.RUNNING; - } catch (final ProjectNotExistingException ex) { - CurrentControllerBean.LOG.info("The project does not exist.", ex); } catch (final NullPointerException ex) { // This exception can occur, when the projectsBean has not been initialized CurrentControllerBean.LOG.warn("A null pointer exception occured.", ex); @@ -172,8 +170,6 @@ public class CurrentControllerBean { public boolean isAnalysisReady() { try { return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.READY; - } catch (final ProjectNotExistingException ex) { - CurrentControllerBean.LOG.info("The project does not exist.", ex); } catch (final NullPointerException ex) { // This exception can occur, when the projectsBean has not been initialized CurrentControllerBean.LOG.warn("A null pointer exception occured.", ex); @@ -189,8 +185,6 @@ public class CurrentControllerBean { public boolean isAnalysisNotAvailable() { try { return this.projectService.getCurrentState(this.projectName) == null; - } catch (final ProjectNotExistingException ex) { - CurrentControllerBean.LOG.info("The project does not exist.", ex); } catch (final NullPointerException ex) { // This exception can occur, when the projectsBean has not been initialized CurrentControllerBean.LOG.warn("A null pointer exception occured.", ex); @@ -206,8 +200,6 @@ public class CurrentControllerBean { public boolean isAnalysisTerminated() { try { return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.TERMINATED; - } catch (final ProjectNotExistingException ex) { - CurrentControllerBean.LOG.info("The project does not exist.", ex); } catch (final NullPointerException ex) { // This exception can occur, when the projectsBean has not been initialized CurrentControllerBean.LOG.warn("A null pointer exception occured.", ex); @@ -223,8 +215,6 @@ public class CurrentControllerBean { public boolean isAnalysisFailed() { try { return this.projectService.getCurrentState(this.projectName) == AnalysisController.STATE.FAILED; - } catch (final ProjectNotExistingException ex) { - CurrentControllerBean.LOG.info("The project does not exist.", ex); } catch (final NullPointerException ex) { // This exception can occur, when the projectsBean has not been initialized CurrentControllerBean.LOG.warn("A null pointer exception occured.", ex); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentProjectOverviewBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentProjectOverviewBean.java index 0c26dc764666e942aed1aa19862d5a868e7dbe4c..96f138d5f7d2b68f1b2cfc5b97e3c6f0ba448f97 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentProjectOverviewBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentProjectOverviewBean.java @@ -31,6 +31,8 @@ import org.springframework.stereotype.Component; /** * The {@link CurrentProjectOverviewBean} contains the necessary data behind an instance of the project overview.<br> + * </br> + * * The class is a Spring managed bean with view scope. * * @author Nils Christian Ehmke @@ -39,11 +41,12 @@ import org.springframework.stereotype.Component; @Scope("view") public class CurrentProjectOverviewBean { - @Autowired - private ProjectsBean projectsBean; private List<String> projects = Collections.emptyList(); private String projectName; + @Autowired + private ProjectsBean projectsBean; + /** * Default constructor. <b>Do not call this constructor manually. It will only be accessed by Spring.</b> */ @@ -51,12 +54,12 @@ public class CurrentProjectOverviewBean { // No code necessary } - public String getProjectName() { - return this.projectName; - } - - public void setProjectName(final String projectName) { - this.projectName = projectName; + /** + * This method should only be called automatically by Spring to update the projects list. + */ + @PostConstruct + protected void initialialize() { + this.updateLists(); } /** @@ -69,27 +72,23 @@ public class CurrentProjectOverviewBean { this.setProjectName((String) event.getObject()); } - public void setProjectsBean(final ProjectsBean projectsBean) { - this.projectsBean = projectsBean; + /** + * Updates the list containing the available projects name. + */ + public void updateLists() { + this.projects = this.projectsBean.getProjects(); } - public List<String> getProjects() { - return this.projects; + public String getProjectName() { + return this.projectName; } - /** - * This method should only be called automatically by Spring to update the projects list. - */ - @PostConstruct - protected void initialialize() { - this.updateLists(); + public void setProjectName(final String projectName) { + this.projectName = projectName; } - /** - * Updates the list containing the available projects name. - */ - public void updateLists() { - this.projects = this.projectsBean.getProjects(); + public List<String> getProjects() { + return this.projects; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java index fbb8823c7827168507375ef5bb6442407dbd4a6b..d2d1b5f67aa74bccc9451b59fc21f93538915d20 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentUserManagementBean.java @@ -25,8 +25,8 @@ import javax.faces.application.FacesMessage; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.exception.DataAccessException; +import kieker.webgui.domain.Role; import kieker.webgui.domain.User; -import kieker.webgui.domain.User.Role; import kieker.webgui.service.IUserService; import kieker.webgui.web.beans.application.GlobalPropertiesBean; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/RoleStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/RoleStringConverter.java index a4c5453e9d323f20853683354c6cc0071a8bfc44..4e993f5a02e285ed1f99c565b534b534447cb7f5 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/RoleStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/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.domain.User.Role; +import kieker.webgui.domain.Role; /** * This converter can convert between instances of {@link String} and {@link Role}. This is necessary in the JSF context. diff --git a/Kieker.WebGUI/src/main/resources/sql/test-data.sql b/Kieker.WebGUI/src/main/resources/sql/initial-data.sql similarity index 100% rename from Kieker.WebGUI/src/main/resources/sql/test-data.sql rename to Kieker.WebGUI/src/main/resources/sql/initial-data.sql 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 4f6555c96d69807c87b210cf3211ec4a05bfacdd..8a32fe3ffef5aa417a2ef5213a6d5caded976da7 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 @@ -68,7 +68,7 @@ <context:component-scan base-package="kieker.webgui"/> <!-- Declare the necessary enumerations. --> - <util:constant id="ROLE_GUEST" static-field="kieker.webgui.domain.User.Role.ROLE_GUEST"/> - <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"/> + <util:constant id="ROLE_GUEST" static-field="kieker.webgui.domain.Role.ROLE_GUEST"/> + <util:constant id="ROLE_USER" static-field="kieker.webgui.domain.Role.ROLE_USER"/> + <util:constant id="ROLE_ADMIN" static-field="kieker.webgui.domain.Role.ROLE_ADMIN"/> </beans> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml index 6473e3d1ec5790a5cf9338f131448bfee2250726..8ba7b65a6a0593efcd2647c196c5595ee6c58c2d 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-database-config.xml @@ -22,7 +22,7 @@ <jdbc:initialize-database ignore-failures="ALL" data-source="userDataSource"> <jdbc:script location="classpath:sql/tables.sql"/> - <jdbc:script location="classpath:sql/test-data.sql"/> + <jdbc:script location="classpath:sql/initial-data.sql"/> </jdbc:initialize-database> </beans> diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java index 7dc6866fbbc00282c653942af5b7c43f75954e95..335c6cada13da931519ac2f60af1a6258e6a8d4c 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java @@ -22,7 +22,7 @@ import java.net.URL; import org.junit.Assert; import org.junit.Test; -import kieker.webgui.common.exception.ProjectLoadException; +import kieker.webgui.common.exception.ReflectionException; import kieker.webgui.persistence.impl.util.CloseableURLClassLoader; /** @@ -52,7 +52,7 @@ public class ClassAndMethodContainerTest { // If this fails, we know that kieker is not available here try { new ClassAndMethodContainer(classLoader); - } catch (final ProjectLoadException ex) { + } catch (final ReflectionException ex) { Assert.fail("Kieker dependency not available."); } diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java index e14ca2aa37d5bd6fc6fc9d44eefee92f3428cc42..a1aac2145afe25938097a515fdf8575e4c152096 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java @@ -27,6 +27,7 @@ import kieker.analysis.plugin.filter.AbstractFilterPlugin; import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.exception.ReflectionException; /** * Test class for {@link PluginFinder}. @@ -46,9 +47,12 @@ public class PluginFinderTest { /** * A test of this test class. + * + * @throws ReflectionException + * If something went wrong. */ @Test - public void testKiekerPlugins() { + public void testKiekerPlugins() throws ReflectionException { final PluginFinder pluginFinder = new PluginFinder(); final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(PluginFinderTest.KIEKER_LIB); final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java index 5a0b403898d66ed5b242bc23e668bd8e2cb836fc..38ff0047f8bf720d6c9a8753bb199af2266f5a0e 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java @@ -52,9 +52,12 @@ public class GraphLayoutServiceImplTest { /** * A test making sure that the layout works for nodes without edges. + * + * @throws GraphLayoutException + * If something went wrong. */ @Test - public void testLayoutWithoutEdges() { + public void testLayoutWithoutEdges() throws GraphLayoutException { final IGraphLayoutService layouter = new GraphLayoutServiceImpl(); final String inputNodes = "12;0 -1 204 72 f 0 0 0 0 1 78;1 -1 216 84 f 1 90 0 0 2 78"; @@ -67,9 +70,12 @@ public class GraphLayoutServiceImplTest { /** * A test making sure that the layout works for nodes with edges. + * + * @throws GraphLayoutException + * If something went wrong. */ @Test - public void testLayoutWithEdges() { + public void testLayoutWithEdges() throws GraphLayoutException { final IGraphLayoutService layouter = new GraphLayoutServiceImpl(); final String inputNodes = "12;0 -1 204 72 f 0 0 0 0 1 78;1 -1 216 84 f 1 90 0 0 2 78"; diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java index 1b8ea30b4c8ddbb830c198b107a1085eccb84f5c..a778e9e2f66c11f9d686c886ad8b1becc7554734 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java @@ -19,7 +19,7 @@ package kieker.webgui.web.converter; import org.junit.Assert; import org.junit.Test; -import kieker.webgui.domain.User.Role; +import kieker.webgui.domain.Role; /** * Test class for {@link RoleStringConverter}.