Skip to content

Commit

Permalink
SAK-23143 - Cancelling site edit for gateway deletes gateway
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/site/trunk@306912 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
jonespm committed Mar 7, 2014
1 parent 279b180 commit 5898384
Showing 1 changed file with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,6 @@ public void doNew(RunData data, Context context)
SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
state.setAttribute("mode", "new");

// mark the site as new, so on cancel it can be deleted
state.setAttribute("new", "true");

// disable auto-updates while in view mode
ObservingCourier courier = (ObservingCourier) state.getAttribute(STATE_OBSERVER);
if (courier != null) courier.disable();
Expand Down Expand Up @@ -1085,6 +1082,9 @@ public void doSave_edit(RunData data, Context context)

try
{
//Remove the new property if it exists
ResourcePropertiesEdit properties = site.getPropertiesEdit();
properties.removeProperty("new");
SiteService.save(site);
}
catch (PermissionException e)
Expand Down Expand Up @@ -1215,8 +1215,9 @@ public void doCancel(RunData data, Context context)
Site site = (Site) state.getAttribute("site");
if (site != null)
{
String property = site.getProperties().getProperty("new");
// if this was a new, delete the site
if ("true".equals(state.getAttribute("new")))
if ("true".equals(property))
{
// remove the site
try
Expand Down Expand Up @@ -1354,6 +1355,8 @@ private boolean readSiteForm(RunData data, SessionState state)
try
{
site = SiteService.addSite(id, type);
// mark the site as new, so on cancel it can be deleted
site.getPropertiesEdit().addProperty("new", "true");

// put the site in the state
state.setAttribute("site", site);
Expand Down Expand Up @@ -1527,11 +1530,9 @@ public void doNew_page(RunData data, Context context)
// make the page so we have the id
Site site = (Site) state.getAttribute("site");
SitePage page = site.addPage();
page.getPropertiesEdit().addProperty("new","true");
state.setAttribute("page", page);

// mark the site as new, so on cancel it can be deleted
state.setAttribute("newPage", "true");

} // doNew_page

/**
Expand Down Expand Up @@ -1631,6 +1632,10 @@ public void doDone_page(RunData data, Context context)

// read the form - if rejected, leave things as they are
if (!readPageForm(data, state)) return;

SitePage page = (SitePage) state.getAttribute("page");
//Clean up new page property
page.getPropertiesEdit().removeProperty("new");

// done with the page
state.removeAttribute("page");
Expand All @@ -1650,8 +1655,9 @@ public void doCancel_page(RunData data, Context context)
Site site = (Site) state.getAttribute("site");
SitePage page = (SitePage) state.getAttribute("page");

String property = page.getProperties().getProperty("new");
// if the page was new, remove it
if ("true".equals(state.getAttribute("newPage")))
if ("true".equals(property))
{
site.removePage(page);
}
Expand Down Expand Up @@ -2148,11 +2154,9 @@ public void doNew_tool(RunData data, Context context)
// make the tool so we have the id
SitePage page = (SitePage) state.getAttribute("page");
ToolConfiguration tool = page.addTool();
tool.getPlacementConfig().setProperty("new", "true");
state.setAttribute("tool", tool);

// mark the site as new, so on cancel it can be deleted
state.setAttribute("newTool", "true");

} // doNew_tool

/**
Expand Down Expand Up @@ -2247,6 +2251,10 @@ public void doDone_tool(RunData data, Context context)
// read the form - if rejected, leave things as they are
if (!readToolForm(data, state)) return;

ToolConfiguration tool = (ToolConfiguration) state.getAttribute("tool");
//Clean up new tool property
tool.getPlacementConfig().remove("new");

// done with the tool
state.removeAttribute("tool");

Expand Down Expand Up @@ -2281,8 +2289,10 @@ public void doCancel_tool(RunData data, Context context)
SitePage page = (SitePage) state.getAttribute("page");
ToolConfiguration tool = (ToolConfiguration) state.getAttribute("tool");

String property = tool.getPlacementConfig().getProperty("new");

// if the tool was new, remove it
if ("true".equals(state.getAttribute("newTool")))
if ("true".equals(property))
{
page.removeTool(tool);
}
Expand Down Expand Up @@ -2542,9 +2552,6 @@ private void cleanState(SessionState state)
state.removeAttribute("site");
state.removeAttribute("page");
state.removeAttribute("tool");
state.removeAttribute("new");
state.removeAttribute("newPage");
state.removeAttribute("newTool");

// clear the search, so after an edit or delete, the search is not automatically re-run
state.removeAttribute(STATE_SEARCH);
Expand Down

0 comments on commit 5898384

Please sign in to comment.