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:
Britt Park
2006-07-03 16:36:31 +00:00
parent 92a7348a43
commit 37843668a4
9 changed files with 163 additions and 6 deletions

View File

@@ -92,6 +92,36 @@ class FileContentImpl implements FileContent, Serializable
SuperRepository.GetInstance().getSession().save(this);
}
/**
* Initialize with the given content.
* @param id
* @param content
*/
public FileContentImpl(long id, File content)
{
fID = id;
fRefCount = 1;
// Initialize the contents.
try
{
OutputStream out = getOutputStream();
InputStream in = new FileInputStream(content);
byte [] buff = new byte[8192];
int count;
while ((count = in.read(buff)) != -1)
{
out.write(buff, 0, count);
}
out.close();
in.close();
}
catch (IOException ie)
{
throw new AVMException("I/O Error.", ie);
}
SuperRepository.GetInstance().getSession().save(this);
}
/**
* Copy constructor, sort of.
* @param other The content to copy from.