From c8ad2f5fda609dc18350b547436d746d5ad13cfe Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Sat, 17 Nov 2012 17:31:41 +0100
Subject: [PATCH] Some minor code modifications for quality reasons.

---
 .../webgui/persistence/IProjectDAO.java       |  9 ++++++
 .../persistence/impl/FSProjectDAOImpl.java    | 19 +++++++++++++
 .../webgui/service/IProjectService.java       |  9 ++++++
 .../service/impl/util/PluginFinder.java       |  4 +++
 .../webgui/web/beans/session/UserBean.java    | 10 +++++++
 .../beans/view/CurrentAnalysisEditorBean.java | 28 +++++++++++++------
 .../web/beans/view/CurrentCockpitBean.java    | 23 ---------------
 .../beans/view/CurrentCockpitEditorBean.java  | 26 +++++++++++++++--
 .../web/converter/RoleStringConverter.java    |  8 ++++++
 9 files changed, 102 insertions(+), 34 deletions(-)

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 89398ec8..21d5e001 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java
@@ -225,6 +225,15 @@ public interface IProjectDAO {
 	@PreAuthorize("isAuthenticated()")
 	public abstract File getProjectFile(String projectName);
 
+	/**
+	 * Deletes the given library of the given project.
+	 * 
+	 * @param projectName
+	 *            The name of the project.
+	 * @param libName
+	 *            The name of the library.
+	 * @return true if and only if the given library has been removed.
+	 */
 	@PreAuthorize("hasAnyRole('User', 'Administrator')")
 	public abstract boolean deleteLibrary(String projectName, String libName);
 
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 eb9c9584..040a337e 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
@@ -104,12 +104,26 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener {
 		this.checkDir(FSProjectDAOImpl.TEMP_DIRECTORY);
 	}
 
+	/**
+	 * This method destroys the object. <b>Do not call this method manually. It will only be accessed by Spring.</b>
+	 * 
+	 * @throws IOException
+	 *             If something went wrong during the cleaning.
+	 */
 	@PreDestroy
 	public void destroy() throws IOException {
 		// Try to clear the temporary directory
 		FileSystemUtils.deleteRecursively(new File(FSProjectDAOImpl.TEMP_DIRECTORY));
 	}
 
+	/**
+	 * Checks whether the given directory exists and creates it if necessary.
+	 * 
+	 * @param dirName
+	 *            The name of the directory.
+	 * @throws IOException
+	 *             If the directory could not be created.
+	 */
 	private void checkDir(final String dirName) throws IOException {
 		final File dir = new File(dirName);
 		if (!dir.exists() && !dir.mkdir()) {
@@ -372,6 +386,11 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener {
 		return classLoader;
 	}
 
+	/**
+	 * This method tries to create a new temporary directory within our temp directory.
+	 * 
+	 * @return A file object pointing to the new temporary directory.
+	 */
 	private File createTemporaryDirectory() {
 		int counter = 0;
 		File tempDir;
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java
index 5ea4c476..c346a357 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java
@@ -345,5 +345,14 @@ public interface IProjectService {
 	 */
 	public Object[] getLogEntries(final String projectName) throws AnalysisStateException;
 
+	/**
+	 * Deletes the given library of the given project.
+	 * 
+	 * @param projectName
+	 *            The name of the project.
+	 * @param libName
+	 *            The name of the library.
+	 * @return true if and only if the given library has been removed.
+	 */
 	public boolean deleteLibrary(String projectName, String libName);
 }
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java
index 00bf5e9c..14114b25 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/PluginFinder.java
@@ -54,6 +54,7 @@ public final class PluginFinder {
 	 *            The container for the necessary reflection methods.
 	 * @return A list containing all available repository-classes or null, if an exception occurred.
 	 * @throws IOException
+	 *             If something went wrong during the opening of the jar file.
 	 */
 	public List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url, final ClassLoader classLoader,
 			final ClassAndMethodContainer classAndMethodContainer) throws IOException {
@@ -86,6 +87,7 @@ public final class PluginFinder {
 	 *            The container for the necessary reflection methods.
 	 * @return A list containing all available plugin-classes or null, if an exception occurred.
 	 * @throws IOException
+	 *             If something went wrong during the opening of the jar file.
 	 */
 	public List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url, final ClassLoader classLoader,
 			final ClassAndMethodContainer classAndMethodContainer) throws IOException {
@@ -112,6 +114,8 @@ public final class PluginFinder {
 	 * @param classLoader
 	 *            The classloader which should be used to load the classes.
 	 * @return A list containing all available classes or null, if an exception occurred.
+	 * @throws IOException
+	 *             If something went wrong during the opening of the jar file.
 	 */
 	private List<Class<?>> getAllClassesWithinJar(final URL url, final ClassLoader classLoader) throws IOException {
 		JarInputStream stream = null;
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java
index df01e14f..a43c2626 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/UserBean.java
@@ -86,6 +86,11 @@ public final class UserBean implements Serializable {
 		return username;
 	}
 
+	/**
+	 * Delivers the role of the current user.
+	 * 
+	 * @return The current userrole.
+	 */
 	public String getUserrole() {
 		String userrole = "N/A";
 
@@ -101,6 +106,11 @@ public final class UserBean implements Serializable {
 		return userrole;
 	}
 
+	/**
+	 * Delivers the {@link UserDetails} of the current user.
+	 * 
+	 * @return The current user details.
+	 */
 	private static UserDetails getUserDetails() {
 		final Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
 		if (principal instanceof UserDetails) {
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 0053064d..137e5b80 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
@@ -221,9 +221,6 @@ public final class CurrentAnalysisEditorBean {
 
 	/**
 	 * This method loads the list of available readers, filters and repositories, using the current libraries within the model.
-	 * 
-	 * @throws ProjectLoadException
-	 *             If something went wrong during the loading of the libraries.
 	 */
 	private synchronized void initializeToolPalette() {
 		// Clean our tool palette
@@ -397,6 +394,7 @@ public final class CurrentAnalysisEditorBean {
 	 * @return The description for the class or a substitute if none is available. This is in either case human readable.
 	 */
 	public synchronized String getDescription(final Class<?> clazz) {
+		final String description;
 		// Get the two potential annotations
 		final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass());
 		final Annotation annotationRepository = clazz.getAnnotation(this.classAndMethodContainer.getRepositoryAnnotationClass());
@@ -408,13 +406,15 @@ public final class CurrentAnalysisEditorBean {
 		if ((annotationPlugin == null) || ((String) ClassAndMethodContainer.invokeMethod(pluginDescrMethod, annotationPlugin, "")).isEmpty()) {
 			if ((annotationRepository == null) || ((String) ClassAndMethodContainer.invokeMethod(repoDescrMethod, annotationRepository, "")).isEmpty()) {
 				// None. Deliver a human readable substitute.
-				return "No description available";
+				description = "No description available";
 			} else {
-				return (String) ClassAndMethodContainer.invokeMethod(repoDescrMethod, annotationRepository, "No description available");
+				description = (String) ClassAndMethodContainer.invokeMethod(repoDescrMethod, annotationRepository, "No description available");
 			}
 		} else {
-			return (String) ClassAndMethodContainer.invokeMethod(pluginDescrMethod, annotationPlugin, "No description available");
+			description = (String) ClassAndMethodContainer.invokeMethod(pluginDescrMethod, annotationPlugin, "No description available");
 		}
+
+		return description;
 	}
 
 	/**
@@ -425,6 +425,8 @@ public final class CurrentAnalysisEditorBean {
 	 * @return The dependencies for the class or a substitute if none is available. This is in either case human readable.
 	 */
 	public synchronized String getDependencies(final Class<?> clazz) {
+		final String description;
+
 		// Get the two potential annotations
 		final Annotation annotationPlugin = clazz.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass());
 		final Annotation annotationRepository = clazz.getAnnotation(this.classAndMethodContainer.getRepositoryAnnotationClass());
@@ -436,13 +438,15 @@ public final class CurrentAnalysisEditorBean {
 		if (annotationPlugin == null) {
 			if (annotationRepository == null) {
 				// None. Deliver a human readable substitute.
-				return "No dependency information available";
+				description = "No dependency information available";
 			} else {
-				return (String) ClassAndMethodContainer.invokeMethod(repoDepMethod, annotationRepository, "No dependency information available");
+				description = (String) ClassAndMethodContainer.invokeMethod(repoDepMethod, annotationRepository, "No dependency information available");
 			}
 		} else {
-			return (String) ClassAndMethodContainer.invokeMethod(pluginDepMethod, annotationPlugin, "No dependency information available");
+			description = (String) ClassAndMethodContainer.invokeMethod(pluginDepMethod, annotationPlugin, "No dependency information available");
 		}
+
+		return description;
 	}
 
 	/**
@@ -646,6 +650,12 @@ public final class CurrentAnalysisEditorBean {
 		}
 	}
 
+	/**
+	 * Removes the library with the given name and reloads the classes and the classloader. Furthermore the tool palette will be reinitalized.
+	 * 
+	 * @param name
+	 *            The name of the library to be removed.
+	 */
 	public synchronized void deleteLibrary(final String name) {
 		if (this.projectService.deleteLibrary(this.projectName, name)) {
 			// Update our class loader and the available plugins & repositories
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 60a650f4..7ca9a1dc 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
@@ -74,29 +74,6 @@ public final class CurrentCockpitBean {
 		return this.project;
 	}
 
-	public synchronized void setProjectService(final IProjectService projectService) {
-		this.projectService = projectService;
-	}
-
-	/**
-	 * The getter for the {@link #projectsBean}-property.
-	 * 
-	 * @return {@link #projectsBean}
-	 */
-	public synchronized ProjectsBean getProjectsBean() {
-		return this.projectsBean;
-	}
-
-	/**
-	 * The setter for the {@link #projectsBean}-property.
-	 * 
-	 * @param projectsBean
-	 *            The new value for {@link #projectsBean}.
-	 */
-	public synchronized void setProjectsBean(final ProjectsBean projectsBean) {
-		this.projectsBean = projectsBean;
-	}
-
 	/**
 	 * This method sets the project stored within this bean.
 	 * 
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java
index ea73f84c..18bc12e3 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java
@@ -99,6 +99,9 @@ public final class CurrentCockpitEditorBean {
 		this.createDashboard();
 	}
 
+	/**
+	 * Creates the initial dashboard object.
+	 */
 	private synchronized void createDashboard() {
 		final FacesContext fc = FacesContext.getCurrentInstance();
 		final Application application = fc.getApplication();
@@ -116,6 +119,9 @@ public final class CurrentCockpitEditorBean {
 		this.dashboard.setModel(this.dashboardModel);
 	}
 
+	/**
+	 * Fills the initial dashboard object.
+	 */
 	private synchronized void fillDashboard() {
 		// Dump the old entries
 		this.clearDashboard();
@@ -147,6 +153,9 @@ public final class CurrentCockpitEditorBean {
 		}
 	}
 
+	/**
+	 * Clears the dashboard and removes all children within it.
+	 */
 	private synchronized void clearDashboard() {
 		// Run through all columns of the dashboard and remove the items
 		final List<DashboardColumn> columns = this.dashboard.getModel().getColumns();
@@ -427,15 +436,17 @@ public final class CurrentCockpitEditorBean {
 			return false;
 		}
 
+		boolean result = false;
 		// Run through all display connectors and check the name against the given one
 		for (final MIDisplayConnector connector : this.activeView.getDisplayConnectors()) {
 			if (connector.getName().equals(name)) {
-				return true;
+				result = true;
+				break;
 			}
 		}
 
 		// The name has not been found
-		return false;
+		return result;
 	}
 
 	/**
@@ -455,10 +466,21 @@ public final class CurrentCockpitEditorBean {
 		}
 	}
 
+	/**
+	 * Getter for the property {@link CurrentCockpitEditorBean#dashboard}.
+	 * 
+	 * @return The current value of the property.
+	 */
 	public synchronized Dashboard getDashboard() {
 		return this.dashboard;
 	}
 
+	/**
+	 * Setter for the property {@link CurrentCockpitEditorBean#dashboard}.
+	 * 
+	 * @param dashboard
+	 *            The new value for the property.
+	 */
 	public synchronized void setDashboard(final Dashboard dashboard) {
 		this.dashboard = dashboard;
 		this.dashboard.setModel(this.dashboardModel);
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 d8e580ff..43f4a9c7 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
@@ -23,9 +23,17 @@ import javax.faces.convert.FacesConverter;
 
 import kieker.webgui.domain.User.Role;
 
+/**
+ * This converter can convert between instances of {@link String} and {@link Role}. This is necessary in the JSF context.
+ * 
+ * @author Nils Christian Ehmke
+ */
 @FacesConverter("roleStringConverter")
 public class RoleStringConverter implements Converter {
 
+	/**
+	 * Creates a new instance of this class. <b>Do not use this constructor. This converter is JSF managed.</b>
+	 */
 	public RoleStringConverter() {
 		// No code necessary
 	}
-- 
GitLab