+
+
Ticket
to login and access the Content Repository.
+ *
+ * A valid ticket is needed in order to access the content from the
+ * repository. This method would be called evertime the tool needs to
+ * upload/download files from the content repository.
+ *
+ * @return ITicket The ticket for repostory access
+ * @throws SubmitFilesException
+ */
+ private ITicket getRepositoryLoginTicket() throws DimdimException {
+ repositoryService = RepositoryProxy.getRepositoryService();
+ ICredentials credentials = new SimpleCredentials(
+ DimdimToolContentHandler.repositoryUser,
+ DimdimToolContentHandler.repositoryId);
+ try {
+ ITicket ticket = repositoryService.login(credentials,
+ DimdimToolContentHandler.repositoryWorkspaceName);
+ return ticket;
+ } catch (AccessDeniedException ae) {
+ throw new DimdimException("Access Denied to repository."
+ + ae.getMessage());
+ } catch (WorkspaceNotFoundException we) {
+ throw new DimdimException("Workspace not found." + we.getMessage());
+ } catch (LoginException e) {
+ throw new DimdimException("Login failed." + e.getMessage());
+ }
+ }
+
+ /*
+ * ===============Methods implemented from ToolContentImport102Manager
+ * ===============
+ */
+
+ /**
+ * Import the data for a 1.0.2 Dimdim
+ */
+ public void import102ToolContent(Long toolContentId, UserDTO user,
+ Hashtable importValues) {
+ Date now = new Date();
+ Dimdim dimdim = new Dimdim();
+ dimdim.setContentInUse(Boolean.FALSE);
+ dimdim.setCreateBy(new Long(user.getUserID().longValue()));
+ dimdim.setCreateDate(now);
+ dimdim.setDefineLater(Boolean.FALSE);
+ dimdim.setInstructions(WebUtil.convertNewlines((String) importValues
+ .get(ToolContentImport102Manager.CONTENT_BODY)));
+ dimdim.setLockOnFinished(Boolean.TRUE);
+ dimdim.setOfflineInstructions(null);
+ dimdim.setOnlineInstructions(null);
+ dimdim.setRunOffline(Boolean.FALSE);
+ dimdim.setTitle((String) importValues
+ .get(ToolContentImport102Manager.CONTENT_TITLE));
+ dimdim.setToolContentId(toolContentId);
+ dimdim.setUpdateDate(now);
+ dimdim.setAllowRichEditor(Boolean.FALSE);
+ // leave as empty, no need to set them to anything.
+ // setDimdimAttachments(Set dimdimAttachments);
+ // setDimdimSessions(Set dimdimSessions);
+ saveOrUpdateDimdim(dimdim);
+ }
+
+ /**
+ * Set the description, throws away the title value as this is not supported
+ * in 2.0
+ */
+ public void setReflectiveData(Long toolContentId, String title,
+ String description) throws ToolException, DataMissingException {
+
+ logger
+ .warn("Setting the reflective field on a dimdim. This doesn't make sense as the dimdim is for reflection and we don't reflect on reflection!");
+ Dimdim dimdim = getDimdimByContentId(toolContentId);
+ if (dimdim == null) {
+ throw new DataMissingException(
+ "Unable to set reflective data titled " + title
+ + " on activity toolContentId " + toolContentId
+ + " as the tool content does not exist.");
+ }
+
+ dimdim.setInstructions(description);
+ }
+
+ // =========================================================================================
+ /* ********** Used by Spring to "inject" the linked objects ************* */
+
+ public IDimdimAttachmentDAO getDimdimAttachmentDAO() {
+ return dimdimAttachmentDAO;
+ }
+
+ public void setDimdimAttachmentDAO(IDimdimAttachmentDAO attachmentDAO) {
+ this.dimdimAttachmentDAO = attachmentDAO;
+ }
+
+ public IDimdimDAO getDimdimDAO() {
+ return dimdimDAO;
+ }
+
+ public void setDimdimDAO(IDimdimDAO dimdimDAO) {
+ this.dimdimDAO = dimdimDAO;
+ }
+
+ public IToolContentHandler getDimdimToolContentHandler() {
+ return dimdimToolContentHandler;
+ }
+
+ public void setDimdimToolContentHandler(
+ IToolContentHandler dimdimToolContentHandler) {
+ this.dimdimToolContentHandler = dimdimToolContentHandler;
+ }
+
+ public IDimdimSessionDAO getDimdimSessionDAO() {
+ return dimdimSessionDAO;
+ }
+
+ public void setDimdimSessionDAO(IDimdimSessionDAO sessionDAO) {
+ this.dimdimSessionDAO = sessionDAO;
+ }
+
+ public ILamsToolService getToolService() {
+ return toolService;
+ }
+
+ public void setToolService(ILamsToolService toolService) {
+ this.toolService = toolService;
+ }
+
+ public IDimdimUserDAO getDimdimUserDAO() {
+ return dimdimUserDAO;
+ }
+
+ public void setDimdimUserDAO(IDimdimUserDAO userDAO) {
+ this.dimdimUserDAO = userDAO;
+ }
+
+ public ILearnerService getLearnerService() {
+ return learnerService;
+ }
+
+ public void setLearnerService(ILearnerService learnerService) {
+ this.learnerService = learnerService;
+ }
+
+ public IExportToolContentService getExportContentService() {
+ return exportContentService;
+ }
+
+ public void setExportContentService(
+ IExportToolContentService exportContentService) {
+ this.exportContentService = exportContentService;
+ }
+
+ public ICoreNotebookService getCoreNotebookService() {
+ return coreNotebookService;
+ }
+
+ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
+ this.coreNotebookService = coreNotebookService;
+ }
+}
Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimServiceProxy.java
===================================================================
diff -u
--- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimServiceProxy.java (revision 0)
+++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimServiceProxy.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6)
@@ -0,0 +1,79 @@
+/****************************************************************
+ * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id$$ */
+
+package org.lamsfoundation.lams.tool.dimdim.service;
+
+import javax.servlet.ServletContext;
+
+import org.lamsfoundation.lams.tool.ToolContentManager;
+import org.lamsfoundation.lams.tool.ToolSessionManager;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * + * This class act as the proxy between web layer and service layer. It is + * designed to decouple the presentation logic and business logic completely. In + * this way, the presentation tier will no longer be aware of the changes in + * service layer. Therefore we can feel free to switch the business logic + * implementation. + *
+ */ + +public class DimdimServiceProxy { + + public static final IDimdimService getDimdimService( + ServletContext servletContext) { + return (IDimdimService) getDimdimDomainService(servletContext); + } + + private static Object getDimdimDomainService(ServletContext servletContext) { + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(servletContext); + return wac.getBean("dimdimService"); + } + + /* + * Return the dimdim tool version of tool session manager implementation. It + * will delegate to the Spring helper method to retrieve the proper bean + * from Spring bean factory. @param servletContext the servletContext for + * current application @return noticeboard service object. + */ + public static final ToolSessionManager getDimdimSessionManager( + ServletContext servletContext) { + return (ToolSessionManager) getDimdimDomainService(servletContext); + } + + /* + * Return the dimdim tool version of tool content manager implementation. It + * will delegate to the Spring helper method to retrieve the proper bean + * from Spring bean factory. @param servletContext the servletContext for + * current application @return noticeboard service object. + */ + public static final ToolContentManager getDimdimContentManager( + ServletContext servletContext) { + return (ToolContentManager) getDimdimDomainService(servletContext); + } + +} Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/IDimdimService.java =================================================================== diff -u --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/IDimdimService.java (revision 0) +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/IDimdimService.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,156 @@ +/**************************************************************** + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dimdim.service; + +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.dimdim.model.Dimdim; +import org.lamsfoundation.lams.tool.dimdim.model.DimdimAttachment; +import org.lamsfoundation.lams.tool.dimdim.model.DimdimSession; +import org.lamsfoundation.lams.tool.dimdim.model.DimdimUser; +import org.lamsfoundation.lams.tool.dimdim.util.DimdimException; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; + +/** + * Defines the services available to the web layer from the Dimdim Service + */ +public interface IDimdimService { + /** + * Makes a copy of the default content and assigns it a newContentID + * + * @params newContentID + * @return + */ + public Dimdim copyDefaultContent(Long newContentID); + + /** + * Returns an instance of the Dimdim tools default content. + * + * @return + */ + public Dimdim getDefaultContent(); + + /** + * @param toolSignature + * @return + */ + public Long getDefaultContentIdBySignature(String toolSignature); + + /** + * @param toolContentID + * @return + */ + public Dimdim getDimdimByContentId(Long toolContentID); + + /** + * @param toolContentId + * @param file + * @param type + * @return + */ + public DimdimAttachment uploadFileToContent(Long toolContentId, + FormFile file, String type); + + /** + * @param uuid + * @param versionID + */ + public void deleteFromRepository(Long uuid, Long versionID) + throws DimdimException; + + /** + * @param dimdim + */ + public void saveOrUpdateDimdim(Dimdim dimdim); + + /** + * @param toolSessionId + * @return + */ + public DimdimSession getSessionBySessionId(Long toolSessionId); + + /** + * @param dimdimSession + */ + public void saveOrUpdateDimdimSession(DimdimSession dimdimSession); + + /** + * + * @param userId + * @param toolSessionId + * @return + */ + public DimdimUser getUserByUserIdAndSessionId(Long userId, + Long toolSessionId); + + /** + * + * @param uid + * @return + */ + public DimdimUser getUserByUID(Long uid); + + /** + * + * @param dimdimUser + */ + public void saveOrUpdateDimdimUser(DimdimUser dimdimUser); + + /** + * + * @param user + * @param dimdimSession + * @return + */ + public DimdimUser createDimdimUser(UserDTO user, DimdimSession dimdimSession); + + /** + * + * @param id + * @param idType + * @param signature + * @param userID + * @param title + * @param entry + * @return + */ + Long createNotebookEntry(Long id, Integer idType, String signature, + Integer userID, String entry); + + /** + * + * @param uid + * @return + */ + NotebookEntry getEntry(Long uid); + + /** + * + * @param uid + * @param title + * @param entry + */ + void updateEntry(Long uid, String entry); +} Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimConstants.java =================================================================== diff -u --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimConstants.java (revision 0) +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimConstants.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,51 @@ +/**************************************************************** + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dimdim.util; + +public interface DimdimConstants { + public static final String TOOL_SIGNATURE = "laddim10"; + + // Dimdim session status + public static final Integer SESSION_NOT_STARTED = new Integer(0); + public static final Integer SESSION_IN_PROGRESS = new Integer(1); + public static final Integer SESSION_COMPLETED = new Integer(2); + + public static final String AUTHORING_DEFAULT_TAB = "1"; + public static final String ATTACHMENT_LIST = "attachmentList"; + public static final String DELETED_ATTACHMENT_LIST = "deletedAttachmentList"; + public static final String AUTH_SESSION_ID_COUNTER = "authoringSessionIdCounter"; + public static final String AUTH_SESSION_ID = "authoringSessionId"; + + public static final int MONITORING_SUMMARY_MAX_MESSAGES = 5; + + // Attribute names + public static final String ATTR_MESSAGE = "message"; + public static final String ATTR_SESSION_MAP = "sessionMap"; + + // Parameter names + public static final String PARAM_PARENT_PAGE = "parentPage"; + + static final String FILTER_REPLACE_TEXT = "***"; +} Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimException.java =================================================================== diff -u --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimException.java (revision 0) +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimException.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,57 @@ +/**************************************************************** + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dimdim.util; + +/** + * + * @author Anthony Sukkar + * + */ +public class DimdimException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -5518806968051758859L; + + public DimdimException(String message) { + super(message); + } + + public DimdimException(String message, Throwable cause) { + super(message, cause); + } + + public DimdimException() { + super(); + + } + + public DimdimException(Throwable cause) { + super(cause); + + } + +} Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimToolContentHandler.java =================================================================== diff -u --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimToolContentHandler.java (revision 0) +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimToolContentHandler.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,76 @@ +/**************************************************************** + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dimdim.util; + +import org.lamsfoundation.lams.contentrepository.client.ToolContentHandler; + +/** + * Simple client for accessing the content repository. + */ +public class DimdimToolContentHandler extends ToolContentHandler { + + // TODO these three fields were changed to public, since accessor methods + // cannot be made static. Check if we can do this a better way. + public static String repositoryWorkspaceName = "dimdimworkspace"; + + public static String repositoryUser = "dimdim"; + + public static char[] repositoryId = { 'l', 'a', 'm', 's', '-', 'e', 'x' }; + + /** + * + */ + public DimdimToolContentHandler() { + 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_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AdminAction.java =================================================================== diff -u --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AdminAction.java (revision 0) +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AdminAction.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,83 @@ +/**************************************************************** + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dimdim.web.actions; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.actions.MappingDispatchAction; +import org.lamsfoundation.lams.tool.dimdim.service.DimdimServiceProxy; +import org.lamsfoundation.lams.tool.dimdim.service.IDimdimService; + +/** + * @struts.action path="/admin/editConfig" name="adminForm" + * parameter="editConfig" scope="request" validate="false" + * @struts.action-forward name="editConfig-success" + * path="tiles:/admin/editConfig" + * + * @struts.action path="/admin/saveConfig" name="adminForm" + * parameter="saveConfig" scope="request" validate="false" + * @struts.action-forward name="saveConfig" path="tiles:/admin/saveConfig" + * + * @author asukkar + * + */ +public class AdminAction extends MappingDispatchAction { + + private IDimdimService dimdimService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws Exception { + + if (dimdimService == null) { + dimdimService = DimdimServiceProxy.getDimdimService(this + .getServlet().getServletContext()); + } + + return super.execute(mapping, form, request, response); + } + + public ActionForward editConfig(ActionMapping mapping, ActionForm form, + ServletRequest request, ServletResponse response) throws Exception { + + + + return mapping.findForward("editConfig-success"); + } + + public ActionForward saveConfig(ActionMapping mapping, ActionForm form, + ServletRequest request, ServletResponse response) throws Exception { + + return mapping.findForward("saveConfig-success"); + } + +} Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java =================================================================== diff -u --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java (revision 0) +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,476 @@ +/**************************************************************** + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dimdim.web.actions; + +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.dimdim.model.Dimdim; +import org.lamsfoundation.lams.tool.dimdim.model.DimdimAttachment; +import org.lamsfoundation.lams.tool.dimdim.service.DimdimServiceProxy; +import org.lamsfoundation.lams.tool.dimdim.service.IDimdimService; +import org.lamsfoundation.lams.tool.dimdim.util.DimdimConstants; +import org.lamsfoundation.lams.tool.dimdim.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.FileValidatorUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * @author + * @version + * + * @struts.action path="/authoring" name="authoringForm" parameter="dispatch" + * scope="request" validate="false" + * + * @struts.action-forward name="success" path="tiles:/authoring/main" + * @struts.action-forward name="message_page" path="tiles:/generic/message" + */ +public class AuthoringAction extends LamsDispatchAction { + + // private static Logger logger = Logger.getLogger(AuthoringAction.class); + + public IDimdimService dimdimService; + + // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + + private static final String KEY_MODE = "mode"; + + private static final String KEY_ONLINE_FILES = "onlineFiles"; + + private static final String KEY_OFFLINE_FILES = "offlineFiles"; + + private static final String KEY_UNSAVED_ONLINE_FILES = "unsavedOnlineFiles"; + + private static final String KEY_UNSAVED_OFFLINE_FILES = "unsavedOfflineFiles"; + + private static final String KEY_DELETED_FILES = "deletedFiles"; + + /** + * Default method when no dispatch parameter is specified. It is expected + * that the parametertoolContentID
will be passed in. This
+ * will be used to retrieve content for this tool.
+ *
+ */
+ protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ // Extract toolContentID from parameters.
+ Long toolContentID = new Long(WebUtil.readLongParam(request,
+ AttributeNames.PARAM_TOOL_CONTENT_ID));
+
+ String contentFolderID = WebUtil.readStrParam(request,
+ AttributeNames.PARAM_CONTENT_FOLDER_ID);
+
+ ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, "mode",
+ true);
+
+ // set up dimdimService
+ if (dimdimService == null) {
+ dimdimService = DimdimServiceProxy.getDimdimService(this
+ .getServlet().getServletContext());
+ }
+
+ // retrieving Dimdim with given toolContentID
+ Dimdim dimdim = dimdimService.getDimdimByContentId(toolContentID);
+ if (dimdim == null) {
+ dimdim = dimdimService.copyDefaultContent(toolContentID);
+ dimdim.setCreateDate(new Date());
+ dimdimService.saveOrUpdateDimdim(dimdim);
+ // TODO NOTE: this causes DB orphans when LD not saved.
+ }
+
+ if (mode != null && mode.isTeacher()) {
+ // Set the defineLater flag so that learners cannot use content
+ // while we
+ // are editing. This flag is released when updateContent is called.
+ dimdim.setDefineLater(true);
+ dimdimService.saveOrUpdateDimdim(dimdim);
+ }
+
+ // Set up the authForm.
+ AuthoringForm authForm = (AuthoringForm) form;
+ updateAuthForm(authForm, dimdim);
+
+ // Set up sessionMap
+ SessionMap
+
+
+ Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org +
Index: lams_tool_dimdim/web/common/message.jsp =================================================================== diff -u --- lams_tool_dimdim/web/common/message.jsp (revision 0) +++ lams_tool_dimdim/web/common/message.jsp (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,10 @@ +<%@ include file="/common/taglibs.jsp"%> + ++ ${requestScope.message}; +
Index: lams_tool_dimdim/web/common/simpleHeader.jsp =================================================================== diff -u --- lams_tool_dimdim/web/common/simpleHeader.jsp (revision 0) +++ lams_tool_dimdim/web/common/simpleHeader.jsp (revision 4c8de20e6e3ea73f98892f70662508e4011e96f6) @@ -0,0 +1,25 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+ + | +
+
+
+
+ |
+
+ + |
+
+
+
+ |
+
+ + | +
+
+
+
+ |
+
+
+ +
++ ${user.firstName} ${user.lastName } + | +|
---|---|
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ ${dimdimDTO.instructions} +
+ +
+
+ + ${userDTO.firstName} ${userDTO.lastName } ++ |
+ |
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+ |
+
+ |
+
+
+
+
+
+
+ |
+ ||
+ |
+ ||
+ |
+
+
+ |
+
+
+ |
+
+ + |
+ ||
+
+
+
+
+ |
+ ||
+ |
+ ||
+ |
+
+
+ |
+
+
+ |
+
+ + ${session.sessionName} ++ |
+
+ |
+ + ${session.numberOfLearners} + | +
+ |
+ + ${session.numberOfFinishedLearners} + | +
+ + ${session.sessionName} ++ |
+
+ |
+ + ${session.numberOfLearners} + | +
+ |
+
+ |
+
---|---|
+ ${user.firstName} ${user.lastName} + | +
+ |
+