kieker.webgui.service.impl
Class ProjectServiceImpl

java.lang.Object
  extended by kieker.webgui.service.impl.ProjectServiceImpl
All Implemented Interfaces:
IProjectService

@Service
public final class ProjectServiceImpl
extends Object
implements IProjectService

This is an implementation of the IProjectService interface for the project management. It makes sure that accesses to the projects are synchronized. Most of the work is delegated to the underlying layer or to the utility classes.

Author:
Nils Christian Ehmke

Constructor Summary
ProjectServiceImpl()
          Default constructor.
 
Method Summary
 void addProject(String projectName, String username)
          This method adds a new project to the application.
 void cleanAnalysis(String projectName)
          This method cleans the analysis of the given project.
 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.
 void deleteProject(String projectName)
          This method removes the given project from the application.
 void emergencyShutdownOfAnalysis(String projectName)
          Initializes an emergency shutdown.
 String getAnalysisLayout(String projectName)
          Delivers the stored analysis layout for the given project.
 ComponentListContainer getAvailableComponents(String projectName)
          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.
 kieker.analysis.AnalysisController.STATE getCurrentState(String projectName)
          This method delivers the current state of the given project.
 long getCurrTimeStamp(String projectName)
          Delivers the current time stamp of the given project.
 Object getDisplay(String projectName, String viewName, String displayName)
          This method delivers the display object of the (currently running) analysis for the given project and the given parameters.
 DisplayType getDisplayType(String projectName, String viewName, String displayConnectorName)
          Delivers the type of the given display connector.
 String getLastUser(String projectName)
          Delivers the last user of the given project or a substituion if the meta data is corrupt or missing.
 Object[] getLogEntries(String projectName)
          This method delivers the available log entries of the analysis controller of the given project.
 String getOwner(String projectName)
          Delivers the owner of the given project or a substituion if the meta data is corrupt or missing.
 List<String> getProjects()
          Delivers a list of the currently available projects.
 void importProject(String projectName, String username, org.primefaces.model.UploadedFile file)
          This method imports an existing kax-file into the application.
protected  void initialize()
          This method does some initialization work after construction.
 void initializeAnalysis(String projectName)
          This method initializes the analysis of the given project.
 List<String> listAllLibraries(String projectName)
          This method lists all available libraries of the given project.
 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.
 void reloadDisplays(String projectName)
          Reloads the displays of the given project.
 void renameProject(String originalProjectName, String newProjectName)
          This method renames the given project.
 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 startAnalysis(String projectName)
          This method starts the analysis of the given project.
 void stopAnalysis(String projectName)
          This method stops the analysis of 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

ProjectServiceImpl

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

Method Detail

initialize

@PostConstruct
protected void initialize()
This method does some initialization work after construction. Do not call this method. The method is Spring managed.


addProject

public void addProject(String projectName,
                       String username)
                throws ProjectAlreadyExistingException,
                       IOException
Description copied from interface: IProjectService
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 IProjectService
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.

deleteProject

public void deleteProject(String projectName)
                   throws ProjectNotExistingException,
                          IOException,
                          ProjectStillRunningException
Description copied from interface: IProjectService
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:
deleteProject in interface IProjectService
Parameters:
projectName - The name of the project.
Throws:
ProjectNotExistingException - If a project with the given name doesn't exist.
IOException - If something went wrong during the removing.
ProjectStillRunningException - If the project is still running.

copyProject

public void copyProject(String originalProjectName,
                        String newProjectName)
                 throws ProjectNotExistingException,
                        ProjectAlreadyExistingException,
                        IOException
Description copied from interface: IProjectService
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 IProjectService
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.

renameProject

public void renameProject(String originalProjectName,
                          String newProjectName)
                   throws ProjectNotExistingException,
                          ProjectAlreadyExistingException,
                          IOException
Description copied from interface: IProjectService
This method renames the given project.

Specified by:
renameProject in interface IProjectService
Parameters:
originalProjectName - The old project name.
newProjectName - The new project name.
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.

importProject

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

loadProject

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

Specified by:
loadProject in interface IProjectService
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.

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: IProjectService
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 IProjectService
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: IProjectService
Delivers the current time stamp of the given project.

Specified by:
getCurrTimeStamp in interface IProjectService
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: IProjectService
This method tries to upload a dependency to the given project. An existing version of the library will be overwritten.

Specified by:
uploadLibrary in interface IProjectService
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: IProjectService
This method delivers a class loader containing the currently available libraries of the given project.

Specified by:
getClassLoader in interface IProjectService
Parameters:
projectName - The name of the project.
requester - The requester of the class loader.
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.

getAvailableComponents

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

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

listAllLibraries

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

Specified by:
listAllLibraries in interface IProjectService
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.

initializeAnalysis

public void initializeAnalysis(String projectName)
                        throws ProjectNotExistingException,
                               InvalidAnalysisStateException,
                               AnalysisInitializationException,
                               IOException
Description copied from interface: IProjectService
This method initializes the analysis of the given project.

Specified by:
initializeAnalysis in interface IProjectService
Parameters:
projectName - The name of the project whose analysis should be initialized.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
InvalidAnalysisStateException - If the analysis of the given project is in the wrong state to be initialized. This means that it has not been cleaned yet.
AnalysisInitializationException - If an error occurred during the initialization of the analysis.
IOException - If something went wrong while loading the file.

