Index: lams_tool_forum/conf/xdoclet/filter-mappings.xml
===================================================================
diff -u
--- lams_tool_forum/conf/xdoclet/filter-mappings.xml (revision 0)
+++ lams_tool_forum/conf/xdoclet/filter-mappings.xml (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -0,0 +1,8 @@
+
+ hibernateFilter
+ *.do
+
+
+ SystemSessionFilter
+ /*
+
\ No newline at end of file
Index: lams_tool_forum/conf/xdoclet/filters.xml
===================================================================
diff -u
--- lams_tool_forum/conf/xdoclet/filters.xml (revision 0)
+++ lams_tool_forum/conf/xdoclet/filters.xml (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -0,0 +1,19 @@
+
+ hibernateFilter
+
+ org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter
+
+
+ sessionFactoryBeanName
+ forumSessionFactory
+
+
+
+
+
+ SystemSessionFilter
+
+ org.lamsfoundation.lams.web.session.SystemSessionFilter
+
+
+
Index: lams_tool_forum/conf/xdoclet/struts-actions.xml
===================================================================
diff -u -rdd63636214e3a807dc010aa392ba85e62fb7dee1 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision dd63636214e3a807dc010aa392ba85e62fb7dee1)
+++ lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -3,7 +3,10 @@
+ name="forumForm"
+ scope="request"
+ parameter="initPage"
+ validate="false">
Index: lams_tool_forum/src/java/forumApplicationContext.xml
===================================================================
diff -u -r0653e8df3351a6178f4dcb842f4eda25a3d2341b -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/src/java/forumApplicationContext.xml (.../forumApplicationContext.xml) (revision 0653e8df3351a6178f4dcb842f4eda25a3d2341b)
+++ lams_tool_forum/src/java/forumApplicationContext.xml (.../forumApplicationContext.xml) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -3,7 +3,7 @@
-
+
@@ -22,28 +22,31 @@
-
+
-
+
-
+
-
+
+
+
+
@@ -54,6 +57,12 @@
+
+
+
+
+
+
@@ -76,8 +85,4 @@
-
-
-
-
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java
===================================================================
diff -u -r0653e8df3351a6178f4dcb842f4eda25a3d2341b -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 0653e8df3351a6178f4dcb842f4eda25a3d2341b)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -21,7 +21,6 @@
import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException;
import org.lamsfoundation.lams.contentrepository.service.IRepositoryService;
-import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy;
import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials;
import org.lamsfoundation.lams.tool.ToolContentManager;
import org.lamsfoundation.lams.tool.ToolSessionExportOutputData;
@@ -236,7 +235,7 @@
public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException {
}
- public Attachment uploadInstructionFile(Long contentId, FormFile uploadFile, String fileType) {
+ public Attachment uploadInstructionFile(Long contentId, FormFile uploadFile, String fileType) throws PersistenceException{
Attachment refile = null;
if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName()))
throw new ForumException("Could not find upload file: " + uploadFile);
@@ -347,7 +346,6 @@
* @throws SubmitFilesException
*/
private ITicket getRepositoryLoginTicket() throws ForumException {
- repositoryService = RepositoryProxy.getRepositoryService();
ICredentials credentials = new SimpleCredentials(
toolContentHandler.getRepositoryUser(),
toolContentHandler.getRepositoryId());
@@ -365,4 +363,12 @@
throw new ForumException("Login failed." + e.getMessage());
}
}
+
+ public IRepositoryService getRepositoryService() {
+ return repositoryService;
+ }
+
+ public void setRepositoryService(IRepositoryService repositoryService) {
+ this.repositoryService = repositoryService;
+ }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java
===================================================================
diff -u -r0653e8df3351a6178f4dcb842f4eda25a3d2341b -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 0653e8df3351a6178f4dcb842f4eda25a3d2341b)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -32,8 +32,8 @@
public Message getMessage(Long messageId) throws PersistenceException;
public void deleteMessage(Long messageId) throws PersistenceException;
public Message replyToMessage(Long parentId, Message message) throws PersistenceException;
- public Attachment uploadInstructionFile(Long contentId, FormFile file, String type);
- public void deleteInstructionFile(Long contentID, Long uuID, Long versionID, String type);
- public void deleteFromRepository(Long uuID, Long versionID);
+ public Attachment uploadInstructionFile(Long contentId, FormFile file, String type) throws PersistenceException;
+ public void deleteInstructionFile(Long contentID, Long uuID, Long versionID, String type) throws PersistenceException;
+ public void deleteFromRepository(Long uuID, Long versionID) throws PersistenceException;
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java
===================================================================
diff -u -rdd63636214e3a807dc010aa392ba85e62fb7dee1 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision dd63636214e3a807dc010aa392ba85e62fb7dee1)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -13,12 +13,11 @@
public final static String CONTENT_HANDLER = "toolContentHandler";
- public static final String TOOL_CONTENT_ID = "contentId";
-
public static final String AUTHORING_DTO = "authoring";
public static final String AUTHORING_TOPICS = "topics";
public static final String AUTHORING_TOPICS_LIST = "topicList";
- public static final String AUTHORING_ATTACHMENT = "attachment";
+ public static final String AUTHORING_OFFLINE_FILE = "offlineFiles";
+ public static final String AUTHORING_ONLINE_FILE = "onlineFiles";
public static final String DEFAULT_TITLE = "Forum";
//TODO:hard code!!! need to read from config
public static final String TOOL_URL_BASE = "/lams/tool/lafrum11/";
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java
===================================================================
diff -u -rdd63636214e3a807dc010aa392ba85e62fb7dee1 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision dd63636214e3a807dc010aa392ba85e62fb7dee1)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -50,6 +50,7 @@
import org.lamsfoundation.lams.tool.forum.web.forms.ForumForm;
import org.lamsfoundation.lams.tool.forum.web.forms.MessageForm;
import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.util.AttributeNames;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -108,7 +109,7 @@
HttpServletRequest request, HttpServletResponse response) {
- Long contentId = new Long(WebUtil.readLongParam(request,ForumConstants.TOOL_CONTENT_ID));
+ Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.TOOL_CONTENT_ID));
//get back the topic list and display them on page
forumService = getForumManager();
@@ -121,6 +122,7 @@
topics = forumService.getTopics(forum.getUid());
((ForumForm)form).setForum(forum);
}
+ ((ForumForm)form).setToolContentID(contentId);
} catch (PersistenceException e) {
log.error(e);
return mapping.findForward("error");
@@ -214,7 +216,7 @@
ForumForm forumForm = (ForumForm)(form);
Forum forum = forumForm.getForum();
Map topics = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_TOPICS);
- Map attachment = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_ATTACHMENT);
+ Map attachment = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_OFFLINE_FILE);
try {
forumService = getForumManager();
@@ -283,10 +285,20 @@
forumService = getForumManager();
Attachment att = forumService.uploadInstructionFile(content.getContentId(), file, type);
//update session
- Map attachmentMap = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_ATTACHMENT);
- attachmentMap.put(att.getUuid(),att);
-// request.getSession().setAttribute(ForumConstants.AUTHORING_ATTACHMENT,attachmentMap);
- return mapping.getInputForward();
+ if(StringUtils.equals(IToolContentHandler.TYPE_OFFLINE,type)){
+ Map attachmentMap = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_OFFLINE_FILE);
+ if(attachmentMap == null)
+ attachmentMap = new HashMap();
+ attachmentMap.put(att.getUuid(),att);
+ request.getSession().setAttribute(ForumConstants.AUTHORING_OFFLINE_FILE,attachmentMap);
+ }else{
+ Map attachmentMap = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_ONLINE_FILE);
+ if(attachmentMap == null)
+ attachmentMap = new HashMap();
+ attachmentMap.put(att.getUuid(),att);
+ request.getSession().setAttribute(ForumConstants.AUTHORING_ONLINE_FILE,attachmentMap);
+ }
+ return mapping.findForward("success");
}
@@ -306,18 +318,26 @@
* @return
*/
private ActionForward deleteFile(HttpServletRequest request, HttpServletResponse response, String type) {
- Long contentID = new Long(WebUtil.readLongParam(request,ForumConstants.TOOL_CONTENT_ID));
+ Long contentID = new Long(WebUtil.readLongParam(request,AttributeNames.TOOL_CONTENT_ID));
Long versionID = new Long(WebUtil.readLongParam(request,"versionID"));
Long uuID = new Long(WebUtil.readLongParam(request,"uuID"));
forumService = getForumManager();
forumService.deleteFromRepository(uuID,versionID);
- Map attachmentMap = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_ATTACHMENT);
- Attachment attachment = (Attachment) attachmentMap.remove(uuID);
+ Attachment attachment;
+ Map attachmentMap;
+ if(StringUtils.equals(IToolContentHandler.TYPE_OFFLINE,type)){
+ attachmentMap = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_OFFLINE_FILE);
+ attachment = (Attachment) attachmentMap.remove(uuID);
+ request.getSession().setAttribute(ForumConstants.AUTHORING_OFFLINE_FILE,attachmentMap);
+ }else{
+ attachmentMap = (Map) request.getSession().getAttribute(ForumConstants.AUTHORING_ONLINE_FILE);
+ attachment = (Attachment) attachmentMap.remove(uuID);
+ request.getSession().setAttribute(ForumConstants.AUTHORING_ONLINE_FILE,attachmentMap);
+ }
if (attachment.getUid() != null) {
forumService.deleteInstructionFile(contentID,uuID,versionID,type);
}
-// request.getSession().setAttribute(ForumConstants.AUTHORING_ATTACHMENT,attachmentMap);
Iterator iter = attachmentMap.values().iterator();
List list = new ArrayList();
@@ -381,10 +401,11 @@
Forum content = new Forum();
try {
- PropertyUtils.copyProperties(forum,content);
+ PropertyUtils.copyProperties(content,forum);
} catch (Exception e) {
log.error(e);
- }
+ }
+ content.setContentId(authForm.getToolContentID());
return content;
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java
===================================================================
diff -u -r0653e8df3351a6178f4dcb842f4eda25a3d2341b -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java (.../ForumForm.java) (revision 0653e8df3351a6178f4dcb842f4eda25a3d2341b)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java (.../ForumForm.java) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -1,14 +1,19 @@
package org.lamsfoundation.lams.tool.forum.web.forms;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import org.apache.struts.validator.ValidatorForm;
+import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler;
+import org.lamsfoundation.lams.tool.forum.persistence.Attachment;
import org.lamsfoundation.lams.tool.forum.persistence.Forum;
import org.lamsfoundation.lams.util.UploadFileUtil;
@@ -23,20 +28,43 @@
*/
public class ForumForm extends ValidatorForm {
private static final long serialVersionUID = -6054354910960460120L;
- private int currentTab;
+ private Long toolContentID;
+ private int currentTab;
private FormFile offlineFile;
private FormFile onlineFile;
+ private List onlineFileList;
+ private List offlineFileList;
private Forum forum;
private static Logger logger = Logger.getLogger(ForumForm.class.getName());
public ForumForm() {
+
+ this.toolContentID = new Long(0);
this.forum = new Forum();
this.forum.setTitle("New Forum");
}
public void setForum(Forum forum) {
this.forum = forum;
+ //set Form special varaible from given forum
+ if(forum != null){
+ this.toolContentID = forum.getContentId();
+ onlineFileList = new ArrayList();
+ offlineFileList = new ArrayList();
+ Set fileSet = forum.getAttachments();
+ if(fileSet != null){
+ Iterator iter = fileSet.iterator();
+ while(iter.hasNext()){
+ Attachment file = (Attachment) iter.next();
+ if(StringUtils.equalsIgnoreCase(file.getType(),IToolContentHandler.TYPE_OFFLINE))
+ offlineFileList.add(file);
+ else
+ onlineFileList.add(file);
+ }
+ }
+ }
+
}
public Forum getForum() {
@@ -96,4 +124,28 @@
public void setCurrentTab(int currentTab) {
this.currentTab = currentTab;
}
+
+ public Long getToolContentID() {
+ return toolContentID;
+ }
+
+ public void setToolContentID(Long toolContentID) {
+ this.toolContentID = toolContentID;
+ }
+
+ public List getOfflineFileList() {
+ return offlineFileList;
+ }
+
+ public void setOfflineFileList(List offlineFileList) {
+ this.offlineFileList = offlineFileList;
+ }
+
+ public List getOnlineFileList() {
+ return onlineFileList;
+ }
+
+ public void setOnlineFileList(List onlineFileList) {
+ this.onlineFileList = onlineFileList;
+ }
}
Index: lams_tool_forum/web/WEB-INF/struts-config.xml
===================================================================
diff -u -rdd63636214e3a807dc010aa392ba85e62fb7dee1 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision dd63636214e3a807dc010aa392ba85e62fb7dee1)
+++ lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -46,7 +46,10 @@
+ name="forumForm"
+ scope="request"
+ parameter="initPage"
+ validate="false">
Index: lams_tool_forum/web/WEB-INF/web.xml
===================================================================
diff -u -ree36bb343b77214b9bffd9a8e47dd9e8caa25813 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/web/WEB-INF/web.xml (.../web.xml) (revision ee36bb343b77214b9bffd9a8e47dd9e8caa25813)
+++ lams_tool_forum/web/WEB-INF/web.xml (.../web.xml) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -26,19 +26,32 @@
-
+
+ hibernateFilter
+
+ org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter
+
+
+ sessionFactoryBeanName
+ forumSessionFactory
+
+
+
+
+ SystemSessionFilter
+
+ org.lamsfoundation.lams.web.session.SystemSessionFilter
+
+
-
+
+ hibernateFilter
+ *.do
+
+
+ SystemSessionFilter
+ /*
+
Index: lams_tool_forum/web/jsps/authoring/basic.jsp
===================================================================
diff -u -rdd63636214e3a807dc010aa392ba85e62fb7dee1 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/web/jsps/authoring/basic.jsp (.../basic.jsp) (revision dd63636214e3a807dc010aa392ba85e62fb7dee1)
+++ lams_tool_forum/web/jsps/authoring/basic.jsp (.../basic.jsp) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -57,7 +57,7 @@
-
+
|
Index: lams_tool_forum/web/jsps/authoring/instructions.jsp
===================================================================
diff -u -rb1ef965ad3a0cd4ea7bb807bd313d1f0cf68d1e7 -r9401077810a09c0dc2a77ff8bce04b1efeb25353
--- lams_tool_forum/web/jsps/authoring/instructions.jsp (.../instructions.jsp) (revision b1ef965ad3a0cd4ea7bb807bd313d1f0cf68d1e7)
+++ lams_tool_forum/web/jsps/authoring/instructions.jsp (.../instructions.jsp) (revision 9401077810a09c0dc2a77ff8bce04b1efeb25353)
@@ -1,6 +1,7 @@