Index: lams_tool_dimdim/conf/hibernate/mappings/org/lamsfoundation/lams/tool/dimdim/model/DimdimConfig.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/conf/hibernate/mappings/org/lamsfoundation/lams/tool/dimdim/model/Attic/DimdimConfig.hbm.xml,v diff -u -r1.1 -r1.2 --- lams_tool_dimdim/conf/hibernate/mappings/org/lamsfoundation/lams/tool/dimdim/model/DimdimConfig.hbm.xml 1 Oct 2008 08:41:39 -0000 1.1 +++ lams_tool_dimdim/conf/hibernate/mappings/org/lamsfoundation/lams/tool/dimdim/model/DimdimConfig.hbm.xml 21 Nov 2008 06:32:54 -0000 1.2 @@ -8,7 +8,7 @@ > + + onlineInstructionsFiles; + Set onlineInstructionsFiles; - public Set offlineInstructionsFiles; + Set offlineInstructionsFiles; - public Set sessionDTOs = new TreeSet(); + Set sessionDTOs = new TreeSet(); - public Long currentTab; + Long currentTab; - private Integer maxAttendeeMikes; + Integer maxAttendeeMikes; /* Constructors */ public ContentDTO() { Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/NotebookEntryDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/Attic/NotebookEntryDTO.java,v diff -u -r1.5 -r1.6 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/NotebookEntryDTO.java 1 Oct 2008 02:59:36 -0000 1.5 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/NotebookEntryDTO.java 21 Nov 2008 06:32:54 -0000 1.6 @@ -30,13 +30,13 @@ public class NotebookEntryDTO { - private Long uid; + Long uid; - private String entry; + String entry; - private Date createDate; + Date createDate; - private Date lastModified; + Date lastModified; public NotebookEntryDTO(NotebookEntry notebookEntry) { this.uid = notebookEntry.getUid(); Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/UserDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/Attic/UserDTO.java,v diff -u -r1.4 -r1.5 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/UserDTO.java 1 Oct 2008 02:59:36 -0000 1.4 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/dto/UserDTO.java 21 Nov 2008 06:32:54 -0000 1.5 @@ -28,19 +28,19 @@ public class UserDTO implements Comparable { - public Long uid; + Long uid; - public String loginName; + String loginName; - public String firstName; + String firstName; - public String lastName; + String lastName; - public boolean finishedActivity; + boolean finishedActivity; - public NotebookEntryDTO notebookEntryDTO; + NotebookEntryDTO notebookEntryDTO; - public Long notebookEntryUID; + Long notebookEntryUID; public UserDTO(DimdimUser user) { this.uid = user.getUid(); Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/DimdimConfig.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/Attic/DimdimConfig.java,v diff -u -r1.3 -r1.4 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/DimdimConfig.java 30 Sep 2008 05:20:29 -0000 1.3 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/DimdimConfig.java 21 Nov 2008 06:32:54 -0000 1.4 @@ -25,7 +25,7 @@ package org.lamsfoundation.lams.tool.dimdim.model; /** - * @hibernate.class table="tl_laddim10_dimdim_config" + * @hibernate.class table="tl_laddim10_config" */ public class DimdimConfig { @@ -35,6 +35,15 @@ private String value; + public DimdimConfig() { + // default constructor + } + + public DimdimConfig(String key, String value) { + this.key = key; + this.value = value; + } + /** * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" */ Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/DimdimSession.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/Attic/DimdimSession.java,v diff -u -r1.8 -r1.9 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/DimdimSession.java 1 Oct 2008 04:21:27 -0000 1.8 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/model/DimdimSession.java 21 Nov 2008 06:32:54 -0000 1.9 @@ -61,6 +61,8 @@ private Set dimdimUsers; + private boolean meetingCreated; + private String meetingKey; private Integer maxAttendeeMikes; @@ -165,7 +167,19 @@ public void setDimdimUsers(Set dimdimUsers) { this.dimdimUsers = dimdimUsers; } + + /** + * @hibernate.property column="meeting_created" + * @return + */ + public boolean isMeetingCreated() { + return meetingCreated; + } + public void setMeetingCreated(boolean meetingCreated) { + this.meetingCreated = meetingCreated; + } + /** * @hibernate.property column="meeting_key" * @return Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java,v diff -u -r1.12 -r1.13 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java 8 Oct 2008 06:02:39 -0000 1.12 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/DimdimService.java 21 Nov 2008 06:32:54 -0000 1.13 @@ -32,13 +32,13 @@ import java.net.URLConnection; import java.net.URLEncoder; import java.util.Date; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -80,6 +80,7 @@ import org.lamsfoundation.lams.tool.dimdim.util.Constants; import org.lamsfoundation.lams.tool.dimdim.util.DimdimException; import org.lamsfoundation.lams.tool.dimdim.util.DimdimToolContentHandler; +import org.lamsfoundation.lams.tool.dimdim.util.DimdimUtil; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; @@ -139,7 +140,6 @@ session.setSessionId(toolSessionId); session.setSessionName(toolSessionName); // learner starts - // TODO need to also set other fields. Dimdim dimdim = getDimdimByContentId(toolContentId); session.setDimdim(dimdim); dimdimSessionDAO.insertOrUpdate(session); @@ -397,9 +397,17 @@ } } + @SuppressWarnings("unchecked") public DimdimUser getUserByUserIdAndSessionId(Long userId, Long toolSessionId) { - // TODO fix this - return dimdimUserDAO.getByUserIdAndSessionId(userId, toolSessionId); + Map map = new HashMap(); + map.put("userId", userId); + map.put("dimdimSession.sessionId", toolSessionId); + List list = dimdimUserDAO.findByProperties(DimdimUser.class, map); + if (list.isEmpty()) { + return null; + } else { + return list.get(0); + } } @SuppressWarnings("unchecked") @@ -410,7 +418,6 @@ } else { return list.get(0); } - } public DimdimAttachment uploadFileToContent(Long toolContentId, FormFile file, String type) { @@ -434,78 +441,151 @@ } } - /** - * - * @param url - * @return - */ - private String sendDimdimRequest(URL url) throws Exception { - URLConnection connection = url.openConnection(); - - BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String dimdimResponse = ""; - String line = ""; - - while ((line = in.readLine()) != null) - dimdimResponse += line; - in.close(); - - logger.debug(dimdimResponse + "1"); - - // Extract the connect url from the json string. - Pattern pattern = Pattern.compile("url:\"(.*?)\""); - Matcher matcher = pattern.matcher(dimdimResponse); - - matcher.find(); - String connectURL = matcher.group(1); - - return connectURL; - } - public String getDimdimJoinConferenceURL(UserDTO userDTO, String meetingKey) throws Exception { // Get Dimdim server url - DimdimConfig serverURL = getConfigEntry(Constants.CONFIG_SERVER_URL); - if (serverURL == null) { - throw new DimdimException("Dimdim server url not found"); + String standardServerURL = getConfigValue(Constants.CFG_STANDARD_SERVER_URL); + if (standardServerURL == null) { + logger.error("Config item : '" + Constants.CFG_STANDARD_SERVER_URL + "' not defined"); + throw new DimdimException("Standard server url not defined"); } - URL url = new URL(serverURL.getValue() + "/dimdim/JoinConferenceCheck.action?" + "email=" + URL url = new URL(standardServerURL + "/dimdim/JoinConferenceCheck.action?" + "email=" + URLEncoder.encode(userDTO.getEmail(), "UTF8") + "&displayName=" + URLEncoder.encode(userDTO.getFirstName() + " " + userDTO.getLastName(), "UTF8") + "&confKey=" + URLEncoder.encode(meetingKey, "UTF8")); - String connectURL = sendDimdimRequest(url); + String response = sendRequest(url); - return serverURL.getValue() + connectURL; + String result = DimdimUtil.getResult(response); + + if (result.equals("success")) { + String path = DimdimUtil.getStandardURL(response); + + return standardServerURL + path; + } else { + logger.error("getDimdimJoinConferenceURL: result: " + result); + } + return null; } - public String getDimdimStartConferenceURL(UserDTO userDTO, String meetingKey, String returnURL, - Integer maxAttendeeMikes) throws Exception { + public String getDimdimStartConferenceURL(UserDTO userDTO, String meetingKey, String returnURL, int maxAttendeeMikes) + throws Exception { - // Get Dimdim server url - DimdimConfig serverURL = getConfigEntry(Constants.CONFIG_SERVER_URL); - if (serverURL == null) { - logger.error("Dimdim server URL is null, configure using dimdim tool management"); - throw new DimdimException("Dimdim server url not found"); + // Get Standard Dimdim Server URL + String standardServerURL = getConfigValue(Constants.CFG_STANDARD_SERVER_URL); + if (standardServerURL == null) { + logger.error("Config item : '" + Constants.CFG_STANDARD_SERVER_URL + "' not defined"); + throw new DimdimException("Standard server url not defined"); } // get dimdim url - URL url = new URL(serverURL.getValue() + "/dimdim/StartNewConferenceCheck.action?" + "email=" + URL url = new URL(standardServerURL + "/dimdim/StartNewConferenceCheck.action?" + "email=" + URLEncoder.encode(userDTO.getEmail(), "UTF8") + "&displayName=" + URLEncoder.encode(userDTO.getFirstName() + " " + userDTO.getLastName(), "UTF8") + "&confKey=" + URLEncoder.encode(meetingKey, "UTF8") + "&lobby=false" + "&networkProfile=3" + "&meetingHours=99" + "&maxAttendeeMikes=" + maxAttendeeMikes + "&returnUrl=" + URLEncoder.encode(returnURL, "UTF8") + "&presenterAV=av" + "&privateChatEnabled=true" + "&publicChatEnabled=true" + "&screenShareEnabled=true" + "&whiteboardEnabled=true"); - String connectURL = sendDimdimRequest(url); + String response = sendRequest(url); - return serverURL.getValue() + connectURL; + String path = DimdimUtil.getStandardURL(response); + return standardServerURL + path; } + /** + * Create user for enterprise version. + */ + public String createUser(Long toolSessionID) throws Exception { + + String enterpriseServerURL = getConfigValue(Constants.CFG_ENTERPRISE_SERVER_URL); + if (enterpriseServerURL == null) { + logger.error("Config item : '" + Constants.CFG_ENTERPRISE_SERVER_URL + "' not defined"); + throw new DimdimException("Enterprise server url not defined"); + } + + String adminPassword = getConfigValue(Constants.CFG_ADMIN_PASSWORD); + if (adminPassword == null) { + logger.error("Config item : '" + Constants.CFG_ADMIN_PASSWORD + "' not defined"); + throw new DimdimException("Administrator credentials not defined"); + } + + URL url = new URL(enterpriseServerURL + "/portal/enterprise/CreateUser.action?" + "adminpassword=" + + adminPassword + "&name=" + "dimdim_" + toolSessionID + "&password=" + "dimdim_" + toolSessionID + + "&email=TODO@mail.com" + "&userType=Premium"); + + String response = sendRequest(url); + + return DimdimUtil.getCode(response); + } + + public String startAction(String username, String password, String returnURL, Integer maxAttendeeMikes) + throws Exception { + + String enterpriseServerURL = getConfigValue(Constants.CFG_ENTERPRISE_SERVER_URL); + if (enterpriseServerURL == null) { + logger.error("Config item : '" + Constants.CFG_ENTERPRISE_SERVER_URL + "' not defined"); + throw new DimdimException("Enterprise server url not defined"); + } + + String adminPassword = getConfigValue(Constants.CFG_ADMIN_PASSWORD); + if (adminPassword == null) { + logger.error("Config item : '" + Constants.CFG_ADMIN_PASSWORD + "' not defined"); + throw new DimdimException("Administrator credentials not defined"); + } + + URL url = new URL(enterpriseServerURL + "/portal/start.action?" + "name=" + + URLEncoder.encode("dimdim_" + username, "UTF8") + "&password=" + + URLEncoder.encode("dimdim_" + password, "UTF8") + "&returnurl=" + + URLEncoder.encode(returnURL, "UTF8") + "&waitingarea=false" + "&network=H" + "&hours=99" + "&mikes=" + + maxAttendeeMikes + "&audioVideo=V" + "&featurePrivateChat=true" + "&featurePublicChat=true" + + "&featurePublisher=true" + "&featureWhiteboard=true" + "&response=json"); + + String response = sendRequest(url); + + String returnCode = DimdimUtil.getCode(response); + + if (returnCode.equals("200")) { + return DimdimUtil.getEnterpriseURL(response); + } else { + logger.error("startAction: unsuccessfull return code: " + returnCode); + } + return null; + } + + public String joinMeeting(DimdimUser user) throws Exception { + + String enterpriseServerURL = getConfigValue(Constants.CFG_ENTERPRISE_SERVER_URL); + if (enterpriseServerURL == null) { + logger.error("Config item : '" + Constants.CFG_ENTERPRISE_SERVER_URL + "' not defined"); + throw new DimdimException("Enterprise server url not defined"); + } + + String adminPassword = getConfigValue(Constants.CFG_ADMIN_PASSWORD); + if (adminPassword == null) { + logger.error("Config item : '" + Constants.CFG_ADMIN_PASSWORD + "' not defined"); + throw new DimdimException("Administrator credentials not defined"); + } + + URL url = new URL(enterpriseServerURL + "/portal/join.action?" + "meetingRoomName=" + + URLEncoder.encode("dimdim_" + user.getDimdimSession().getSessionId(), "UTF8") + "&displayname=" + + URLEncoder.encode(user.getFirstName() + " " + user.getLastName(), "UTF8") + "&response=json"); + + String response = sendRequest(url); + + String returnCode = DimdimUtil.getCode(response); + + if (returnCode.equals("200")) { + return DimdimUtil.getEnterpriseURL(response); + } else { + logger.error("startAction: unsuccessfull return code: " + returnCode); + } + return null; + } + public void saveOrUpdateDimdim(Dimdim dimdim) { dimdimDAO.insertOrUpdate(dimdim); } @@ -525,8 +605,7 @@ } @SuppressWarnings("unchecked") - public DimdimConfig getConfigEntry(String key) { - dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); + public DimdimConfig getConfig(String key) { List list = (List) dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); if (list.isEmpty()) { return null; @@ -535,6 +614,16 @@ } } + @SuppressWarnings("unchecked") + public String getConfigValue(String key) { + List list = (List) dimdimConfigDAO.findByProperty(DimdimConfig.class, "key", key); + if (list.isEmpty()) { + return null; + } else { + return list.get(0).getValue(); + } + } + public void saveOrUpdateConfigEntry(DimdimConfig dimdimConfig) { dimdimConfigDAO.insertOrUpdate(dimdimConfig); } @@ -547,6 +636,29 @@ this.auditService = auditService; } + private String sendRequest(URL url) throws IOException { + + if (logger.isDebugEnabled()) { + logger.debug("request = " + url); + } + + URLConnection connection = url.openConnection(); + + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String response = ""; + String line = ""; + + while ((line = in.readLine()) != null) + response += line; + in.close(); + + if (logger.isDebugEnabled()) { + logger.debug("response = " + response); + } + + return response; + } + private NodeKey processFile(FormFile file, String type) { NodeKey node = null; if (file != null && !StringUtils.isEmpty(file.getFileName())) { @@ -645,8 +757,7 @@ dimdim.setReflectInstructions(description); } - // ========================================================================== - // =============== + // ========================================================================================= /* Used by Spring to "inject" the linked objects */ public IDimdimAttachmentDAO getDimdimAttachmentDAO() { Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/IDimdimService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/Attic/IDimdimService.java,v diff -u -r1.9 -r1.10 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/IDimdimService.java 8 Oct 2008 06:02:38 -0000 1.9 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/service/IDimdimService.java 21 Nov 2008 06:32:54 -0000 1.10 @@ -161,32 +161,65 @@ * * @param key */ - DimdimConfig getConfigEntry(String key); - + DimdimConfig getConfig(String key); + /** * * @param key + */ + String getConfigValue(String key); + + /** + * + * @param key * @param value */ void saveOrUpdateConfigEntry(DimdimConfig dimdimConfig); /** - * + * Start a standard meeting * @param userDTO * @param meetingKey * @param maxAttendeeMikes - * @return + * @return Meeting url * @throws Exception */ - String getDimdimStartConferenceURL(UserDTO userDTO, String meetingKey, String returnURL, Integer maxAttendeeMikes) + String getDimdimStartConferenceURL(UserDTO userDTO, String meetingKey, String returnURL, int maxAttendeeMikes) throws Exception; /** - * - * @param userDTOm + * Join a standard meeting + * @param userDTO * @param meetingKey - * @return + * @return Meeting url */ String getDimdimJoinConferenceURL(UserDTO userDTO, String meetingKey) throws Exception; + /** + * Create a user on an enterprise server + * @param toolSessionID + * @return Return code + */ + public String createUser(Long toolSessionID) throws Exception; + + + /** + * Start an enterprise meeting. + * @param username + * @param password + * @param returnURL + * @param maxAttendeeMikes + * @return Meeting url + * @throws Exception + */ + public String startAction(String username, String password, String returnURL, + Integer maxAttendeeMikes) throws Exception; + + /** + * Join an enterprise meeting. + * @param userDTO + * @return Meeting url + */ + public String joinMeeting(DimdimUser user) throws Exception; + } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/Constants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/Attic/Constants.java,v diff -u -r1.7 -r1.8 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/Constants.java 1 Oct 2008 02:59:36 -0000 1.7 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/Constants.java 21 Nov 2008 06:32:54 -0000 1.8 @@ -26,34 +26,44 @@ public final class Constants { - // Tool signature - public static final String TOOL_SIGNATURE = "laddim10"; + public static final String APP_RESOURCES = "org.lamsfoundation.lams.tool.dimdim.ApplicationResources"; + // Attribute names + public static final String ATTR_ALLOW_VERSION_CHANGE = "allowVersionChange"; + public static final String ATTR_CONFIG_DTO = "configDTO"; + public static final String ATTR_CONTENT_DTO = "contentDTO"; + public static final String ATTR_CONTENT_FOLDER_ID = "contentFolderID"; + public static final String ATTR_MEETING_OPEN = "meetingOpen"; + public static final String ATTR_MEETING_URL = "meetingURL"; + public static final String ATTR_MESSAGE_KEY = "messageKey"; + public static final String ATTR_SESSION_MAP = "sessionMap"; + public static final String ATTR_TOOL_SESSION_ID = "toolSessionID"; + public static final String ATTR_USER_DTO = "userDTO"; + // Configuration keys - public static final String CONFIG_SERVER_URL = "server_url"; + public static final String CFG_ADMIN_PASSWORD = "admin_password"; + public static final String CFG_ENTERPRISE_SERVER_URL = "enterprise_server_url"; + public static final String CFG_STANDARD_SERVER_URL = "standard_server_url"; + public static final String CFG_VERSION = "version"; + public static final String CFG_VERSION_ENTERPRISE = "enterprise"; + public static final String CFG_VERSION_STANDARD = "standard"; // Authoring SessionMap key names - public static final String KEY_TOOL_CONTENT_ID = "toolContentID"; public static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + public static final String KEY_DELETED_FILES = "deletedFiles"; public static final String KEY_MODE = "mode"; - public static final String KEY_ONLINE_FILES = "onlineFiles"; public static final String KEY_OFFLINE_FILES = "offlineFiles"; - public static final String KEY_UNSAVED_ONLINE_FILES = "unsavedOnlineFiles"; + public static final String KEY_ONLINE_FILES = "onlineFiles"; + public static final String KEY_TOOL_CONTENT_ID = "toolContentID"; public static final String KEY_UNSAVED_OFFLINE_FILES = "unsavedOfflineFiles"; - public static final String KEY_DELETED_FILES = "deletedFiles"; + public static final String KEY_UNSAVED_ONLINE_FILES = "unsavedOnlineFiles"; - // Attribute names - public static final String ATTR_CONTENT_DTO = "contentDTO"; - public static final String ATTR_CONTENT_FOLDER_ID = "contentFolderID"; - public static final String ATTR_SESSION_MAP = "sessionMap"; - public static final String ATTR_USER_DTO = "userDTO"; - public static final String ATTR_CONFERENCE_URL = "conferenceURL"; - public static final String ATTR_CONFERENCE_OPEN = "conferenceOpen"; - public static final String ATTR_TOOL_SESSION_ID = "toolSessionID"; - // Parameter names public static final String PARAM_USER_UID = "userUID"; + // Tool signature + public static final String TOOL_SIGNATURE = "laddim10"; + private Constants() { // prevent construction } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimToolContentHandler.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/Attic/DimdimToolContentHandler.java,v diff -u -r1.3 -r1.4 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimToolContentHandler.java 30 Sep 2008 05:20:29 -0000 1.3 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimToolContentHandler.java 21 Nov 2008 06:32:54 -0000 1.4 @@ -31,17 +31,15 @@ */ 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(); } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/Attic/DimdimUtil.java,v diff -u -r1.3 -r1.4 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimUtil.java 7 Oct 2008 05:33:12 -0000 1.3 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/util/DimdimUtil.java 21 Nov 2008 06:32:54 -0000 1.4 @@ -25,6 +25,8 @@ package org.lamsfoundation.lams.tool.dimdim.util; import java.util.Random; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; @@ -34,7 +36,7 @@ return new Long(System.currentTimeMillis()).toString() + "-" + (new Random().nextInt()); } - public static String generateReturnURL(HttpServletRequest request) { + public static String getReturnURL(HttpServletRequest request) { String protocol = request.getProtocol(); if (protocol.startsWith("HTTPS")) { protocol = "https://"; @@ -51,4 +53,43 @@ return path; } + + // helper functions to extract info from json response. + + + // get return code -- enterprise version + private static Pattern patternCode = Pattern.compile("code:\"(.*?)\""); + + public static String getCode(String json) { + Matcher matcher = patternCode.matcher(json); + matcher.find(); + return matcher.group(1); + } + + // get result -- standard version + private static Pattern patternResult = Pattern.compile("result:\"(.*?)\""); + + public static String getResult(String json) { + Matcher matcher = patternResult.matcher(json); + matcher.find(); + return matcher.group(1); + } + + // enterprise version + private static Pattern patternEnterpriseURL = Pattern.compile("data:\\{text:\"(.*?)\""); + + public static String getEnterpriseURL(String json) { + Matcher matcherUrl = patternEnterpriseURL.matcher(json); + matcherUrl.find(); + return matcherUrl.group(1); + } + + // standard version + private static Pattern patternStandardURL = Pattern.compile("url:\"(.*?)\""); + + public static String getStandardURL(String response) throws Exception { + Matcher matcher = patternStandardURL.matcher(response); + matcher.find(); + return matcher.group(1); + } } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AdminAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/Attic/AdminAction.java,v diff -u -r1.5 -r1.6 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AdminAction.java 30 Sep 2008 05:20:29 -0000 1.5 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AdminAction.java 21 Nov 2008 06:32:54 -0000 1.6 @@ -31,19 +31,24 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.MappingDispatchAction; +import org.lamsfoundation.lams.tool.dimdim.dto.ConfigDTO; import org.lamsfoundation.lams.tool.dimdim.model.DimdimConfig; import org.lamsfoundation.lams.tool.dimdim.service.DimdimServiceProxy; import org.lamsfoundation.lams.tool.dimdim.service.IDimdimService; import org.lamsfoundation.lams.tool.dimdim.util.Constants; import org.lamsfoundation.lams.tool.dimdim.web.forms.AdminForm; /** - * @struts.action path="/admin/main" name="adminForm" parameter="main" scope="request" validate="false" - * @struts.action-forward name="main-success" path="tiles:/admin/main" + * @struts.action path="/admin/view" name="adminForm" parameter="view" scope="request" validate="false" + * @struts.action-forward name="view-success" path="tiles:/admin/view" * - * @struts.action path="/admin/save" name="adminForm" parameter="save" scope="request" validate="false" - * @struts.action-forward name="save-success" redirect="true" path="/admin/main.do" + * @struts.action path="/admin/edit" name="adminForm" parameter="edit" scope="request" validate="false" + * @struts.action-forward name="edit-success" path="tiles:/admin/edit" * + * @struts.action path="/admin/save" name="adminForm" parameter="save" scope="request" validate="true" + * input="tiles:/admin/edit" + * @struts.action-forward name="save-success" redirect="true" path="/admin/view.do" + * * @author Anthony Sukkar * */ @@ -63,34 +68,77 @@ return super.execute(mapping, form, request, response); } - public ActionForward main(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + ConfigDTO configDTO = new ConfigDTO(); + + configDTO.setStandardServerURL(dimdimService.getConfigValue(Constants.CFG_STANDARD_SERVER_URL)); + configDTO.setEnterpriseServerURL(dimdimService.getConfigValue(Constants.CFG_ENTERPRISE_SERVER_URL)); + configDTO.setAdminPassword(dimdimService.getConfigValue(Constants.CFG_ADMIN_PASSWORD)); + configDTO.setVersion(dimdimService.getConfigValue(Constants.CFG_VERSION)); + + request.setAttribute(Constants.ATTR_CONFIG_DTO, configDTO); + return mapping.findForward("view-success"); + } + + public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + AdminForm adminForm = (AdminForm) form; - DimdimConfig serverURL = dimdimService.getConfigEntry(Constants.CONFIG_SERVER_URL); - if (serverURL != null) { - adminForm.setDimdimServerURL(serverURL.getValue()); + adminForm.setStandardServerURL(dimdimService.getConfigValue(Constants.CFG_STANDARD_SERVER_URL)); + adminForm.setEnterpriseServerURL(dimdimService.getConfigValue(Constants.CFG_ENTERPRISE_SERVER_URL)); + adminForm.setAdminPassword(dimdimService.getConfigValue(Constants.CFG_ADMIN_PASSWORD)); + adminForm.setVersion(dimdimService.getConfigValue(Constants.CFG_VERSION)); + + String version = adminForm.getVersion(); + boolean allowVersionChange = true; + if (isVersionSet(version)) { + allowVersionChange = false; } + request.setAttribute(Constants.ATTR_ALLOW_VERSION_CHANGE, allowVersionChange); - return mapping.findForward("main-success"); + return mapping.findForward("edit-success"); } public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - AdminForm adminForm = (AdminForm) form; + if (!isCancelled(request)) { - DimdimConfig dimdimConfig = dimdimService.getConfigEntry(Constants.CONFIG_SERVER_URL); + AdminForm adminForm = (AdminForm) form; - if (dimdimConfig == null) { - dimdimConfig = new DimdimConfig(); - dimdimConfig.setKey(Constants.CONFIG_SERVER_URL); - } + // if version is already set, do not update + String version = dimdimService.getConfigValue(Constants.CFG_VERSION); + if (!isVersionSet(version)) { + updateConfig(Constants.CFG_VERSION, adminForm.getVersion()); + } - dimdimConfig.setValue(adminForm.getDimdimServerURL()); - dimdimService.saveOrUpdateConfigEntry(dimdimConfig); + updateConfig(Constants.CFG_STANDARD_SERVER_URL, adminForm.getStandardServerURL()); + updateConfig(Constants.CFG_ENTERPRISE_SERVER_URL, adminForm.getEnterpriseServerURL()); + updateConfig(Constants.CFG_ADMIN_PASSWORD, adminForm.getAdminPassword()); + } + return mapping.findForward("save-success"); } + + private void updateConfig(String key, String value) { + + DimdimConfig config = dimdimService.getConfig(key); + + if (config == null) { + config = new DimdimConfig(key, value); + } else { + config.setValue(value); + } + + dimdimService.saveOrUpdateConfigEntry(config); + } + + private boolean isVersionSet(String version) { + return version != null + && (version.equals(Constants.CFG_VERSION_STANDARD) || version.equals(Constants.CFG_VERSION_ENTERPRISE)); + } } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java,v diff -u -r1.10 -r1.11 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java 7 Oct 2008 05:33:12 -0000 1.10 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/AuthoringAction.java 21 Nov 2008 06:32:54 -0000 1.11 @@ -135,7 +135,6 @@ public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - // TODO need error checking. // get authForm and session map. AuthoringForm authForm = (AuthoringForm) form; @@ -347,8 +346,8 @@ dimdim.setReflectOnActivity(authForm.isReflectOnActivity()); dimdim.setReflectInstructions(authForm.getReflectInstructions()); dimdim.setLockOnFinished(authForm.isLockOnFinished()); - - // TODO check whether these fields should be in here + + // dimdim fields dimdim.setMaxAttendeeMikes(authForm.getMaxAttendeeMikes()); } } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/LearningAction.java,v diff -u -r1.13 -r1.14 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/LearningAction.java 8 Oct 2008 06:02:39 -0000 1.13 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/LearningAction.java 21 Nov 2008 06:32:54 -0000 1.14 @@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; @@ -54,6 +53,8 @@ import org.lamsfoundation.lams.tool.dimdim.web.forms.LearningForm; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -66,6 +67,7 @@ * @struts.action-forward name="notebook" path="tiles:/learning/notebook" * @struts.action-forward name="runOffline" path="tiles:/learning/runOffline" * @struts.action-forward name="defineLater" path="tiles:/learning/defineLater" + * @struts.action-forward name="generalMessage" path="tiles:/general/message" */ public class LearningAction extends DispatchAction { @@ -83,113 +85,97 @@ return super.execute(mapping, form, request, response); } - public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { - LearningForm learningForm = (LearningForm) form; - - // 'toolSessionID' and 'mode' parameters are expected to be present. - // TODO need to catch exceptions and handle errors. - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, false); - Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); - // Retrieve the session and content. - DimdimSession dimdimSession = dimdimService.getSessionBySessionId(toolSessionID); - if (dimdimSession == null) { - throw new DimdimException("Cannot retrieve session with toolSessionID" + toolSessionID); - } + DimdimUser user = getCurrentUser(toolSessionID); - Dimdim dimdim = dimdimSession.getDimdim(); + if (user != null) { - // check defineLater - if (dimdim.isDefineLater()) { - return mapping.findForward("defineLater"); - } + LearningForm learningForm = (LearningForm) form; - // set mode, toolSessionID and DimdimDTO - request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); - learningForm.setToolSessionID(toolSessionID); + if (user.getNotebookEntryUID() == null) { + user.setNotebookEntryUID(dimdimService.createNotebookEntry(toolSessionID, + CoreNotebookConstants.NOTEBOOK_TOOL, Constants.TOOL_SIGNATURE, user.getUserId().intValue(), + learningForm.getEntryText())); + } else { + // update existing entry. + dimdimService.updateNotebookEntry(user.getNotebookEntryUID(), learningForm.getEntryText()); + } - ContentDTO contentDTO = new ContentDTO(); - contentDTO.title = dimdim.getTitle(); - contentDTO.instructions = dimdim.getInstructions(); - contentDTO.lockOnFinish = dimdim.isLockOnFinished(); - contentDTO.reflectOnActivity = dimdim.isReflectOnActivity(); - contentDTO.reflectInstructions = dimdim.getReflectInstructions(); - - request.setAttribute(Constants.ATTR_CONTENT_DTO, contentDTO); - - // Set the content in use flag. - if (!dimdim.isContentInUse()) { - dimdim.setContentInUse(true); - dimdimService.saveOrUpdateDimdim(dimdim); + user.setFinishedActivity(true); + dimdimService.saveOrUpdateDimdimUser(user); + } else { + logger.error("finishActivity(): couldn't find/create DimdimUser in toolSessionID: " + toolSessionID); } - // check runOffline - if (dimdim.isRunOffline()) { - return mapping.findForward("runOffline"); - } + ToolSessionManager sessionMgrService = DimdimServiceProxy.getDimdimSessionManager(getServlet() + .getServletContext()); - DimdimUser dimdimUser; - if (mode.equals(ToolAccessMode.TEACHER)) { - Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); - dimdimUser = dimdimService.getUserByUserIdAndSessionId(userID, toolSessionID); - } else { - dimdimUser = getCurrentUser(toolSessionID); + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, user.getUserId()); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new DimdimException(e); + } catch (ToolException e) { + throw new DimdimException(e); + } catch (IOException e) { + throw new DimdimException(e); } - // get any existing notebook entries and create userDTO - NotebookEntry entry = dimdimService.getNotebookEntry(dimdimUser.getNotebookEntryUID()); - UserDTO userDTO = new UserDTO(dimdimUser); - if (entry != null) { - userDTO.setNotebookEntryDTO(new NotebookEntryDTO(entry)); - } - request.setAttribute(Constants.ATTR_USER_DTO, userDTO); + return null; + } - // Get LAMS userDTO + private DimdimUser getCurrentUser(Long toolSessionId) { org.lamsfoundation.lams.usermanagement.dto.UserDTO lamsUserDTO = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager .getSession().getAttribute(AttributeNames.USER); - String connectURL = ""; - if (mode.isAuthor()) { - String meetingKey = DimdimUtil.generateMeetingKey(); - String returnURL = DimdimUtil.generateReturnURL(request); - connectURL = dimdimService.getDimdimStartConferenceURL(lamsUserDTO, meetingKey, returnURL, dimdim - .getMaxAttendeeMikes()); - } else { - if (dimdimSession.getMeetingKey() != null) { - connectURL = dimdimService.getDimdimJoinConferenceURL(lamsUserDTO, dimdimSession.getMeetingKey()); - } // otherwise, meeting has not been started in monitoring + // attempt to retrieve user using userId and toolSessionId + DimdimUser user = dimdimService.getUserByUserIdAndSessionId(new Long(lamsUserDTO.getUserID().intValue()), + toolSessionId); + + if (user == null) { + DimdimSession dimdimSession = dimdimService.getSessionBySessionId(toolSessionId); + user = dimdimService.createDimdimUser(lamsUserDTO, dimdimSession); } - boolean conferenceOpen = StringUtils.isEmpty(connectURL) ? false : true; - request.setAttribute(Constants.ATTR_CONFERENCE_OPEN, conferenceOpen); + return user; + } - if (conferenceOpen) { - request.setAttribute(Constants.ATTR_CONFERENCE_URL, connectURL); - } + private static final String CODE_OK = "200"; + private static final String CODE_USER_EXISTS = "302"; - // set toolSessionID in request - request.setAttribute(Constants.ATTR_TOOL_SESSION_ID, dimdimSession.getSessionId()); + public ActionForward openLearnerMeeting(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - return mapping.findForward("dimdim"); - } + // get user uid parameter + Long uid = WebUtil.readLongParam(request, Constants.PARAM_USER_UID); + DimdimUser user = dimdimService.getUserByUID(uid); + DimdimSession session = user.getDimdimSession(); - private DimdimUser getCurrentUser(Long toolSessionId) { - org.lamsfoundation.lams.usermanagement.dto.UserDTO user = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager - .getSession().getAttribute(AttributeNames.USER); + // Create new user on enterprise dimdim server using the toolSessionId as the name. + String returnCode = dimdimService.createUser(session.getSessionId()); - // attempt to retrieve user using userId and toolSessionId - DimdimUser dimdimUser = dimdimService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), - toolSessionId); + if (!returnCode.equals(CODE_OK) && !returnCode.equals(CODE_USER_EXISTS)) { + logger.error("Could not create dimdim enterprise user with id :" + session.getSessionId()); + throw new DimdimException("Unable to start dimdim enterprise meeting"); + } - if (dimdimUser == null) { - DimdimSession dimdimSession = dimdimService.getSessionBySessionId(toolSessionId); - dimdimUser = dimdimService.createDimdimUser(user, dimdimSession); + // Start a new dimdim web meeting + String meetingURL = dimdimService.joinMeeting(user); + + if (meetingURL != null) { + response.sendRedirect(meetingURL); + } else { + logger.error("startAction did not return a url to start the meeting"); + request.setAttribute(Constants.ATTR_MESSAGE_KEY, "message.unableToStartLesson"); + return mapping.findForward("generalMessage"); } - return dimdimUser; + return null; } public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, @@ -198,12 +184,12 @@ LearningForm lrnForm = (LearningForm) form; // set the finished flag - DimdimUser dimdimUser = getCurrentUser(lrnForm.getToolSessionID()); - ContentDTO contentDTO = new ContentDTO(dimdimUser.getDimdimSession().getDimdim()); + DimdimUser user = getCurrentUser(lrnForm.getToolSessionID()); + ContentDTO contentDTO = new ContentDTO(user.getDimdimSession().getDimdim()); request.setAttribute(Constants.ATTR_CONTENT_DTO, contentDTO); - NotebookEntry notebookEntry = dimdimService.getNotebookEntry(dimdimUser.getNotebookEntryUID()); + NotebookEntry notebookEntry = dimdimService.getNotebookEntry(user.getNotebookEntryUID()); if (notebookEntry != null) { lrnForm.setEntryText(notebookEntry.getEntry()); @@ -213,26 +199,56 @@ } + public ActionForward openPreviewMeeting(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // get user uid parameter + Long uid = WebUtil.readLongParam(request, Constants.PARAM_USER_UID); + DimdimUser user = dimdimService.getUserByUID(uid); + DimdimSession session = user.getDimdimSession(); + + // Create new user on enterprise dimdim server using the toolSessionId as the name. + String returnCode = dimdimService.createUser(session.getSessionId()); + + if (!returnCode.equals(CODE_OK) && !returnCode.equals(CODE_USER_EXISTS)) { + logger.error("Could not create dimdim enterprise user with id :" + session.getSessionId()); + throw new DimdimException("Unable to start dimdim enterprise meeting"); + } + + // Start a new dimdim web meeting + String meetingURL = dimdimService.startAction(session.getSessionId().toString(), session.getSessionId() + .toString(), DimdimUtil.getReturnURL(request), session.getDimdim().getMaxAttendeeMikes()); + + if (meetingURL != null) { + response.sendRedirect(meetingURL); + } else { + logger.error("startAction did not return a url to start the meeting"); + throw new DimdimException("Unable to start meeting"); + } + + return null; + } + public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { // save the reflection entry and call the notebook. LearningForm lrnForm = (LearningForm) form; - DimdimUser dimdimUser = getCurrentUser(lrnForm.getToolSessionID()); - Long toolSessionID = dimdimUser.getDimdimSession().getSessionId(); - Integer userID = dimdimUser.getUserId().intValue(); + DimdimUser user = getCurrentUser(lrnForm.getToolSessionID()); + Long toolSessionID = user.getDimdimSession().getSessionId(); + Integer userID = user.getUserId().intValue(); // check for existing notebook entry - NotebookEntry entry = dimdimService.getNotebookEntry(dimdimUser.getNotebookEntryUID()); + NotebookEntry entry = dimdimService.getNotebookEntry(user.getNotebookEntryUID()); if (entry == null) { // create new entry Long entryUID = dimdimService.createNotebookEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, Constants.TOOL_SIGNATURE, userID, lrnForm.getEntryText()); - dimdimUser.setNotebookEntryUID(entryUID); - dimdimService.saveOrUpdateDimdimUser(dimdimUser); + user.setNotebookEntryUID(entryUID); + dimdimService.saveOrUpdateDimdimUser(user); } else { // update existing entry entry.setEntry(lrnForm.getEntryText()); @@ -243,49 +259,126 @@ return finishActivity(mapping, form, request, response); } - public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) { + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + LearningForm learningForm = (LearningForm) form; + + // 'toolSessionID' and 'mode' parameters are expected to be present. + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, false); + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); - DimdimUser dimdimUser = getCurrentUser(toolSessionID); + // Retrieve the session and content. + DimdimSession session = dimdimService.getSessionBySessionId(toolSessionID); + if (session == null) { + throw new DimdimException("Cannot retrieve session with toolSessionID" + toolSessionID); + } - if (dimdimUser != null) { + Dimdim dimdim = session.getDimdim(); - LearningForm learningForm = (LearningForm) form; + // check defineLater + if (dimdim.isDefineLater()) { + return mapping.findForward("defineLater"); + } - // TODO fix idType to use real value not 999 + // set mode, toolSessionID and DimdimDTO + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + learningForm.setToolSessionID(toolSessionID); - if (dimdimUser.getNotebookEntryUID() == null) { - dimdimUser.setNotebookEntryUID(dimdimService.createNotebookEntry(toolSessionID, - CoreNotebookConstants.NOTEBOOK_TOOL, Constants.TOOL_SIGNATURE, dimdimUser.getUserId() - .intValue(), learningForm.getEntryText())); + ContentDTO contentDTO = new ContentDTO(); + contentDTO.setTitle(dimdim.getTitle()); + contentDTO.setInstructions(dimdim.getInstructions()); + contentDTO.setLockOnFinish(dimdim.isLockOnFinished()); + contentDTO.setReflectOnActivity(dimdim.isReflectOnActivity()); + contentDTO.setReflectInstructions(dimdim.getReflectInstructions()); + + request.setAttribute(Constants.ATTR_CONTENT_DTO, contentDTO); + + // Set the content in use flag. + if (!dimdim.isContentInUse()) { + dimdim.setContentInUse(true); + dimdimService.saveOrUpdateDimdim(dimdim); + } + + // check runOffline + if (dimdim.isRunOffline()) { + return mapping.findForward("runOffline"); + } + + DimdimUser user; + if (mode.equals(ToolAccessMode.TEACHER)) { + Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); + user = dimdimService.getUserByUserIdAndSessionId(userID, toolSessionID); + } else { + user = getCurrentUser(toolSessionID); + } + + // get any existing notebook entries and create userDTO + NotebookEntry entry = dimdimService.getNotebookEntry(user.getNotebookEntryUID()); + UserDTO userDTO = new UserDTO(user); + if (entry != null) { + userDTO.setNotebookEntryDTO(new NotebookEntryDTO(entry)); + } + request.setAttribute(Constants.ATTR_USER_DTO, userDTO); + + // Get LAMS userDTO + org.lamsfoundation.lams.usermanagement.dto.UserDTO lamsUserDTO = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager + .getSession().getAttribute(AttributeNames.USER); + + String meetingURL = new String(); + boolean meetingOpen = false; + + String version = dimdimService.getConfigValue(Constants.CFG_VERSION); + if (version == null) { + logger.error("Config value " + Constants.CFG_VERSION + " returned null"); + throw new DimdimException("Server version not defined"); + } + + if (version.equals(Constants.CFG_VERSION_ENTERPRISE)) { + // Enterprise Version + if (mode.isAuthor()) { + + meetingURL = Configuration.get(ConfigurationKeys.SERVER_URL) + "/tool/" + Constants.TOOL_SIGNATURE + + "/learning.do?dispatch=openPreviewMeeting&" + Constants.PARAM_USER_UID + "=" + + user.getUid(); + meetingOpen = true; } else { - // update existing entry. - dimdimService.updateNotebookEntry(dimdimUser.getNotebookEntryUID(), learningForm.getEntryText()); + if (session.isMeetingCreated()) { + meetingURL = Configuration.get(ConfigurationKeys.SERVER_URL) + "/tool/" + Constants.TOOL_SIGNATURE + + "/learning.do?dispatch=openLearnerMeeting&" + Constants.PARAM_USER_UID + "=" + + user.getUid(); + meetingOpen = true; + } // otherwise, meeting has not been started in monitoring } - dimdimUser.setFinishedActivity(true); - dimdimService.saveOrUpdateDimdimUser(dimdimUser); + } else if (version.equals(Constants.CFG_VERSION_STANDARD)) { + // Standard Version + + if (mode.isAuthor()) { + String meetingKey = DimdimUtil.generateMeetingKey(); + String returnURL = DimdimUtil.getReturnURL(request); + meetingURL = dimdimService.getDimdimStartConferenceURL(lamsUserDTO, meetingKey, returnURL, dimdim + .getMaxAttendeeMikes()); + meetingOpen = true; + } else { + if (session.isMeetingCreated()) { + meetingURL = dimdimService.getDimdimJoinConferenceURL(lamsUserDTO, session.getMeetingKey()); + meetingOpen = true; + } // otherwise, meeting has not been started in monitoring + } } else { - logger.error("finishActivity(): couldn't find/create DimdimUser in toolSessionID: " + toolSessionID); + // Illegal version value. + logger.error("Unknown dimdim version :'" + version + "'"); + throw new DimdimException("Unknown dimdim version"); } - ToolSessionManager sessionMgrService = DimdimServiceProxy.getDimdimSessionManager(getServlet() - .getServletContext()); + request.setAttribute(Constants.ATTR_MEETING_OPEN, meetingOpen); + request.setAttribute(Constants.ATTR_MEETING_URL, meetingURL); - String nextActivityUrl; - try { - nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, dimdimUser.getUserId()); - response.sendRedirect(nextActivityUrl); - } catch (DataMissingException e) { - throw new DimdimException(e); - } catch (ToolException e) { - throw new DimdimException(e); - } catch (IOException e) { - throw new DimdimException(e); - } + // set toolSessionID in request + request.setAttribute(Constants.ATTR_TOOL_SESSION_ID, session.getSessionId()); - return null; // TODO need to return proper page. + return mapping.findForward("dimdim"); } } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/MonitoringAction.java,v diff -u -r1.11 -r1.12 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/MonitoringAction.java 8 Oct 2008 06:02:39 -0000 1.11 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/actions/MonitoringAction.java 21 Nov 2008 06:32:54 -0000 1.12 @@ -27,6 +27,7 @@ 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; @@ -41,6 +42,7 @@ import org.lamsfoundation.lams.tool.dimdim.service.DimdimServiceProxy; import org.lamsfoundation.lams.tool.dimdim.service.IDimdimService; import org.lamsfoundation.lams.tool.dimdim.util.Constants; +import org.lamsfoundation.lams.tool.dimdim.util.DimdimException; import org.lamsfoundation.lams.tool.dimdim.util.DimdimUtil; import org.lamsfoundation.lams.tool.dimdim.web.forms.MonitoringForm; import org.lamsfoundation.lams.util.WebUtil; @@ -58,8 +60,7 @@ */ public class MonitoringAction extends DispatchAction { - // private static final Logger logger = - // Logger.getLogger(MonitoringAction.class); + private static final Logger logger = Logger.getLogger(MonitoringAction.class); private IDimdimService dimdimService; @@ -83,7 +84,8 @@ Dimdim dimdim = dimdimService.getDimdimByContentId(toolContentID); if (dimdim == null) { - // TODO error page. + logger.error("Unable to find tool content with id :" + toolContentID); + throw new DimdimException("Invalid value for " + AttributeNames.PARAM_TOOL_CONTENT_ID); } ContentDTO contentDT0 = new ContentDTO(dimdim); @@ -92,8 +94,6 @@ // populate using authoring values monitoringForm.setMaxAttendeeMikes((contentDT0.getMaxAttendeeMikes())); - // TODO may need to populate using session values if they already exist - Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); contentDT0.setCurrentTab(currentTab); @@ -117,7 +117,7 @@ return mapping.findForward("dimdim_display"); } - public ActionForward startDimdim(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward startMeeting(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MonitoringForm monitoringForm = (MonitoringForm) form; @@ -132,18 +132,59 @@ org.lamsfoundation.lams.usermanagement.dto.UserDTO lamsUserDTO = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager .getSession().getAttribute(AttributeNames.USER); - String meetingKey = DimdimUtil.generateMeetingKey(); - session.setMeetingKey(meetingKey); - dimdimService.saveOrUpdateDimdimSession(session); + // Get dimdim version + String version = dimdimService.getConfigValue(Constants.CFG_VERSION); + + if (version == null) { + logger.error("Config value " + Constants.CFG_VERSION + " returned null"); + throw new DimdimException("Server version not defined"); + } + + if (version.equals(Constants.CFG_VERSION_STANDARD)) { + // Standard Version + String meetingKey = DimdimUtil.generateMeetingKey(); + session.setMeetingCreated(true); + session.setMeetingKey(meetingKey); - String returnURL = DimdimUtil.generateReturnURL(request); + String returnURL = DimdimUtil.getReturnURL(request); - String startConferenceURL = dimdimService.getDimdimStartConferenceURL(lamsUserDTO, session.getMeetingKey(), - returnURL, session.getMaxAttendeeMikes()); + String startConferenceURL = dimdimService.getDimdimStartConferenceURL(lamsUserDTO, session.getMeetingKey(), + returnURL, session.getMaxAttendeeMikes()); - response.sendRedirect(startConferenceURL); + response.sendRedirect(startConferenceURL); + } else if (version.equals(Constants.CFG_VERSION_ENTERPRISE)) { + // Enterprise Version - return null; + // Create new user on enterprise dimdim server using the toolSessionId as the name. + // NB User may already exist + String returnCode = dimdimService.createUser(session.getSessionId()); + if (!returnCode.equals("200") && !returnCode.equals("302")) { + // 200 = success, 302 = user already exists + logger.error("Could not create dimdim enterprise user with id :" + session.getSessionId()); + throw new DimdimException("Unable to start dimdim enterprise meeting"); + } + + // Start a new dimdim web meeting + String meetingStartURL = dimdimService.startAction(session.getSessionId().toString(), session + .getSessionId().toString(), DimdimUtil.getReturnURL(request), session.getMaxAttendeeMikes()); + + if (meetingStartURL != null) { + session.setMeetingCreated(true); + response.sendRedirect(meetingStartURL); + } else { + logger.error("startAction did not return a url to start the meeting"); + throw new DimdimException("Unable to start meeting"); + } + + } else { + // Illegal version value. + logger.error("Unknown dimdim version :'" + version + "'"); + throw new DimdimException("Unknown dimdim version"); + } + + dimdimService.saveOrUpdateDimdimSession(session); + + return null; } } Index: lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/forms/AdminForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/forms/Attic/AdminForm.java,v diff -u -r1.5 -r1.6 --- lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/forms/AdminForm.java 30 Sep 2008 05:20:29 -0000 1.5 +++ lams_tool_dimdim/src/java/org/lamsfoundation/lams/tool/dimdim/web/forms/AdminForm.java 21 Nov 2008 06:32:54 -0000 1.6 @@ -30,6 +30,10 @@ import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.util.MessageResources; +import org.lamsfoundation.lams.tool.dimdim.util.Constants; /** * @struts.form name="adminForm" @@ -41,25 +45,77 @@ // Fields - private String dimdimServerURL; + private String adminPassword; + private String enterpriseServerURL; + + private String standardServerURL; + + private String version; + + public String getAdminPassword() { + return adminPassword; + } + + public String getEnterpriseServerURL() { + return enterpriseServerURL; + } + + public String getStandardServerURL() { + return standardServerURL; + } + + public String getVersion() { + return version; + } + + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + public void setEnterpriseServerURL(String enterpriseServerURL) { + this.enterpriseServerURL = enterpriseServerURL; + } + + public void setStandardServerURL(String standardServerURL) { + this.standardServerURL = standardServerURL; + } + + public void setVersion(String version) { + this.version = version; + } + @Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); - if (StringUtils.isBlank(this.dimdimServerURL)) { - // TODO add error messages; + MessageResources resources = MessageResources.getMessageResources(Constants.APP_RESOURCES); + + if (this.version.equals(Constants.CFG_VERSION_STANDARD)) { + // check standard options + if (StringUtils.isBlank(this.standardServerURL)) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mandatoryField", resources + .getMessage("config.standardServerURL"))); + } + + } else if (this.version.equals(Constants.CFG_VERSION_ENTERPRISE)) { + // check enterprise options + + if (StringUtils.isBlank(this.enterpriseServerURL)) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mandatoryField", resources + .getMessage("config.enterpriseServerURL"))); + } + + if (StringUtils.isBlank(this.adminPassword)) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mandatoryField", resources + .getMessage("config.adminPassword"))); + } + } else { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mandatoryField", resources + .getMessage("config.version"))); } return errors; } - public String getDimdimServerURL() { - return dimdimServerURL; - } - - public void setDimdimServerURL(String dimdimServerURL) { - this.dimdimServerURL = dimdimServerURL; - } - -} +} \ No newline at end of file Index: lams_tool_dimdim/web/WEB-INF/web.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/WEB-INF/web.xml,v diff -u -r1.3 -r1.4 --- lams_tool_dimdim/web/WEB-INF/web.xml 22 Sep 2008 05:29:25 -0000 1.3 +++ lams_tool_dimdim/web/WEB-INF/web.xml 21 Nov 2008 06:32:54 -0000 1.4 @@ -16,7 +16,8 @@ classpath:/org/lamsfoundation/lams/toolApplicationContext.xml classpath:/org/lamsfoundation/lams/learning/learningApplicationContext.xml classpath:/org/lamsfoundation/lams/contentrepository/applicationContext.xml - classpath:/org/lamsfoundation/lams/tool/dimdim/dimdimApplicationContext.xml + classpath:/org/lamsfoundation/lams/tool/dimdim/dimdimApplicationContext.xml + classpath:/org/lamsfoundation/lams/tool/dimdim/dbupdates/autopatchContext.xml @@ -61,6 +62,11 @@ org.springframework.web.context.ContextLoaderListener + + + org.lamsfoundation.lams.web.session.SetMaxTimeoutListener + + action @@ -139,6 +145,10 @@ /exportPortfolio + + 120 + + + Index: lams_tool_dimdim/web/WEB-INF/struts/tiles-defs.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/WEB-INF/struts/Attic/tiles-defs.xml,v diff -u -r1.5 -r1.6 --- lams_tool_dimdim/web/WEB-INF/struts/tiles-defs.xml 7 Oct 2008 05:33:12 -0000 1.5 +++ lams_tool_dimdim/web/WEB-INF/struts/tiles-defs.xml 21 Nov 2008 06:32:54 -0000 1.6 @@ -1,33 +1,27 @@ - + - + - + @@ -63,11 +57,11 @@ - + - + @@ -80,33 +74,43 @@ - + - + - + - - + + - + - - + + + + + + - + - + + + + + + Index: lams_tool_dimdim/web/common/message.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/common/Attic/message.jsp,v diff -u -r1.1 -r1.2 --- lams_tool_dimdim/web/common/message.jsp 15 Aug 2008 08:42:42 -0000 1.1 +++ lams_tool_dimdim/web/common/message.jsp 21 Nov 2008 06:32:54 -0000 1.2 @@ -1,10 +1,11 @@ <%@ include file="/common/taglibs.jsp"%> -

- <%-- TODO check if message exists --%> - -

+
+
-

- ${requestScope.message}; -

+
+ +
+
+ Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_tool_dimdim/web/pages/admin/admin.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_dimdim/web/pages/admin/edit.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/pages/admin/Attic/edit.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_dimdim/web/pages/admin/edit.jsp 21 Nov 2008 06:32:54 -0000 1.1 @@ -0,0 +1,85 @@ +<%@ include file="/common/taglibs.jsp"%> + + + + + + + +
+ +

+ + +

+ +
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ +
+ + + +
+
+ Index: lams_tool_dimdim/web/pages/admin/view.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/pages/admin/Attic/view.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_dimdim/web/pages/admin/view.jsp 21 Nov 2008 06:32:54 -0000 1.1 @@ -0,0 +1,32 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+ +

+ + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
Index: lams_tool_dimdim/web/pages/dimdim/end_meeting.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/pages/dimdim/Attic/end_meeting.jsp,v diff -u -r1.1 -r1.2 --- lams_tool_dimdim/web/pages/dimdim/end_meeting.jsp 7 Oct 2008 05:33:12 -0000 1.1 +++ lams_tool_dimdim/web/pages/dimdim/end_meeting.jsp 21 Nov 2008 06:32:54 -0000 1.2 @@ -1,15 +1,12 @@ <%@ include file="/common/taglibs.jsp"%>
-
- -
- -
- - - - - -
-
\ No newline at end of file + +
+ +
+ +
+ + \ No newline at end of file Index: lams_tool_dimdim/web/pages/learning/learning.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/pages/learning/Attic/learning.jsp,v diff -u -r1.6 -r1.7 --- lams_tool_dimdim/web/pages/learning/learning.jsp 1 Oct 2008 04:44:53 -0000 1.6 +++ lams_tool_dimdim/web/pages/learning/learning.jsp 21 Nov 2008 06:32:54 -0000 1.7 @@ -64,8 +64,8 @@

- - + + Index: lams_tool_dimdim/web/pages/monitoring/summary.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_dimdim/web/pages/monitoring/Attic/summary.jsp,v diff -u -r1.10 -r1.11 --- lams_tool_dimdim/web/pages/monitoring/summary.jsp 1 Oct 2008 04:44:53 -0000 1.10 +++ lams_tool_dimdim/web/pages/monitoring/summary.jsp 21 Nov 2008 06:32:54 -0000 1.11 @@ -48,93 +48,82 @@ - - - - - - - - + + +

- + ${session.sessionName}

- - - - - - - - - - - - - -
- - : - - - - - - - -
- - - -
-
-
- - - - - -

- ${session.sessionName} -

- -

- ${session.numberOfLearners} -

- - - - - - - - - - + +

+ +

+ + + + + + +

+ + : + + + + + + + +

+ +

+ + + +

+
+ + +

+ ${session.numberOfLearners} +

+ +
- - - -
+ - - + + - -
- ${user.firstName} ${user.lastName} - - - - - - - - - - - - - + + + +
-
+ + + + + + ${user.firstName} ${user.lastName} + + + + + + + + + + + + + + + + + + + + +