cleanAnalysis

public void cleanAnalysis(String projectName)
                   throws ProjectNotExistingException,
                          InvalidAnalysisStateException
Description copied from interface: IProjectService
This method cleans the analysis of the given project.

Specified by:
cleanAnalysis in interface IProjectService
Parameters:
projectName - The name of the project whose analysis should be cleaned.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
InvalidAnalysisStateException - If the analysis of the given project is in the wrong state to be cleaned. This means that it has not been terminated yet.

startAnalysis

public void startAnalysis(String projectName)
                   throws ProjectNotExistingException,
                          InvalidAnalysisStateException
Description copied from interface: IProjectService
This method starts the analysis of the given project.

Specified by:
startAnalysis in interface IProjectService
Parameters:
projectName - The name of the project whose analysis should be started.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
InvalidAnalysisStateException - If the analysis of the given project is in the wrong state to be started. This means that it has not been initialized yet.

stopAnalysis

public void stopAnalysis(String projectName)
                  throws ProjectNotExistingException,
                         InvalidAnalysisStateException
Description copied from interface: IProjectService
This method stops the analysis of the given project.

Specified by:
stopAnalysis in interface IProjectService
Parameters:
projectName - The name of the project whose analysis should be stopped.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
InvalidAnalysisStateException - If the analysis of the given project is in the wrong state to be stopped. This means that it has not been started yet or is no longer running.

emergencyShutdownOfAnalysis

public void emergencyShutdownOfAnalysis(String projectName)
                                 throws ProjectNotExistingException,
                                        InvalidAnalysisStateException
Description copied from interface: IProjectService
Initializes an emergency shutdown.

Specified by:
emergencyShutdownOfAnalysis in interface IProjectService
Parameters:
projectName - The name of the project whose analysis should be stopped.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.
InvalidAnalysisStateException - If the analysis of the given project is in the wrong state to be stopped.

getDisplay

public Object getDisplay(String projectName,
                         String viewName,
                         String displayName)
                  throws InvalidAnalysisStateException
Description copied from interface: IProjectService
This method delivers the display object of the (currently running) analysis for the given project and the given parameters. Technically it is an instance of AbstractDisplay, but in fact the project specific class loader has been used.

Specified by:
getDisplay in interface IProjectService
Parameters:
projectName - The name of the project.
viewName - The name of the view.
displayName - The name of the display.
Returns:
A display object for the given parameters.
Throws:
InvalidAnalysisStateException - If the analysis of the given project is in the wrong state to deliver the display.

getCurrentState

public kieker.analysis.AnalysisController.STATE getCurrentState(String projectName)
Description copied from interface: IProjectService
This method delivers the current state of the given project.

Specified by:
getCurrentState in interface IProjectService
Parameters:
projectName - The name of the project whose state have to be returned.
Returns:
The state of the given project, if available. null otherwise.

getLogEntries

public Object[] getLogEntries(String projectName)
                       throws InvalidAnalysisStateException
Description copied from interface: IProjectService
This method delivers the available log entries of the analysis controller of the given project.

Specified by:
getLogEntries in interface IProjectService
Parameters:
projectName - The name of the project.
Returns:
An array containing the entries of the log.
Throws:
InvalidAnalysisStateException - If the analysis is in an invalid state to deliver the entries.

deleteLibrary

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

Specified by:
deleteLibrary in interface IProjectService
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.

getOwner

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

Specified by:
getOwner in interface IProjectService
Parameters:
projectName - The name of the project whose owner should be delivered.
Returns:
The owner (creator) of the project.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.

getLastUser

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

Specified by:
getLastUser in interface IProjectService
Parameters:
projectName - The name of the project whose last user should be delivered.
Returns:
The last user of the project.
Throws:
ProjectNotExistingException - If a project with the given name does not exist.

getAnalysisLayout

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

Specified by:
getAnalysisLayout in interface IProjectService
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: IProjectService
Delivers the stored cockpit layout for the given project.

Specified by:
getCockpitLayout in interface IProjectService
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.

getDisplayType

public DisplayType getDisplayType(String projectName,
                                  String viewName,
                                  String displayConnectorName)
Description copied from interface: IProjectService
Delivers the type of the given display connector.

Specified by:
getDisplayType in interface IProjectService
Parameters:
projectName - The name of the project.
viewName - The name of the view.
displayConnectorName - The name of the display connector.
Returns:
The type of the display connector.

getProjects

public List<String> getProjects()
Description copied from interface: IProjectService
Delivers a list of the currently available projects. The returned list is a copy.

Specified by:
getProjects in interface IProjectService
Returns:
A list containing the available projects.

reloadDisplays

public void reloadDisplays(String projectName)
                    throws AnalysisDisplayReloadException,
                           InvalidAnalysisStateException
Description copied from interface: IProjectService
Reloads the displays of the given project.

Specified by:
reloadDisplays in interface IProjectService
Parameters:
projectName - The name of the project.
Throws:
AnalysisDisplayReloadException - If something went wrong while reloading the displays.
InvalidAnalysisStateException - If the analysis is in an invalid state for the operation.


Copyright © 2015. All rights reserved.