Index: lams_tool_wiki/build.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/build.properties,v diff -u -r1.2 -r1.3 --- lams_tool_wiki/build.properties 21 Jan 2009 22:17:04 -0000 1.2 +++ lams_tool_wiki/build.properties 19 Mar 2012 14:39:35 -0000 1.3 @@ -3,7 +3,7 @@ signature=lawiki10 #project version -tool.version=20090121 +tool.version=20120315 package=org/lamsfoundation/lams/tool/wiki package.name=org.lamsfoundation.lams.tool.wiki Index: lams_tool_wiki/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/conf/language/lams/ApplicationResources.properties,v diff -u -r1.10 -r1.11 --- lams_tool_wiki/conf/language/lams/ApplicationResources.properties 13 Mar 2012 17:28:07 -0000 1.10 +++ lams_tool_wiki/conf/language/lams/ApplicationResources.properties 19 Mar 2012 14:39:35 -0000 1.11 @@ -118,6 +118,9 @@ label.wiki.remove =Remove label.wiki.remove.toolTip =Remove this Wiki page label.wiki.remove.confirm =Are you sure you want to delete this Wiki page? This action cannot be undone. +label.wiki.remove.mark.toolTip =Mark this page as removed +label.wiki.remove.mark.confirm =Are you sure you want to mark this Wiki page as removed? +label.wiki.removed =This page has been removed. label.wiki.pages =Wiki Pages label.wiki.savechanges =Save changes label.wiki.history =History Index: lams_tool_wiki/db/sql/create_lams_tool_wiki.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/db/sql/create_lams_tool_wiki.sql,v diff -u -r1.10 -r1.11 --- lams_tool_wiki/db/sql/create_lams_tool_wiki.sql 19 Feb 2012 20:25:46 -0000 1.10 +++ lams_tool_wiki/db/sql/create_lams_tool_wiki.sql 19 Mar 2012 14:39:35 -0000 1.11 @@ -15,7 +15,8 @@ uid bigint not null auto_increment, wiki_uid bigint, title varchar(255), - editable bit, + editable bit, + deleted bit DEFAULT 0, wiki_current_content bigint, added_by bigint, wiki_session_uid bigint, Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java,v diff -u -r1.1 -r1.2 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java 8 Oct 2008 05:33:00 -0000 1.1 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java 19 Mar 2012 14:39:35 -0000 1.2 @@ -1,8 +1,10 @@ package org.lamsfoundation.lams.tool.wiki.dao.hibernate; import org.hibernate.Query; +import org.hibernate.SQLQuery; import org.lamsfoundation.lams.dao.hibernate.BaseDAO; import org.lamsfoundation.lams.tool.wiki.dao.IWikiPageDAO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; import org.lamsfoundation.lams.tool.wiki.model.Wiki; import org.lamsfoundation.lams.tool.wiki.model.WikiPage; import org.lamsfoundation.lams.tool.wiki.model.WikiSession; @@ -15,6 +17,11 @@ public static final String GET_BY_SESSION_AND_TITLE = "from tl_lawiki10_wiki_page in class " + WikiPage.class.getName() + " where wiki_session_uid=? AND title=?"; + public static final String REMOVE_WIKI_REFERENCES = "UPDATE tl_lawiki10_wiki_page_content " + + "SET body=REPLACE(body,?,?) WHERE editor IS NULL"; + + public static final String CHANGE_WIKI_JAVASCRIPT_METHOD = "javascript:changeWikiPage('?')"; + public void saveOrUpdate(WikiPage wikiPage) { this.getHibernateTemplate().saveOrUpdate(wikiPage); } @@ -41,4 +48,19 @@ return null; } -} + public void delete(Object object) { + // remove references to the removed page + WikiPage removedWikiPage = (WikiPage) object; + String title = removedWikiPage.getTitle(); + String escapedTitle = WikiPageDTO.javaScriptEscape(title); + String codeToReplace = WikiPageDAO.CHANGE_WIKI_JAVASCRIPT_METHOD.replace("?", escapedTitle); + String replacementCode = "#"; + + SQLQuery query = this.getSession().createSQLQuery(REMOVE_WIKI_REFERENCES); + query.setString(0, codeToReplace); + query.setString(1, replacementCode); + + super.delete(object); + query.executeUpdate(); + } +} \ No newline at end of file Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dbupdates/patch20120315.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dbupdates/patch20120315.sql,v diff -u Binary files differ Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java,v diff -u -r1.3 -r1.4 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java 20 Apr 2009 00:11:11 -0000 1.3 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java 19 Mar 2012 14:39:35 -0000 1.4 @@ -8,6 +8,7 @@ private String title; private String javaScriptTitle; private Boolean editable; + private Boolean deleted; private WikiPageContentDTO currentWikiContentDTO; public WikiPageDTO() { @@ -17,6 +18,7 @@ this.uid = wikiPage.getUid(); this.title = wikiPage.getTitle().trim(); this.editable = wikiPage.getEditable(); + this.deleted = wikiPage.getDeleted(); this.currentWikiContentDTO = new WikiPageContentDTO(wikiPage.getCurrentWikiContent()); this.javaScriptTitle = this.javaScriptEscape(wikiPage.getTitle()); } @@ -45,6 +47,14 @@ this.editable = editable; } + public Boolean getDeleted() { + return deleted; + } + + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + public WikiPageContentDTO getCurrentWikiContentDTO() { return currentWikiContentDTO; } @@ -65,7 +75,7 @@ return wikiPageDTO.getUid().compareTo(uid) * -1; } - public String javaScriptEscape(String string) + public static String javaScriptEscape(String string) { String replaced = string.replaceAll("\n", "").replaceAll("\'", "`").replaceAll("\"","\\"");; Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java,v diff -u -r1.4 -r1.5 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java 13 Oct 2008 05:09:33 -0000 1.4 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java 19 Mar 2012 14:39:35 -0000 1.5 @@ -22,6 +22,7 @@ private Wiki parentWiki; private String title; private Boolean editable; + private Boolean deleted; private Set wikiContentVersions; private WikiPageContent currentWikiContent; private WikiSession wikiSession; @@ -78,7 +79,19 @@ public void setEditable(Boolean editable) { this.editable = editable; } + + /** + * @hibernate.property column="deleted" length="1" + * + */ + public Boolean getDeleted() { + return deleted; + } + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + /** * @hibernate.set lazy="true" inverse="false" cascade="all-delete-orphan" * order-by="uid asc" Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java,v diff -u -r1.7 -r1.8 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java 15 Feb 2011 20:37:59 -0000 1.7 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java 19 Mar 2012 14:39:35 -0000 1.8 @@ -148,6 +148,13 @@ * @param wikiPage */ public void deleteWikiPage(WikiPage wikiPage); + + /** + * Mark an existing wiki page as deleted, but do not remove it for real. + * + * @param wikiPage + */ + public void markWikiPageAsDeleted(WikiPage wikiPage); /** * Gets a wiki page by wiki and title Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java,v diff -u -r1.16 -r1.17 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java 15 Feb 2011 20:37:59 -0000 1.16 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java 19 Mar 2012 14:39:35 -0000 1.17 @@ -739,6 +739,11 @@ public void deleteWikiPage(WikiPage wikiPage) { wikiPageDAO.delete(wikiPage); } + + public void markWikiPageAsDeleted(WikiPage wikiPage) { + wikiPage.setDeleted(true); + wikiPageDAO.saveOrUpdate(wikiPage); + } public void deleteInstructionFile(Long contentID, Long uuid, Long versionID, String type) { wikiDAO.deleteInstructionFile(contentID, uuid, versionID, type); Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java,v diff -u -r1.5 -r1.6 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java 29 Jan 2009 21:59:06 -0000 1.5 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java 19 Mar 2012 14:39:35 -0000 1.6 @@ -115,7 +115,7 @@ String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, "mode", true); + ToolAccessMode mode = getAccessMode(request); // Set up the authForm. AuthoringForm authForm = (AuthoringForm) form; @@ -156,7 +156,8 @@ if (currentPageUid != null) { currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); } else { - currentWikiPage = wiki.getMainPage(); + // get real instance instead of lazily initialized handler + currentWikiPage = wiki.getMainPage(); } WikiPageDTO currentPageDTO = new WikiPageDTO(currentWikiPage); request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, currentPageDTO); @@ -174,12 +175,17 @@ // Get the child wiki pages SortedSet wikiPageDTOs = new TreeSet(); for (WikiPage wikiPage : wiki.getWikiPages()) { - wikiPageDTOs.add(new WikiPageDTO(wikiPage)); + // check if page exists in real, not only phantom proxied object + // (happens after removing a wiki page) + wikiPage = wikiService.getWikiPageByUid(wikiPage.getUid()); + if (wikiPage != null) { + wikiPageDTOs.add(new WikiPageDTO(wikiPage)); + } } request.setAttribute(WikiConstants.ATTR_WIKI_PAGES, wikiPageDTOs); // Set up sessionMap - SessionMap map = createSessionMap(wiki, getAccessMode(request), contentFolderID, toolContentID); + SessionMap map = createSessionMap(wiki, mode, contentFolderID, toolContentID); authForm.setSessionMapID(map.getSessionID()); // add the sessionMap to HTTPSession. @@ -189,6 +195,29 @@ return mapping.findForward("success"); } + public ActionForward removePage(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + Wiki wiki = wikiService.getWikiByContentId(toolContentID); + if (wiki.isDefineLater()) { + // Only mark as removed if editing a live version (monitor/live edit) + return super.removePage(mapping, form, request, response); + } + // Completely delete the page + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + WikiPage wikiPage = wikiService.getWikiPageByUid(currentPageUid); + wikiService.deleteWikiPage(wikiPage); + + // return to the main page, by setting the current page to null + return this.returnToWiki(mapping, form, request, response, null); + } + /** * Wrapper method to make sure that the correct wiki is returned to from the WikiPageAction class */ @@ -530,14 +559,11 @@ * @return */ private ToolAccessMode getAccessMode(HttpServletRequest request) { - ToolAccessMode mode; String modeStr = request.getParameter(AttributeNames.ATTR_MODE); if (StringUtils.equalsIgnoreCase(modeStr, ToolAccessMode.TEACHER.toString())) { - mode = ToolAccessMode.TEACHER; - } else { - mode = ToolAccessMode.AUTHOR; + return ToolAccessMode.TEACHER; } - return mode; + return ToolAccessMode.AUTHOR; } /** Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java,v diff -u -r1.10 -r1.11 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java 12 Mar 2012 20:34:38 -0000 1.10 +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java 19 Mar 2012 14:39:35 -0000 1.11 @@ -428,15 +428,15 @@ // Updating the wikiPage, setting a null user which indicated this // change was made in author - wikiService.deleteWikiPage(wikiPage); + wikiService.markWikiPageAsDeleted(wikiPage); // Send removed page notifications if (toolSessionID != null && user != null) { notifyWikiChange(toolSessionID, "notify.pageRemoved.subject", "notify.pageRemoved.body", user, request); } - // return to the main page, by setting the current page to null - return this.returnToWiki(mapping, form, request, response, null); + // return to the same page with information about being removed displayed + return this.returnToWiki(mapping, form, request, response, currentPageUid); } Index: lams_tool_wiki/web/pages/authoring/authoring.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/web/pages/authoring/authoring.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_wiki/web/pages/authoring/authoring.jsp 13 Oct 2008 03:02:29 -0000 1.2 +++ lams_tool_wiki/web/pages/authoring/authoring.jsp 19 Mar 2012 14:39:35 -0000 1.3 @@ -7,9 +7,9 @@ - + - + @@ -318,5 +328,4 @@ --> - - + \ No newline at end of file Index: lams_tool_wiki/web/pages/learning/wiki.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/web/pages/learning/wiki.jsp,v diff -u -r1.21 -r1.22 --- lams_tool_wiki/web/pages/learning/wiki.jsp 17 Mar 2012 09:28:58 -0000 1.21 +++ lams_tool_wiki/web/pages/learning/wiki.jsp 19 Mar 2012 14:39:35 -0000 1.22 @@ -99,6 +99,9 @@ + +

+
  @@ -115,7 +118,7 @@ - + @@ -165,8 +168,8 @@   - ')" - title="" + ')" + title="" >