001/*002// This software is subject to the terms of the Eclipse Public License v1.0003// Agreement, available at the following URL:004// http://www.eclipse.org/legal/epl-v10.html.005// You must accept the terms of that agreement to use this software.006//007// Copyright (C) 2012-2012 Pentaho and others008// All Rights Reserved.009*/010package mondrian.rolap;011012import mondrian.olap.Util;013import mondrian.util.*;014015/**016 * Globally unique identifier for the metadata content of a schema.017 *018 * <p>Two schemas have the same content if they have same schema XML.019 * But schemas are also deemed to have the same content if they are read from020 * the same URL (subject to rules about how often the contents of a URL change)021 * or if their content has the same MD5 hash.</p>022 *023 * @see SchemaKey024 *025 * @author jhyde026 */027class SchemaContentKey extends StringKey {028 private SchemaContentKey(String s) {029 super(s);030 }031032 static SchemaContentKey create(033 final Util.PropertyList connectInfo,034 final String catalogUrl,035 final String catalogContents)036 {037 final String catalogContentProp =038 RolapConnectionProperties.CatalogContent.name();039 final String dynamicSchemaProp =040 RolapConnectionProperties.DynamicSchemaProcessor.name();041042 StringBuilder buf = new StringBuilder();043 if (!Util.isEmpty(connectInfo.get(catalogContentProp))044 || !Util.isEmpty(connectInfo.get(dynamicSchemaProp)))045 {046 ConnectionKey.attributeValue(buf, "catalogStr", catalogContents);047 } else {048 ConnectionKey.attributeValue(buf, "catalog", catalogUrl);049 }050 return new SchemaContentKey(051 new ByteString(Util.digestMd5(buf.toString())).toString());052 }053}054055// End SchemaContentKey.java