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: AttributeSchema.java,v 1.13 2009/01/13 06:56:08 mahesh_prasad_r Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste * Portions Copyrighted 2014-2016 ForgeRock AS.
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington */
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.sm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.AccessController;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.text.MessageFormat;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Collections;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashMap;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Iterator;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Set;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Document;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Element;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Node;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.debug.Debug;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.xml.XMLUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.sso.SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.security.EncodeAction;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>AttributeSchema</code> provides methods to access the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * schema of a configuration parameter. Also, it provides methods to set default
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and choice values.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.all.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class AttributeSchema {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Debug
0f5abdb7626a4e93390d1ed9e361229af6df5ae7Rich Riley private Debug debug = Debug.getInstance("amSMS");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Instance variable
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServiceSchemaManager ssm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServiceSchema ss;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PluginSchema ps;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AttributeSchemaImpl as;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor. Makes it private so that it cannot be instantiated.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private AttributeSchema() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructor used by ServiceSchema to instantiate
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>AttributeSchema</code> objects.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected AttributeSchema(AttributeSchemaImpl as, ServiceSchemaManager ssm,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServiceSchema ss) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.ssm = ssm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.ss = ss;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.as = as;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (as == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("AttributeSchema:: IMPL is NULL");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected AttributeSchema(AttributeSchemaImpl as, PluginSchema ps) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.as = as;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.ps = ps;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the name of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the name of the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the type of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the type of the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.Type getType() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getType());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns Service Schema.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return Service Schema.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ServiceSchema getServiceSchema() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return ss;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the type.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param type
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * to be changed to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setType(String type) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_TYPE, type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington /**
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington * Returns the list order of the attribute.
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington *
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington * @return 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 as.getListOrder();
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington }
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the UI type of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the UI type of the attribute; or null if the UI Type is not
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * defined
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.UIType getUIType() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getUIType());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the <code>UIType</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param uiType
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * user interface type.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>UIType</code> to the attribute schema.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setUIType(String uiType) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_UITYPE, uiType);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the syntax of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the syntax of the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AttributeSchema.Syntax getSyntax() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getSyntax());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the Syntax attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param synt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * syntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * syntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setSyntax(String synt) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_SYNTAX, synt);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the I18N key to describe the configuration attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the I18N key to describe the configuration attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getI18NKey() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getI18NKey());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the I18N key to describe the configuration attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param i18nKey
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the I18N key to describe the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set I18N key to the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute schema
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setI18NKey(String i18nKey) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.I18N_KEY, i18nKey);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of the <code>cosQualifier</code> for this attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * that is <code>default, override, operational or merge-cos</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the value of the <code>cosQualifier</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getCosQualifier() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getCosQualifier());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the <code>cosQualifier</code> attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param cosq
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * value of <code>cosQualifier</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setCosQualifier(String cosq) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_COS_QUALIFIER, cosq);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the default values of the attribute. If there are no default
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * values defined for this attribute in the schema then this method returns
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a Collections.EMPTY_SET
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return set of default values of the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Set getDefaultValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getDefaultValues());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the default values of the attribute for the given environment
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * parameters. If there are no default values defined for this attribute in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the schema then this method returns a Collections.EMPTY_SET
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envParams
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map of environment parameter to a set of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return set of default values of the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Set getDefaultValues(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getDefaultValues(envParams));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the default values of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the set of default values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setDefaultValues(Set values) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateDefaultValues(values);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Protected method to set the default values in the given XML document.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster void setDefaultValues(Set values, Document document) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateDefaultValues(values, document);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Adds a default value to the existing set of default values.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the default value to add
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addDefaultValue(String value) throws SMSException, SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set defaultValues = getDefaultValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (defaultValues != Collections.EMPTY_SET) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues.add(value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues = new HashSet();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues.add(value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateDefaultValues(defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes the all the default values for the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeDefaultValues() throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateDefaultValues(new HashSet());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes the given value from the set of default values.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the default value to remove
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeDefaultValue(String value) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set defaultValues = getDefaultValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (defaultValues != Collections.EMPTY_SET) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster defaultValues.remove(value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateDefaultValues(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 set of possible choice values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String[] getChoiceValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getChoiceValues());
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>, for the given environment parameters.
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envParams
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map of environment parameter to a set of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return set of possible choice values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String[] getChoiceValues(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getChoiceValues(envParams));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts /**
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * Returns the possible choice values for the attribute if the attribute
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * type is either <code>SINGLE_CHOICE</code> or
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * <code>MULTIPLE_CHOICE</code>, for the given environment parameters,
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * along with the values' i18n keys.
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts *
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * @param envParams
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * Map of environment parameter to a set of values
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * @return Map of value to i18n key.
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts */
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts public Map getChoiceValuesMap(Map envParams) {
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts return as.getChoiceValuesMap(envParams);
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts }
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts /**
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts * Indicates whether this AttributeSchema has choice values defined.
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts */
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts public boolean hasChoiceValues() {
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts return as.hasChoiceValues();
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts }
11f8ea9dfa5d4e12b124ee8ef6e967cdaa7d14fcJames Phillpotts
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the I18N key for the given choice value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param cValue
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * choice value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the I18N key for the given choice value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getChoiceValueI18NKey(String cValue) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getChoiceValueI18NKey(cValue));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Adds a choice value and its i18n key to the existing set of choice
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * values.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the choice value to add
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param i18nKey
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the I18N key for the choice value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void addChoiceValue(String value, String i18nKey)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map choiceValues = as.getChoiceValuesMap();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster choiceValues.put(value, i18nKey);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateChoiceValues(choiceValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Removes the given value from the set of choice values.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the choice value to remove
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeChoiceValue(String value) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map choiceValues = as.getChoiceValuesMap();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (choiceValues.remove(value) != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateChoiceValues(choiceValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
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 * @return the start range for the attribute value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getStartRange() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getStartRange());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the start range attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param stRange
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * start range.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setStartRange(String stRange) throws SMSException, SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_RANGE_START, stRange);
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 * @return the end range for the attribute value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getEndRange() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getEndRange());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the end range Attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param edRange
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * end range.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setEndRange(String edRange) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_RANGE_END, edRange);
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 (as.getValidator());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the Validator attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param valid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * validator
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setValidator(String valid) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_VALIDATOR, valid);
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 * @return the minimum number of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int getMinValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getMinValue());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the minimum value attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param minV
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * minimum value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setMinValue(String minV) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_MIN_VALUE, minV);
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 * @return the maximum number of values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int getMaxValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getMaxValue());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the maximum value attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param maxV
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * maximum value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setMaxValue(String maxV) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_MAX_VALUE, maxV);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the boolean values of the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param trueValue string value for <code>BooleanTrueValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param trueValueI18nKey <code>I18N</code> key for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>BooleanTrueValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param falseValue string value for <code>BooleanFalseValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param falseValueI18nKey <code>I18N</code> Key for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>BooleanFalseValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setBooleanValues(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String trueValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String trueValueI18nKey,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String falseValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String falseValueI18nKey
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ) throws SSOException, SMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateBooleanValues(trueValue, trueValueI18nKey,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseValue, falseValueI18nKey, null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the string value for <code>BooleanTrueValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the string value for <code>BooleanTrueValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getTrueValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getTrueValue());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the <code>I18N</code> key for <code>BooleanTrueValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the <code>I18N</code> key for <code>BooleanTrueValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getTrueValueI18NKey() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getTrueValueI18NKey());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the string value for <code>BooleanFalseValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the string value for <code>BooleanFalseValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getFalseValue() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getFalseValue());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the <code>I18N</code> Key for <code>BooleanFalseValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the <code>I18N</code> Key for <code>BooleanFalseValue</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getFalseValueI18NKey() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getFalseValueI18NKey());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns true if the attribute is an optional attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if the attribute is an optional attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isOptional() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.isOptional());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns true if the attribute is a service identifier (i.e., in the case
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of LDAP it would be the COS Specifier attribute).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if the attribute is service identifier attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isServiceIdentifier() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.isServiceIdentifier());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks if the attribute allows to have resource name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if the attribute allows to have resource name; false
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isResourceNameAllowed() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.isResourceNameAllowed());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns true if the attribute is a service's status attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if the attribute is a status attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isStatusAttribute() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.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 * @return value of "any" attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getAny() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.getAny());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the any attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * value for any attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setAny(String a) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_ANY, a);
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 (as.getPropertiesViewBeanURL());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the URL of the view bean for the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param prop
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * properties view bean URL.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setPropertiesViewBeanUR(String prop) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ATTRIBUTE_VIEW_BEAN_URL, prop);
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 (as.isSearchable());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the attribute isSearchable, if value is set to <code>true
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * </code>,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * or <code>false</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if set to <code>true</code> the attribute will be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * searchable; else searches cannot be performed on this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if an error is encountered when trying to set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the single sign on token is invalid or expired
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setSearchable(String value) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((!(value.toLowerCase()).equals("yes"))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster && (!(value.toLowerCase()).equals("no"))) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] arg = { value };
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("AttributeSchema: Invalid isSearchable value");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new SMSException(SMSEntry.bundle
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .getString("sms-invalid-searchable-value")
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + ":" + arg, "sms-invalid-searchable-value");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(SMSUtils.ISSEARCHABLE, value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts /**
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * Returns the name of this attribute when used in a CREST representation.
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts */
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts public String getResourceName() {
a2b64c9e3378d4d0127e550f5d19286f37d42011James Phillpotts String resourceName = as.getResourceName();
a2b64c9e3378d4d0127e550f5d19286f37d42011James Phillpotts return resourceName == null ? getName() : resourceName;
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts }
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts /**
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * Sets the CREST representation name for the attribute.
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts *
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * @param name
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * the name of the CREST property.
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * @throws SMSException
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * if an error is encountered when trying to set.
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * @throws SSOException
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts * if the single sign on token is invalid or expired.
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts */
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts public void setResourceName(String name) throws SSOException, SMSException {
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts updateXMLDocument(SMSUtils.RESOURCE_NAME, name);
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts }
d135fba117a27e6d0de2f5518a274bba4c0a38efJames Phillpotts
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a string representation of this <code> AttributeSchema </code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return String representation of this object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (as.toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method for modifying default values
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateDefaultValues(Set defaultValues) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateDefaultValues(defaultValues, null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method for modifying default values given the XML document
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateDefaultValues(Set defaultValues, Document doc)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check if the values are valid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (ss != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map tempattrs = new HashMap(1);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tempattrs.put(getName(), defaultValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ss.validateAttributes(tempattrs);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check if the attributes have to be encoded
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean encode = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (getSyntax().equals(Syntax.PASSWORD)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster || getSyntax().equals(Syntax.ENCRYPTED_PASSWORD)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster encode = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct DefaultValues node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster StringBuffer sb = new StringBuffer(100);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(XML_PREFIX).append(DEFAULT_VALUES_BEGIN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator items = defaultValues.iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while (items.hasNext()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(VALUE_BEGIN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (encode) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String encString = (String) items.next();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster encString = (String) AccessController
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .doPrivileged(new EncodeAction(encString));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Throwable e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("AttributeSchema: Unable to encode", e);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(encString);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(SMSSchema.escapeSpecialCharacters((String) items
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .next()));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(VALUE_END);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(DEFAULT_VALUES_END);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(sb, SMSUtils.ATTRIBUTE_DEFAULT_ELEMENT, doc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateChoiceValues(Map choiceValues) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateChoiceValues(choiceValues, null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateChoiceValues(Map choiceValues, Document doc)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct ChoiceValues
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster StringBuffer sb = new StringBuffer(100);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(XML_PREFIX).append(CHOICE_VALUES_BEGIN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Iterator items = choiceValues.keySet().iterator();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while (items.hasNext()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] vals = new String[2];
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String value = SMSSchema.escapeSpecialCharacters((String) items
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .next());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String i18nKey = (String) choiceValues.get(value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (i18nKey == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vals[0] = value;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(MessageFormat.format(CHOICE_VALUE, (Object[])vals));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vals[0] = i18nKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vals[1] = value;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(MessageFormat.format(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster CHOICE_VALUE_KEY, (Object[])vals));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(CHOICE_VALUES_END);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(sb, SMSUtils.ATTRIBUTE_CHOICE_VALUES_ELEMENT, doc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateBooleanValues(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String trueValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String trueValueI18nKey,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String falseValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String falseValueI18nKey,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Document doc
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct BooleanValues
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster StringBuffer sb = new StringBuffer(100);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(XML_PREFIX).append(BOOLEAN_VALUES_BEGIN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] trueVals = new String[2];
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((trueValueI18nKey != null) && (trueValue != null)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueVals[0] = trueValueI18nKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueVals[1] = SMSSchema.escapeSpecialCharacters(trueValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueVals[0] = getTrueValueI18NKey();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster trueVals[1] = getTrueValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(MessageFormat.format(TRUE_BOOLEAN_KEY, (Object[])trueVals));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] falseVals = new String[2];
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((falseValueI18nKey != null) && (falseValue != null)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseVals[0] = falseValueI18nKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseVals[1] = SMSSchema.escapeSpecialCharacters(falseValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseVals[0] = getFalseValueI18NKey();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster falseVals[1] = getFalseValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(MessageFormat.format(FALSE_BOOLEAN_KEY, (Object[])falseVals));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster sb.append(BOOLEAN_VALUES_END);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster updateXMLDocument(sb, SMSUtils.ATTRIBUTE_BOOLEAN_VALUES_ELEMENT, doc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateXMLDocument(StringBuffer sb, String elementName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Document updateDoc) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Update the default element in XML
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct the XML document
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Document doc = SMSSchema.getXMLDocument(sb.toString(), false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node node = XMLUtils.getRootNode(doc, elementName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Convert to Schema's document
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Document schemaDoc = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (updateDoc != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaDoc = updateDoc;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (ssm != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaDoc = ssm.getDocumentCopy();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaDoc = ps.getDocumentCopy();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node nNode = schemaDoc.importNode(node, true);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Traverse the document to get this attribute element
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node schemaNode = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (ss != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaNode = ss.getSchemaNode(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaNode = ps.getPluginSchemaNode(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node attrSchemaNode = XMLUtils.getNamedChildNode(schemaNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.SCHEMA_ATTRIBUTE, SMSUtils.NAME, getName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Try getting OrganizationAttributeSchema if AttributeSchema
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // node is not there within Organization node.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // This will be a special case for idrepo service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (attrSchemaNode == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaNode = ss.getOrgAttrSchemaNode(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrSchemaNode = XMLUtils.getNamedChildNode(schemaNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.SCHEMA_ATTRIBUTE, SMSUtils.NAME, getName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node oNode = XMLUtils.getChildNode(attrSchemaNode, elementName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (oNode != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrSchemaNode.replaceChild(nNode, oNode);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrSchemaNode.appendChild(nNode);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Update the schema in the directory
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (updateDoc != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // do nothing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (ssm != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ssm.replaceSchema(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ps.replacePluginSchema(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(e.getMessage(), e,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "sms-cannot-update-xml-document"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * update attribute value in attribute schema element
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void updateXMLDocument(String attrName, String attrValue)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Update the default element in XML
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct the XML document
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Document schemaDoc = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (ssm != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaDoc = ssm.getDocumentCopy();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaDoc = ps.getDocumentCopy();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Traverse the document to get this attribute element
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node schemaNode = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (ss != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaNode = ss.getSchemaNode(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster schemaNode = ps.getPluginSchemaNode(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node attrSchemaNode = XMLUtils.getNamedChildNode(schemaNode,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.SCHEMA_ATTRIBUTE, SMSUtils.NAME, getName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ((Element) attrSchemaNode).setAttribute(attrName, attrValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Update the schema in the directory
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (ssm != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ssm.replaceSchema(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ps.replacePluginSchema(schemaDoc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(e.getMessage(), e,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "sms-cannot-update-xml-document"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>Type</code> defines the types of schema attributes and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * provides static constants for these types. This could also be viewed as a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * higher level structured data types like Set, List, etc. The primitive
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * data types are defined by <code>Syntax</code>. Currently defined
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * schema attribute types are <code>SINGLE</code>, <code>LIST</code>,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>SINGLE_CHOICE</code>, <code>MULTIPLE_CHOICE</code>,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>SIGNATURE</code> and <code>VALIDATOR</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static class Type extends Object {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>SINGLE</code> attribute type specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * can have only a single value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Type SINGLE = new Type("single");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>LIST</code> attribute type specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * can have multiple values, i.e., multi-valued attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Type LIST = new Type("list");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>SINGLE_CHOICE</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute can have value defined by the <code>getChoiceValues</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * method of <code>AttributeSchema</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Type SINGLE_CHOICE = new Type("single_choice");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>MULTIPLE_CHOICE</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute can have multiple values defined by the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>getChoiceValues</code> method of <code>AttributeSchema</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Type MULTIPLE_CHOICE = new Type("multiple_choice");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>SIGNATURE</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a signing attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Type SIGNATURE = new Type("signature");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>VALIDATOR</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute defines a attribute validator plugin.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Type VALIDATOR = new Type("validator");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String attrType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Type() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Type(String type) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The method returns the string representation of the schema attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * type.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return String string representation of schema attribute type
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return attrType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to check if two schema attribute types are equal.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param schemaAttrType
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the reference object with which to compare
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if the objects are same; <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * false</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean equals(Object schemaAttrType) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (schemaAttrType instanceof Type) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Type s = (Type) schemaAttrType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (s.attrType.equals(attrType));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a hash code value for the object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a hash code value for the object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int hashCode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return attrType.hashCode();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington /**
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington * This enum {@code ListOrder} defines the list orders of schema attributes and provides constants for these list
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington * orders. These types will mainly be used by the GUI to determine how to display the schema attributes.
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington */
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington public enum ListOrder {
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington /** Orders lists naturally. */
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington NATURAL,
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington /** Orders lists in the order they are entered in LDAP. */
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington INSERTION
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington }
3286da3756e1d2f07709aafdbc5419b26ff71dffPhill Cunnington
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>UIType</code> defines the UI types of schema attributes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and provides static constants for these types. These types mainly will be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * used by the GUI to determine how to display the schema attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Currently defined schema attribute UI types are <code>RADIO</code>,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>LINK</code>, <code>BUTTON</code> and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>NAME_VALUE_LIST</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static class UIType extends Object {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>RADIO</code> attribute type specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * should be display as radio button.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType RADIO = new UIType("radio");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>LINK</code> attribute type specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * should be display as a link.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType LINK = new UIType("link");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>BUTTON</code> attribute type specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * should be display as a button.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType BUTTON = new UIType("button");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>NAME_VALUE_LIST</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute should be display as a name value list widget.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType NAME_VALUE_LIST = new UIType(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "name_value_list");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>UNORDERED_LIST</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute should be display as an unordered list widget.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType UNORDEREDLIST = new UIType("unorderedlist");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>ORDERED_LIST</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute should be display as an ordered list widget.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType ORDEREDLIST = new UIType("orderedlist");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>MAP_LIST</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute should be display as an map list widget.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType MAPLIST = new UIType("maplist");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>GLOBALMAP_LIST</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute should be display as a global map list widget.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType GLOBALMAPLIST = new UIType("globalmaplist");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>ADDREMOVELIST</code> attribute type specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * multiple choice attribute should be display as add remove list
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * widget.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final UIType ADDREMOVELIST = new UIType("addremovelist");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
4701cb94cccc5ef52c5333593fe9dd5a2376a9d9Jaco Jooste /**
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * The <code>SCRIPTSELECT</code> attribute type specifies that the
4701cb94cccc5ef52c5333593fe9dd5a2376a9d9Jaco Jooste * attribute should be display as drop down widget.
4701cb94cccc5ef52c5333593fe9dd5a2376a9d9Jaco Jooste */
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste public static final UIType SCRIPTSELECT = new UIType("scriptSelect");
4701cb94cccc5ef52c5333593fe9dd5a2376a9d9Jaco Jooste
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste /**
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste * The <code>GLOBALSCRIPTSELECT</code> attribute type specifies that the
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste * attribute should be display as drop down widget with only global scripts.
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste */
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste public static final UIType GLOBALSCRIPTSELECT = new UIType("globalScriptSelect");
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String attrType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private UIType() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private UIType(String type) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The method returns the string representation of the schema attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * UI type.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return String string representation of schema attribute UI type
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return attrType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to check if two schema attribute UI types are equal.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param schemaAttrType
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the reference object with which to compare
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if the objects are same; <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * false</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean equals(Object schemaAttrType) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (schemaAttrType instanceof UIType) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster UIType s = (UIType) schemaAttrType;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (s.attrType.equals(attrType));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a hash code value for the object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a hash code value for the object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int hashCode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return attrType.hashCode();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The class <code>Syntax</code> defines the syntax of the schema
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attributes and provides static constants for these types. In other words,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * this class defines the primitive data types for the schema attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static class Syntax {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>BOOLEAN</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is of boolean type, i.e., can have a value of either
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>true</code> or <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * false</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax BOOLEAN = new Syntax("boolean");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>EMAIL</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a email address.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax EMAIL = new Syntax("email");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>URL</code> attribute syntax specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is a URL.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax URL = new Syntax("url");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>STRING</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is of text type, i.e., can have any unicode characters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax STRING = new Syntax("string");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>PARAGRAPH</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is of multi-lined text type.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax PARAGRAPH = new Syntax("paragraph");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>XML</code> attribute syntax specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is of XML type, i.e., can have any unicode characters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax XML = new Syntax("xml");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
f56a278c148b90f6c2a675e0c1fa8686ca5abed4Robert Wapshott /**
f56a278c148b90f6c2a675e0c1fa8686ca5abed4Robert Wapshott * The <code>SCRIPT</code> attribute syntax specifies that the
f56a278c148b90f6c2a675e0c1fa8686ca5abed4Robert Wapshott * attribute is of multi-lined text type and more specifically a script.
f56a278c148b90f6c2a675e0c1fa8686ca5abed4Robert Wapshott */
f56a278c148b90f6c2a675e0c1fa8686ca5abed4Robert Wapshott public static final Syntax SCRIPT = new Syntax("script");
f56a278c148b90f6c2a675e0c1fa8686ca5abed4Robert Wapshott
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>PASSWORD</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is of password type, will be used by UI to mask the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * password typed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax PASSWORD = new Syntax("password");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>ENCRYPTED PASSWORD</code> attribute syntax specifies that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the attribute is of password type, will be used by UI to mask the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * password typed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax ENCRYPTED_PASSWORD = new Syntax(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "encrypted_password");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>DATE</code> attribute syntax specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * is of date type.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax DATE = new Syntax("date");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>NUMERIC</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is numeric, i.e., can have numbers only.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax NUMERIC = new Syntax("numeric");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>NUMBER</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a number.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax NUMBER = new Syntax("number");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>DECIMAL</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a decimal value.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax DECIMAL = new Syntax("decimal");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>PERCENT</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a percentage.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax PERCENT = new Syntax("percent");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>NUMBER_RANGE</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a number within a range.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax NUMBER_RANGE = new Syntax("number_range");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>DECIMAL_RANGE</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a decimal number within a range.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax DECIMAL_RANGE = new Syntax("decimal_range");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>DECIMAL_NUMBER</code> attribute syntax specifies that the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute is a floating point number, e.g., 1.5, 3.56, etc.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax DECIMAL_NUMBER =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new Syntax("decimal_number");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>DN</code> attribute syntax specifies that the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * should be an LDAP distinguished name (DN).
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final Syntax DN = new Syntax("dn");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String attrSyntax;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Syntax() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private Syntax(String syntax) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attrSyntax = syntax;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The method returns the string representation of the schema attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * syntax.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return String string representation of schema attribute syntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toString() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (attrSyntax);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to check if two schema attribute syntax are equal.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param schemaAttrSyntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the reference object with which to compare
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if the objects are same; <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * false</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean equals(Object schemaAttrSyntax) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (schemaAttrSyntax instanceof Syntax) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Syntax s = (Syntax) schemaAttrSyntax;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (s.attrSyntax.equals(attrSyntax));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a hash code value for the object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a hash code value for the object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int hashCode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return attrSyntax.hashCode();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String XML_PREFIX =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String DEFAULT_VALUES_BEGIN = "<"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_DEFAULT_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String DEFAULT_VALUES_END = "</"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_DEFAULT_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String VALUE_BEGIN = "<" + SMSUtils.ATTRIBUTE_VALUE + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String VALUE_END = "</" + SMSUtils.ATTRIBUTE_VALUE + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String CHOICE_VALUES_BEGIN = "<"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_CHOICE_VALUES_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String CHOICE_VALUES_END = "</"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_CHOICE_VALUES_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String CHOICE_VALUE_KEY = "<"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_CHOICE_VALUE_ELEMENT + " " + SMSUtils.I18N_KEY
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "=\"{0}\">{1}</" + SMSUtils.ATTRIBUTE_CHOICE_VALUE_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String CHOICE_VALUE = "<"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_CHOICE_VALUE_ELEMENT + ">{0}</"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + SMSUtils.ATTRIBUTE_CHOICE_VALUE_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String BOOLEAN_VALUES_BEGIN =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "<" + SMSUtils.ATTRIBUTE_BOOLEAN_VALUES_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String BOOLEAN_VALUES_END =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "</" + SMSUtils.ATTRIBUTE_BOOLEAN_VALUES_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String TRUE_BOOLEAN_KEY =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "<" + SMSUtils.ATTRIBUTE_TRUE_BOOLEAN_ELEMENT +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster " " + SMSUtils.I18N_KEY + "=\"{0}\">{1}</" +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_TRUE_BOOLEAN_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String FALSE_BOOLEAN_KEY =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "<" + SMSUtils.ATTRIBUTE_FALSE_BOOLEAN_ELEMENT +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster " " + SMSUtils.I18N_KEY + "=\"{0}\">{1}</" +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSUtils.ATTRIBUTE_FALSE_BOOLEAN_ELEMENT + ">";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}