5aad467ce6f83c127919b32d6610b3e13ebc180bPhill Cunnington/*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: AttributeSchemaImpl.java,v 1.3 2008/06/25 05:44:03 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
5aad467ce6f83c127919b32d6610b3e13ebc180bPhill Cunnington * Portions Copyrighted 2011-2016 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.sm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport static com.sun.identity.sm.AttributeSchema.ListOrder.INSERTION;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport static java.util.Collections.emptySet;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Lunaimport static org.forgerock.openam.utils.CollectionUtils.isEmpty;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.AccessController;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashMap;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Iterator;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.LinkedHashMap;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.LinkedHashSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Set;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Node;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.NodeList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.security.DecodeAction;
5aad467ce6f83c127919b32d6610b3e13ebc180bPhill Cunningtonimport com.sun.identity.shared.xml.XMLUtils;
5aad467ce6f83c127919b32d6610b3e13ebc180bPhill Cunnington
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>AttributeSchemaImpl</code> provides methods to access the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * schema of a configuration parameter.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class AttributeSchemaImpl {
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee // Input variables
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Node attrSchemaNode;
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Variables derived from the Node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String name;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String key;
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String resourceName;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.Type type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.UIType uitype;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.ListOrder listOrder;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.Syntax syntax;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private Set<String> defaultValues = null;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private Set<String> exampleValues = null;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private DefaultValues defaultsObject = null;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private Map choiceValues;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private ChoiceValues choiceObject = null;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String trueBooleanValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private String trueValueKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String falseBooleanValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private String falseValueKey;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private String cosQualifier;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private String rangeStart;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna private String rangeEnd;
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private int minValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private int maxValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String validator;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private boolean isOptional;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private boolean isServiceIdentifier;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private boolean isResourceNameAllowed;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private boolean isStatusAttribute;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String any;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Attribute display properties
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String attributeViewBeanURL;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean isSearchable;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private boolean hasChoiceValues;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Integer order;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor used by ServiceSchema to instantiate AttributeSchema objects.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected AttributeSchemaImpl(Node node) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster update(node);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Retunrs the name of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the name of the attribute for CREST representation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getResourceName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (resourceName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the type of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.Type getType() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the UI type of the attribute; or null if UI type is not defined.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.UIType getUIType() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (uitype);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the list order of the attribute, or {@code null} if the list order is not defined.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.ListOrder getListOrder() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return listOrder;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the syntax of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.Syntax getSyntax() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (syntax);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the I18N key to describe the configuration attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getI18NKey() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (key);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the order of this attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the order of this attribute, null if not defined
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Integer getOrder() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return order;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of the cosQualifier for this attribute. Either default,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * overrid, operational or merge-cos.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the value of the cosQualifier for this attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getCosQualifier() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (cosQualifier);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the default values of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Set<String> getDefaultValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (defaultsObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = defaultsObject.getDefaultValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getValuesCopy(defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the default values of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envParams
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map of environment parameter to a set of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return default values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Set getDefaultValues(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (defaultsObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = defaultsObject.getDefaultValues(envParams);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getValuesCopy(defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the example values of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Set getExampleValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return getValuesCopy(exampleValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private <T> Set<T> getValuesCopy(Set<T> defaultValues) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (isEmpty(defaultValues)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return emptySet();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (INSERTION.equals(listOrder)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return new LinkedHashSet<>(defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return new HashSet<>(defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the possible choice values for the attribute if the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * type is either <code>SINGLE_CHOICE</code> or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>MULTIPLE_CHOICE</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String[] getChoiceValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set ret = choiceValues.keySet();
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna return ((String[]) ret.toArray(new String[ret.size()]));
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna }
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna return (null);
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna }
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna /**
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna * Returns the possible choice values for the attribute if the attribute
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna * type is either <code>SINGLE_CHOICE</code> or
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna * <code>MULTIPLE_CHOICE</code>.
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna *
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna * @param envParams
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna * Map of environment parameter to a set of values
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna * @return choice values for the attribute
32bd4dbf7dd85069d8cba66ae42fad635cdd34d5David Luna */
32bd4dbf7dd85069d8cba66ae42fad635cdd34d5David Luna public String[] getChoiceValues(Map envParams) {
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna if (choiceObject != null) {
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna choiceValues = choiceObject.getChoiceValues(envParams);
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set ret = choiceValues.keySet();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return ((String[]) ret.toArray(new String[ret.size()]));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the choice values as a Map.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute and its i18n key
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected Map getChoiceValuesMap() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (choiceValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (new HashMap());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the choice values as a set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected Set getChoiceValuesSet() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues != null) {
f340ca28e0f04c4b3b878647094bfd9439c0b698David Luna return (choiceValues.keySet());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (new HashSet());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the choice values as a Map.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envParams
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map of environment parameter to a set of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected Map getChoiceValuesMap(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues(envParams);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (choiceValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (new HashMap());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the choice values as a set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envParams
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map of environment parameter to a set of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected Set getChoiceValuesSet(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues(envParams);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (choiceValues.keySet());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (new HashSet());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the I18N key for the given choice value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the I18N key for the given choice value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getChoiceValueI18NKey(String cValue) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return ((String) choiceValues.get(cValue));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Indicates whether this AttributeSchema has choice values configured.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean hasChoiceValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return hasChoiceValues;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the start range if the attribute syntax is either
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>NUMBER_RANGE</code> or <code>DECIMAL_RANGE</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getStartRange() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (rangeStart);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the end range if the attribute syntax is either
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>NUMBER_RANGE</code> or <code>DECIMAL_RANGE</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getEndRange() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (rangeEnd);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to get the validator name for using to validate this service
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the validator name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getValidator() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (validator);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the minimum number of values for the attribute if the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is of type <code>MULTIPLE_CHOICE</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int getMinValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (minValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the maximum number of values for the attribute if the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is of type <code>MULTIPLE_CHOICE</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int getMaxValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (maxValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the string value for BooleanTrueValue.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getTrueValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (trueBooleanValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Retruns the I18N Key for BooleanTrueValue.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getTrueValueI18NKey() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (trueValueKey);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the string value for BooleanFalseValue.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getFalseValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (falseBooleanValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the I18N Key for BooleanFalseValue.
*/
public String getFalseValueI18NKey() {
return (falseValueKey);
}
/**
* Checks if the attribute is an optional attribute.
*/
public boolean isOptional() {
return (isOptional);
}
/**
* Chekcs if the attribute is a service identifier (i.e., in the case of
* LDAP it would be the COS Specifier attribute).
*/
public boolean isServiceIdentifier() {
return (isServiceIdentifier);
}
/**
* Checks if the attribute allows to have resource name.
*/
public boolean isResourceNameAllowed() {
return (isResourceNameAllowed);
}
/**
* Checkds if the attribute is a service's status attribute.
*/
public boolean isStatusAttribute() {
return (isStatusAttribute);
}
/**
* Method to get service specific attributes. It return the value of the
* "any" attribute, if set in the XML schema for the service
*/
public String getAny() {
return (any);
}
/**
* Returns URL of the view bean for the attribute.
*
* @return URL for view bean
*/
public String getPropertiesViewBeanURL() {
return (attributeViewBeanURL);
}
/**
* String represenation of the AttributeSchema
*/
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("Attr Name=").append(name);
buf.append("\n\tType=").append(type);
buf.append("\n\tUIType=").append(uitype);
buf.append("\n\tSyntax=").append(syntax);
buf.append("\n\tI18n Key=").append(key);
buf.append("\n\tDefault values=").append(defaultValues);
buf.append("\n\tChoice Values=").append(choiceValues);
buf.append("\n\tRangeStart=").append(rangeStart);
buf.append("\n\tRangeEnd=").append(rangeEnd);
buf.append("\n\tMinValue=").append(minValue);
buf.append("\n\tMaxValue=").append(maxValue);
buf.append("\n\tCoS Qualifier=").append(cosQualifier);
buf.append("\n\tAny=").append(any);
buf.append("\n\tView Bean URL=").append(attributeViewBeanURL);
buf.append("\n\tisOptional=").append(isOptional);
buf.append("\n\tisServiceIdentifier=").append(isServiceIdentifier);
buf.append("\n\tisResourceNameAllowed=").append(isResourceNameAllowed);
buf.append("\n\tisStatusAttribute=").append(isStatusAttribute);
buf.append("\n\tisSearchable=").append(isSearchable);
buf.append("\n\tresourceName=").append(resourceName);
buf.append("\n");
return buf.toString();
}
public Node getAttributeSchemaNode() {
return attrSchemaNode;
}
/**
* Updates the attribute schema object based on information in the XML node
*/
void update(Node n) {
Node node;
// Copy the XML node
attrSchemaNode = n;
// Get attribute name
name = XMLUtils.getNodeAttributeValue(n, SMSUtils.NAME);
// Get json name
resourceName = XMLUtils.getNodeAttributeValue(n, SMSUtils.RESOURCE_NAME);
// Get I18N key
key = XMLUtils.getNodeAttributeValue(n, SMSUtils.I18N_KEY);
try {
order = Integer.valueOf(XMLUtils.getNodeAttributeValue(n, SMSUtils.ORDER));
} catch (NumberFormatException e) {
order = null;
}
// Get Attribute type
String attrType = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_TYPE);
type = AttributeSchema.Type.LIST;
if (attrType != null) {
try {
Class attrClass = (AttributeSchema.Type.LIST).getClass();
type = (AttributeSchema.Type) (attrClass.getField(attrType
.toUpperCase()).get(AttributeSchema.Type.LIST));
} catch (Exception e) {
// do nothing, use the default
}
}
// Get attribute UI type
String attrUIType = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_UITYPE);
uitype = null;
if (attrUIType != null) {
try {
Class attrClass = (AttributeSchema.UIType.LINK).getClass();
uitype = (AttributeSchema.UIType) (attrClass
.getField(attrUIType.toUpperCase())
.get(AttributeSchema.UIType.LINK));
} catch (Exception e) {
// do nothing, use the default
}
}
// Get attribute list order
String attrListOrder = XMLUtils.getNodeAttributeValue(n, SMSUtils.ATTRIBUTE_LIST_ORDER);
listOrder = null;
if (attrListOrder != null) {
try {
listOrder = AttributeSchema.ListOrder.valueOf(attrListOrder.toUpperCase());
} catch (Exception e) {
// do nothing, use the default
}
}
// Get attribute syntax
String attrSyntax = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_SYNTAX);
syntax = AttributeSchema.Syntax.STRING;
if (attrSyntax != null) {
try {
Class syntaxClass = (AttributeSchema.Syntax.STRING).getClass();
syntax = (AttributeSchema.Syntax) (syntaxClass
.getField(attrSyntax.toUpperCase())
.get(AttributeSchema.Syntax.STRING));
} catch (Exception e) {
// do nothing, use the default setting
}
}
// If syntax is boolean, get the "true" & "false" values
Node booleanValue;
if ((syntax.equals(AttributeSchema.Syntax.BOOLEAN))
&& ((booleanValue = XMLUtils.getChildNode(n,
SMSUtils.ATTRIBUTE_BOOLEAN_VALUES_ELEMENT)) != null)) {
// Get the True value
if ((node = XMLUtils.getChildNode(booleanValue,
SMSUtils.ATTRIBUTE_TRUE_BOOLEAN_ELEMENT)) != null) {
trueBooleanValue = XMLUtils.getValueOfValueNode(node);
trueValueKey = XMLUtils.getNodeAttributeValue(node,
SMSUtils.I18N_KEY);
} else {
trueBooleanValue = "true";
}
// Get the false value
if ((node = XMLUtils.getChildNode(booleanValue,
SMSUtils.ATTRIBUTE_FALSE_BOOLEAN_ELEMENT)) != null) {
falseBooleanValue = XMLUtils.getValueOfValueNode(node);
falseValueKey = XMLUtils.getNodeAttributeValue(node,
SMSUtils.I18N_KEY);
} else {
falseBooleanValue = "false";
}
} else {
trueBooleanValue = "true";
falseBooleanValue = "false";
}
// Get choice values, if applicable
if (type.equals(AttributeSchema.Type.SINGLE_CHOICE)
|| type.equals(AttributeSchema.Type.MULTIPLE_CHOICE)
|| type.equals(AttributeSchema.Type.LIST)) {
Node choiceValueNode = XMLUtils.getChildNode(n,
SMSUtils.ATTRIBUTE_CHOICE_VALUES_ELEMENT);
if (choiceValueNode != null) {
hasChoiceValues = true;
// If the sub-element ChoiceValuesClassName, use it
Node cvClassName = XMLUtils.getChildNode(choiceValueNode,
SMSUtils.ATTRIBUTE_CHOICE_CLASS);
if (cvClassName != null) {
String className = XMLUtils.getNodeAttributeValue(
cvClassName, SMSUtils.CLASS_NAME);
try {
Class c = Class.forName(className);
choiceObject = (ChoiceValues) c.newInstance();
choiceObject.setAttributeSchema(this);
choiceObject.setKeyValues(cvClassName);
choiceObject.setParentNode(n);
} catch (Exception e) {
SMSEntry.debug.warning("SMS AttributeSchema: Unable to load class: {}", className, e);
choiceObject = null;
}
}
// If choice class not present, use ChoiceValues element
if (choiceObject == null) {
// Choice object was not configured or error in obtaining it
choiceValues = new LinkedHashMap();
Iterator cit = XMLUtils.getChildNodes(choiceValueNode,
SMSUtils.ATTRIBUTE_CHOICE_VALUE_ELEMENT).iterator();
while (cit.hasNext()) {
Node cnode = (Node) cit.next();
String choiceValue = XMLUtils
.getValueOfValueNode(cnode);
String i18nKey = XMLUtils.getNodeAttributeValue(cnode,
SMSUtils.I18N_KEY);
choiceValues.put(choiceValue, i18nKey);
}
}
}
}
// Get default values
if ((node = XMLUtils
.getChildNode(n, SMSUtils.ATTRIBUTE_DEFAULT_ELEMENT)) != null) {
// If the sub-element DefaultValuesClassName, use it
Node dvClassName = XMLUtils.getChildNode(node,
SMSUtils.ATTRIBUTE_DEFAULT_CLASS);
if (dvClassName != null) {
String className = XMLUtils.getNodeAttributeValue(dvClassName,
SMSUtils.CLASS_NAME);
try {
Class c = Class.forName(className);
defaultsObject = (DefaultValues) c.newInstance();
defaultsObject.setAttributeSchema(this);
defaultsObject.setKeyValues(dvClassName);
defaultsObject.setParentNode(n);
} catch (Exception e) {
SMSEntry.debug.error("SMS AttributeSchema: "
+ "Unable to load class: " + className, e);
// use default approach
defaultValues = getValues(node);
}
} else {
defaultValues = getValues(node);
}
}
if ((node = XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_EXAMPLE_ELEMENT)) != null) {
exampleValues = getValues(node);
}
// If syntax is password, decrypt the attribute values
if ((syntax.equals(AttributeSchema.Syntax.PASSWORD) || syntax
.equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))
&& (defaultValues != null)) {
Iterator iter = defaultValues.iterator();
defaultValues = new HashSet();
while (iter.hasNext()) {
String value = (String) iter.next();
if (value != null) {
try {
value = (String) AccessController
.doPrivileged(new DecodeAction(value));
} catch (Throwable e) {
SMSEntry.debug.error(
"AttributeSchemaImpl: Unable to decode", e);
}
}
defaultValues.add(value);
}
}
// Set the cosQualifier
if ((cosQualifier = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_COS_QUALIFIER)) == null) {
cosQualifier = "default";
}
// Get range start
rangeStart = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_RANGE_START);
// Get range end
rangeEnd = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_RANGE_END);
// Get minimum number of values
try {
minValue = Integer.parseInt(XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_MIN_VALUE));
} catch (NumberFormatException e) {
minValue = -1;
}
// Get maximum number of values
try {
maxValue = Integer.parseInt(XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_MAX_VALUE));
} catch (NumberFormatException e) {
maxValue = -1;
}
// get validator
validator = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_VALIDATOR);
// Check if the variable is optional
if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_OPTIONAL) != null) {
isOptional = true;
}
// COS identifer
isServiceIdentifier = false;
if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_SERVICE_ID) != null) {
isServiceIdentifier = true;
}
// Resource name allowed
isResourceNameAllowed = false;
if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_RESOURCE_NAME) != null){
isResourceNameAllowed = true;
}
// Service Status attribute
isStatusAttribute = false;
if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_STATUS_ATTR) != null) {
isStatusAttribute = true;
}
// Any attribute
any = XMLUtils.getNodeAttributeValue(n, SMSUtils.ATTRIBUTE_ANY);
// Get view bean url
attributeViewBeanURL = XMLUtils.getNodeAttributeValue(n,
SMSUtils.ATTRIBUTE_VIEW_BEAN_URL);
isSearchable = false;
String srch = XMLUtils.getNodeAttributeValue(n, SMSUtils.ISSEARCHABLE);
if ((srch != null) && (srch.equalsIgnoreCase("yes"))) {
isSearchable = true;
}
}
protected static Set getValues(Node node) {
Set retVal = new HashSet();
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node n = children.item(i);
if (n.getNodeName().equals(SMSUtils.ATTRIBUTE_VALUE)) {
retVal.add(XMLUtils.getValueOfValueNode(n));
}
}
return (retVal);
}
/**
* Returns <code>true</code> if the attribute is searchable;
* <code>false</code> otherwise
*
* @return <code>true</code> if the attribute is an optional attribute;
* <code>false</code> otherwise
*/
public boolean isSearchable() {
return (isSearchable);
}
}