[svn r15223] improve dealing of errors in oogie/woogie (FS#2515)

skala
Eric Marguin 17 years ago
parent dda6800035
commit c93ce77847
  1. BIN
      main/inc/lib/ppt2png/DokeosConverter.class
  2. 10
      main/inc/lib/ppt2png/DokeosConverter.java
  3. 15
      main/newscorm/openoffice_document.class.php
  4. 26
      main/upload/upload_ppt.php
  5. 26
      main/upload/upload_word.php

@ -57,6 +57,7 @@ public class DokeosConverter {
private static final Options OPTIONS = initOptions();
private static final int EXIT_CODE_CONNECTION_FAILED = 1;
private static final int EXIT_CODE_CONVERSION_FAILED = 2;
private static final int EXIT_CODE_TOO_FEW_ARGS = 255;
private static Options initOptions() {
@ -152,7 +153,14 @@ public class DokeosConverter {
convertOne(converter, inputFile, outputFile, verbose);
}
}
} finally {
}
catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e)
{
connection.disconnect();
System.err.println("ERROR: conversion failed.");
System.exit(EXIT_CODE_CONVERSION_FAILED);
}
finally {
if (verbose) {
System.out.println("-- disconnecting");
}

@ -85,9 +85,20 @@ abstract class OpenofficeDocument extends learnpath {
$locale = 'en_US.UTF-8'; // TODO : improve it because we're not sure this locale is present everywhere
putenv('LC_ALL='.$locale);
$shell = exec($cmd, $files, $return);
if($return != 0) { //if the java application returns an error code
DocumentManager::delete_document($_course, $dir_name, $this->base_work_dir);
switch($return)
{
// can't connect to openoffice
case 1 : $this->error = get_lang('CannotConnectToOpenOffice');break;
// conversion failed in openoffice
case 2 : $this->error = get_lang('OogieConversionFailed');break;
// conversion can't be launch because command failed
case 255 : $this->error = get_lang('OogieUnknownError');break;
}
DocumentManager::delete_document($_course, $dir_name, $this->base_work_dir);
return false;
}

@ -41,12 +41,26 @@ $htmlHeadXtra[] = $form_style;
if(isset($_POST['convert'])){
$cwdir = getcwd();
require('../newscorm/lp_upload.php');
if(isset($o_ppt) && $first_item_id != 0){
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
}
else {
$errorMessage = get_lang('Ppt2lpError');
if(isset($_FILES['user_file']))
{
$allowed_extensions = array('odp','sxi','ppt','pps','sxd','pptx');
if(in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions))
{
require('../newscorm/lp_upload.php');
if(isset($o_ppt) && $first_item_id != 0){
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
}
else {
if(!empty($o_ppt->error))
$errorMessage = $o_ppt->error;
else
$errorMessage = get_lang('OogieUnknownError');
}
}
else
{
$errorMessage = get_lang('BadExtension');
}
}
}

@ -37,12 +37,26 @@ $htmlHeadXtra[] = $form_style;
if(isset($_POST['convert'])){
$cwdir = getcwd();
require('../newscorm/lp_upload.php');
if(isset($o_doc) && $first_item_id != 0){
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
}
else {
$errorMessage = get_lang('WoogieError');
if(isset($_FILES['user_file']))
{
$allowed_extensions = array('doc','docx','odt','txt','sxw','rtf');
if(in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions))
{
require('../newscorm/lp_upload.php');
if(isset($o_doc) && $first_item_id != 0){
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
}
else {
if(!empty($o_doc->error))
$errorMessage = $o_doc->error;
else
$errorMessage = get_lang('OogieUnknownError');
}
}
else
{
$errorMessage = get_lang('BadExtension');
}
}
}

Loading…
Cancel
Save