SubConfigMeta.java revision 28de0461d82a4e6471c71d793af7a9492ca98dd3
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * The contents of this file are subject to the terms
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * of the Common Development and Distribution License
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * (the License). You may not use this file except in
5c65eaa08f2ec993a19c9bef6e5463918e40e0ebvboxsync * compliance with the License.
5c65eaa08f2ec993a19c9bef6e5463918e40e0ebvboxsync * You can obtain a copy of the License at
5c65eaa08f2ec993a19c9bef6e5463918e40e0ebvboxsync * https://opensso.dev.java.net/public/CDDLv1.0.html or
5c65eaa08f2ec993a19c9bef6e5463918e40e0ebvboxsync * See the License for the specific language governing
5c65eaa08f2ec993a19c9bef6e5463918e40e0ebvboxsync * permission and limitations under the License.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * When distributing Covered Code, include this CDDL
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Header Notice in each file and include the License file
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * If applicable, add the following below the CDDL Header,
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * with the fields enclosed by brackets [] replaced by
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * your own identifying information:
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * "Portions Copyrighted [year] [name of copyright owner]"
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * $Id: SubConfigMeta.java,v 1.2 2008/06/25 05:42:50 qcheng Exp $
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Portions Copyrighted 2015 ForgeRock AS.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsyncimport com.sun.identity.shared.datastruct.CollectionHelper;
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync/* - NEED NOT LOG - */
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync public static final String SUBCONFIG_ID_DELIMITER = "/";
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync public SubConfigMeta(String serviceName, AMModel model) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync private void resetMeta() {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns true if there are global sub schema.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @return true if there are global sub schema.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync public boolean hasGlobalSubSchema() {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns list of sub configuration objects.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @return list of sub configuration objects.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @see SMSubConfig
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns a map of sub schema name to its localized name. We should
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * be able to create sub configuration with these names.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @return Map of sub schema name to its localized name.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync Map map = new HashMap(creatableGlobalSubSchemas.size() *2);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync for (Iterator i = creatableGlobalSubSchemas.iterator(); i.hasNext(); ) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns sub service schema.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws SMSException if sub schema cannot be determined.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns sub service schema of current sub schema.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param name Name of sub schema.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws SMSException if sub schema cannot be determined.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns default values of sub service schema of current sub schema. Map
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * of attribute name (String) to attribute values (Set).
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param name Name of sub schema.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws SMSException if default values be determined.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync public Map getServiceSchemaDefaultValues(String name)
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync private void initialize() {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync ServiceConfigManager mgr = new ServiceConfigManager(
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync ServiceSchemaManager schemaMgr = new ServiceSchemaManager(
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync if ((rbName != null) && (rbName.trim().length() > 0)) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync serviceResourceBundle = AMResBundleCacher.getBundle(rbName,
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SSOException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getGlobalSchema" ,e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getGlobalSchema" ,e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync private boolean validInstance() {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync creatableGlobalSubSchemas.addAll(globalSubSchemaNames);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SSOException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getParentId", e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getParentId", e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Get the parent configuration's display name. It will check if the service configuration
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * has an internationalization key and if it does, the localised name will be returned.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Otherwise the config name itself will be returned.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @return The parent configuration's display name.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String i18nKey = CollectionHelper.getMapAttr(parentConfig.getAttributes(), SMSUtils.I18N_KEY);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync return StringUtils.isEmpty(i18nKey) ? parentConfig.getName() : getLocalizedString(i18nKey);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync globalSubSchemaNames = corrSchema.getSubSchemaNames();
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync for (Iterator i =globalSubSchemaNames.iterator(); i.hasNext();){
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync if ((i18nKey == null) || (i18nKey.trim().length() == 0)) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync mapServiceSchemaNameToL10NName.put(name, getLocalizedString(i18nKey));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getSupportedGlobalSubSchema" ,e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync return StringUtils.isEmpty(key) ? null : Locale.getString(serviceResourceBundle, key, AMModelBase.debug);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync private void getCorrespondingSchema(String parentId)
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * discard the first one because it is always /
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync configId = AMAdminUtils.replaceString(configId, "%2F", "/");
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync configId = AMAdminUtils.replaceString(configId, "%25", "%");
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync parentConfig = parentConfig.getSubConfig(configId);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync corrSchema = corrSchema.getSubSchema(parentConfig.getSchemaID());
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] params = {serviceName, parentConfig.getComponentName()};
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync amModel.logEvent("ATTEMPT_READ_GLOBAL_SUB_CONFIGURATION_NAMES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync for (Iterator iter = names.iterator(); iter.hasNext(); ) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync ServiceConfig conf = parentConfig.getSubConfig(name);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync CollectionHelper.getMapAttr(conf.getAttributes(), SMSUtils.I18N_KEY));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync set.add(new SMSubConfig(conf.getComponentName(), name, displayType, localizedName));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync if (singleInstanceGlobalSubSchemas.contains(schemaID)) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync globalSubConfigurations = new ArrayList(set.size());
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync amModel.logEvent("SUCCEED_READ_GLOBAL_SUB_CONFIGURATION_NAMES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SSOException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SSO_EXCEPTION_READ_GLOBAL_SUB_CONFIGURATION_NAMES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getSubConfigurations", e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SMS_EXCEPTION_READ_GLOBAL_SUB_CONFIGURATION_NAMES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AMModelBase.debug.error("SubConfigMeta.getSubConfigurations", e);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Deletes sub configurations.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param names Set of sub configuration names that are to be deleted.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws AMConsoleException if sub configurations cannot be deleted.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync for (Iterator iter = names.iterator(); iter.hasNext(); ) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "ATTEMPT_DELETE_GLOBAL_SUB_CONFIGURATION", params);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SUCCEED_DELETE_GLOBAL_SUB_CONFIGURATION", params);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SSOException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync amModel.logEvent("SSO_EXCEPTION_DELETE_GLOBAL_SUB_CONFIGURATION",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync throw new AMConsoleException(amModel.getErrorString(e));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync amModel.logEvent("SMS_EXCEPTION_DELETE_GLOBAL_SUB_CONFIGURATION",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync throw new AMConsoleException(amModel.getErrorString(e));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync private void removeFromSubConfigList(String name) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync boolean removed = false;
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync for (Iterator i = globalSubConfigurations.iterator();
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Creates a new sub configuration.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param name Name of sub configuration.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param schemaName Name of schema name.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param values Map of attribute name to its values.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws AMConsoleException if sub configuration cannot be created.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync public void createSubConfig(String name, String schemaName, Map values)
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] params = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "ATTEMPT_CREATE_GLOBAL_SUB_CONFIGURATION", params);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync parentConfig.addSubConfig(name, schemaName, 0, values);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SUCCEED_CREATE_GLOBAL_SUB_CONFIGURATION", params);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SSOException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync amModel.logEvent("SSO_EXCEPTION_CREATE_GLOBAL_SUB_CONFIGURATION",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync throw new AMConsoleException(amModel.getErrorString(e));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync amModel.logEvent("SMS_EXCEPTION_CREATE_GLOBAL_SUB_CONFIGURATION",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync throw new AMConsoleException(amModel.getErrorString(e));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Returns attribute values.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @return attribute values.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws AMConsoleException if attribute values cannot be determined.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] params = {serviceName, parentConfig.getComponentName()};
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SUCCEED_READ_GLOBAL_SUB_CONFIGURATION_ATTRIBUTE_VALUES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Set attribute values.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param values Attribute values.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @throws AMConsoleException if attribute values cannot be set.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync public void setSubConfigAttributeValues(Map values)
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] params = {serviceName, parentConfig.getComponentName()};
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "ATTEMPT_WRITE_GLOBAL_SUB_CONFIGURATION_ATTRIBUTE_VALUES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SUCCEED_WRITE_GLOBAL_SUB_CONFIGURATION_ATTRIBUTE_VALUES",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SSOException e) {
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SSO_EXCEPTION_WRITE_GLOBAL_SUB_CONFIGURATION_ATTRIBUTE_VALU",
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync throw new AMConsoleException(amModel.getErrorString(e));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync } catch (SMSException e) {
b8908d384db2324f04a2f68a13e67ea32ebf609avboxsync String[] paramsEx = {serviceName, parentConfig.getComponentName(),
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync "SMS_EXCEPTION_WRITE_GLOBAL_SUB_CONFIGURATION_ATTRIBUTE_VALU",