private void processMetadata( MetadataList metadata, Dictionary<string, string> headers ) { StringBuilder listable = new StringBuilder(); StringBuilder nonListable = new StringBuilder(); log.TraceEvent(TraceEventType.Verbose, 0, "Processing " + metadata.Count() + " metadata entries" ); foreach( Metadata meta in metadata ) { if( meta.Listable ) { if( listable.Length > 0 ) { listable.Append( ", " ); } listable.Append( formatTag( meta ) ); } else { if( nonListable.Length > 0 ) { nonListable.Append( ", " ); } nonListable.Append( formatTag( meta ) ); } } // Only set the headers if there's data if( listable.Length > 0 ) { headers.Add( "x-emc-listable-meta", listable.ToString() ); } if( nonListable.Length > 0 ) { headers.Add( "x-emc-meta", nonListable.ToString() ); } if (utf8Enabled && !headers.ContainsKey("x-emc-utf8")) { headers.Add("x-emc-utf8", "true"); } }
public void testUtf8MetadataFilter() { String oneByteCharacters = "Hello! "; String twoByteCharacters = "\u0410\u0411\u0412\u0413"; // Cyrillic letters String fourByteCharacters = "\ud841\udf0e\ud841\udf31\ud841\udf79\ud843\udc53"; // Chinese symbols String utf8String = oneByteCharacters + twoByteCharacters + fourByteCharacters; MetadataList metaList = new MetadataList(); metaList.AddMetadata( new Metadata( "utf8Key", utf8String, false ) ); metaList.AddMetadata( new Metadata( utf8String, "utf8Value", false ) ); ObjectId id = this.esu.CreateObject( null, metaList, null, null ); cleanup.Add( id ); // apply a filter that includes the UTF8 tag MetadataTags tags = new MetadataTags(); tags.AddTag( new MetadataTag( utf8String, false ) ); metaList = this.esu.GetUserMetadata( id, tags ); Assert.AreEqual( metaList.Count(), 1, "UTF8 filter was not honored" ); Assert.IsNotNull( metaList.GetMetadata( utf8String ), "UTF8 key was not found in filtered results" ); }