org.sakaiproject.component.legacy.site
Class DbSiteService.DbStorage

java.lang.Object
  extended byorg.sakaiproject.util.storage.BaseDbFlatStorage
      extended byorg.sakaiproject.component.legacy.site.DbSiteService.DbStorage
All Implemented Interfaces:
BaseSiteService.Storage, SqlReader
Enclosing class:
DbSiteService

protected class DbSiteService.DbStorage
extends BaseDbFlatStorage
implements BaseSiteService.Storage, SqlReader

Storage implementation


Field Summary
protected  BaseSiteService.Storage m_oldStorage
          A prior version's storage model.
protected  BaseSiteService m_service
          The service.
 
Fields inherited from class org.sakaiproject.util.storage.BaseDbFlatStorage
m_caseInsensitive, m_locking, m_locks, m_locksAreInTable, m_reader, m_resourcePropertyTableName, m_resourceTableDbidField, m_resourceTableIdField, m_resourceTableInsertFields, m_resourceTableInsertValues, m_resourceTableName, m_resourceTableReadFields, m_resourceTableSortField1, m_resourceTableSortField2, m_resourceTableUpdateFields, m_sql
 
Constructor Summary
DbSiteService.DbStorage(BaseSiteService service)
          Construct.
 
Method Summary
 boolean check(String id)
          Does the site with this id exist?
 int count()
          Count all the sites.
 int countSites(SiteService.SelectionType type, Object ofType, String criteria, Map propertyCriteria)
          Count the Site objets that meet specified criteria.
protected  Object[] fields(String id, Site edit, boolean idAgain)
          Get the fields for the database from the edit for this id, and the id again at the end if needed
 String findGroupSiteId(String id)
          Access the Site id for the group with this id.
 SitePage findPage(String id)
          Access the Page that has this id, if one is defined, else return null. The page may be on any Site.
 String findPageSiteId(String id)
          Access the Site id for the page with this id.
 ToolConfiguration findTool(String id)
          Access the ToolConfiguration that has this id, if one is defined, else return null.
 String findToolSiteId(String id)
          Access the Site id for the tool with this id.
 Site get(String id)
          Get the site with this id, or null if not found.
 List getAll()
          Get all sites.
 List getSites(SiteService.SelectionType type, Object ofType, String criteria, Map propertyCriteria, SiteService.SortType sort, PagingPosition page)
          Access a list of Site objets that meet specified criteria.
 String getSiteSkin(String siteId)
          Return the skin for this site
 List getSiteTypes()
          Access a unique list of String site types for any site type defined for any site, sorted by type.
 Site put(String id)
          Add a new site with this id.
 void readAllSiteProperties(Site site)
          Read site properties and all page and tool properties for the site from storage.
 void readGroupProperties(Group group, Properties props)
          Read group properties from storage into the group's properties.
 void readPageProperties(SitePage page, ResourcePropertiesEdit props)
          Read page properties from storage into the page's properties.
 void readPageTools(SitePage page, ResourceVector tools)
          Read site page tools from storage into the page's tools.
protected  void readSiteGroupProperties(BaseSite site)
          Read properties for all groups in the site
 void readSiteGroups(Site site, Collection groups)
          Read site pages from storage into the site's pages.
protected  void readSitePageProperties(BaseSite site)
          Read properties for all pages in the site
 void readSitePages(Site site, ResourceVector pages)
          Read site pages from storage into the site's pages.
 void readSiteProperties(Site site, ResourcePropertiesEdit props)
          Read site properties from storage into the site's properties.
protected  void readSiteToolProperties(BaseSite site)
          Read properties for all tools in the site
 void readSiteTools(Site site)
          Read tools for all pages from storage into the site's page's tools.
 Object readSqlResultRecord(ResultSet result)
          Read from the result one set of fields to create a Resource.
 void readToolProperties(ToolConfiguration tool, Properties props)
          Read tool properties from storage into the tool's properties.
 void remove(Site edit)
          Remove this site.
