log.debug("isAsIs: " + isAsIs);
// add outputfolders for profiles
// if it is a presenation it will be copied to another place
if (!(canBeConverted || isPdf || isImage || isVideo || isAsIs)) {
returnError.addItem("wrongType", new ConverterProcessResult("The file type cannot be converted"));
return returnError;
}
File completeName = new File(
isAsIs ? OmFileHelper.getUploadFilesDir() : OmFileHelper.getUploadTempFilesDir()
, newFileSystemName + newFileExtDot);
log.debug("writing file to: " + completeName);
FileHelper.copy(is, completeName);
is.close();
Long ownerId = null;
if (parentFolderId == -2) {
parentFolderId = 0L;
ownerId = userId;
}
if (isOwner) {
ownerId = userId;
}
String fileHashName = newFileSystemName + newFileExtDot;
Boolean isPresentation = false;
if (canBeConverted || isPdf) {
// In case of a presentation the hash is a folder-name
fileHashName = newFileSystemName;
isPresentation = true;
}
if (isImage) {
fileHashName = newFileSystemName + ".jpg";
}
if (isVideo) {
fileHashName = newFileSystemName + ".flv";
}
FileExplorerItem fileExplorerItem = fileExplorerItemDao.getFileExplorerItemsById(parentFolderId);
if (fileExplorerItem != null) {
if (fileExplorerItem.getIsFolder() == null
|| !fileExplorerItem.getIsFolder()) {
parentFolderId = 0L;
}
}
Long fileExplorerItemId = fileExplorerItemDao.add(
fileSystemName, fileHashName, // The Hashname of the file
parentFolderId, ownerId, room_id, userId, false, // isFolder
isImage, isPresentation, "", false, isChart,
externalFileId, externalType);
log.debug("fileExplorerItemId: " + fileExplorerItemId);
log.debug("canBeConverted: " + canBeConverted);
if (canBeConverted) {
// convert to pdf, thumbs, swf and xml-description
returnError = generatePDF.convertPDF(newFileSystemName, "files", true, completeName);
} else if (isPdf) {
// convert to thumbs, swf and xml-description
returnError = generatePDF.convertPDF(newFileSystemName, "files", false, completeName);
} else if (isChart) {
log.debug("uploaded chart file");
} else if (isImage && !isAsIs) {
// convert it to JPG
log.debug("##### convert it to JPG: ");
returnError = generateImage.convertImage(newFileSystemName, newFileExtDot, "files",
newFileSystemName, false);
} else if (isAsIs) {
ConverterProcessResult processThumb = generateThumbs.generateThumb("_thumb_", completeName, 50);
returnError.addItem("processThumb", processThumb);
} else if (isVideo) {
List<ConverterProcessResult> returnList = flvExplorerConverter.startConversion(fileExplorerItemId, completeName.getCanonicalPath());
int i=0;