Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r01bae3b1a3ef4595d5a7968cf3a34cca816087d7 -ra025faab3c749cdf984d23d3ff43af98cfa68118 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 01bae3b1a3ef4595d5a7968cf3a34cca816087d7) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision a025faab3c749cdf984d23d3ff43af98cfa68118) @@ -36,6 +36,7 @@ import java.util.Properties; import java.util.Set; import java.util.SortedMap; +import java.util.TreeMap; import java.util.Vector; import java.util.Date; @@ -1259,6 +1260,24 @@ return flashMessage.serializeMessage(); } + /** + * @see org.lamsfoundation.lams.authoring.service.IAuthoringService#copyMultipleToolContent(java.lang.Integer, java.util.List) + */ + public String copyMultipleToolContent(Integer userId, List toolContentIds) { + StringBuffer idMap = new StringBuffer(); + for ( Long oldToolContentId : toolContentIds) { + if ( oldToolContentId != null ) { + Long newToolContentId = lamsCoreToolService.notifyToolToCopyContent(oldToolContentId); + idMap.append(oldToolContentId); + idMap.append('='); + idMap.append(newToolContentId); + idMap.append(','); + } + } + // return the id list, stripping off the trailing , + return idMap.length() > 0 ? idMap.substring(0, idMap.length()-1) : ""; + } + /** @see org.lamsfoundation.lams.authoring.service.IAuthoringService#getAvailableLicenses() */ public Vector getAvailableLicenses() { List licenses = licenseDAO.findAll(License.class); @@ -1358,6 +1377,6 @@ } return newName; } - + } \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java =================================================================== diff -u -r870373d635bc769aee2dc271e6ff12818fcfcea6 -ra025faab3c749cdf984d23d3ff43af98cfa68118 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java (.../IAuthoringService.java) (revision 870373d635bc769aee2dc271e6ff12818fcfcea6) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java (.../IAuthoringService.java) (revision a025faab3c749cdf984d23d3ff43af98cfa68118) @@ -25,6 +25,8 @@ import java.io.IOException; import java.util.List; +import java.util.Map; +import java.util.SortedMap; import java.util.Vector; import org.lamsfoundation.lams.learningdesign.Activity; @@ -50,6 +52,7 @@ public static final String STORE_LD_MESSAGE_KEY = "storeLearningDesignDetails"; public static final String INSERT_LD_MESSAGE_KEY = "insertLearningDesign"; public static final String START_EDIT_ON_FLY_MESSAGE_KEY = "startEditOnFly"; + public static final String COPY_TOOL_CONTENT_MESSAGE_KEY = "copyMultipleToolContent"; /** * Returns a populated LearningDesign object corresponding to the given learningDesignID @@ -239,6 +242,24 @@ */ public String copyToolContent(Long toolContentID) throws IOException; + /** + * Calls an appropriate tools to copy the content indicated by toolContentIds. Batch + * version of String copyToolContent(Long toolContentID). Returns a map containing + * the old and new ids, and this is converted to a WDDX format in the calling servlet. + * + * The is called when the user copies and pastes a complex activity icon in authoring. + * Authoring calls this method to copy all the contained tool activities' content + * in one go. + * + * It should only be called on a ToolActivity - never a Gate or Grouping or + * Complex activity. + * + * @param userId Id of the user requesting the copy + * @param toolContentIDs The toolContentIDs indicating the content to copy + * @return New Id map in format oldId1=newId1,oldId2=newId2,oldId3=newId3 + */ + public String copyMultipleToolContent(Integer userId,List toolContentIds); + /** Get the available licenses. This will include our supported Creative Common * licenses and an "OTHER" license which may be used for user entered license details. * The picture url supplied should be a full URL i.e. if it was a relative URL in the Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/CopyMultipleToolContentServlet.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/CopyMultipleToolContentServlet.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/CopyMultipleToolContentServlet.java (revision a025faab3c749cdf984d23d3ff43af98cfa68118) @@ -0,0 +1,118 @@ +/*************************************************************************** + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ************************************************************************ + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.authoring.web; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Map; +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.authoring.dto.StoreLearningDesignResultsDTO; +import org.lamsfoundation.lams.authoring.service.IAuthoringService; +import org.lamsfoundation.lams.learningdesign.LearningDesign; +import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; +import org.lamsfoundation.lams.learningdesign.dto.AuthoringActivityDTO; + +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +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.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + + +/** + * Copy all the tool content entries for the given ids. This is a batch version of AuthoringAction.copyToolContent. + * It is used when a complex object is copied in the Flash authoring client. + * + * Input: wddx packet containing tool content ids + * Output: wddx packet containing list of old a new ids, in the format oldId=newId,oldId=newId, etc + * + * @author Fiona Malikoff + * + * @web:servlet name="copyMultipleToolContent" + * @web:servlet-mapping url-pattern="/servlet/authoring/copyMultipleToolContent" + */ +public class CopyMultipleToolContentServlet extends AbstractStoreWDDXPacketServlet { + + private static Logger log = Logger.getLogger(CopyMultipleToolContentServlet.class); + + private Integer getUserId() { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + return user != null ? user.getUserID() : null; + } + + public IAuthoringService getAuthoringService(){ + WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); + return (IAuthoringService) webContext.getBean(AuthoringConstants.AUTHORING_SERVICE_BEAN_NAME); + } + + protected String process(String wddxPacket, HttpServletRequest request) + throws Exception + { + String returnPacket = null; + IAuthoringService authoringService = getAuthoringService(); + + try { + Hashtable table = (Hashtable)WDDXProcessor.deserialize(wddxPacket); + + String toolContentIdList = WDDXProcessor.convertToString(table,WDDXTAGS.TOOL_CONTENT_IDS); + if ( toolContentIdList != null ) { + String[] stringIds = toolContentIdList.split(","); + ArrayList longIds = new ArrayList(); + for ( int i=0; i 0 ) + longIds.add(new Long(stringIds[i])); + } + String idMap = authoringService.copyMultipleToolContent(getUserId(), longIds); + return new FlashMessage(getMessageKey(wddxPacket, request), idMap).serializeMessage(); + } + + return new FlashMessage(getMessageKey(wddxPacket, request), "").serializeMessage(); + + } catch ( Exception e) { + log.error("Authoring error. input packet was "+wddxPacket,e); + FlashMessage flashMessage = new FlashMessage(getMessageKey(wddxPacket, request), + authoringService.getMessageService().getMessage("invalid.wddx.packet",new Object[]{e.getMessage()}), + FlashMessage.ERROR); + returnPacket = flashMessage.serializeMessage(); + } + return returnPacket; + } + + protected String getMessageKey(String designDetails, HttpServletRequest request) { + return IAuthoringService.COPY_TOOL_CONTENT_MESSAGE_KEY; + } + +} Index: lams_central/web/WEB-INF/web.xml =================================================================== diff -u -r4f68a533e24967e0185132c5e361a8a054f43941 -ra025faab3c749cdf984d23d3ff43af98cfa68118 --- lams_central/web/WEB-INF/web.xml (.../web.xml) (revision 4f68a533e24967e0185132c5e361a8a054f43941) +++ lams_central/web/WEB-INF/web.xml (.../web.xml) (revision a025faab3c749cdf984d23d3ff43af98cfa68118) @@ -106,11 +106,15 @@ /fckeditor/* - + hibernateFilter /LoginRequest + hibernateFilter + /ForgotPasswordRequest + + LocaleFilter *.do @@ -154,6 +158,11 @@ + forgotPasswordServlet + org.lamsfoundation.lams.web.ForgotPasswordServlet + + + dumpWDDX org.lamsfoundation.lams.web.ReportWddxStructureServlet @@ -263,7 +272,12 @@ org.lamsfoundation.lams.notebook.web.StoreNBEntryServlet + + copyMultipleToolContent + org.lamsfoundation.lams.authoring.web.CopyMultipleToolContentServlet + + action @@ -384,6 +398,10 @@ + forgotPasswordServlet + /ForgotPasswordRequest + + dumpWDDX /servlet/dumpWDDX @@ -431,6 +449,10 @@ storeNotebookEntry /servlet/notebook/storeNotebookEntry + + copyMultipleToolContent + /servlet/authoring/copyMultipleToolContent + 120 @@ -533,11 +555,37 @@ Secure Content - *.jsp + /addLesson.jsp + /admin.jsp + /author.jsp + /authoringConfirm.jsp + /community.jsp + /editprofile.jsp + /footer.jsp + /group.jsp + /groupContents.jsp + /groupHeader.jsp + /header.jsp + /index.jsp + /lams_shared_library.jsp + /launchlearner.jsp + /learner.jsp + /lessons.jsp + /main.jsp + /monitorLesson.jsp + /msgContent.jsp + /passwordChangeContent.jsp + /passwordChangeOkContent.jsp + /portrait.jsp + /profile.jsp + /sysadmin.jsp + /template.jsp *.html *.do /servlet/* /fckeditor/* + /toolcontent/* + /development/* LEARNER