protected  void save(Connection conn, Site edit)
          Commit with optional connection to use.
 void save(Site edit)
          Save the changes.
 void saveInfo(String siteId, String description, String infoUrl)
          Save the changes to the two info fields (description and infoUrl) only.
 void saveToolConfig(Connection conn, ToolConfiguration tool)
          Write an updated tool configuration to the database.
 void setSiteSecurity(String siteId, Set updateUsers, Set visitUnpUsers, Set visitUsers)
          Establish the internal security for this site.
 void setUserSecurity(String userId, Set updateSites, Set visitUnpSites, Set visitSites)
          Establish the internal security for user for all sites. Previous security settings are replaced for this user. Assigning a user with update implies the two reads; assigning a user with unp read implies the other read.
 
Methods inherited from class org.sakaiproject.util.storage.BaseDbFlatStorage
cancelResource, caseId, checkResource, close, commitResource, commitResource, countAllResources, countSelectedResources, countSelectedResources, deleteProperties, editResource, editResource, fieldList, getAllResources, getAllResources, getResource, getResource, getSelectedResources, getSelectedResources, getSelectedResources, getSelectedResources, getSelectedResources, getSelectedResources, insertResource, open, putResource, putResource, qualifyField, readProperties, readProperties, readProperties, readProperties, readProperties, readProperties, removeResource, removeResource, setCaseInsensitivity, setDbidField, setLocking, setSortField, setWriteFields, updateFields, updateSet, valuesParams, writeProperties, writeProperties, writeProperties, writeProperties, writeProperties, writeProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sakaiproject.component.legacy.site.BaseSiteService.Storage
close, open
 

Field Detail

m_oldStorage

protected BaseSiteService.Storage m_oldStorage
A prior version's storage model.


m_service

protected BaseSiteService m_service
The service.

Constructor Detail

DbSiteService.DbStorage

public DbSiteService.DbStorage(BaseSiteService service)
Construct.

Method Detail

check

public boolean check(String id)
Description copied from interface: BaseSiteService.Storage
Does the site with this id exist?

Specified by:
check in interface BaseSiteService.Storage
Parameters:
id - The site id.
Returns:
true if the site with this id exists, false if not.

get

public Site get(String id)
Description copied from interface: BaseSiteService.Storage
Get the site with this id, or null if not found.

Specified by:
get in interface BaseSiteService.Storage
Parameters:
id - The site id.
Returns:
The site with this id, or null if not found.

getAll

public List getAll()
Description copied from interface: BaseSiteService.Storage
Get all sites.

Specified by:
getAll in interface BaseSiteService.Storage
Returns:
The list of all sites.

put

public Site put(String id)
Description copied from interface: BaseSiteService.Storage
Add a new site with this id.

Specified by:
put in interface BaseSiteService.Storage
Parameters:
id - The site id.
Returns:
The site with this id, or null if in use.

save

public void save(Site edit)
Description copied from interface: BaseSiteService.Storage
Save the changes.

Specified by:
save in interface BaseSiteService.Storage
Parameters:
edit - The site to commit.

save

protected void save(Connection conn,
                    Site edit)
Commit with optional connection to use.

Parameters:
conn - Optional connection to use.
edit - Edit to commit.

saveInfo

public void saveInfo(String siteId,
                     String description,
                     String infoUrl)
Description copied from interface: BaseSiteService.Storage
Save the changes to the two info fields (description and infoUrl) only.

Specified by:
saveInfo in interface BaseSiteService.Storage
Parameters:
siteId - The site to commit.
description - The new site description.
infoUrl - The new site infoUrl.

saveToolConfig

public void saveToolConfig(Connection conn,
                           ToolConfiguration tool)
Description copied from interface: BaseSiteService.Storage
Write an updated tool configuration to the database.

Specified by:
saveToolConfig in interface BaseSiteService.Storage
Parameters:
conn - Optional connection to use.
tool - TooConfiguration to commit.

remove

public void remove(Site edit)
Description copied from interface: BaseSiteService.Storage
Remove this site.

Specified by:
remove in interface BaseSiteService.Storage

count

public int count()
Description copied from interface: BaseSiteService.Storage
Count all the sites.

Specified by:
count in interface BaseSiteService.Storage
Returns:
The count of all sites.

getSites

public List getSites(SiteService.SelectionType type,
                     Object ofType,
                     String criteria,
                     Map propertyCriteria,
                     SiteService.SortType sort,
                     PagingPosition page)
Access a list of Site objets that meet specified criteria.

Specified by:
getSites in interface BaseSiteService.Storage
Parameters:
type - The SelectionType specifying what sort of selection is intended.
ofType - Site type criteria: null for any type; a String to match a single type; A String[], List or Set to match any type in the collection.
criteria - Additional selection criteria: sits returned will match this string somewhere in their id, title, description, or skin.
propertyCriteria - Additional selection criteria: sites returned will have a property named to match each key in the map, whose values match (somewhere in their value) the value in the map (may be null or empty).
sort - A SortType indicating the desired sort. For no sort, set to SortType.NONE.
page - The PagePosition subset of items to return.
Returns:
The List (Site) of Site objets that meet specified criteria.

getSiteTypes

public List getSiteTypes()
Access a unique list of String site types for any site type defined for any site, sorted by type.

Specified by:
getSiteTypes in interface BaseSiteService.Storage
Returns:
A list (String) of all used site types.

getSiteSkin

public String getSiteSkin(String siteId)
Return the skin for this site

Specified by:
getSiteSkin in interface BaseSiteService.Storage
Parameters:
siteId - The site id.
Returns:
the skin for this site.

countSites

public int countSites(SiteService.SelectionType type,
                      Object ofType,
                      String criteria,
                      Map propertyCriteria)
Count the Site objets that meet specified criteria.

Specified by:
countSites in interface BaseSiteService.Storage
Parameters:
type - The SelectionType specifying what sort of selection is intended.
ofType - Site type criteria: null for any type; a String to match a single type; A String[], List or Set to match any type in the collection.
criteria - Additional selection criteria: sits returned will match this string somewhere in their id, title, description, or skin.
propertyCriteria - Additional selection criteria: sites returned will have a property named to match each key in the map, whose values match (somewhere in their value) the value in the map (may be null or empty).
Returns:
The count of Site objets that meet specified criteria.

findTool

public ToolConfiguration findTool(String id)
Access the ToolConfiguration that has this id, if one is defined, else return null. The tool may be on any SitePage in the site.

Specified by:
findTool in interface BaseSiteService.Storage
Parameters:
id - The id of the tool.
Returns:
The ToolConfiguration that has this id, if one is defined, else return null.

findPage

public SitePage findPage(String id)
Access the Page that has this id, if one is defined, else return null. The page may be on any Site.

Specified by:
findPage in interface BaseSiteService.Storage
Parameters:
id - The id of the page.
Returns:
The SitePage that has this id, if one is defined, else return null.

findPageSiteId

public String findPageSiteId(String id)
Access the Site id for the page with this id.

Specified by:
findPageSiteId in interface BaseSiteService.Storage
Parameters:
id - The id of the page.
Returns:
The Site id for the page with this id, if the page is found, else null.

findGroupSiteId

public String findGroupSiteId(String id)
Access the Site id for the group with this id.

Specified by:
findGroupSiteId in interface BaseSiteService.Storage
Parameters:
id - The id of the group.
Returns:
The Site id for the group with this id, if the group is found, else null.

findToolSiteId

public String findToolSiteId(String id)
Access the Site id for the tool with this id.

Specified by:
findToolSiteId in interface BaseSiteService.Storage
Parameters:
id - The id of the tool.
Returns:
The Site id for the tool with this id, if the tool is found, else null.

setSiteSecurity

public void setSiteSecurity(String siteId,
                            Set updateUsers,
                            Set visitUnpUsers,
                            Set visitUsers)
Establish the internal security for this site. Previous security settings are replaced for this site. Assigning a user with update implies the two reads; assigning a user with unp read implies the other read.

