this.clearMessages();
File tempDir = new File(System.getProperty("java.io.tmpdir"));
File userTempDir = new File(tempDir, getPortletRequest().getUserPrincipal().getName());
final FileUpload upload = ((FileUploadField) this.get("importFile")).getFileUpload();
if (upload == null)
{
this.errorMessage = createMessage("import.message.nofile", null);
return;
}
synchronized (this)
{
try
{
if (!userTempDir.isDirectory())
{
userTempDir.mkdirs();
}
final File importFile = new File(userTempDir, upload.getClientFileName());
this.fileName = importFile.getCanonicalPath();
if (importFile.exists())
{
importFile.delete();
}
upload.writeTo(importFile);
}
catch (IOException ioe)
{
this.errorMessage = createMessage("import.message.exception", new Object[]
{ upload.getClientFileName(), ioe.getMessage()});
}
try
{
getJetspeedSerializer().importData(this.fileName, this.settings);
this.infoMessage = createMessage("import.message.success", new Object[]
{ this.fileName});
}
catch (SerializerException se)
{
this.errorMessage = createMessage("import.message.exception", new Object[]
{ upload.getClientFileName(), se.getMessage()});
}
}
}