kieker.webgui.persistence.impl
Class FSProjectDAOImpl

java.lang.Object
  extended by kieker.webgui.persistence.impl.FSProjectDAOImpl
All Implemented Interfaces:
IProjectDAO, org.springframework.util.WeakReferenceMonitor.ReleaseListener

@Service
public final class FSProjectDAOImpl
extends Object
implements IProjectDAO, org.springframework.util.WeakReferenceMonitor.ReleaseListener

This is an implementation of the IProjectDAO interface, which uses the file system to store the available projects and everything.

Author:
Nils Christian Ehmke

Constructor Summary
FSProjectDAOImpl()
          Default constructor.
 
Method Summary
 void addProject(String projectName, String username)
          This method adds a new project to the application.
 void copyProject(String originalProjectName, String newProjectName)
          This method makes a copy of a project and saves it under another name.
 boolean deleteLibrary(String projectName, String libName)
          Deletes the given library of the given project.
 String getAnalysisLayout(String projectName)
          Delivers the stored analysis layout for the given project.
 ComponentListContainer getAvailableComponents(String project)
          Delivers the available components (readers, filters and repositories) for the given project.
 ClassLoader getClassLoader(String projectName, Object requester)
          This method delivers a class loader containing the currently available libraries of the given project.
 String getCockpitLayout(String projectName)
          Delivers the stored cockpit layout for the given project.
 long getCurrTimeStamp(String projectName)
          Delivers the current time stamp of the given project.
 String getLastUser(String projectName)
          Delivers the last user of the given project or a substitution if the meta data is corrupt or missing.
 String getOwner(String projectName)
          Delivers the owner of the given project or a substitution if the meta data is corrupt or missing.
 File getProjectFile(String projectName)
          Delivers the kax-file for the given project.
 void importProject(String projectName, String username, org.primefaces.model.UploadedFile file)
          This method imports an existing kax-file into the application.
 void initialize()
          This method initializes the object.
 List<String> listAllLibraries(String projectName)
          This method lists all available libraries of the given project.
 Collection<String> listAllProjects()
          This method lists all available projects on the file system.
 kieker.analysis.model.analysisMetaModel.MIProject loadProject(String projectName)
          This method loads the kax-file for the given project name and delivers an initializes instance of MIProject.
 Object loadProject(String projectName, ClassContainer classAndMethodContainer)
          This method loads the kax-file for the given project name and delivers an initializes instance of MIProject - but instead of using the "normal" class loader, it uses the methods and classes stored in the given instance of ClassContainer.
 void released()
           
 void removeProject(String projectName)
          This method removes the given project from the application.
 void saveProject(String projectName, kieker.analysis.model.analysisMetaModel.MIProject project, long timeStamp, boolean overwriteNewerProject, String username, String analysisLayout, String cockpitLayout)
          This method tries to save the given model instance for the given project.
 void uploadLibrary(org.primefaces.model.UploadedFile file, String projectName)
          This method tries to upload a dependency to the given project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSProjectDAOImpl

public FSProjectDAOImpl()
Default constructor. Do not use this constructor. This bean is Spring managed.

Method Detail

initialize

@PostConstruct
public void initialize()
                throws IOException
This method initializes the object. Do not call this method manually. It will only be accessed by Spring.

Throws:
IOException - If either the creation of the necessary directories failed or if something went wrong during the initialization of the projects.

getProjectFile

public File getProjectFile(String projectName)
Description copied from interface: IProjectDAO
Delivers the kax-file for the given project.

Specified by:
getProjectFile in interface IProjectDAO
Parameters:
projectName - The name of the project.
Returns:
The kax-file of the project.

getAnalysisLayout

public String getAnalysisLayout(String projectName)
Description copied from interface: IProjectDAO
Delivers the stored analysis layout for the given project.

Specified by:
getAnalysisLayout in interface IProjectDAO
Parameters:
projectName - The name of the project.
Returns:
The layout string as it is stored within the meta data. If this isn't available, null will be returned.

getCockpitLayout

public String getCockpitLayout(String projectName)
Description copied from interface: IProjectDAO
Delivers the stored cockpit layout for the given project.

Specified by:
getCockpitLayout in interface IProjectDAO
Parameters:
projectName - The name of the project.
Returns:
The layout string as it is stored within the meta data. If this isn't available, null will be returned.

getOwner

public String getOwner(String projectName)
Description copied from interface: IProjectDAO
Delivers the owner of the given project or a substitution if the meta data is corrupt or missing.

