Skip to content
Snippets Groups Projects
Commit cc688884 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Some minor code modifications for quality reasons

parent 372e022e
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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();
}
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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();
......
......@@ -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");
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment