Index: lams_central/src/flash/org/lamsfoundation/lams/learner/Scratchpad.as =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/flash/org/lamsfoundation/lams/learner/Attic/Scratchpad.as,v diff -u -r1.1 -r1.2 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/notebook/web/StoreNBEntryServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/notebook/web/StoreNBEntryServlet.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/src/java/org/lamsfoundation/lams/notebook/web/StoreNBEntryServlet.java 31 Jul 2006 08:01:18 -0000 1.1 @@ -0,0 +1,125 @@ +/*************************************************************************** + * 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 version 2.0 + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ +/* $$Id: StoreNBEntryServlet.java,v 1.1 2006/07/31 08:01:18 mseaton Exp $$ */ +package org.lamsfoundation.lams.notebook.web; + +import java.util.Hashtable; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.util.wddx.FlashMessage; +import org.lamsfoundation.lams.util.wddx.WDDXProcessor; +import org.lamsfoundation.lams.util.wddx.WDDXTAGS; +import org.lamsfoundation.lams.web.servlet.AbstractStoreWDDXPacketServlet; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * Store a Notebook entry (private). + * + * @author Mitchell Seaton + * + * @web:servlet name="storeNotebookEntry" + * @web:servlet-mapping url-pattern="/notebook/storeNotebookEntry" + */ +public class StoreNBEntryServlet extends AbstractStoreWDDXPacketServlet { + + private static Logger log = Logger.getLogger(StoreNBEntryServlet.class); + public static final String STORE_NBENTRY_MESSAGE_KEY = "storeNotebookEntry"; + + /** for sending acknowledgment/error messages back to flash */ + private FlashMessage flashMessage; + + public ICoreNotebookService getNotebookService(){ + WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); + return (ICoreNotebookService) webContext.getBean("coreNotebookService"); + } + + protected String process(String entryDetails, HttpServletRequest request) + throws Exception + { + + ICoreNotebookService notebookService = getNotebookService(); + + + Hashtable table = (Hashtable)WDDXProcessor.deserialize(entryDetails); + NotebookEntry notebookEntry = new NotebookEntry(); + + try { + + if (keyExists(table, WDDXTAGS.EXTERNAL_ID)) { + notebookEntry.setExternalID(WDDXProcessor.convertToLong(table, WDDXTAGS.EXTERNAL_ID)); + } + if (keyExists(table, WDDXTAGS.EXTERNAL_ID_TYPE)) { + notebookEntry.setExternalIDType(WDDXProcessor.convertToInteger(table, WDDXTAGS.EXTERNAL_ID_TYPE)); + } + if (keyExists(table, WDDXTAGS.EXTERNAL_SIG)) { + notebookEntry.setExternalSignature(WDDXProcessor.convertToString(table, WDDXTAGS.EXTERNAL_SIG)); + } + if (keyExists(table, WDDXTAGS.USER_ID)) { + notebookEntry.setUserID(WDDXProcessor.convertToInteger(table, WDDXTAGS.USER_ID)); + } + if (keyExists(table, WDDXTAGS.TITLE)) { + notebookEntry.setTitle(WDDXProcessor.convertToString(table, WDDXTAGS.TITLE)); + } + if (keyExists(table, WDDXTAGS.ENTRY)) { + notebookEntry.setEntry(WDDXProcessor.convertToString(table, WDDXTAGS.ENTRY)); + } + + notebookService.saveOrUpdateNotebookEntry(notebookEntry); + + } catch ( Exception e ) { + flashMessage = new FlashMessage(STORE_NBENTRY_MESSAGE_KEY, + notebookService.getMessageService().getMessage("invalid.wddx.packet",new Object[]{e.getMessage()}), + FlashMessage.ERROR); + } + + flashMessage = new FlashMessage(STORE_NBENTRY_MESSAGE_KEY, notebookEntry.getUid()); + + return flashMessage.serializeMessage(); + + } + + protected String getMessageKey(String designDetails, HttpServletRequest request) { + return STORE_NBENTRY_MESSAGE_KEY; + } + + /** + * Checks whether the hashtable contains the key specified by key + * If the key exists, returns true, otherwise return false. + * @param table The hashtable to check + * @param key The key to find + * @return + */ + private boolean keyExists(Hashtable table, String key) + { + if (table.containsKey(key)) + return true; + else + return false; + } + +} Index: lams_learning/web/lams_learner.swf =================================================================== RCS file: /usr/local/cvsroot/lams_learning/web/Attic/lams_learner.swf,v diff -u -r1.34 -r1.35 Binary files differ