PropertyXMLBuilderBase.java revision 590e03a0114f53c994d970cfb356dadaaa57e39d
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: PropertyXMLBuilderBase.java,v 1.20 2009/12/11 23:23:55 veiming Exp $
*
*/
/*
* Portions Copyrighted 2011-2016 ForgeRock AS.
* Portions Copyrighted 2013-2014 Nomura Research Institute, Ltd
*/
public abstract class PropertyXMLBuilderBase
implements PropertyTemplate
{
protected static ResourceBundle properties =
static {
"schemaType.organization");
"namevaluelist");
"unorderedlist");
"orderedlist");
"globalmaplist");
"multiple_choice");
"password");
}
protected ServiceSchemaManager svcSchemaManager;
protected boolean supportSubConfig;
protected String viewBeanName;
protected ResourceBundle serviceBundle;
protected Map mapTypeToAttributeSchema;
protected String serviceName;
protected boolean allAttributesReadonly;
protected String currentRealm;
try {
} catch (MissingResourceException e) {
// do nothing
}
}
try {
} catch (MissingResourceException e) {
// do nothing
}
}
if (tagClassName == null) {
try {
} catch (MissingResourceException e) {
// do nothing
}
}
}
// last try
if (tagClassName == null) {
try {
} catch (MissingResourceException e) {
// do nothing
}
}
tagClassName = null;
}
return tagClassName;
}
/**
* Removes hidden attribute schemas.
*
* @param attributeSchemas Set of Attribute Schemas.
*/
) {
}
}
}
/**
* Removes attribute schema that does not have <code>i18nKey</code>.
*
* @param attributeSchemas Set of Attribute Schemas.
*/
{
}
}
}
/**
* Removes the attributes that do not match a specified set of any
* display strings.
*
* @param attributeSchemas Set of Attribute Schemas.
*/
boolean found = false;
}
}
}
}
boolean has = false;
}
}
return has;
}
/**
* Returns a replaced XML. This method replaces a property element.
*
* @param xml XML to operate on.
* @param propertyName Name of the property (attribute) that is going to be
* replaced.
* @param propertyXML XML to replace.
* @return a replaced XML.
*/
public static String swapXMLProperty(
) {
if (start != -1) {
if (end != -1) {
}
}
return xml;
}
/**
* Inserts XML to a property XML.
*
* @param xml Original property XML.
* @param insertXML XML to be inserted to <code>xml</code>.
* @param marker A marker where <code>insertXML</code> will be inserted.
* @param afterMarker <code>true</code> to insert XML after marker.
* @return the modified XML.
*/
boolean afterMarker
) {
if (idx != -1) {
}
return xml;
}
/**
* Inserts XML to a property XML.
*
* @param xml Original property XML.
* @param insertXML XML to be inserted to <code>xml</code>.
* @param marker A marker where <code>insertXML</code> will be inserted.
* @return the modified XML.
*/
) {
if (idx != -1) {
}
return xml;
}
/**
* Returns true if sub configuration is supported.
*
* @return true if sub configuration is supported.
*/
public boolean isSubConfigSupported() {
return supportSubConfig;
}
/**
* Set support sub configuration state.
*
* @param state <code>true</code> to support sub configuration.
*/
public void setSupportSubConfig(boolean state) {
}
/**
* Set name of view bean.
*
* @param name Name of view bean.
*/
viewBeanName = name;
}
/**
* Returns name of view bean.
*
* @return Name of view bean.
*/
public String getViewBeanName() {
return viewBeanName;
}
protected void getServiceResourceBundle() {
try {
model.getUserLocale());
} catch (MissingResourceException e) {
"PropertyXMLBuilderBase.getServiceResourceBundle " +
e.getMessage());
}
}
/**
* Returns a set of attributeSchemas that are displayed.
*
* @return Set of attribute names that are displayed.
*/
public Set getAttributeSchemas() {
}
return set;
}
try {
model.getUserLocale());
} catch (MissingResourceException e) {
"PropertyXMLBuilderBase.getServiceResourceBundle", e);
}
}
protected void buildReadonlyXML(
) {
}
}
protected void buildAttributeSchemaTypeXML(
boolean addSubSection
) {
if (tagClassName != null) {
boolean addremovelist =
if (listTyped && addSubSection) {
/*
* create a subsection without a title to hold the
* editable list component.
*/
}
if (needRequiredTag(as)) {
} else {
}
if (addremovelist) {
addremovelist = true;
} else {
//need to handle link specially.
"&" +
"linkLabel" + name,
};
};
} else if (listTyped) {
/*
* putting the editable list component wihin a group tag
* to help isolate the list box and text box together on the
* page. Otherwise the list component blends in with other
* components on the page.
*/
name,
};
if (editableList) {
} else if (orderedList) {
} else if (unorderedList) {
} else if (mapList) {
} else if (globalMapList) {
}
} else {
/*
* if its a textarea component add the no localize attribute
* set the size of the text field based on its syntax
*/
pSize));
}
}
}
}
}
}
// close off the group and subsection tags for the editable list
if (listTyped) {
.append("<p>")
if (addSubSection) {
}
}
}
}
/**
* This will get the syntax of the attribute, and compute an appropriate
* size for the length of the text field. This will help the user
* understand what the expected value is for the field. The field sizes
* are set in amProperty.properties so the customer can change the
* defaults as necessary.
*/
try {
} else {
}
} catch (MissingResourceException e) {
}
}
return size;
}
/**
* This will get the syntax of the attribute and retrieve the desired size for the text area.
* The text area rows and columns are set in amProperty.properties and can be configured as required.
*
* @param as the attribute schema holding the text area properties.
* @return a Map with keys "columns" and "rows" as specified in the properties
* file or an empty map if nothing was specified.
*/
}
return sizeMap;
}
private void appendDateMarker(
) {
}
}
protected void buildConfirmPasswordXML(
) {
if (needRequiredTag(as)) {
} else {
}
}
/**
* Adds a file upload button below the last attribute added. This will dynamically upload a file and then paste
* the contents back into the field of the previous attribute on the form.
*
* @param as The attribute that describes this UI element.
* @param xml The XML document to add the element to.
* @param model The AMModel that stores admin constants.
*/
}
private void buildScriptSelectXML(AttributeSchema as, StringBuffer xml, AMModel model, ResourceBundle bundle,
boolean globalOnly) {
xml.append(MessageFormat.format(OPTION_TAG, escapeSpecialChars(model.getLocalizedString(entry.getValue())),
}
// Users can't create global scripts
if (!globalOnly) {
}
}
private void addLabel(
) {
name};
}
private void addPasswordConfirmLabel(
) {
Object[] labelParam = {
};
"password.confirm.label"), labelParam);
}
private void getInlineHelp(
) {
return;
}
try {
if (helpString == null) {
return;
}
} catch (MissingResourceException e) {
// no-op, assumption here is help is not defined for this attr.
}
}
for (int i = 0; i < len; i++) {
switch (c) {
case '&':
break;
case '<':
break;
case '>':
break;
case '"':
break;
default:
break;
}
}
} else {
}
return escaped;
}
private void appendChoiceValues(
) {
{
}
}
}
private void appendMultipleChoiceCheckboxes(
) {
nameArg));
params));
}
}
private void appendAddRemoveListComponent(
}
}
public static String getMultipleChoiceCheck(
) {
}
params));
}
}
}
/*
* Sets the value for the current realm name being used to build the
* property sheet xml page.
*
* @param value the name of the realm
*/
}
/*
* Returns the current realm name value which can be used for constructing
* the xml page. If the realm name has not been set the default location
* which is stored in <code>AMModelBase</code> will be returned. If no
* location has been set in the model the realm where the user logged in
* is returned.
*
* @return name of the realm used for building the page.
*/
protected String getCurrentRealm() {
}
private Set getSortedChoiceValues(
) {
sorted = new LinkedHashSet();
}
localizedName = val;
} else {
}
}
}
return sorted;
}
if (model instanceof SubConfigModel) {
}
@SuppressWarnings("unchecked")
}
private void appendChoiceValueForSelectableComponent(
boolean includeDefault,
) {
boolean defaultValue = false;
if (includeDefault && !defaultValue) {
.append("\" />");
defaultValue = true;
}
}
}
/*
* This will remove an entire subsection which surrounds the
* specified attribute. The subsection will be replaced with a
* <code><property></code> tag.
*
* @param original xml string to be modified.
* @param attribute name which is going to be removed.
* @param insert string with new xml.
*
* @return new xml string without subsection.
*/
public static String removeSubSection(
) {
// the attribute is not within a subsection
if (index == -1) {
return original;
}
// the end of the subsection is missing. invalid xml perhaps.
if (index == -1) {
return original;
}
}
/**
* Returns an altered XML. This method prepends a property element.
*
* @param xml XML to operate on.
* @param propertyXML XML to replace.
* @return the altered XML.
*/
public static String prependXMLProperty(
) {
}
/**
* Returns an altered XML. This method appends a property element.
*
* @param xml XML to operate on.
* @param propertyXML XML to replace.
* @return the altered XML.
*/
public static String appendXMLProperty(
) {
if (idx != -1) {
}
return xml;
}
/**
* Returns service schema manager.
*
* @return service schema manager.
*/
public ServiceSchemaManager getServiceSchemaManager() {
return svcSchemaManager;
}
protected void buildSchemaTypeXML(
) {
buildSchemaTypeXML(schemaTypeName, attributeSchemas, xml, model, serviceBundle, readonly, true, true);
}
protected void buildSchemaTypeXML(
boolean section,
boolean addSubSection
) {
if (section) {
}
if (!(attributeSchemas instanceof LinkedHashSet)) {
// Sort attribute schemas by property key if they are not sorted by section properties.
}
} else {
}
}
}
}
}
protected void buildSchemaTypeXML(
) {
// skip empty sections
return;
}
}
protected Set<AttributeSchema> getAttributeSchemaForSection(Set<AttributeSchema> attributeSchemas, List<String> sectionList) {
// Create an attribute schema set sorted by section properties.
break;
}
}
}
return result;
}
/**
* Returns a property XML of a given well formed attributes XML string.
*
* @param properties Well formed attributes XML string..
* @return a property XML of a given well formed attributes XML string.
*/
return formPropertySheetXML(properties, false);
}
/**
* Returns a property XML of a given well formed attributes XML string.
*
* @param properties Well formed attributes XML string..
* @param addSection <code>true</code> to add a dummy section to the XML.
* @return a property XML of a given well formed attributes XML string.
*/
public static String formPropertySheetXML(
boolean addSection
) {
return (addSection)
?
:
}
/**
* Set all all attribute values read only.
*
* @param flag true if all attribute values are read only.
*/
public void setAllAttributeReadOnly(boolean flag) {
}
}
/**
* Performs a tag substitution on a string.
*
* @param template Template for tag swapping.
* @param tag Tag.
* @param value Value of Tag.
*/
while (idx != -1) {
}
return template;
}
}
public static String getXMLDefinitionHeader() {
return PropertyTemplate.DEFINITION;
}
}