Ejemplo n.º 1
0
 /// <summary>
 /// Adds another ObjectClassInfo to the schema.
 /// </summary>
 /// <remarks>
 /// Also, adds this
 /// to the set of supported classes for every operation defined by
 /// the Connector.
 /// </remarks>
 /// <param name="info"></param>
 /// <exception cref="IllegalStateException">If already defined</exception>
 public void DefineObjectClass(ObjectClassInfo info)
 {
     Assertions.NullCheck(info, "info");
     if (_declaredObjectClasses.Contains(info))
     {
         throw new InvalidOperationException("ObjectClass already defined: " +
                 info.ObjectType);
     }
     _declaredObjectClasses.Add(info);
     foreach (SafeType<APIOperation> op in
         FrameworkUtil.GetDefaultSupportedOperations(_connectorClass))
     {
         ICollection<ObjectClassInfo> oclasses =
             CollectionUtil.GetValue(_supportedObjectClassesByOperation, op, null);
         if (oclasses == null)
         {
             oclasses = new HashSet<ObjectClassInfo>();
             _supportedObjectClassesByOperation[op] = oclasses;
         }
         oclasses.Add(info);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes the given ObjectClassInfo as a supported ObjectClass for
 /// the given operation.
 /// </summary>
 /// <param name="op">The SPI operation</param>
 /// <param name="def">The ObjectClassInfo</param>
 /// <exception cref="ArgumentException">If the given ObjectClassInfo was
 /// not already defined using <see cref="DefineObjectClass(ObjectClassInfo)" />.</exception>
 public void RemoveSupportedObjectClass(SafeType<SPIOperation> op,
     ObjectClassInfo def)
 {
     Assertions.NullCheck(op, "op");
     Assertions.NullCheck(def, "def");
     ICollection<SafeType<APIOperation>> apis =
         FrameworkUtil.Spi2Apis(op);
     if (!_declaredObjectClasses.Contains(def))
     {
         throw new ArgumentException("ObjectClass " + def.ObjectType +
                 " not defined in schema.");
     }
     foreach (SafeType<APIOperation> api in apis)
     {
         ICollection<ObjectClassInfo> infos =
             CollectionUtil.GetValue(_supportedObjectClassesByOperation, api, null);
         if (infos == null)
         {
             throw new ArgumentException("Operation " + op +
                     " not implement by connector.");
         }
         if (!infos.Contains(def))
         {
             throw new ArgumentException("ObjectClass " + def.ObjectType
                     + " already removed for operation " + op);
         }
         infos.Remove(def);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds another ObjectClassInfo to the schema.
 /// 
 /// Also, adds this to the set of supported classes for every operation
 /// defined by the Connector.
 /// </summary>
 /// <param name="info"> </param>
 /// <param name="operations">
 ///            The SPI operation which use supports this
 ///            <c>objectClassInfo</c>
 /// </param>
 /// <exception cref="InvalidOperationException">
 ///             If already defined </exception>
 public void DefineObjectClass(ObjectClassInfo info, params SafeType<SPIOperation>[] operations)
 {
     if (operations.Length > 0)
     {
         Assertions.NullCheck(info, "objectClassInfo");
         if (_declaredObjectClasses.Contains(info))
         {
             throw new InvalidOperationException("ObjectClass already defined: " + info.ObjectType);
         }
         _declaredObjectClasses.Add(info);
         foreach (SafeType<SPIOperation> spi in operations)
         {
             if (typeof(SchemaOp) == spi.RawType ||
                 typeof(ScriptOnConnectorOp) == spi.RawType ||
                 typeof(ScriptOnResourceOp) == spi.RawType ||
                 typeof(TestOp) == spi.RawType)
             {
                 continue;
             }
             IEnumerable<SafeType<APIOperation>> apiOperations = FrameworkUtil.Spi2Apis(spi).Intersect(_defaultSupportedOperations);
             foreach (SafeType<APIOperation> op in apiOperations)
             {
                 if (ObjectClassOperation(op))
                 {
                     ICollection<ObjectClassInfo> oclasses =
                         CollectionUtil.GetValue(_supportedObjectClassesByOperation, op, null);
                     if (oclasses == null)
                     {
                         oclasses = new HashSet<ObjectClassInfo>();
                         _supportedObjectClassesByOperation[op] = oclasses;
                     }
                     oclasses.Add(info);
                 }
             }
         }
     }
     else
     {
         DefineObjectClass(info);
     }
 }