mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
A new flavor of createFile. Slightly slower. Significantly safer.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3277 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
@@ -241,10 +242,30 @@ class RepositoryImpl implements Repository, Serializable
|
||||
PlainFileNodeImpl file = new PlainFileNodeImpl(this);
|
||||
file.setVersionID(getNextVersionID());
|
||||
dir.putChild(name, file);
|
||||
file.updateModTime();
|
||||
dir.updateModTime();
|
||||
return file.getContentForWrite().getOutputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file with the given contents.
|
||||
* @param path The path to the containing directory.
|
||||
* @param name The name to give the new file.
|
||||
* @param data The contents.
|
||||
*/
|
||||
public void createFile(String path, String name, File data)
|
||||
{
|
||||
Lookup lPath = lookupDirectory(-1, path, true);
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
if (dir.lookupChild(lPath, name, -1, true) != null)
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
}
|
||||
PlainFileNodeImpl file = new PlainFileNodeImpl(this, data);
|
||||
file.setVersionID(getNextVersionID());
|
||||
dir.putChild(name, file);
|
||||
dir.updateModTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new layered file.
|
||||
* @param srcPath The target indirection for the layered file.
|
||||
|
Reference in New Issue
Block a user