Skip to content

Commit

Permalink
LSNBLDR-718 - deleteOrphanPages unable to delete from service (sakaip…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonespm authored and ottenhoff committed Aug 25, 2016
1 parent 96d767f commit f58722a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2655,10 +2655,12 @@ public String deleteOrphanPages() {
return "permission-failed";
if (!checkCsrf())
return "permission-failed";
return deleteOrphanPagesInternal();
deleteOrphanPagesInternal();
return deletePages();
}

//This is an internal call that expects you will check permissions before calling it
//Public because it's accessed from entity producer
public String deleteOrphanPagesInternal() {
// code is mostly from PagePickerProducer
// list we're going to display
Expand All @@ -2682,7 +2684,7 @@ public String deleteOrphanPagesInternal() {

// this adds everything you can find from top level pages to entries
for (SimplePageItem sitePageItem : sitePages) {
// log.info("findallpages " + sitePageItem.getName() + " " + true);
log.debug("findallpages " + sitePageItem.getName() + " " + true);
pagePickerProducer().findAllPages(sitePageItem, entries, pageMap, topLevelPages, sharedPages, 0, true, true);
}

Expand All @@ -2698,17 +2700,22 @@ public String deleteOrphanPagesInternal() {
// do the deletetion
// selectedEntities is the argument for deletePages
selectedEntities = orphans.toArray(selectedEntities);
deletePages();
deletePagesInternal();
}
return "success";
}

//External method for deleting pages for the tool CSRF protected
public String deletePages() {
if (getEditPrivs() != 0)
return "permission-failed";
if (!checkCsrf())
return "permission-failed";

if (getEditPrivs() != 0)
return "permission-failed";
if (!checkCsrf())
return "permission-failed";
return deletePagesInternal();
}

//Service method for deleting pages
protected String deletePagesInternal() {
String siteId = getCurrentSiteId();
log.debug("Found "+ selectedEntities.length + " pages to delete");
for (int i = 0; i < selectedEntities.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.site.api.ToolConfiguration;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.ToolSession;


import javax.jws.WebMethod;
import javax.jws.WebParam;
Expand Down Expand Up @@ -82,6 +84,8 @@ public String deleteOrphanPages(
return "Tool sakai.lessonbuildertool NOT found in site=" + context;
}
// Lets go down and hack our essence into the thread
ToolSession toolSession = session.getToolSession(tool.getId());
sessionManager.setCurrentToolSession(toolSession);
threadLocalManager.set(CURRENT_PLACEMENT, tool);
threadLocalManager.set(CURRENT_TOOL, tool.getTool());
return lessonBuilderAccessAPI.deleteOrphanPages(site.getId());
Expand Down

0 comments on commit f58722a

Please sign in to comment.