Specified by:
setSiteSecurity in interface BaseSiteService.Storage
Parameters:
siteId - The id of the site.
updateUsers - The set of String User Ids who have update access.
visitUnpUsers - The set of String User Ids who have visit unpublished access.
visitUsers - The set of String User Ids who have visit access.

setUserSecurity

public void setUserSecurity(String userId,
                            Set updateSites,
                            Set visitUnpSites,
                            Set visitSites)
Establish the internal security for user for all sites. Previous security settings are replaced for this user. Assigning a user with update implies the two reads; assigning a user with unp read implies the other read.

Specified by:
setUserSecurity in interface BaseSiteService.Storage
Parameters:
userId - The id of the user.
updateSites - The set of String site ids where the user has update access.
visitUnpSites - The set of String site ids where the user has visit unpublished access.
visitSites - The set of String site ids where the user has visit access.

readSiteProperties

public void readSiteProperties(Site site,
                               ResourcePropertiesEdit props)
Read site properties from storage into the site's properties.

Specified by:
readSiteProperties in interface BaseSiteService.Storage
Parameters:
site - The site for which properties are desired.

readAllSiteProperties

public void readAllSiteProperties(Site site)
Read site properties and all page and tool properties for the site from storage.

Specified by:
readAllSiteProperties in interface BaseSiteService.Storage
Parameters:
site - The site for which properties are desired.

readSitePageProperties

protected void readSitePageProperties(BaseSite site)
Read properties for all pages in the site

Parameters:
site - The site to read properties for.

readSiteToolProperties

protected void readSiteToolProperties(BaseSite site)
Read properties for all tools in the site

Parameters:
site - The site to read properties for.

readSiteGroupProperties

protected void readSiteGroupProperties(BaseSite site)
Read properties for all groups in the site

Parameters:
site - The site to read group properties for.

readPageProperties

public void readPageProperties(SitePage page,
                               ResourcePropertiesEdit props)
Read page properties from storage into the page's properties.

Specified by:
readPageProperties in interface BaseSiteService.Storage
Parameters:
page - The page for which properties are desired.

readToolProperties

public void readToolProperties(ToolConfiguration tool,
                               Properties props)
Read tool properties from storage into the tool's properties.

Specified by:
readToolProperties in interface BaseSiteService.Storage
Parameters:
tool - The tool for which properties are desired.

readGroupProperties

public void readGroupProperties(Group group,
                                Properties props)
Read group properties from storage into the group's properties.

Specified by:
readGroupProperties in interface BaseSiteService.Storage
Parameters:
group - The group for which properties are desired.

readSitePages

public void readSitePages(Site site,
                          ResourceVector pages)
Read site pages from storage into the site's pages.

Specified by:
readSitePages in interface BaseSiteService.Storage
Parameters:
site - The site for which pages are desired.

readPageTools

public void readPageTools(SitePage page,
                          ResourceVector tools)
Read site page tools from storage into the page's tools.

Specified by:
readPageTools in interface BaseSiteService.Storage
Parameters:
page - The page for which tools are desired.

readSiteTools

public void readSiteTools(Site site)
Read tools for all pages from storage into the site's page's tools.

Specified by:
readSiteTools in interface BaseSiteService.Storage
Parameters:
site - The site for which tools are desired.

readSiteGroups

public void readSiteGroups(Site site,
                           Collection groups)
Description copied from interface: BaseSiteService.Storage
Read site pages from storage into the site's pages.

Specified by:
readSiteGroups in interface BaseSiteService.Storage
Parameters:
site - The site for which groups are desired.
groups - The Collection to fill in.

fields

protected Object[] fields(String id,
                          Site edit,
                          boolean idAgain)
Get the fields for the database from the edit for this id, and the id again at the end if needed

Parameters:
id - The resource id
edit - The edit (may be null in a new)
idAgain - If true, include the id field again at the end, else don't.
Returns:
The fields for the database.

readSqlResultRecord

public Object readSqlResultRecord(ResultSet result)
Read from the result one set of fields to create a Resource.

Specified by:
readSqlResultRecord in interface SqlReader
Parameters:
result - The Sql query result.
Returns:
The Resource object.