Beispiel #1
0
        public IDictionary <String, SchemaMetadataDiff> GetAllSchemaMetadataDiffs()
        {
            IDictionary <String, SchemaMetadataDiff> diffs
                = new Dictionary <String, SchemaMetadataDiff>();

            SchemaComparableList <SchemaEntry> baseAtEntries =
                baseEntryFetcher.GetAttributeSchemaEntries();
            SchemaComparableList <SchemaEntry> baseOcEntries =
                baseEntryFetcher.GetClassSchemaEntries();

            foreach (KeyValuePair <String, IEntryFetcher> p in entryFetchers)
            {
                String             serverName = p.Key;
                IEntryFetcher      fetcher    = p.Value;
                SchemaMetadataDiff diff       = null;
                if (fetcher != null)
                {
                    SchemaComparableList <SchemaEntry> otherAtEntries =
                        fetcher.GetAttributeSchemaEntries();
                    SchemaComparableList <SchemaEntry> otherOcEntries =
                        fetcher.GetClassSchemaEntries();

                    diff = new SchemaMetadataDiff(
                        baseAtEntries, baseOcEntries, otherAtEntries, otherOcEntries);
                }
                diffs.Add(serverName, diff);
            }
            return(diffs);
        }
Beispiel #2
0
        public TupleList <T, T> GetDiff(SchemaComparableList <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            TupleList <T, T> diff = new TupleList <T, T>();
            int i = 0, j = 0;

            while (i < this.Count || j < other.Count)
            {
                if (i == this.Count)
                {
                    diff.Add(default(T), other[j]);
                    j++;
                }
                else if (j == other.Count)
                {
                    diff.Add(this[i], default(T));
                    i++;
                }
                else
                {
                    int nameCmp = this[i].NameCompareTo(other[j]);
                    if (nameCmp < 0)
                    {
                        diff.Add(this[i], default(T));
                        i++;
                    }
                    else if (nameCmp > 0)
                    {
                        diff.Add(default(T), other[j]);
                        j++;
                    }
                    else
                    {
                        if (this[i].FullCompareTo(other[j]) != 0)
                        {
                            diff.Add(this[i], other[j]);
                        }
                        i++;
                        j++;
                    }
                }
            }

            return(diff);
        }
Beispiel #3
0
        public void ExportToXML(String filepath)
        {
            using (XmlTextWriter writer = new XmlTextWriter(filepath, null))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("Node");

                // host name
                writer.WriteElementString("HostName", baseServerName);

                // host status
                writer.WriteElementString("Status", "1");

                // dse root
                DseRootEntry dseRootEntry = baseEntryFetcher.GetDseRootEntry();
                writer.WriteStartElement("DseRootEntry");
                writer.WriteElementString("Domain", dseRootEntry.domain);
                writer.WriteElementString("ServerDn", dseRootEntry.serverDn);
                writer.WriteEndElement();

                // list of server nodes
                IList <ServerEntry> serverEntries = baseEntryFetcher.GetServerEntries();
                writer.WriteStartElement("ServerEntries");
                foreach (ServerEntry e in serverEntries)
                {
                    writer.WriteStartElement("ServerEntry");
                    writer.WriteElementString("DN", e.dn);
                    writer.WriteElementString("ServerName", e.serverName);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // subschema subentry
                SubSchemaSubEntry baseSubSchema = baseEntryFetcher.GetSubSchemaSubEntry();
                writer.WriteStartElement("SubSchemaSubEntry");
                writer.WriteStartElement("AttributeTypes");
                foreach (AttributeType at in baseSubSchema.GetAttributeTypeList())
                {
                    writer.WriteElementString("AttributeType", at.ToString());
                }
                writer.WriteEndElement();
                writer.WriteStartElement("ObjectClasses");
                foreach (ObjectClass oc in baseSubSchema.GetObjectClassList())
                {
                    writer.WriteElementString("ObjectClass", oc.ToString());
                }
                writer.WriteEndElement();
                writer.WriteEndElement();

                // list of attribute schema entries
                SchemaComparableList <SchemaEntry> baseAtEntries =
                    baseEntryFetcher.GetAttributeSchemaEntries();
                SchemaComparableList <SchemaEntry> baseOcEntries =
                    baseEntryFetcher.GetClassSchemaEntries();
                writer.WriteStartElement("SchemaEntries");
                writer.WriteStartElement("AttributeSchemaEntries");
                foreach (SchemaEntry ae in baseAtEntries)
                {
                    writer.WriteStartElement("AttributeSchemaEntry");
                    writer.WriteElementString("Name", ae.defName);
                    writer.WriteStartElement("AttributeMetadata");
                    foreach (AttributeMetadata m in ae.GetMetadataList())
                    {
                        writer.WriteElementString("Value", m.raw);
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // list of class schema entries
                writer.WriteStartElement("ClassSchemaEntries");
                foreach (SchemaEntry ce in baseOcEntries)
                {
                    writer.WriteStartElement("ClassSchemaEntry");
                    writer.WriteElementString("Name", ce.defName);
                    writer.WriteStartElement("AttributeMetadata");
                    foreach (AttributeMetadata m in ce.GetMetadataList())
                    {
                        writer.WriteElementString("Value", m.raw);
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();

                // end node
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }