Child pages
  • UNE Migration Utility

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

from a JSP page:

Code Block
borderStylesolid
titlehow to use the utility from a JSP page
borderStylesolid

<!-- A web form like the one in the screen grab above would capture what course
 you wanted to convert and also any associated options. These would then be processed
 like below and then the converter is called. -->

<!--setup flags for the conversion command -->
<c:if test="${export_modules == 1 && export_quizzes == 0 && export_files == 0}">
	<c:set var="export_options" value="--melete" scope="application" />
</c:if>
		
...
		
<c:if test="${export_modules == 1 && export_quizzes == 1 && export_files == 0}">
	<c:set var="export_options" value="--melete --samigo" scope="application" />
</c:if>	
	
...
		
<c:if test="${export_modules == 1 && export_quizzes == 1 && export_files == 1}">
	<c:set var="export_options" value="--all" scope="application" />
</c:if>

<%

String command = "java -cp " + application.getAttribute("converter_location").toString() + 
		" Converter" + 
		" --export=" + application.getAttribute("export_path").toString() +
		" --destination=" + application.getAttribute("conversion_output_dir").toString() +
		" " + application.getAttribute("export_options").toString() +
		" --classpath=" + application.getAttribute("converter_location").toString() +
		" --webcthost=" + application.getAttribute("webct_host").toString() +
		" --webctdir=" + application.getAttribute("webct_user_dir").toString() +
		" --tmp=" + application.getAttribute("webct_tmp_dir").toString();

out.print("command:" + command + "<br/>");
Process p =	Runtime.getRuntime().exec(command);
int ret=p.waitFor();
				
if(ret != 0) {
	pageContext.setAttribute("proceed_ok", false);
	pageContext.setAttribute("ret", ret);
}
out.print("ret:" + ret + "<br/>");

%>

<c:if test="${proceed_ok == false}">
	<div class="portlet-msg-error">
		<h3>Conversion process failed</h3>
		<p>The converter returned status code <strong><c:out value="${ret}" /></strong> and could not complete successfully. Please contact the system administrator.</p>
		<p><input type="button" value="Back" onclick="javascript:history.back(); return false;" /></p>
	</div>
</c:if>

from the commandline

Code Block
borderStylesolid
titlehow to use the utility from the commandline
borderStylesolid

$ java -cp bin Converter
	
The following options are supported:
 	--export=/full/path/to/export.zip
    [ --destination=/full/path/to/destination/ ]
    [ --classpath=/full/path/to/classes/and/scripts/ ]
    [ --webcthost=webct host with NO PROTOCOL eg online.une.eu.au ]
    [ --webctdir=/full/path/to/webct/user ]
    [ --tmp=/full/path/to/temp/working/directory/ ]
    [ --modules ] (convert only modules)
    [ --quizzes ] (convert only quizzes)
    [ --userfiles ] (collect webct user files)
    [ --all ]  (convert both melete and samigo if available (default))
	
Trailing slashes are required.

from another Java class:

Code Block
borderStylesolid
titlehow to use the utility from another Java class
borderStylesolid
	
String exportZip="/Users/bfunnel/dev/converter/exports/educ293_07s2_COURSE_20070829131046.zip";
String destination="/Users/bfunnel/dev/converter/complete/";
		
Converter c = new Converter();
c.setExportZip(exportZip);
c.setDestination(destination);
c.unZip();
	
if(c.convertAll()==0) {
	c.moveMeleteZip();
	c.moveSamigoZip();
	System.out.println("Completed successfully");
} else
	System.out.println("Error");
	
c.deleteTmp();

...