+ +
+
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 every time
+ * the tool needs to upload/download files from the content repository.
+ *
+ * @return ITicket The ticket for repository access
+ * @throws SubmitFilesException
+ */
+ private ITicket getRepositoryLoginTicket() throws BbbException {
+ ICredentials credentials = new SimpleCredentials(BbbToolContentHandler.repositoryUser,
+ BbbToolContentHandler.repositoryId);
+ try {
+ ITicket ticket = repositoryService.login(credentials, BbbToolContentHandler.repositoryWorkspaceName);
+ return ticket;
+ } catch (AccessDeniedException ae) {
+ throw new BbbException("Access Denied to repository." + ae.getMessage());
+ } catch (WorkspaceNotFoundException we) {
+ throw new BbbException("Workspace not found." + we.getMessage());
+ } catch (LoginException e) {
+ throw new BbbException("Login failed." + e.getMessage());
+ }
+ }
+
+ /**
+ * 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 bbb. This doesn't make sense as the bbb is for reflection and we don't reflect on reflection!");
+ Bbb bbb = getBbbByContentId(toolContentId);
+ if (bbb == null) {
+ throw new DataMissingException("Unable to set reflective data titled " + title
+ + " on activity toolContentId " + toolContentId + " as the tool content does not exist.");
+ }
+
+ bbb.setReflectOnActivity(Boolean.TRUE);
+ bbb.setReflectInstructions(description);
+ }
+
+ // =========================================================================================
+ /* Used by Spring to "inject" the linked objects */
+
+ public IBbbAttachmentDAO getBbbAttachmentDAO() {
+ return bbbAttachmentDAO;
+ }
+
+ public void setBbbAttachmentDAO(IBbbAttachmentDAO attachmentDAO) {
+ this.bbbAttachmentDAO = attachmentDAO;
+ }
+
+ public IBbbDAO getBbbDAO() {
+ return bbbDAO;
+ }
+
+ public void setBbbDAO(IBbbDAO bbbDAO) {
+ this.bbbDAO = bbbDAO;
+ }
+
+ public IToolContentHandler getBbbToolContentHandler() {
+ return bbbToolContentHandler;
+ }
+
+ public void setBbbToolContentHandler(IToolContentHandler bbbToolContentHandler) {
+ this.bbbToolContentHandler = bbbToolContentHandler;
+ }
+
+ public IBbbSessionDAO getBbbSessionDAO() {
+ return bbbSessionDAO;
+ }
+
+ public void setBbbSessionDAO(IBbbSessionDAO sessionDAO) {
+ this.bbbSessionDAO = sessionDAO;
+ }
+
+ public IBbbConfigDAO getBbbConfigDAO() {
+ return bbbConfigDAO;
+ }
+
+ public void setBbbConfigDAO(IBbbConfigDAO bbbConfigDAO) {
+ this.bbbConfigDAO = bbbConfigDAO;
+ }
+
+ public ILamsToolService getToolService() {
+ return toolService;
+ }
+
+ public void setToolService(ILamsToolService toolService) {
+ this.toolService = toolService;
+ }
+
+ public IBbbUserDAO getBbbUserDAO() {
+ return bbbUserDAO;
+ }
+
+ public void setBbbUserDAO(IBbbUserDAO userDAO) {
+ this.bbbUserDAO = 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;
+ }
+
+ public IRepositoryService getRepositoryService() {
+ return repositoryService;
+ }
+
+ public void setRepositoryService(IRepositoryService repositoryService) {
+ this.repositoryService = repositoryService;
+ }
+
+
+}
Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbServiceProxy.java
===================================================================
diff -u
--- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbServiceProxy.java (revision 0)
+++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbServiceProxy.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5)
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.bbb.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 BbbServiceProxy { + + public static final IBbbService getBbbService(ServletContext servletContext) { + return (IBbbService) getBbbDomainService(servletContext); + } + + private static Object getBbbDomainService(ServletContext servletContext) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return wac.getBean("bbbService"); + } + + /* + * Return the bbb 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 getBbbSessionManager(ServletContext servletContext) { + return (ToolSessionManager) getBbbDomainService(servletContext); + } + + /* + * Return the bbb 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 getBbbContentManager(ServletContext servletContext) { + return (ToolContentManager) getBbbDomainService(servletContext); + } + +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/IBbbService.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/IBbbService.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/IBbbService.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,205 @@ +/**************************************************************** + * 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.bbb.service; + +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.bbb.model.Bbb; +import org.lamsfoundation.lams.tool.bbb.model.BbbAttachment; +import org.lamsfoundation.lams.tool.bbb.model.BbbConfig; +import org.lamsfoundation.lams.tool.bbb.model.BbbSession; +import org.lamsfoundation.lams.tool.bbb.model.BbbUser; +import org.lamsfoundation.lams.tool.bbb.util.BbbException; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; + +/** + * Defines the services available to the web layer from the Bbb Service + */ +public interface IBbbService { + /** + * Makes a copy of the default content and assigns it a newContentID + * + * @params newContentID + * @return + */ + public Bbb copyDefaultContent(Long newContentID); + + /** + * Returns an instance of the Bbb tools default content. + * + * @return + */ + public Bbb getDefaultContent(); + + /** + * @param toolSignature + * @return + */ + public Long getDefaultContentIdBySignature(String toolSignature); + + /** + * @param toolContentID + * @return + */ + public Bbb getBbbByContentId(Long toolContentID); + + /** + * @param toolContentId + * @param file + * @param type + * @return + */ + public BbbAttachment uploadFileToContent(Long toolContentId, FormFile file, String type); + + /** + * @param uuid + * @param versionID + */ + public void deleteFromRepository(Long uuid, Long versionID) throws BbbException; + + /** + * @param bbb + */ + public void saveOrUpdateBbb(Bbb bbb); + + /** + * @param toolSessionId + * @return + */ + public BbbSession getSessionBySessionId(Long toolSessionId); + + /** + * @param bbbSession + */ + public void saveOrUpdateBbbSession(BbbSession bbbSession); + + /** + * + * @param userId + * @param toolSessionId + * @return + */ + public BbbUser getUserByUserIdAndSessionId(Long userId, Long toolSessionId); + + /** + * + * @param uid + * @return + */ + public BbbUser getUserByUID(Long uid); + + /** + * + * @param bbbUser + */ + public void saveOrUpdateBbbUser(BbbUser bbbUser); + + /** + * + * @param user + * @param bbbSession + * @return + */ + public BbbUser createBbbUser(UserDTO user, BbbSession bbbSession); + + /** + * + * @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 getNotebookEntry(Long uid); + + /** + * + * @param notebookEntry + */ + void updateNotebookEntry(NotebookEntry notebookEntry); + + /** + * + * @param uid + * @param title + * @param entry + */ + void updateNotebookEntry(Long uid, String entry); + + /** + * + * @param key + */ + BbbConfig getConfig(String key); + + /** + * + * @param key + */ + String getConfigValue(String key); + + /** + * + * @param key + * @param value + */ + void saveOrUpdateConfigEntry(BbbConfig bbbConfig); + + /** + * Start a standard meeting + * + * @param meetingKey + * @param attendeePassword + * @param moderatorPassword + * @return Meeting url + * @throws Exception + */ + String startConference(String meetingKey, String atendeePassword, String moderatorPassword, + String returnURL, String welcomeMessage) + throws Exception; + + /** + * Join a standard meeting + * + * @param userDTO + * @param meetingKey + * @param password + * @return Meeting url + */ + String getJoinMeetingURL(UserDTO userDTO, String meetingKey, String password) throws Exception; + + Boolean isMeetingRunning(String meetingKey) throws Exception; + + +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbException.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbException.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbException.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,53 @@ +/**************************************************************** + * 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.bbb.util; + +/** + * + * @author Ernie Ghiglione + * + */ +public class BbbException extends RuntimeException { + + private static final long serialVersionUID = -5518806968051758859L; + + public BbbException(String message) { + super(message); + } + + public BbbException(String message, Throwable cause) { + super(message, cause); + } + + public BbbException() { + super(); + + } + + public BbbException(Throwable cause) { + super(cause); + + } +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbToolContentHandler.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbToolContentHandler.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbToolContentHandler.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.bbb.util; + +import org.lamsfoundation.lams.contentrepository.client.ToolContentHandler; + +/** + * Simple client for accessing the content repository. + */ +public class BbbToolContentHandler extends ToolContentHandler { + + public static String repositoryWorkspaceName = "bbbworkspace"; + + public static String repositoryUser = "bbb"; + + public static char[] repositoryId = { 'l', 'a', 'm', 's', '-', 'e', 'x' }; + + /** + * + */ + public BbbToolContentHandler() { + super(); + } + + /* + * (non-Javadoc) + * + * @seeorg.lamsfoundation.lams.contentrepository.client.ToolContentHandler# getRepositoryWorkspaceName() + */ + public String getRepositoryWorkspaceName() { + return repositoryWorkspaceName; + } + + /* + * (non-Javadoc) + * + * @seeorg.lamsfoundation.lams.contentrepository.client.ToolContentHandler# getRepositoryUser() + */ + public String getRepositoryUser() { + return repositoryUser; + } + + /* + * (non-Javadoc) + * + * @seeorg.lamsfoundation.lams.contentrepository.client.ToolContentHandler# getRepositoryId() + */ + public char[] getRepositoryId() { + return repositoryId; + } + +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbUtil.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbUtil.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/BbbUtil.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -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.bbb.util; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.http.HttpServletRequest; +import org.lamsfoundation.lams.integration.security.RandomPasswordGenerator; + +public class BbbUtil { + + public static String getMeetingKey(Long toolSessionId) { + return "bbb_" + RandomPasswordGenerator.nextPassword(12) + "-" + toolSessionId; + } + + public static String getReturnURL(HttpServletRequest request) { + String protocol; + if (request.isSecure()) { + protocol = "https://"; + } else { + protocol = "http://"; + } + + String path = protocol + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); + if (!path.endsWith("/")) { + path = path + "/"; + } + + path += "endMeeting.do"; + + return path; + } + + // helper functions to extract info from XML response. + + // 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); + } + + public static String getResponse(String response) throws Exception { + + if (response.contains(Constants.RESPONSE_SUCCESS)) { + return Constants.RESPONSE_SUCCESS; + } else { + return Constants.RESPONSE_FAIL; + + } + + + } + +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/Constants.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/Constants.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/util/Constants.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,72 @@ +/**************************************************************** + * 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.bbb.util; + +public final class Constants { + + public static final String APP_RESOURCES = "org.lamsfoundation.lams.tool.bbb.ApplicationResources"; + + // Attribute names + 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 CFG_SERVER_URL = "server_url"; + public static final String CFG_SECURITYSALT = "security_salt"; + + // Authoring SessionMap key names + 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_OFFLINE_FILES = "offlineFiles"; + 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_UNSAVED_ONLINE_FILES = "unsavedOnlineFiles"; + + // Big Blue Button parameters + public static final String BBB_CREATE_PARAM = "bigbluebutton/api/create?"; + public static final String BBB_JOIN_PARAM = "bigbluebutton/api/join?"; + public static final String BBB_MEETING_RUNNING_PARAM = "bigbluebutton/api/isMeetingRunning?"; + + // Parameter names + public static final String PARAM_USER_UID = "userUID"; + public static final String RESPONSE_SUCCESS = "SUCCESS"; + public static final String RESPONSE_FAIL = "FAIL"; + + // Tool signature + public static final String TOOL_SIGNATURE = "labbb10"; + + private Constants() { + // prevent construction + } +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/web/actions/AdminAction.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/web/actions/AdminAction.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/web/actions/AdminAction.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,129 @@ +/**************************************************************** + * 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.bbb.web.actions; + +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.bbb.dto.ConfigDTO; +import org.lamsfoundation.lams.tool.bbb.model.BbbConfig; +import org.lamsfoundation.lams.tool.bbb.service.BbbServiceProxy; +import org.lamsfoundation.lams.tool.bbb.service.IBbbService; +import org.lamsfoundation.lams.tool.bbb.util.Constants; +import org.lamsfoundation.lams.tool.bbb.web.forms.AdminForm; + + +/** + * @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/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 Ernie Ghiglione + * + */ +public class AdminAction extends MappingDispatchAction { + + private IBbbService bbbService; + + // private static final Logger logger = Logger.getLogger(AdminAction.class); + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // set up bbbService + bbbService = BbbServiceProxy.getBbbService(this.getServlet().getServletContext()); + + return super.execute(mapping, form, request, response); + } + + public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + ConfigDTO configDTO = new ConfigDTO(); + + configDTO.setServerURL(bbbService.getConfigValue(Constants.CFG_SERVER_URL)); + configDTO.setSecuritySalt(bbbService.getConfigValue(Constants.CFG_SECURITYSALT)); + + 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; + + adminForm.setServerURL(bbbService.getConfigValue(Constants.CFG_SERVER_URL)); + adminForm.setSecuritySalt(bbbService.getConfigValue(Constants.CFG_SECURITYSALT)); + + return mapping.findForward("edit-success"); + } + + public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + if (!isCancelled(request)) { + + AdminForm adminForm = (AdminForm) form; + + String bbbServerURL = adminForm.getServerURL().trim(); + + if (!bbbServerURL.endsWith("/")) { + bbbServerURL = bbbServerURL + "/"; + } + + updateConfig(Constants.CFG_SECURITYSALT, adminForm.getSecuritySalt()); + updateConfig(Constants.CFG_SERVER_URL, bbbServerURL); + + } + + return mapping.findForward("save-success"); + } + + private void updateConfig(String key, String value) { + + BbbConfig config = bbbService.getConfig(key); + + if (config == null) { + config = new BbbConfig(key, value); + } else { + config.setValue(value); + } + + bbbService.saveOrUpdateConfigEntry(config); + } + +} Index: lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/web/actions/AuthoringAction.java =================================================================== diff -u --- lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/web/actions/AuthoringAction.java (revision 0) +++ lams2/lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/web/actions/AuthoringAction.java (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,445 @@ +/**************************************************************** + * 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.bbb.web.actions; + +import java.lang.reflect.InvocationTargetException; +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.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.beanutils.BeanUtils; +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.actions.DispatchAction; +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.bbb.model.Bbb; +import org.lamsfoundation.lams.tool.bbb.model.BbbAttachment; +import org.lamsfoundation.lams.tool.bbb.service.BbbServiceProxy; +import org.lamsfoundation.lams.tool.bbb.service.IBbbService; +import org.lamsfoundation.lams.tool.bbb.util.Constants; +import org.lamsfoundation.lams.tool.bbb.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.FileValidatorUtil; +import org.lamsfoundation.lams.util.WebUtil; +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" + */ +public class AuthoringAction extends DispatchAction { + + // private static final Logger logger = + // Logger.getLogger(AuthoringAction.class); + + private IBbbService bbbService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // set up bbbService + bbbService = BbbServiceProxy.getBbbService(this.getServlet().getServletContext()); + + return super.execute(mapping, form, request, response); + } + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + *toolContentID
will be passed in. This will be used to retrieve content for this tool.
+ *
+ * @throws ServletException
+ *
+ */
+ protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws ServletException {
+
+ // 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, AttributeNames.PARAM_MODE, true);
+
+ // retrieving Bbb with given toolContentID
+ Bbb bbb = bbbService.getBbbByContentId(toolContentID);
+ if (bbb == null) {
+ bbb = bbbService.copyDefaultContent(toolContentID);
+ bbb.setCreateDate(new Date());
+ bbbService.saveOrUpdateBbb(bbb);
+ // 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.
+ bbb.setDefineLater(true);
+ bbbService.saveOrUpdateBbb(bbb);
+ }
+
+ // Set up the authForm.
+ AuthoringForm authForm = (AuthoringForm) form;
+ copyProperties(authForm, bbb);
+
+ // Set up sessionMap
+ SessionMap
+
+
+ Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org +
Index: lams2/lams_tool_bbb/web/common/message.jsp =================================================================== diff -u --- lams2/lams_tool_bbb/web/common/message.jsp (revision 0) +++ lams2/lams_tool_bbb/web/common/message.jsp (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,11 @@ +<%@ include file="/common/taglibs.jsp"%> + + + Index: lams2/lams_tool_bbb/web/common/simpleHeader.jsp =================================================================== diff -u --- lams2/lams_tool_bbb/web/common/simpleHeader.jsp (revision 0) +++ lams2/lams_tool_bbb/web/common/simpleHeader.jsp (revision 98e1b625dacfad7111d234a3ac508e98530e17c5) @@ -0,0 +1,25 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+ + | +
+
+
+
+ |
+
+ + |
+
+
+
+ |
+
+ + | +
+
+
+
+ |
+
+
+ ${contentDTO.instructions} +
+ +
+
+
+
+
+
+
+ |
+
+ |
+
+ |
+
+ |
+
+
+
+
+
+
+ |
+ ||
+ |
+ ||
+ |
+
+
+ |
+
+
+ |
+
+ + |
+ ||
+
+
+
+
+ |
+ ||
+ |
+ ||
+ |
+
+
+ |
+
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+ + ${session.numberOfLearners} + | +
+ |
+ + ${session.numberOfFinishedLearners} + | +
+
+
+ |
+
+ |
+
---|---|
+ ${user.firstName} ${user.lastName} + | +
+ |
+