Specified by:
getOwner in interface IProjectDAO
Parameters:
projectName - The name of the project whose owner should be delivered.
Returns:
The owner (creator) of the project.

getLastUser

public String getLastUser(String projectName)
Description copied from interface: IProjectDAO
Delivers the last user of the given project or a substitution if the meta data is corrupt or missing.

Specified by:
getLastUser in interface IProjectDAO
Parameters:
projectName - The name of the project whose last user should be delivered.
Returns:
The last user of the project.

removeProject

public void removeProject(String projectName)
                   throws IOException,
                          ProjectNotExistingException
Description copied from interface: IProjectDAO
This method removes the given project from the application. This is done by simply removing the whole project directory. It is possible that this action fails for various reasons - in this cases it is not guaranteed that the project is still in a valid state.

Specified by:
removeProject in interface IProjectDAO
Parameters:
projectName - The name of the project.
Throws:
IOException - If something went wrong during the removing.
ProjectNotExistingException - If a project with the given name does not exist.

addProject

public void addProject(String projectName,
                       String username)
                throws ProjectAlreadyExistingException,
                       IOException
Description copied from interface: IProjectDAO
This method adds a new project to the application. It creates an empty, but nevertheless valid kax-file to the file system. If the method fails due to an IOException, it will make sure that the project-directories will be removed as if the method would never have been called.

Specified by:
addProject in interface IProjectDAO
Parameters:
projectName - The name of the new project.
username - The name of the user who created the project.
Throws:
ProjectAlreadyExistingException - If a project with the same name exists already.
IOException - If something went wrong during the creation of the project.

importProject

public void importProject(String projectName,
                          String username,
                          org.primefaces.model.UploadedFile file)
                   throws ProjectAlreadyExistingException,
                          IOException
Description copied from interface: IProjectDAO
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 first place.

Specified by:
importProject in interface IProjectDAO
Parameters:
projectName - The name of the new project.
username - The name of the user who imported the project.
file - The kax file to be uploaded.
Throws:
ProjectAlreadyExistingException - If a project with the same name exists already.
IOException - If something went wrong during the creation of the project or the uploading of the file.

copyProject

public void copyProject(String originalProjectName,
                        String newProjectName)
                 throws ProjectNotExistingException,
                        ProjectAlreadyExistingException,
                        IOException
Description copied from interface: IProjectDAO
This method makes a copy of a project and saves it under another name. If the method fails due to an IOException, it will make sure that the project-directories of the destination-project will be removed as if the method would never have been called.

Specified by:
copyProject in interface IProjectDAO
Parameters:
originalProjectName - The name of the source project.
newProjectName - The name of the target project.
Throws:
ProjectNotExistingException - If a project with the given (source) name doesn't exist.
ProjectAlreadyExistingException - If a project with the same (target) name exists already.
IOException - If something went wrong during the creation of the target-project or during the loading of the source-project.

loadProject

public kieker.analysis.model.analysisMetaModel.MIProject loadProject(String projectName)
                                                              throws ProjectNotExistingException,
                                                                     IOException
Description copied from interface: IProjectDAO
This method loads the kax-file for the given project name and delivers an initializes instance of MIProject.

Specified by:
loadProject in interface IProjectDAO
Parameters:
projectName - The name of the project to be loaded.
Returns:
The model instance as defined by the corresponding kax-file.
Throws:
ProjectNotExistingException - If a project with the given (source) name doesn't exist.
IOException - If something went wrong during the opening of the project.

loadProject

public Object loadProject(String projectName,
                          ClassContainer classAndMethodContainer)
                   throws ProjectNotExistingException,
                          IOException
Description copied from interface: IProjectDAO
This method loads the kax-file for the given project name and delivers an initializes instance of MIProject - but instead of using the "normal" class loader, it uses the methods and classes stored in the given instance of ClassContainer. This means that this method does return an instance of MIProject, but the one defined in the container. This is also the reason why this method has to return an Object-instance.

Specified by:
loadProject in interface IProjectDAO
Parameters:
projectName - The name of the project to be loaded.
classAndMethodContainer - The container, which will be used to load the project instance.
Returns:
The model instance as defined by the corresponding kax-file.
Throws:
ProjectNotExistingException - If a project with the given (source) name doesn't exist.
IOException - If something went wrong during the opening of the project. This can also mean that the given ClassContainer is somehow invalid.

