d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts/*
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 *
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * Portions Copyrighted 2011-2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.sm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Joosteimport static com.sun.identity.sm.AttributeSchema.ListOrder.*;
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Joosteimport static java.util.Collections.emptySet;
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Joosteimport static org.forgerock.openam.utils.CollectionUtils.isEmpty;
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.security.DecodeAction;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.xml.XMLUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.AccessController;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashMap;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Iterator;
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunningtonimport java.util.LinkedHashMap;
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Joosteimport java.util.LinkedHashSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Set;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Node;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.NodeList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
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 {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Input variables
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Node attrSchemaNode;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Variables derived from the Node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String name;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String key;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts private String resourceName;
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.Type type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.UIType uitype;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington private AttributeSchema.ListOrder listOrder;
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema.Syntax syntax;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Set defaultValues = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private DefaultValues defaultsObject = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Map choiceValues;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private ChoiceValues choiceObject = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String trueBooleanValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String trueValueKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String falseBooleanValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String falseValueKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String cosQualifier;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String rangeStart;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String rangeEnd;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
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
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts private boolean hasChoiceValues;
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts
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
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts /**
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * Returns the name of the attribute for CREST representation.
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts */
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts public String getResourceName() {
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts return (resourceName);
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts }
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts
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
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington /**
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington * Returns the list order of the attribute, or {@code null} if the list order is not defined.
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington */
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington public AttributeSchema.ListOrder getListOrder() {
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington return listOrder;
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington }
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington
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 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 getDefaultValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (defaultsObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = defaultsObject.getDefaultValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste return getDefaultValuesCopy(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 }
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste return getDefaultValuesCopy(defaultValues);
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste }
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste private Set<?> getDefaultValuesCopy(Set<?> defaultValues) {
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste if (isEmpty(defaultValues)) {
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste return emptySet();
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste }
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste if (INSERTION.equals(listOrder)) {
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste return new LinkedHashSet<>(defaultValues);
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste } else {
c423fd5d4f121413c5e72c134412b6ce5daa0dd9Jaco Jooste 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();
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 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 * @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 public String[] getChoiceValues(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues = choiceObject.getChoiceValues(envParams);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
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) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster 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
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts /**
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * Indicates whether this AttributeSchema has choice values configured.
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts */
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts boolean hasChoiceValues() {
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts return hasChoiceValues;
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts }
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts
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.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getFalseValueI18NKey() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (falseValueKey);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks if the attribute is an optional attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isOptional() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (isOptional);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Chekcs if the attribute is a service identifier (i.e., in the case of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * LDAP it would be the COS Specifier attribute).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isServiceIdentifier() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (isServiceIdentifier);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks if the attribute allows to have resource name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isResourceNameAllowed() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (isResourceNameAllowed);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checkds if the attribute is a service's status attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isStatusAttribute() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (isStatusAttribute);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to get service specific attributes. It return the value of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "any" attribute, if set in the XML schema for the service
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getAny() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (any);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns URL of the view bean for the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return URL for view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getPropertiesViewBeanURL() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (attributeViewBeanURL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * String represenation of the AttributeSchema
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster StringBuilder buf = new StringBuilder();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("Attr Name=").append(name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tType=").append(type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tUIType=").append(uitype);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tSyntax=").append(syntax);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tI18n Key=").append(key);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tDefault values=").append(defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tChoice Values=").append(choiceValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tRangeStart=").append(rangeStart);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tRangeEnd=").append(rangeEnd);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tMinValue=").append(minValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tMaxValue=").append(maxValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tCoS Qualifier=").append(cosQualifier);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tAny=").append(any);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tView Bean URL=").append(attributeViewBeanURL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tisOptional=").append(isOptional);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tisServiceIdentifier=").append(isServiceIdentifier);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tisResourceNameAllowed=").append(isResourceNameAllowed);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tisStatusAttribute=").append(isStatusAttribute);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n\tisSearchable=").append(isSearchable);
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts buf.append("\n\tresourceName=").append(resourceName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster buf.append("\n");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return buf.toString();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Node getAttributeSchemaNode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return attrSchemaNode;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Updates the attribute schema object based on information in the XML node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster void update(Node n) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node node;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Copy the XML node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrSchemaNode = n;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get attribute name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster name = XMLUtils.getNodeAttributeValue(n, SMSUtils.NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts // Get json name
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts resourceName = XMLUtils.getNodeAttributeValue(n, SMSUtils.RESOURCE_NAME);
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get I18N key
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster key = XMLUtils.getNodeAttributeValue(n, SMSUtils.I18N_KEY);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get Attribute type
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String attrType = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_TYPE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster type = AttributeSchema.Type.LIST;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (attrType != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Class attrClass = (AttributeSchema.Type.LIST).getClass();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster type = (AttributeSchema.Type) (attrClass.getField(attrType
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .toUpperCase()).get(AttributeSchema.Type.LIST));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // do nothing, use the default
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get attribute UI type
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String attrUIType = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_UITYPE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uitype = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (attrUIType != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Class attrClass = (AttributeSchema.UIType.LINK).getClass();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uitype = (AttributeSchema.UIType) (attrClass
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .getField(attrUIType.toUpperCase())
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .get(AttributeSchema.UIType.LINK));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // do nothing, use the default
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington // Get attribute list order
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington String attrListOrder = XMLUtils.getNodeAttributeValue(n, SMSUtils.ATTRIBUTE_LIST_ORDER);
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington listOrder = null;
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington if (attrListOrder != null) {
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington try {
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington listOrder = AttributeSchema.ListOrder.valueOf(attrListOrder.toUpperCase());
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington } catch (Exception e) {
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington // do nothing, use the default
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington }
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington }
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get attribute syntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String attrSyntax = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_SYNTAX);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster syntax = AttributeSchema.Syntax.STRING;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (attrSyntax != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Class syntaxClass = (AttributeSchema.Syntax.STRING).getClass();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster syntax = (AttributeSchema.Syntax) (syntaxClass
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .getField(attrSyntax.toUpperCase())
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .get(AttributeSchema.Syntax.STRING));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // do nothing, use the default setting
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If syntax is boolean, get the "true" & "false" values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node booleanValue;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((syntax.equals(AttributeSchema.Syntax.BOOLEAN))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster && ((booleanValue = XMLUtils.getChildNode(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_BOOLEAN_VALUES_ELEMENT)) != null)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the True value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((node = XMLUtils.getChildNode(booleanValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_TRUE_BOOLEAN_ELEMENT)) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueBooleanValue = XMLUtils.getValueOfValueNode(node);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueValueKey = XMLUtils.getNodeAttributeValue(node,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.I18N_KEY);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueBooleanValue = "true";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the false value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((node = XMLUtils.getChildNode(booleanValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_FALSE_BOOLEAN_ELEMENT)) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseBooleanValue = XMLUtils.getValueOfValueNode(node);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseValueKey = XMLUtils.getNodeAttributeValue(node,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.I18N_KEY);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseBooleanValue = "false";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueBooleanValue = "true";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseBooleanValue = "false";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get choice values, if applicable
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (type.equals(AttributeSchema.Type.SINGLE_CHOICE)
1cb968daf78963d139ff89a7b192e85314e82509James Phillpotts || type.equals(AttributeSchema.Type.MULTIPLE_CHOICE)
1cb968daf78963d139ff89a7b192e85314e82509James Phillpotts || type.equals(AttributeSchema.Type.LIST)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node choiceValueNode = XMLUtils.getChildNode(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_CHOICE_VALUES_ELEMENT);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValueNode != null) {
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts hasChoiceValues = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If the sub-element ChoiceValuesClassName, use it
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node cvClassName = XMLUtils.getChildNode(choiceValueNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_CHOICE_CLASS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (cvClassName != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String className = XMLUtils.getNodeAttributeValue(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cvClassName, SMSUtils.CLASS_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Class c = Class.forName(className);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceObject = (ChoiceValues) c.newInstance();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceObject.setAttributeSchema(this);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceObject.setKeyValues(cvClassName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceObject.setParentNode(n);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSEntry.debug.error("SMS AttributeSchema: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Unable to load class: " + className, e);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceObject = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If choice class not present, use ChoiceValues element
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceObject == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Choice object was not configured or error in obtaining it
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington choiceValues = new LinkedHashMap();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator cit = XMLUtils.getChildNodes(choiceValueNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_CHOICE_VALUE_ELEMENT).iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while (cit.hasNext()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node cnode = (Node) cit.next();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String choiceValue = XMLUtils
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .getValueOfValueNode(cnode);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String i18nKey = XMLUtils.getNodeAttributeValue(cnode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.I18N_KEY);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues.put(choiceValue, i18nKey);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get default values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((node = XMLUtils
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .getChildNode(n, SMSUtils.ATTRIBUTE_DEFAULT_ELEMENT)) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If the sub-element DefaultValuesClassName, use it
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node dvClassName = XMLUtils.getChildNode(node,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_DEFAULT_CLASS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (dvClassName != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String className = XMLUtils.getNodeAttributeValue(dvClassName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.CLASS_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Class c = Class.forName(className);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultsObject = (DefaultValues) c.newInstance();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultsObject.setAttributeSchema(this);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultsObject.setKeyValues(dvClassName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultsObject.setParentNode(n);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSEntry.debug.error("SMS AttributeSchema: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Unable to load class: " + className, e);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // use default approach
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = getValues(node);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = getValues(node);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If syntax is password, decrypt the attribute values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((syntax.equals(AttributeSchema.Syntax.PASSWORD) || syntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster && (defaultValues != null)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator iter = defaultValues.iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = new HashSet();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while (iter.hasNext()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String value = (String) iter.next();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (value != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster value = (String) AccessController
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .doPrivileged(new DecodeAction(value));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Throwable e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSEntry.debug.error(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "AttributeSchemaImpl: Unable to decode", e);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues.add(value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Set the cosQualifier
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((cosQualifier = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_COS_QUALIFIER)) == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cosQualifier = "default";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get range start
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rangeStart = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_RANGE_START);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get range end
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rangeEnd = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_RANGE_END);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get minimum number of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster minValue = Integer.parseInt(XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_MIN_VALUE));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (NumberFormatException e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster minValue = -1;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get maximum number of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster maxValue = Integer.parseInt(XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_MAX_VALUE));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (NumberFormatException e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster maxValue = -1;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // get validator
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster validator = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_VALIDATOR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check if the variable is optional
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_OPTIONAL) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isOptional = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // COS identifer
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isServiceIdentifier = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_SERVICE_ID) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isServiceIdentifier = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Resource name allowed
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isResourceNameAllowed = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_RESOURCE_NAME) != null){
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isResourceNameAllowed = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Service Status attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isStatusAttribute = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (XMLUtils.getChildNode(n, SMSUtils.ATTRIBUTE_STATUS_ATTR) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isStatusAttribute = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Any attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster any = XMLUtils.getNodeAttributeValue(n, SMSUtils.ATTRIBUTE_ANY);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get view bean url
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attributeViewBeanURL = XMLUtils.getNodeAttributeValue(n,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_VIEW_BEAN_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isSearchable = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String srch = XMLUtils.getNodeAttributeValue(n, SMSUtils.ISSEARCHABLE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((srch != null) && (srch.equalsIgnoreCase("yes"))) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isSearchable = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected static Set getValues(Node node) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set retVal = new HashSet();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster NodeList children = node.getChildNodes();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < children.getLength(); i++) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node n = children.item(i);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (n.getNodeName().equals(SMSUtils.ATTRIBUTE_VALUE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster retVal.add(XMLUtils.getValueOfValueNode(n));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (retVal);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns <code>true</code> if the attribute is searchable;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>false</code> otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if the attribute is an optional attribute;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>false</code> otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isSearchable() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (isSearchable);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}