diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java index 965eb13d767873c863bf7a8c5280cb24d85fad14..fad4a1aa3604391decdf716ea32c040acb086cd1 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java @@ -43,7 +43,7 @@ public final class ThemeSwitcherBean { /** * A map containing all available themes. */ - private final Map<String, String> themes = new TreeMap<String, String>(); + private final Map<String, String> themes = new TreeMap<String, String>(); // NOPMD (No concurrent access) /** * Default constructor. <b>Do not use this constructor. This bean is JSF managed.</b> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java index b6df74fe480c88ee1034268d2fa9ada743c94b8f..a8664d8e541e7f9595288cf17a2da8f7c2ec96ca 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java @@ -78,7 +78,7 @@ public final class CurrentThemeBean implements Serializable { */ private void setDefaultTheme() { // Get the parameters within the current context. - final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); + final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); // NOPMD (No concurrent access) // Try to find the default theme within the parameters. if (params.containsKey(CurrentThemeBean.KEY_THEME)) { this.theme = params.get(CurrentThemeBean.KEY_THEME); @@ -93,7 +93,7 @@ public final class CurrentThemeBean implements Serializable { */ private void searchThemeInCookies() { // Try to find the cookie for the theme. - final Map<String, Object> cookies = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap(); + final Map<String, Object> cookies = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap(); // NOPMD (No concurrent access) if (cookies.containsKey(CurrentThemeBean.KEY_COOKIE_THEME)) { this.theme = ((Cookie) cookies.get(CurrentThemeBean.KEY_COOKIE_THEME)).getValue(); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java index 88da8b885a37546ad52a51aa31345c83ef5501e7..f2a9478e64d212db5497a2e81a9c0d8e3449e3e3 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java @@ -80,7 +80,10 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; /** - * This bean contains the project of the current (session) user for the analysis editor. + * The {@link CurrentAnalysisEditorBean} contains the necessary data behind an instance of the analysis editor. It provides various methods to manipulate the current + * project, as the analysis editor is the most important part of the whole application.<br> + * The class is a JSF managed bean with view scope to make sure that one user (even in one session) can open multiple projects at a time without causing any + * problems. * * @author Nils Christian Ehmke * @version 1.0 @@ -179,7 +182,6 @@ public final class CurrentAnalysisEditorBean { * * @param newName * The name of the project. - * @return The name of the page for the project work space, if the project has been accepted, '' if it is null. */ public void setProjectName(final String newName) { synchronized (this) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java index 9f6a5a670890e98c312dc6d8df593331b9b49940..d0e935f59fb7f73fa542ce869fc9343ff33a2a44 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitBean.java @@ -34,7 +34,10 @@ import kieker.webgui.common.ACManager; import kieker.webgui.common.Global; /** - * This bean contains the project of the current (session) user for the cockpit. + * The {@link CurrentCockpitBean} contains the necessary data behind an instance of the cockpit. It provides methods to read the state of the currently + * selected project.<br> + * The class is a JSF managed bean with view scope to make sure that one user (even in one session) can open multiple projects at a time without causing any + * problems. * * @author Nils Christian Ehmke * @version 1.0 @@ -79,7 +82,6 @@ public class CurrentCockpitBean { * * @param newName * The name of the project. - * @return The name of the page for the cockpit. */ public void setProjectName(final String newName) { synchronized (this) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java index cd496fadcee08b54ad4f3911d9d6d125b630e6a1..c8795ae75ffd03e8155915a29473959e3345de73 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentCockpitEditorBean.java @@ -53,7 +53,9 @@ import org.primefaces.context.RequestContext; import org.primefaces.event.TabChangeEvent; /** - * This bean contains the project of the current (session) user for the cockpit editor. + * The {@link CurrentCockpitEditorBean} contains the necessary data behind an instance of the cockpit editor. + * The class is a JSF managed bean with view scope to make sure that one user (even in one session) can open multiple projects at a time without causing any + * problems. * * @author Nils Christian Ehmke * @version 1.0 @@ -109,7 +111,6 @@ public class CurrentCockpitEditorBean { * * @param newName * The name of the project. - * @return The name of the page for the analysis view work space. */ public void setProjectName(final String newName) { synchronized (this) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java index 508549fa903ceb006ce7262105f06437285677aa..6e54a55baa02977812033a1b66f25de9add0b096 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentControllerBean.java @@ -42,7 +42,10 @@ import kieker.webgui.common.exception.ProjectAlreadyStartedException; import kieker.webgui.common.exception.ProjectStillRunningException; /** - * This bean contains the project of the current (session) user for the controller page. + * /** + * The {@link CurrentControllerBean} contains the necessary data behind an instance of the analysis controller. + * The class is a JSF managed bean with view scope to make sure that one user (even in one session) can open multiple projects at a time without causing any + * problems. * * @author Nils Christian Ehmke * @version 1.0 @@ -75,7 +78,6 @@ public class CurrentControllerBean { * * @param newName * The name of the project. - * @return The name of the page for the cockpit. */ public void setProjectName(final String newName) { synchronized (this) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java index 4657efaad43c67800400110c60e7afbf0690a1d1..3b66b882caff913d0200de8352b3f36f0f6bb065 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentProjectOverviewBean.java @@ -34,7 +34,9 @@ import kieker.webgui.beans.application.ProjectsBean; import org.primefaces.event.SelectEvent; /** - * This bean is used in the context of the project overview page. + * /** + * The {@link CurrentControllerBean} contains the necessary data behind an instance of the project overview.<br> + * The class is a JSF managed bean with view scope. * * @author Nils Christian Ehmke * @version 1.0 @@ -106,6 +108,11 @@ public class CurrentProjectOverviewBean { this.projects = bean.getProjects(); } + /** + * This method delivers the current instance of this bean, using the current faces context and the necessary el resolver. + * + * @return The current instance of {@link CurrentProjectOverviewBean}. + */ public static CurrentProjectOverviewBean getCurrentInstance() { // Get both the context and the resolver final FacesContext facesContext = FacesContext.getCurrentInstance(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java index 85b70ccc8611dab5019d4a5ed38d674788055660..3b50267b2b2e643330882bb98036114281be5288 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java @@ -377,23 +377,52 @@ public final class FSManager { // NOCS (Class Data Abstraction Coupling, Class F * @param dst * The destination element. This should be a (non existing) file. * @throws IOException - * If something went wrong + * If something went wrong. In this case the method will try to close all streams nevertheless. */ private void copyFile(final File src, final File dst) throws IOException { + boolean result = true; // Open the files - final FileInputStream fileInputStream = new FileInputStream(src); - final FileOutputStream fileOutputStream = new FileOutputStream(dst); - final FileChannel inputChannel = fileInputStream.getChannel(); - final FileChannel outputChannel = fileOutputStream.getChannel(); - - // Copy the data - this.transfer(inputChannel, outputChannel, src.length()); - - // Close the streams - fileInputStream.close(); - fileOutputStream.close(); + FileInputStream fileInputStream = null; + FileOutputStream fileOutputStream = null; + + try { + fileInputStream = new FileInputStream(src); + fileOutputStream = new FileOutputStream(dst); + final FileChannel inputChannel = fileInputStream.getChannel(); + final FileChannel outputChannel = fileOutputStream.getChannel(); + + // Copy the data + this.transfer(inputChannel, outputChannel, src.length()); + + // This is just necessary to calm findbugs + result = dst.setLastModified(src.lastModified()); + + } catch (final IOException ex) { + FSManager.LOG.error("An IO error occured", ex); + result = false; + } finally { + // Try to close the streams + if (fileInputStream != null) { + try { + fileInputStream.close(); + } catch (final IOException ex) { + FSManager.LOG.error("An IO error occured", ex); + result = false; + } + } + if (fileOutputStream != null) { + try { + fileOutputStream.close(); + } catch (final IOException ex) { + FSManager.LOG.error("An IO error occured", ex); + result = false; + } + } + } - dst.setLastModified(src.lastModified()); + if (!result) { + throw new IOException("An IO error occured"); + } } /**