001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// 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 others 008// All Rights Reserved. 009*/ 010package mondrian.rolap; 011 012import mondrian.olap.Util; 013import mondrian.util.*; 014 015/** 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 from 020 * 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 SchemaKey 024 * 025 * @author jhyde 026 */ 027class SchemaContentKey extends StringKey { 028 private SchemaContentKey(String s) { 029 super(s); 030 } 031 032 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(); 041 042 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} 054 055// End SchemaContentKey.java