Examples of ConverterProcessResultList


Examples of org.apache.openmeetings.util.process.ConverterProcessResultList

    }
   
  private void uploadFile(HttpServletRequest request, boolean userProfile, Long userId, String roomName,
      InputStream is, String fileSystemName, UploadCompleteMessage uploadCompleteMessage)
      throws Exception {
    ConverterProcessResultList returnError = new ConverterProcessResultList();

    // Check variable to see if this file is a presentation
    int dotidx = fileSystemName.lastIndexOf('.');
    String newFileName = StringComparer.getInstance().compareForRealPaths(
        fileSystemName.substring(0, dotidx));
    String newFileExtDot = fileSystemName.substring(dotidx,
        fileSystemName.length()).toLowerCase();
    String newFileExt = newFileExtDot.substring(1);

    // trim long names cause cannot output that
    final int MAX_FILE_NAME_LENGTH = 30;
    if (newFileName.length() >= MAX_FILE_NAME_LENGTH) {
      newFileName = newFileName.substring(0, MAX_FILE_NAME_LENGTH);
    }
    StoredFile storedFile = new StoredFile(newFileName, newFileExt);

    // check if this is a a file that can be converted by
    // openoffice-service
    boolean canBeConverted = storedFile.isConvertable();
    boolean isPdf = storedFile.isPdf();
    boolean isImage = storedFile.isImage();
    boolean isAsIs = storedFile.isAsIs();

    File workingDir = null;
    // add outputfolders for profiles
    if (userProfile) {
      // User Profile Update
      this.deleteUserProfileFilesStoreTemp(userId);
      newFileName = "profile"; //set unified file name to avoid any problems with national characters
      workingDir = OmFileHelper.getUploadProfilesUserDir(userId);
    }
    // if it is a presenation it will be copied to another
    // place
    if (isAsIs) {
      // check if this is a room file or UserProfile
      if (!userProfile) {
        workingDir = OmFileHelper.getUploadRoomDir(roomName);
      }
    } else if (canBeConverted || isPdf || isImage) {
      workingDir = OmFileHelper.getUploadTempProfilesUserDir(userId);
    } else {
      return;
    }

    File completeName = OmFileHelper.getNewFile(workingDir, newFileName, newFileExtDot);

    log.debug("write file to : " + completeName);

    FileHelper.copy(is, completeName);
    is.close();

    log.debug("canBeConverted: " + canBeConverted);
    if (canBeConverted) {
      // convert to pdf, thumbs, swf and xml-description
      returnError = generatePDF.convertPDF(newFileName, roomName, true, completeName);
    } else if (isPdf) {
     
      boolean isEncrypted = true;
     
      log.debug("isEncrypted :: " + isEncrypted);

      if (isEncrypted) {
        // Do convert pdf to other pdf first
        File f_old = completeName;

        completeName = OmFileHelper.appendSuffix(completeName, "_N_E");
        newFileName += "_N_E";

        generateThumbs.decodePDF(f_old.getCanonicalPath(), completeName.getCanonicalPath());

        if (f_old.exists()) {
          f_old.delete();
        }

      }

      // convert to thumbs, swf and xml-description
      returnError = generatePDF.convertPDF(newFileName, roomName, false, completeName);

      // returnError.put("decodePDF", returnError2);

    } else if (isImage && !isAsIs) {

      log.debug("##### isImage! userProfilePic: " + userProfile);

      if (userProfile) {
        // convert it to JPG
        returnError = generateImage.convertImageUserProfile(completeName, userId, true);
      } else {
        // convert it to JPG
        log.debug("##### convert it to JPG: " + userProfile);
        returnError = generateImage.convertImage(
          newFileName, newFileExtDot, roomName, newFileName, false);
      }
    } else if (isAsIs) {
      if (userProfile) {
        // User Profile Update
        this.deleteUserProfileFiles(userId);
        // is UserProfile Picture
        returnError.addItem("processThumb1", generateThumbs
            .generateThumb(chatImagePrefix, completeName, 40));
        returnError.addItem("processThumb2", generateThumbs
            .generateThumb(profileImagePrefix, completeName, 126));
        returnError.addItem("processThumb3", generateThumbs
            .generateThumb(bigImagePrefix, completeName, 240));

        String pictureuri = completeName.getName();
        User us = usersDao.get(userId);
        us.setUpdatetime(new java.util.Date());
        us.setPictureuri(pictureuri);
        usersDao.update(us, userId);

        //FIXME: After updating the picture url all other users should refresh
      } else {
        returnError.addItem("processThumb", generateThumbs
            .generateThumb(thumbImagePrefix, completeName, 50));
      }
    }

    uploadCompleteMessage.setMessage("library");
    uploadCompleteMessage.setAction("newFile");
   
    uploadCompleteMessage.setHasError(returnError.hasError());
   
    //we only send the complete log to the client if there is really something
    //to show because of an error
    if (returnError.hasError()) {
      uploadCompleteMessage.setError(returnError.getLogMessage());
    }
    uploadCompleteMessage.setFileName(completeName.getName());
   
  }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResultList

  public ConverterProcessResultList convertPDF(String fileName,
      String roomName, boolean fullProcessing, File inFile)
      throws Exception {

    String inFileName = inFile.getName();
    ConverterProcessResultList returnError = new ConverterProcessResultList();

    File fileFullPath = new File(OmFileHelper.getUploadTempRoomDir(roomName), inFileName);
    File destinationFolder = OmFileHelper.getNewDir(OmFileHelper.getUploadRoomDir(roomName), fileName);

    log.debug("fullProcessing: " + fullProcessing);
    if (fullProcessing) {
      ConverterProcessResult processOpenOffice = doJodConvert(
          fileFullPath, destinationFolder, fileName);
      returnError.addItem("processOpenOffice", processOpenOffice);
      ConverterProcessResult processThumb = generateThumbs
          .generateBatchThumb(new File(destinationFolder, fileName + ".pdf"), destinationFolder, 80, "thumb");
      returnError.addItem("processThumb", processThumb);
      ConverterProcessResult processSWF = generateSWF
          .generateSwf(destinationFolder, destinationFolder, fileName);
      returnError.addItem("processSWF", processSWF);
    } else {

      log.debug("-- generateBatchThumb --");

      ConverterProcessResult processThumb = generateThumbs
          .generateBatchThumb(fileFullPath, destinationFolder, 80, "thumb");
      returnError.addItem("processThumb", processThumb);

      ConverterProcessResult processSWF = generateSWF.generateSwf(
          fileFullPath.getParentFile(), destinationFolder, fileName);
      returnError.addItem("processSWF", processSWF);
    }

    // now it should be completed so copy that file to the expected location
    File fileWhereToMove = new File(destinationFolder, inFileName);
    fileWhereToMove.createNewFile();
    FileHelper.moveRec(inFile, fileWhereToMove);

    if (fullProcessing) {
      ConverterProcessResult processXML = CreateLibraryPresentation
          .generateXMLDocument(destinationFolder,
              inFileName, fileName + ".pdf",
              fileName + ".swf");
      returnError.addItem("processXML", processXML);
    } else {
      ConverterProcessResult processXML = CreateLibraryPresentation
          .generateXMLDocument(destinationFolder,
              inFileName, null, fileName + ".swf");
      returnError.addItem("processXML", processXML);
    }

    return returnError;
  }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResultList

        User externalUser = userDao.getExternalUser(externalUserId, externalType);

        LinkedHashMap<String, Object> hs = new LinkedHashMap<String, Object>();
        hs.put("user", externalUser);

        ConverterProcessResultList returnError = fileProcessor
            .processFile(externalUser.getUser_id(), room_id,
                isOwner, inputstream, parentFolderId,
                fileSystemName,
                externalFileId, externalType);

        // Flash cannot read the response of an upload
        // httpServletResponse.getWriter().print(returnError);
        hs.put("message", "library");
        hs.put("action", "newFile");
        hs.put("fileExplorerItem", fileExplorerItemDao
            .getFileExplorerItemsById(returnError.getFileExplorerItemId()));
        hs.put("error", returnError.getLogMessage());
        hs.put("fileName", returnError.getCompleteName());
       
        //FIXME: Send event to UI that there is a new file

        return returnError.convertToFileImportErrors();

      }
    } catch (Exception err) {
      log.error("[importFile]", err);
    }
View Full Code Here

Examples of org.apache.openmeetings.util.process.ConverterProcessResultList

        User internalUser = userDao.get(internalUserId);

        LinkedHashMap<String, Object> hs = new LinkedHashMap<String, Object>();
        hs.put("user", internalUser);

        ConverterProcessResultList returnError = fileProcessor
            .processFile(internalUser.getUser_id(), room_id,
                isOwner, inputstream, parentFolderId,
                fileSystemName,
                externalFileId, externalType);

        // Flash cannot read the response of an upload
        // httpServletResponse.getWriter().print(returnError);
        hs.put("message", "library");
        hs.put("action", "newFile");
        hs.put("fileExplorerItem", fileExplorerItemDao
            .getFileExplorerItemsById(returnError.getFileExplorerItemId()));
        hs.put("error", returnError);
        hs.put("fileName", returnError.getCompleteName());
       
        //FIXME: Notificate UI of clients of new file

        return returnError.convertToFileImportErrors();

      }
    } catch (Exception err) {
      log.error("[importFileByInternalUserId]", err);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.