Index: lams_central/conf/language/ApplicationResources.properties
===================================================================
diff -u -r598efc598d075ec9e4f4e83cd9c1ea369dc27aac -rb3da97f5c8cfdd02a2c2cb566dcee601100f3c07
--- lams_central/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 598efc598d075ec9e4f4e83cd9c1ea369dc27aac)
+++ lams_central/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -53,4 +53,24 @@
index.addlesson = Add Lesson
index.monitor = Monitor
index.participate = Participate
-index.dummymonitor = Dummy Monitor
\ No newline at end of file
+index.dummymonitor = Dummy Monitor
+
+
+############# Since by 20 June 2006 #############
+title.import.result=Import tool content result
+title.import=Import tool content
+title.import.instruction=Please choose learning design zip file and import.
+title.export.loading=Export tool content loading
+
+label.ld.zip.file=Learning Design zip file
+msg.import.success=Learning design and activities import successfully.
+msg.import.ld.success=Learning design import successfully.
+msg.import.tool.error.prefix=But there are some tool(s) imported failed
+
+msg.export.success=Learning design and activities export successfully.
+msg.export.ld.success=Learning design export successfully.
+msg.export.tool.error.prefix=But there are some tool(s) exported failed
+
+button.open.design=Open learning design
+button.close=Close
+button.import=Import
\ No newline at end of file
Index: lams_central/conf/xdoclet/servlet-mappings.xml
===================================================================
diff -u -raf5a6d9874421d5f5bb335259ae58b23116b0bf5 -rb3da97f5c8cfdd02a2c2cb566dcee601100f3c07
--- lams_central/conf/xdoclet/servlet-mappings.xml (.../servlet-mappings.xml) (revision af5a6d9874421d5f5bb335259ae58b23116b0bf5)
+++ lams_central/conf/xdoclet/servlet-mappings.xml (.../servlet-mappings.xml) (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -14,13 +14,3 @@
SimpleUploader
/fckeditor/editor/filemanager/upload/simpleuploader
-
-
- ExportToolContent
- /ExportToolContent
-
-
-
- ImportToolContent
- /ImportToolContent
-
\ No newline at end of file
Index: lams_central/conf/xdoclet/servlets.xml
===================================================================
diff -u -raf5a6d9874421d5f5bb335259ae58b23116b0bf5 -rb3da97f5c8cfdd02a2c2cb566dcee601100f3c07
--- lams_central/conf/xdoclet/servlets.xml (.../servlets.xml) (revision af5a6d9874421d5f5bb335259ae58b23116b0bf5)
+++ lams_central/conf/xdoclet/servlets.xml (.../servlets.xml) (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -84,12 +84,3 @@
1
-
-
- ExportToolContent
- org.lamsfoundation.lams.authoring.web.ExportToolContentServlet
-
-
- ImportToolContent
- org.lamsfoundation.lams.authoring.web.ImportToolContentServlet
-
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentAction.java
===================================================================
diff -u
--- lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentAction.java (revision 0)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentAction.java (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -0,0 +1,138 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.authoring.web;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException;
+import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService;
+import org.lamsfoundation.lams.util.FileUtil;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsAction;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+/**
+ *
+ * @struts.action name = "ExportAction"
+ * parameter = "method"
+ * validate = "false"
+ * @struts.action-forward name = "loading" path = "/toolcontent/exportloading.jsp"
+ * @struts.action-forward name = "result" path = "/toolcontent/exportresult.jsp"
+ *
+ * Export tool content action. It needs learingDesignID as input parameter.
+ * @author Steve.Ni
+ * @version $Revision$
+ */
+public class ExportToolContentAction extends LamsAction {
+
+ private static final long serialVersionUID = 1L;
+ public static final String EXPORT_TOOLCONTENT_SERVICE_BEAN_NAME = "exportToolContentService";
+ public static final String PARAM_LEARING_DESIGN_ID = "learningDesignID";
+ public static final String ATTR_TOOLS_ERROR_MESSAGE = "toolsErrorMessages";
+ public static final String ATTR_LD_ERROR_MESSAGE = "ldErrorMessages";
+
+ private Logger log = Logger.getLogger(ExportToolContentAction.class);
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ String param = mapping.getParameter();
+ //-----------------------Resource Author function ---------------------------
+ if(param.equals("export")){
+ return exportLD(mapping,request,response);
+ }else{
+ Long learningDesignId = WebUtil.readLongParam(request,PARAM_LEARING_DESIGN_ID);
+ request.setAttribute(PARAM_LEARING_DESIGN_ID,learningDesignId);
+ //display initial page for upload
+ return mapping.findForward("loading");
+ }
+ }
+ private ActionForward exportLD(ActionMapping mapping, HttpServletRequest request,HttpServletResponse response){
+ Long learningDesignId = WebUtil.readLongParam(request,PARAM_LEARING_DESIGN_ID);
+ IExportToolContentService service = getExportService();
+ List ldErrorMsgs = new ArrayList();
+ try {
+ List toolsErrorMsgs = new ArrayList();
+ String zipFilename = service.exportLearningDesign(learningDesignId,toolsErrorMsgs);
+ request.setAttribute(ATTR_TOOLS_ERROR_MESSAGE,toolsErrorMsgs);
+ //write zip file as response stream.
+ response.setContentType("application/zip");
+ response.setHeader("Content-Disposition","attachment;filename="+FileUtil.getFileName(zipFilename));
+ InputStream in = null;
+ OutputStream out = null;
+ try {
+ in = new BufferedInputStream(new FileInputStream(zipFilename));
+ out = response.getOutputStream();
+ int count = 0;
+
+ int ch;
+ while ((ch = in.read()) != -1)
+ {
+ out.write((char) ch);
+ count++;
+ }
+ log.debug("Wrote out " + count + " bytes");
+ response.setContentLength(count);
+ out.flush();
+ return null;
+ } catch (Exception e) {
+ log.error( "Exception occured writing out file:" + e.getMessage());
+ throw new ExportToolContentException(e);
+ } finally {
+ try {
+ if (in != null) in.close(); // very important
+ if (out != null) out.close();
+ }
+ catch (Exception e) {
+ log.error("Error Closing file. File already written out - no exception being thrown.",e);
+ }
+ }
+ } catch (ExportToolContentException e1) {
+ log.error("Unable to export tool content: " + e1.toString());
+ request.setAttribute(ATTR_LD_ERROR_MESSAGE,ldErrorMsgs);
+ }
+ //display initial page for upload
+ return mapping.findForward("result");
+ }
+
+ //***************************************************************************************
+ // Private method
+ //***************************************************************************************
+ private IExportToolContentService getExportService(){
+ WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext());
+ return (IExportToolContentService) webContext.getBean(EXPORT_TOOLCONTENT_SERVICE_BEAN_NAME);
+ }
+}
Fisheye: Tag b3da97f5c8cfdd02a2c2cb566dcee601100f3c07 refers to a dead (removed) revision in file `lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentServlet.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentAction.java
===================================================================
diff -u
--- lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentAction.java (revision 0)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentAction.java (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -0,0 +1,172 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.authoring.web;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.fileupload.DiskFileUpload;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException;
+import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.FileUtil;
+import org.lamsfoundation.lams.util.zipfile.ZipFileUtil;
+import org.lamsfoundation.lams.web.action.LamsAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+/**
+ * * @struts.action name = "ImportAction"
+ * parameter = "method"
+ * validate = "false"
+ * @struts.action-forward name = "upload" path = "/toolcontent/import.jsp"
+ * @struts.action-forward name = "success" path = "/toolcontent/importresult.jsp"
+ *
+ * Import tool content servlet. It needs an uploaded learning design zip file.
+ * @author Steve.Ni
+ *
+ * @version $Revision$
+ */
+public class ImportToolContentAction extends LamsAction {
+
+ private static final long serialVersionUID = 1L;
+ public static final String EXPORT_TOOLCONTENT_SERVICE_BEAN_NAME = "exportToolContentService";
+ public static final String USER_SERVICE_BEAN_NAME = "userManagementService";
+ public static final String PARAM_LEARING_DESIGN_ID = "learningDesignID";
+ public static final String ATTR_TOOLS_ERROR_MESSAGE = "toolsErrorMessages";
+ public static final String ATTR_LD_ERROR_MESSAGE = "ldErrorMessages";
+ public static final String ATTR_LD_ID = "learningDesignID";
+
+
+ private Logger log = Logger.getLogger(ImportToolContentAction.class);
+
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ String param = mapping.getParameter();
+ //-----------------------Resource Author function ---------------------------
+ if(param.equals("import")){
+ importLD(request);
+ return mapping.findForward("success");
+ }else{
+ //display initial page for upload
+ return mapping.findForward("upload");
+ }
+ }
+
+
+ /**
+ * @param request
+ */
+ private void importLD(HttpServletRequest request) {
+ List ldErrorMsgs = new ArrayList();
+ try {
+ Integer workspaceFolderUid = null;
+
+ //get shared session
+ HttpSession ss = SessionManager.getSession();
+ //get back login user DTO
+ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ User user = (User)getUserService().findById(User.class,userDto.getUserID());
+
+ FileItem file = null;
+ Map params = new HashMap();
+ String filename = null;
+
+ String uploadPath = FileUtil.createTempDirectory("_uploaded_learningdesing");
+
+ DiskFileUpload fu = new DiskFileUpload();
+ // maximum size that will be stored in memory
+ fu.setSizeThreshold(4096);
+ // the location for saving data that is larger than getSizeThreshold()
+ fu.setRepositoryPath(uploadPath);
+
+ List fileItems = fu.parseRequest(request);
+ Iterator iter = fileItems.iterator();
+ while (iter.hasNext()) {
+ FileItem fi = (FileItem) iter.next();
+ //UPLOAD_FILE is input field from HTML page
+ if (!fi.getFieldName().equalsIgnoreCase("UPLOAD_FILE"))
+ params.put(fi.getFieldName(), fi.getString());
+ else {
+ // filename on the client
+ filename = FileUtil.getFileName(fi.getName());
+ file = fi;
+ }
+ workspaceFolderUid = NumberUtils.createInteger((String) params.get("WORKSPACE_FOLDER_UID"));
+ }
+ if (file == null) {
+ String msg = "Can not find the upload file.";
+ log.error(msg);
+ throw new ExportToolContentException(msg);
+ }
+ // write the file
+ String ldPath = ZipFileUtil.expandZip(file.getInputStream(),filename);
+ IExportToolContentService service = getExportService();
+ List toolsErrorMsgs = new ArrayList();
+ Long ldId = service.importLearningDesign(ldPath,user,workspaceFolderUid,toolsErrorMsgs);
+ if(ldId == -1){
+ String msg = "Learning design saved failed.";
+ throw new ExportToolContentException(msg);
+ }
+ request.setAttribute(ATTR_TOOLS_ERROR_MESSAGE,toolsErrorMsgs);
+ request.setAttribute(ATTR_LD_ID,ldId);
+ } catch (Exception e) {
+ String msg = e.toString();
+ log.error(msg);
+ ldErrorMsgs.add(msg);
+ request.setAttribute(ATTR_LD_ERROR_MESSAGE,ldErrorMsgs);
+ }
+ }
+
+ //***************************************************************************************
+ // Private method
+ //***************************************************************************************
+ private IUserManagementService getUserService(){
+ WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext());
+ return (IUserManagementService) webContext.getBean(USER_SERVICE_BEAN_NAME);
+ }
+ private IExportToolContentService getExportService(){
+ WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext());
+ return (IExportToolContentService) webContext.getBean(EXPORT_TOOLCONTENT_SERVICE_BEAN_NAME);
+ }
+
+}
Fisheye: Tag b3da97f5c8cfdd02a2c2cb566dcee601100f3c07 refers to a dead (removed) revision in file `lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentServlet.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_central/web/WEB-INF/struts/struts-config.xml
===================================================================
diff -u -ra884335b596c130586d105a1bef8c423905d98c1 -rb3da97f5c8cfdd02a2c2cb566dcee601100f3c07
--- lams_central/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision a884335b596c130586d105a1bef8c423905d98c1)
+++ lams_central/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -63,6 +63,26 @@
/>
+
+
+
+
+
+
+
+ 1
-
- ExportToolContent
- org.lamsfoundation.lams.authoring.web.ExportToolContentServlet
-
-
- ImportToolContent
- org.lamsfoundation.lams.authoring.web.ImportToolContentServlet
-
-
action
*.do
@@ -202,16 +193,6 @@
/fckeditor/editor/filemanager/upload/simpleuploader
-
- ExportToolContent
- /ExportToolContent
-
-
-
- ImportToolContent
- /ImportToolContent
-
-
flashCrashDump
/flashCrashDump
Fisheye: Tag b3da97f5c8cfdd02a2c2cb566dcee601100f3c07 refers to a dead (removed) revision in file `lams_central/web/importToolContent/import.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_central/web/toolcontent/exportloading.jsp
===================================================================
diff -u
--- lams_central/web/toolcontent/exportloading.jsp (revision 0)
+++ lams_central/web/toolcontent/exportloading.jsp (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -0,0 +1,22 @@
+<%@ taglib uri="tags-lams" prefix="lams"%>
+<%@ taglib uri="tags-core" prefix="c"%>
+<%@ taglib uri="tags-fmt" prefix="fmt"%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
Index: lams_central/web/toolcontent/exportresult.jsp
===================================================================
diff -u
--- lams_central/web/toolcontent/exportresult.jsp (revision 0)
+++ lams_central/web/toolcontent/exportresult.jsp (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -0,0 +1,46 @@
+<%@ taglib uri="tags-lams" prefix="lams"%>
+<%@ taglib uri="tags-core" prefix="c"%>
+<%@ taglib uri="tags-fmt" prefix="fmt"%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${toolError}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_central/web/toolcontent/import.jsp
===================================================================
diff -u
--- lams_central/web/toolcontent/import.jsp (revision 0)
+++ lams_central/web/toolcontent/import.jsp (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -0,0 +1,28 @@
+<%@ taglib uri="tags-lams" prefix="lams"%>
+<%@ taglib uri="tags-core" prefix="c"%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ " method="post" enctype="multipart/form-data">
+
+ :
+
+ " />
+
+
+
+
Index: lams_central/web/toolcontent/importresult.jsp
===================================================================
diff -u
--- lams_central/web/toolcontent/importresult.jsp (revision 0)
+++ lams_central/web/toolcontent/importresult.jsp (revision b3da97f5c8cfdd02a2c2cb566dcee601100f3c07)
@@ -0,0 +1,54 @@
+<%@ taglib uri="tags-lams" prefix="lams"%>
+<%@ taglib uri="tags-core" prefix="c"%>
+<%@ taglib uri="tags-fmt" prefix="fmt"%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${toolError}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+