More functionality which didn't need to be moved to FileProjectManager, as it wasn't file system specific, has been moved back to ProjectManager.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@992 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
c72b4571a5
commit
0af7e5fcf5
@ -86,10 +86,33 @@ public abstract class ProjectManager {
|
||||
public abstract void exportProject(long projectId, TarOutputStream tos) throws IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Saves a project and its metadata to the data store
|
||||
* @param id
|
||||
*/
|
||||
public abstract void ensureProjectSaved(long id);
|
||||
public void ensureProjectSaved(long id) {
|
||||
synchronized(this){
|
||||
ProjectMetadata metadata = _projectsMetadata.get(id);
|
||||
if (metadata != null) {
|
||||
try {
|
||||
saveMetadata(metadata, id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Project project = _projects.get(id);
|
||||
if (project != null && metadata.getModified().after(project.lastSave)) {
|
||||
try {
|
||||
saveProject(project);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
protected abstract void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception;
|
||||
protected abstract void saveProject(Project project);
|
||||
|
||||
public ProjectMetadata getProjectMetadata(long id) {
|
||||
return _projectsMetadata.get(id);
|
||||
|
@ -179,37 +179,17 @@ public class FileProjectManager extends ProjectManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that a project's metadata and data are saved to file. For example,
|
||||
* this method is called before the project is exported to a .tar file.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void ensureProjectSaved(long id) {
|
||||
synchronized (this) {
|
||||
File projectDir = getProjectDir(id);
|
||||
|
||||
ProjectMetadata metadata = _projectsMetadata.get(id);
|
||||
if (metadata != null) {
|
||||
try {
|
||||
@Override
|
||||
protected void saveMetadata(ProjectMetadata metadata, long projectId) throws Exception {
|
||||
File projectDir = getProjectDir(projectId);
|
||||
ProjectMetadataUtilities.save(metadata, projectDir);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Project project = _projects.get(id);
|
||||
if (project != null && metadata.getModified().after(project.lastSave)) {
|
||||
try {
|
||||
ProjectUtilities.save(project);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveProject(Project project){
|
||||
ProjectUtilities.save(project);
|
||||
}
|
||||
|
||||
public Project loadProject(long id) {
|
||||
return ProjectUtilities.load(getProjectDir(id), id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user