Package org.sakaiproject.site.util
Class SiteSetupQuestionFileParser
- java.lang.Object
-
- org.sakaiproject.site.util.SiteSetupQuestionFileParser
-
public class SiteSetupQuestionFileParser extends Object
This parser is mainly to parse the questions.xml file:- Author:
- zqian
-
-
Field Summary
Fields Modifier and Type Field Description protected static Stringm_adminSiteNameprotected static Stringm_configBackupFolderprotected static Stringm_configFolderprotected static Stringm_configXmlprotected static SiteSetupQuestionMapm_siteSetupQuestionMap
-
Constructor Summary
Constructors Constructor Description SiteSetupQuestionFileParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidenableSecurityAdvisor()Establish a security advisor to allow the "embedded" azg work to occur with no need for additional security permissions.protected static booleanexists(String resourceName)Does the specified configuration/hierarchy resource exist?StringgetAdminSiteName()static StringgetConfigBackupFolderReference()the reference to config backup folderstatic StringgetConfigFolderReference()the reference to config folderprotected StringgetText(Document root, String elementName)Get the text associated with this elementprotected StringgetText(Element root, String elementName)Get the text associated with this elementprotected static DocumentBuildergetXmlDocumentBuilder()Get a DOM Document builder.static booleanisConfigurationXmlAvailable()Is the configuration XML file provided and readableprotected StringnormalizeText(String original, String update)"Normalize" XML text node content to create a simple stringprotected static DocumentparseXmlFromStream(InputStream stream)Parse an XML resourceprotected static voidpopSecurityAdvisor()remove recent SecurityAdvisorprotected static SiteSetupQuestionMappopulateConfig(String configurationXml, InputStream stream)Populate cached values from a configuration XML resource.protected voidsaveParameter(Document document, Map parameterMap, String name)Lookup and save one dynamic configuration parametervoidsetAdminSiteName(String siteName)static SiteSetupQuestionMapupdateConfig()Update configuration data from an XML resource
-
-
-
Field Detail
-
m_adminSiteName
protected static String m_adminSiteName
-
m_configFolder
protected static String m_configFolder
-
m_configBackupFolder
protected static String m_configBackupFolder
-
m_configXml
protected static String m_configXml
-
m_siteSetupQuestionMap
protected static SiteSetupQuestionMap m_siteSetupQuestionMap
-
-
Method Detail
-
getAdminSiteName
public String getAdminSiteName()
-
setAdminSiteName
public void setAdminSiteName(String siteName)
-
getConfigFolderReference
public static String getConfigFolderReference()
the reference to config folder- Returns:
-
getConfigBackupFolderReference
public static String getConfigBackupFolderReference()
the reference to config backup folder- Returns:
-
isConfigurationXmlAvailable
public static boolean isConfigurationXmlAvailable()
Is the configuration XML file provided and readable- Returns:
- true If the XML file is provided and readable, false otherwise
-
exists
protected static boolean exists(String resourceName)
Does the specified configuration/hierarchy resource exist?- Parameters:
resourceName- Resource name- Returns:
- true If we can access this content
-
enableSecurityAdvisor
protected static void enableSecurityAdvisor()
Establish a security advisor to allow the "embedded" azg work to occur with no need for additional security permissions.
-
popSecurityAdvisor
protected static void popSecurityAdvisor()
remove recent SecurityAdvisor
-
updateConfig
public static SiteSetupQuestionMap updateConfig()
Update configuration data from an XML resource- Parameters:
configFileRef- XML configuration reference (/content/...)
-
populateConfig
protected static SiteSetupQuestionMap populateConfig(String configurationXml, InputStream stream)
Populate cached values from a configuration XML resource. We always try to parse the resource, regardless of any prior success or failure.- Parameters:
configurationXml- Configuration resource name (this doubles as a unique key into the configuration cache)
-
saveParameter
protected void saveParameter(Document document, Map parameterMap, String name)
Lookup and save one dynamic configuration parameter- Parameters:
Configuration- XMLparameterMap- Parameter name=value pairsname- Parameter name
-
parseXmlFromStream
protected static Document parseXmlFromStream(InputStream stream)
Parse an XML resource- Parameters:
filename- The filename (or URI) to parse- Returns:
- DOM Document (null if parse fails)
-
getXmlDocumentBuilder
protected static DocumentBuilder getXmlDocumentBuilder()
Get a DOM Document builder.- Returns:
- The DocumentBuilder
- Throws:
DomException
-
normalizeText
protected String normalizeText(String original, String update)
"Normalize" XML text node content to create a simple string- Parameters:
original- Original textupdate- Text to add to the original string (a space separates the two)- Returns:
- Concatenated contents (trimmed)
-
getText
protected String getText(Document root, String elementName)
Get the text associated with this element- Parameters:
root- The document containing the text element- Returns:
- Text (trimmed of leading/trailing whitespace, null if none)
-
-