Skip to content

Commit

Permalink
KNL-422 add site hierarchy API
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/kernel/trunk@309478 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
steveswinsburg committed May 14, 2014
1 parent e5fd227 commit 8dd769b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1119,5 +1119,21 @@ public boolean isAsc()
* @return <code>true</code> is the advisor was removed.
*/
public boolean removeSiteRemovalAdvisor(SiteRemovalAdvisor siteRemovalAdvisor);

/**
* Get the list of Sites that list the given site as a parent, ie the child sites of the given site
*
* @param siteId - parent siteId
* @return
*/
public List<Site> getSubSites(String siteId);

/**
* Get the parent siteId of the given site. A site can only have one parent.
*
* @param siteId - child siteId
* @return
*/
public String getParentSite(String siteId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
Expand Down Expand Up @@ -3396,5 +3397,42 @@ else if (EVENT_SITE_VISIT_DENIED.equals(eventType) || AuthzGroupService.SECURE_U
protected Storage storage() {
return m_storage;
}

/**
* @inheritDoc
*/
@Override
public List<Site> getSubSites(String siteId) {

if (StringUtils.isBlank(siteId)) {
return new ArrayList<Site>();
}
Map<String, String> propMap = new HashMap<String, String>();
propMap.put(PROP_PARENT_ID, siteId);

return this.getSites(SelectionType.ACCESS, null, null, propMap, SiteService.SortType.TITLE_ASC, null);
}

/**
* @inheritDoc
*/
@Override
public String getParentSite(String siteId) {

if (StringUtils.isBlank(siteId)) {
return null;
}

String parentId = null;
try {
Site s = this.getSite(siteId);
ResourceProperties rp = s.getProperties();
parentId = rp.getProperty(PROP_PARENT_ID);
} catch (IdUnusedException e) {
M_log.error("getParentSite failed for " + siteId + ": " + e.getClass() + " : " + e.getMessage());
return null;
}
return parentId;
}

}

0 comments on commit 8dd769b

Please sign in to comment.