Skip to content

Commit

Permalink
SAK-12433 - Import/Add ability to delete existing content prior to im…
Browse files Browse the repository at this point in the history
…porting new content to support import for gradebook.

git-svn-id: https://source.sakaiproject.org/svn/web/trunk@39237 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
Tan Nguyen committed Dec 13, 2007
1 parent c9c8a1a commit 9e48762
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,56 @@ public String trimToNull(String value)
if (value.length() == 0) return null;
return value;
}

public void transferCopyEntities(String fromContext, String toContext, List ids, boolean cleanup)
{
try
{
if(cleanup == true)
{
// retrieve all of the news tools to remove

Site toSite = SiteService.getSite(toContext);

List toSitePages = toSite.getPages();

if (toSitePages != null && !toSitePages.isEmpty())
{
Iterator pageIter = toSitePages.iterator();
while (pageIter.hasNext())
{
SitePage currPage = (SitePage) pageIter.next();

List toolList = currPage.getTools();
Iterator toolIter = toolList.iterator();
while (toolIter.hasNext())
{
ToolConfiguration toolConfig = (ToolConfiguration)toolIter.next();
String toolId = toolConfig.getToolId();

if (toolId.equals(TOOL_ID))
{
toolConfig.getPlacementConfig().setProperty(NEWS_URL_PROP, null);
toolConfig.setTitle(null);
currPage.setTitle(null);

}
}
}
}
SiteService.save(toSite);
ToolSession session = SessionManager.getCurrentToolSession();

if (session.getAttribute(ATTR_TOP_REFRESH) == null)
{
session.setAttribute(ATTR_TOP_REFRESH, Boolean.TRUE);
}
}
}
catch (Exception e)
{
M_log.info("News transferCopyEntities Error" + e);
}
transferCopyEntities(fromContext, toContext, ids);
}
}

0 comments on commit 9e48762

Please sign in to comment.