saveProject

public void saveProject(String projectName,
                        kieker.analysis.model.analysisMetaModel.MIProject project,
                        long timeStamp,
                        boolean overwriteNewerProject,
                        String username,
                        String analysisLayout,
                        String cockpitLayout)
                 throws ProjectNotExistingException,
                        IOException,
                        NewerProjectException
Description copied from interface: IProjectDAO
This method tries to save the given model instance for the given project. The given time stamp will be compared (if the corresponding flag says so) with the current time stamp of the project. If the project on the file system has been modified in the meantime, a NewerProjectException will be thrown. If something goes wrong during the storage, it is not guaranteed that the resulting file will be valid.

Specified by:
saveProject in interface IProjectDAO
Parameters:
projectName - The name of the project which has to be saved.
project - The model instance to be stored in the corresponding kax-file.
timeStamp - The time stamp which has to be compared with the "real" time stamp of the project.
overwriteNewerProject - Determines whether a newer project file will be overwritten without further warning or not.
username - The name of the user who saves the project.
analysisLayout - The current layout of the analysis graph. It is valid if this parameter is null. In this case the stored layout will not be changed.
cockpitLayout - The current layout of the cockpit. It is valid if this parameter is null. In this case the stored layout will not be changed.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
IOException - If something went wrong during the storage of the model instance.
NewerProjectException - If the project on the file system is newer and the overwriteNewerProject-flag has not been set.

getCurrTimeStamp

public long getCurrTimeStamp(String projectName)
                      throws ProjectNotExistingException
Description copied from interface: IProjectDAO
Delivers the current time stamp of the given project.

Specified by:
getCurrTimeStamp in interface IProjectDAO
Parameters:
projectName - The name of the project whose time stamp will be delivered.
Returns:
The current time stamp.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.

uploadLibrary

public void uploadLibrary(org.primefaces.model.UploadedFile file,
                          String projectName)
                   throws ProjectNotExistingException,
                          IOException
Description copied from interface: IProjectDAO
This method tries to upload a dependency to the given project. AN existing version will be overwritten.

Specified by:
uploadLibrary in interface IProjectDAO
Parameters:
file - The file to be uploaded to the project.
projectName - The name of the project.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
IOException - If something went wrong during the uploading.

getClassLoader

public ClassLoader getClassLoader(String projectName,
                                  Object requester)
                           throws ProjectNotExistingException,
                                  IOException
Description copied from interface: IProjectDAO
This method delivers a class loader containing the currently available libraries of the given project.

Specified by:
getClassLoader in interface IProjectDAO
Parameters:
projectName - The name of the project.
requester - The requester of the classloader.
Returns:
A class loader for the given project.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
IOException - If something went wrong during the initialization of the class loader.

listAllLibraries

public List<String> listAllLibraries(String projectName)
                              throws ProjectNotExistingException
Description copied from interface: IProjectDAO
This method lists all available libraries of the given project.

Specified by:
listAllLibraries in interface IProjectDAO
Parameters:
projectName - The name of the project whose libraries have to be delivered.
Returns:
A list containing all available library-names of the project.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.

listAllProjects

public Collection<String> listAllProjects()
Description copied from interface: IProjectDAO
This method lists all available projects on the file system. This method is not secured with an annotation, as one of the services needs it only during initialization. It should not be called during normal runtime.

Specified by:
listAllProjects in interface IProjectDAO
Returns:
A list containing all available project names.

getAvailableComponents

public ComponentListContainer getAvailableComponents(String project)
Description copied from interface: IProjectDAO
Delivers the available components (readers, filters and repositories) for the given project.

Specified by:
getAvailableComponents in interface IProjectDAO
Parameters:
project - The project whose components should be loaded.
Returns:
An object containing the available components as model instances.

deleteLibrary

public boolean deleteLibrary(String projectName,
                             String libName)
                      throws IOException,
                             ProjectNotExistingException
Description copied from interface: IProjectDAO
Deletes the given library of the given project.

Specified by:
deleteLibrary in interface IProjectDAO
Parameters:
projectName - The name of the project.
libName - The name of the library.
Returns:
true if and only if the given library has been removed.
Throws:
IOException - If something went wrong during the reloading of the components.
ProjectNotExistingException - If a project with the given name does not exist.

released

public void released()
Specified by:
released in interface org.springframework.util.WeakReferenceMonitor.ReleaseListener


Copyright © 2015. All rights reserved.