Index: lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McContent.hbm.xml
===================================================================
diff -u -re47ae0076c4cd0eae4874a006baaaa8da251c667 -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df
--- lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McContent.hbm.xml (.../McContent.hbm.xml) (revision e47ae0076c4cd0eae4874a006baaaa8da251c667)
+++ lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McContent.hbm.xml (.../McContent.hbm.xml) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -222,7 +222,25 @@
/>
+
+
DTO that holds file attachment data for jsp purposes + *
+ * + * @author Ozgur Demirtas + */ +public class McAttachmentDTO +{ + private String uid; + + private String uuid; + + private boolean isOfflineFile; + + private String filename; + /** + * @return Returns the filename. + */ + public String getFilename() { + return filename; + } + /** + * @param filename The filename to set. + */ + public void setFilename(String filename) { + this.filename = filename; + } + + /** + * @return Returns the uuid. + */ + public String getUuid() { + return uuid; + } + /** + * @param uuid The uuid to set. + */ + public void setUuid(String uuid) { + this.uuid = uuid; + } + /** + * @return Returns the isOfflineFile. + */ + public boolean isOfflineFile() { + return isOfflineFile; + } + /** + * @param isOfflineFile The isOfflineFile to set. + */ + public void setOfflineFile(boolean isOfflineFile) { + this.isOfflineFile = isOfflineFile; + } + /** + * @return Returns the uid. + */ + public String getUid() { + return uid; + } + /** + * @param uid The uid to set. + */ + public void setUid(String uid) { + this.uid = uid; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McContent.java =================================================================== diff -u -r25a3cd766f44f20c25042ad630f87b5b79a53671 -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McContent.java (.../McContent.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McContent.java (.../McContent.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df) @@ -113,9 +113,12 @@ /** persistent field */ private Set mcSessions; + + /** persistent field */ + private Set mcAttachments; /** full constructor */ - public McContent(Long mcContentId, String title, String instructions, boolean defineLater, boolean runOffline, String creationDate, Date updateDate, boolean questionsSequenced, boolean usernameVisible, String reportTitle, String monitoringReportTitle, long createdBy, boolean synchInMonitor, boolean contentInUse, String offlineInstructions, String onlineInstructions, String endLearningMessage, Integer passMark, boolean showFeedback, boolean retries, Set mcQueContents, Set mcSessions) { + public McContent(Long mcContentId, String title, String instructions, boolean defineLater, boolean runOffline, String creationDate, Date updateDate, boolean questionsSequenced, boolean usernameVisible, String reportTitle, String monitoringReportTitle, long createdBy, boolean synchInMonitor, boolean contentInUse, String offlineInstructions, String onlineInstructions, String endLearningMessage, Integer passMark, boolean showFeedback, boolean retries, Set mcQueContents, Set mcSessions, Set mcAttachments) { this.mcContentId = mcContentId; this.title = title; this.instructions = instructions; @@ -138,6 +141,7 @@ this.showFeedback = showFeedback; this.mcQueContents = mcQueContents; this.mcSessions = mcSessions; + this.mcAttachments = mcAttachments; } /** default constructor */ @@ -187,7 +191,9 @@ mc.isRetries(), mc.isShowFeedback(), new TreeSet(), - new TreeSet()); + new TreeSet(), + new TreeSet() + ); newContent.setMcQueContents(mc.deepCopyMcQueContent(newContent)); return newContent; } @@ -424,4 +430,16 @@ public void setShowReport(boolean showReport) { this.showReport = showReport; } + /** + * @return Returns the mcAttachments. + */ + public Set getMcAttachments() { + return mcAttachments; + } + /** + * @param mcAttachments The mcAttachments to set. + */ + public void setMcAttachments(Set mcAttachments) { + this.mcAttachments = mcAttachments; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java =================================================================== diff -u -r25a3cd766f44f20c25042ad630f87b5b79a53671 -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java (.../IMcUploadedFileDAO.java) (revision 25a3cd766f44f20c25042ad630f87b5b79a53671) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUploadedFileDAO.java (.../IMcUploadedFileDAO.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df) @@ -165,6 +165,9 @@ * @param mcContentId * @return List */ + + public boolean isUuidPersisted(String uuid); + public void cleanUploadedFilesMetaData(); public void flush(); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUploadedFileDAO.java =================================================================== diff -u -rd6cf8ad18993af7a9d51820aa2cd2274d1560ac7 -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUploadedFileDAO.java (.../McUploadedFileDAO.java) (revision d6cf8ad18993af7a9d51820aa2cd2274d1560ac7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUploadedFileDAO.java (.../McUploadedFileDAO.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df) @@ -52,10 +52,11 @@ private static final String GET_FILES_UUID ="select mcUploadedFile.uuid from McUploadedFile mcUploadedFile where mcUploadedFile.filename=:filename"; - private static final String GET_OFFLINE_FILES_UUIDPLUSFILENAME = "select (mcUploadedFile.uuid + '~' + mcUploadedFile.filename) from McUploadedFile mcUploadedFile where mcUploadedFile.mcContentId = :mcContentId and mcUploadedFile.fileOnline=0"; private static final String FIND_ALL_UPLOADED_FILE_DATA = "from mcUploadedFile in class McUploadedFile"; + + private static final String IS_UUID_PERSISTED ="select mcUploadedFile.uuid from McUploadedFile mcUploadedFile where mcUploadedFile.uuid=:uuid"; public McUploadedFile getUploadedFileById(long submissionId) @@ -77,24 +78,28 @@ public void updateUploadFile(McUploadedFile mcUploadedFile) { + this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().update(mcUploadedFile); this.getSession().setFlushMode(FlushMode.AUTO); } public void saveUploadFile(McUploadedFile mcUploadedFile) { + this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().save(mcUploadedFile); this.getSession().setFlushMode(FlushMode.AUTO); } public void createUploadFile(McUploadedFile mcUploadedFile) { + this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().save(mcUploadedFile); } public void UpdateUploadFile(McUploadedFile mcUploadedFile) { + this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().update(mcUploadedFile); } @@ -118,6 +123,20 @@ } + public boolean isUuidPersisted(String uuid) + { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(IS_UUID_PERSISTED) + .setString("uuid", uuid) + .list(); + + if (list != null && list.size() > 0) + { + return true; + } + return false; + } + public String getFileUuid(String filename) { @@ -237,6 +256,7 @@ public void deleteUploadFile(McUploadedFile mcUploadedFile) { + this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().delete(mcUploadedFile); } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml =================================================================== diff -u -r61b5e4280bd941e994fbb7f9f5d3ad39b5ff570c -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml (.../mcApplicationContext.xml) (revision 61b5e4280bd941e994fbb7f9f5d3ad39b5ff570c) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/mcApplicationContext.xml (.../mcApplicationContext.xml) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df) @@ -63,6 +63,11 @@Ticket
to login and access the Content Repository.
@@ -1744,9 +1768,13 @@
}
}
+
+ public boolean isUuidPersisted(String uuid) throws McApplicationException
+ {
+ return mcUploadedFileDAO.isUuidPersisted(uuid);
+ }
+
/**
- * !! COMPLETE THIS !!
- *
* adds a new entry to the uploaded files table
*/
public void persistFile(String uuid, boolean isOnlineFile, String fileName, McContent mcContent) throws McApplicationException {
@@ -2034,4 +2062,16 @@
this.mcUploadedFileDAO = mcUploadedFileDAO;
}
+ /**
+ * @return Returns the mcToolContentHandler.
+ */
+ public IToolContentHandler getMcToolContentHandler() {
+ return mcToolContentHandler;
+ }
+ /**
+ * @param mcToolContentHandler The mcToolContentHandler to set.
+ */
+ public void setMcToolContentHandler(IToolContentHandler mcToolContentHandler) {
+ this.mcToolContentHandler = mcToolContentHandler;
+ }
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McToolContentHandler.java
===================================================================
diff -u
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McToolContentHandler.java (revision 0)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McToolContentHandler.java (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -0,0 +1,64 @@
+/*
+Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+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
+*/
+package org.lamsfoundation.lams.tool.mc.util;
+
+import org.lamsfoundation.lams.contentrepository.client.ToolContentHandler;
+
+/**
+ * Simple client for accessing the content repository.
+ *
+ * @author Ozgur Demirtas
+ */
+public class McToolContentHandler extends ToolContentHandler {
+
+ private static String repositoryWorkspaceName = "lamc11";
+ private final String repositoryUser = "lamc11";
+ private final char[] repositoryId = {'l','a','m','c','_','1', '1'};
+
+
+ /**
+ *
+ */
+ public McToolContentHandler() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryWorkspaceName()
+ */
+ public String getRepositoryWorkspaceName() {
+ return repositoryWorkspaceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryUser()
+ */
+ public String getRepositoryUser() {
+ return repositoryUser;
+ }
+
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryId()
+ */
+ public char[] getRepositoryId() {
+ return repositoryId;
+ }
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java
===================================================================
diff -u -rb7285ac977222460053f4293718569503f17fe1e -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision b7285ac977222460053f4293718569503f17fe1e)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -3,6 +3,9 @@
*/
package org.lamsfoundation.lams.tool.mc.web;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
@@ -15,8 +18,13 @@
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
+import org.apache.struts.upload.FormFile;
+import org.lamsfoundation.lams.contentrepository.NodeKey;
+import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.mc.McAppConstants;
+import org.lamsfoundation.lams.tool.mc.McApplicationException;
+import org.lamsfoundation.lams.tool.mc.McAttachmentDTO;
import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McContent;
import org.lamsfoundation.lams.tool.mc.McOptsContent;
@@ -1539,6 +1547,185 @@
}
+ public static McAttachmentDTO uploadFile(HttpServletRequest request, McAuthoringForm mcAuthoringForm, boolean isOfflineFile) throws RepositoryCheckedException
+ {
+ logger.debug("doing uploadFile...");
+ logger.debug("isOfflineFile:" + isOfflineFile);
+
+ InputStream stream=null;
+ String fileName=null;
+ String mimeType=null;
+ String fileProperty=null;
+
+ if (isOfflineFile)
+ {
+ FormFile theOfflineFile = mcAuthoringForm.getTheOfflineFile();
+ logger.debug("retrieved theOfflineFile: " + theOfflineFile);
+
+
+ try
+ {
+ stream = theOfflineFile.getInputStream();
+ fileName=theOfflineFile.getFileName();
+ logger.debug("retrieved fileName: " + fileName);
+ fileProperty="OFFLINE";
+
+ }
+ catch(FileNotFoundException e)
+ {
+ logger.debug("filenotfound exception occured in accessing the repository server for the offline file : " + e.getMessage());
+ }
+ catch(IOException e)
+ {
+ logger.debug("io exception occured in accessing the repository server for the offline file : " + e.getMessage());
+ }
+
+ List listUploadedOfflineFileNames=(List)request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILENAMES);
+ logger.debug("listUploadedOfflineFileNames:" + listUploadedOfflineFileNames);
+ listUploadedOfflineFileNames.add(fileName);
+ logger.debug("listUploadedOfflineFileNames after add :" + listUploadedOfflineFileNames);
+ request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames);
+ }
+ else
+ {
+ FormFile theOnlineFile = mcAuthoringForm.getTheOnlineFile();
+ logger.debug("retrieved theOnlineFile: " + theOnlineFile);
+
+ try
+ {
+ stream = theOnlineFile.getInputStream();
+ fileName=theOnlineFile.getFileName();
+ logger.debug("retrieved fileName: " + fileName);
+ fileProperty="ONLINE";
+
+ }
+ catch(FileNotFoundException e)
+ {
+ logger.debug("filenotfound exception occured in accessing the repository server for the online file : " + e.getMessage());
+ }
+ catch(IOException e)
+ {
+ logger.debug("io exception occured in accessing the repository server for the online file : " + e.getMessage());
+ }
+ List listUploadedOnlineFileNames=(List)request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILENAMES);
+ logger.debug("listUploadedOnlineFileNames:" + listUploadedOnlineFileNames);
+ listUploadedOnlineFileNames.add(fileName);
+ logger.debug("listUploadedOnlineFileNames after add :" + listUploadedOnlineFileNames);
+ request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames);
+ }
+
+ IMcService mcService =McUtils.getToolService(request);
+ logger.debug("calling uploadFile with:");
+ logger.debug("istream:" + stream);
+ logger.debug("filename:" + fileName);
+ logger.debug("mimeType:" + mimeType);
+ logger.debug("fileProperty:" + fileProperty);
+
+ NodeKey nodeKey=mcService.uploadFile(stream, fileName, mimeType, fileProperty);
+ logger.debug("nodeKey:" + nodeKey);
+ logger.debug("nodeKey uuid:" + nodeKey.getUuid());
+
+ McAttachmentDTO mcAttachmentDTO= new McAttachmentDTO();
+ mcAttachmentDTO.setUid(null);
+ mcAttachmentDTO.setUuid(nodeKey.getUuid().toString());
+ mcAttachmentDTO.setFilename(fileName);
+ mcAttachmentDTO.setOfflineFile(isOfflineFile);
+
+ return mcAttachmentDTO;
+ }
+
+
+ public static void removeFileItem(HttpServletRequest request, String filename, String offlineFile)
+ {
+ logger.debug("offlineFile:" + offlineFile);
+ if (offlineFile.equals("1"))
+ {
+ logger.debug("will remove an offline file");
+ List listUploadedOfflineFileNames=(List)request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILENAMES);
+ logger.debug("listUploadedOfflineFileNames:" + listUploadedOfflineFileNames);
+ int index=findFileNameIndex(listUploadedOfflineFileNames, filename);
+ logger.debug("returned index:" + index);
+ listUploadedOfflineFileNames.remove(index);
+ logger.debug("listUploadedOfflineFileNames after remove :" + listUploadedOfflineFileNames);
+ request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames);
+ }
+ else
+ {
+ logger.debug("will remove an online file");
+ List listUploadedOnlineFileNames=(List)request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILENAMES);
+ logger.debug("listUploadedOnlineFileNames:" + listUploadedOnlineFileNames);
+ int index=findFileNameIndex(listUploadedOnlineFileNames, filename);
+ logger.debug("returned index:" + index);
+ listUploadedOnlineFileNames.remove(index);
+ logger.debug("listUploadedOnlineFileNames after remove :" + listUploadedOnlineFileNames);
+ request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames);
+ }
+ }
+
+
+ public static int findFileNameIndex(List listUploadedFileNames, String filename)
+ {
+ Iterator itListUploadedOfflineFileNames = listUploadedFileNames.iterator();
+ int mainIndex=0;
+ while (itListUploadedOfflineFileNames.hasNext())
+ {
+ mainIndex++;
+ String currentFilename=(String) itListUploadedOfflineFileNames.next();
+ logger.debug("currentFilename :" + currentFilename);
+ if (currentFilename.equals(filename))
+ {
+ logger.debug("currentFilename found in the list at mainIndex :" + mainIndex);
+ return mainIndex;
+ }
+ }
+ return 0;
+ }
+
+
+ public static void persistFilesMetaData(HttpServletRequest request, boolean isOfflineFile, McContent mcContent)
+ {
+ IMcService mcService =McUtils.getToolService(request);
+
+ List listFilesMetaData=null;
+ logger.debug("doing persistFilesMetaData...");
+ logger.debug("isOfflineFile:" + isOfflineFile);
+
+ if (isOfflineFile)
+ {
+ listFilesMetaData =(List)request.getSession().getAttribute(LIST_OFFLINEFILES_METADATA);
+ }
+ else
+ {
+ listFilesMetaData =(List)request.getSession().getAttribute(LIST_ONLINEFILES_METADATA);
+ }
+ logger.debug("listFilesMetaData:" + listFilesMetaData);
+
+ Iterator itListFilesMetaData = listFilesMetaData.iterator();
+ while (itListFilesMetaData.hasNext())
+ {
+ McAttachmentDTO mcAttachmentDTO=(McAttachmentDTO)itListFilesMetaData.next();
+ logger.debug("mcAttachmentDTO:" + mcAttachmentDTO);
+ String uid=mcAttachmentDTO.getUid();
+ logger.debug("uid:" + uid);
+
+ String uuid=mcAttachmentDTO.getUuid();
+ boolean isOnlineFile=!mcAttachmentDTO.isOfflineFile();
+ String fileName=mcAttachmentDTO.getFilename();
+
+ if (uid == null)
+ {
+ logger.debug("persisting files metadata...");
+ if (!mcService.isUuidPersisted(uuid))
+ {
+ mcService.persistFile(uuid, isOnlineFile, fileName, mcContent);
+ }
+ }
+ }
+ }
+
+
+
+
public void simulatePropertyInspector_RunOffline(HttpServletRequest request)
{
IMcService mcService =McUtils.getToolService(request);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java
===================================================================
diff -u -rb7285ac977222460053f4293718569503f17fe1e -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision b7285ac977222460053f4293718569503f17fe1e)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -39,8 +39,10 @@
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
+import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.tool.mc.McAppConstants;
import org.lamsfoundation.lams.tool.mc.McApplicationException;
+import org.lamsfoundation.lams.tool.mc.McAttachmentDTO;
import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McContent;
import org.lamsfoundation.lams.tool.mc.McOptsContent;
@@ -1422,10 +1424,14 @@
logger.debug("calling selectAndPersistOptions");
AuthoringUtil.selectAndPersistOptions(request, mapStartupGeneralOptionsContent, mapStartupGeneralSelectedOptionsContent, mapGeneralOptionsContent, mapGeneralSelectedOptionsContent, mapStartupGeneralOptionsQueId);
+ logger.debug("start persisting offline files metadata");
+ AuthoringUtil.persistFilesMetaData(request, true, mcContent);
+ logger.debug("start persisting online files metadata");
+ AuthoringUtil.persistFilesMetaData(request, false, mcContent);
- logger.debug("will do addUploadedFilesMetaData");
- McUtils.addUploadedFilesMetaData(request,mcContent);
- logger.debug("done addUploadedFilesMetaData");
+ //logger.debug("will do addUploadedFilesMetaData");
+ //McUtils.addUploadedFilesMetaData(request,mcContent);
+ //logger.debug("done addUploadedFilesMetaData");
errors.clear();
errors.add(Globals.ERROR_KEY,new ActionMessage("submit.successful"));
@@ -1529,12 +1535,59 @@
request.getSession().setAttribute(FILE_NAME, filename);
mcAuthoringForm.resetUserAction();
- request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(2));
- logger.debug("setting EDIT_OPTIONS_MODE :" + 2);
- return (mapping.findForward(ALL_INSTRUCTIONS));
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ logger.debug("setting EDIT_OPTIONS_MODE :" + 0);
+ return (mapping.findForward(LOAD_QUESTIONS));
}
+
+ /**
+ * removes file data
+ * deleteFileItem(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ *
+ * @param request
+ * @param form
+ * @param mapping
+ * @return ActionForward
+ */
+ public ActionForward deleteFileItem(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+
+ {
+ logger.debug("dispatching deleteFileItem...");
+ McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
+ IMcService mcService =McUtils.getToolService(request);
+
+ AuthoringUtil.readData(request, mcAuthoringForm);
+
+ String userAction="deleteFileItem";
+ request.setAttribute(USER_ACTION, userAction);
+ logger.debug("userAction:" + userAction);
+
+ String filename= request.getParameter("fileItem");
+ logger.debug("filename:" + filename);
+
+ String offlineFile= request.getParameter("offlineFile");
+ logger.debug("offlineFile:" + offlineFile);
+
+ logger.debug("start removing file:" + filename + " it is an:" + offlineFile);
+ AuthoringUtil.removeFileItem(request, filename, offlineFile);
+ logger.debug("done removing offline file");
+
+ mcAuthoringForm.resetUserAction();
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ logger.debug("setting EDIT_OPTIONS_MODE :" + 0);
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
/**
* moves from Advanced Tab to Basic Tab
* doneAdvancedTab(ActionMapping mapping,
@@ -1616,7 +1669,8 @@
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException,
- ServletException
+ ServletException,
+ RepositoryCheckedException
{
logger.debug("dispatching submitOfflineFile...");
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
@@ -1628,13 +1682,20 @@
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
- McUtils.addFileToContentRepository(request, mcAuthoringForm, true);
- logger.debug("offline file added to repository successfully.");
-
+ logger.debug("will uploadFile for offline file:");
+ McAttachmentDTO mcAttachmentDTO=AuthoringUtil.uploadFile(request, mcAuthoringForm, true);
+ logger.debug("returned mcAttachmentDTO:" + mcAttachmentDTO);
+
+ List listOfflineFilesMetaData =(List)request.getSession().getAttribute(LIST_OFFLINEFILES_METADATA);
+ logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData);
+ listOfflineFilesMetaData.add(mcAttachmentDTO);
+ logger.debug("listOfflineFilesMetaData after add:" + listOfflineFilesMetaData);
+ request.getSession().setAttribute(LIST_OFFLINEFILES_METADATA, listOfflineFilesMetaData);
+
mcAuthoringForm.resetUserAction();
- request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(2));
- logger.debug("setting EDIT_OPTIONS_MODE :" + 2 );
- return (mapping.findForward(ALL_INSTRUCTIONS));
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ logger.debug("setting EDIT_OPTIONS_MODE :" + 0);
+ return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -1654,7 +1715,8 @@
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException,
- ServletException
+ ServletException,
+ RepositoryCheckedException
{
logger.debug("dispatching submitOnlineFiles...");
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
@@ -1666,13 +1728,20 @@
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
- McUtils.addFileToContentRepository(request, mcAuthoringForm, false);
- logger.debug("online file added to repository successfully.");
-
+ logger.debug("will uploadFile for online file:");
+ McAttachmentDTO mcAttachmentDTO=AuthoringUtil.uploadFile(request, mcAuthoringForm, false);
+ logger.debug("returned mcAttachmentDTO:" + mcAttachmentDTO);
+
+ List listOnlineFilesMetaData =(List)request.getSession().getAttribute(LIST_ONLINEFILES_METADATA);
+ logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData);
+ listOnlineFilesMetaData.add(mcAttachmentDTO);
+ logger.debug("listOnlineFilesMetaData after add:" + listOnlineFilesMetaData);
+ request.getSession().setAttribute(LIST_ONLINEFILES_METADATA, listOnlineFilesMetaData);
+
mcAuthoringForm.resetUserAction();
- request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(2));
- logger.debug("setting EDIT_OPTIONS_MODE :" + 2);
- return (mapping.findForward(ALL_INSTRUCTIONS));
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ logger.debug("setting EDIT_OPTIONS_MODE :" + 0);
+ return (mapping.findForward(LOAD_QUESTIONS));
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java
===================================================================
diff -u -rb7285ac977222460053f4293718569503f17fe1e -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision b7285ac977222460053f4293718569503f17fe1e)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -24,6 +24,7 @@
protected String fileItem;
protected FormFile receivedFile;
+ protected String offlineFile;
protected String addContent;
protected String removeContent;
@@ -121,6 +122,7 @@
this.submitTabDone=null;
this.submitOfflineFile=null;
this.submitOnlineFile=null;
+ this.offlineFile=null;
this.dispatch=null;
@@ -726,4 +728,17 @@
public void setDispatch(String buttonValue) {
this.dispatch = buttonValue;
}
+
+ /**
+ * @return Returns the offlineFile.
+ */
+ public String getOfflineFile() {
+ return offlineFile;
+ }
+ /**
+ * @param offlineFile The offlineFile to set.
+ */
+ public void setOfflineFile(String offlineFile) {
+ this.offlineFile = offlineFile;
+ }
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java
===================================================================
diff -u -r947350765d420ce70874db716e0b8ef38c295abf -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 947350765d420ce70874db716e0b8ef38c295abf)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -589,6 +589,12 @@
request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES,listUploadedOnlineFiles);
request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames);
+
+ LinkedList listOfflineFilesMetaData= new LinkedList();
+ LinkedList listOnlineFilesMetaData= new LinkedList();
+ request.getSession().setAttribute(LIST_OFFLINEFILES_METADATA, listOfflineFilesMetaData);
+ request.getSession().setAttribute(LIST_ONLINEFILES_METADATA, listOnlineFilesMetaData);
+
Map mapQuestionsContent= new TreeMap(new McComparator());
Map mapOptionsContent= new TreeMap(new McComparator());
Map mapDefaultOptionsContent= new TreeMap(new McComparator());
Index: lams_tool_lamc/web/InstructionsContent.jsp
===================================================================
diff -u -rb7285ac977222460053f4293718569503f17fe1e -ra94de5ff6e0fa1bf65e068d94c81ccdd232c06df
--- lams_tool_lamc/web/InstructionsContent.jsp (.../InstructionsContent.jsp) (revision b7285ac977222460053f4293718569503f17fe1e)
+++ lams_tool_lamc/web/InstructionsContent.jsp (.../InstructionsContent.jsp) (revision a94de5ff6e0fa1bf65e068d94c81ccdd232c06df)
@@ -16,6 +16,12 @@
submitMethod(actionMethod);
}
+function deleteFileItem(fileItemValue, actionMethod, offlineFile) {
+ document.McAuthoringForm.fileItem.value=fileItemValue;
+ document.McAuthoringForm.offlineFile.value=offlineFile;
+ submitMethod(actionMethod);
+}
+
//-->
@@ -55,6 +61,9 @@