Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[higgins-dev] fix for IdAS "blind deletions" defect

For https://bugs.eclipse.org/bugs/show_bug.cgi?id=193226, I followed the final proposal as can be seen in the attached patch file.

Note that I also ended up adding a few overloaded .equals methods here and there in order to accomplish this.

If you're lucky enough to be using the org.eclipse.higgins.idas.spi package to help implement your CP, it's likely that there's no work for you to do.  Otherwise, your CP will not build until you implement the new functionality.

I plan to test these changes and check them in tomorrow unless I hear otherwise.

Jim

### Eclipse Workspace Patch 1.0
#P org.eclipse.higgins.idas.api
Index: src/org/eclipse/higgins/idas/api/IHasMetadata.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.api/src/org/eclipse/higgins/idas/api/IHasMetadata.java,v
retrieving revision 1.1
diff -u -r1.1 IHasMetadata.java
--- src/org/eclipse/higgins/idas/api/IHasMetadata.java	23 May 2007 22:23:32 -0000	1.1
+++ src/org/eclipse/higgins/idas/api/IHasMetadata.java	11 Sep 2007 21:04:20 -0000
@@ -47,7 +47,7 @@
 	 * @throws {@link IdASException}
 	 * @throws {@link InvalidTypeException} when the metadataID is invalid
 	 */
-	IMetadata addMetadata(URI metadataID) throws IdASException, InvalidTypeException;
+	public IMetadata addMetadata(URI metadataID) throws IdASException, InvalidTypeException;
 
 	/**
 	 * Creates a new Metadata element for this container of metadata 
@@ -58,5 +58,15 @@
 	 * Metadata element.
 	 * @throws {@link IdASException}
 	 */
-	IMetadata addMetadata(IMetadata copyFrom) throws IdASException;
+	public IMetadata addMetadata(IMetadata copyFrom) throws IdASException;
+	
+	/**
+	 * Returns true if the passed metadata set is equal to this one.
+	 * The sets are compared for size, and then each metadata 
+	 * item in the set is compared for equality
+	 * @param metadataSet the set of metadata to compare to this one
+	 * @return true if the sets are equal, false otherwise.
+	 * @throws IdASException
+	 */
+	public boolean equals (IHasMetadata metadataSet) throws IdASException;
 }
Index: src/org/eclipse/higgins/idas/api/IAttribute.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.api/src/org/eclipse/higgins/idas/api/IAttribute.java,v
retrieving revision 1.2
diff -u -r1.2 IAttribute.java
--- src/org/eclipse/higgins/idas/api/IAttribute.java	11 Jun 2007 20:54:49 -0000	1.2
+++ src/org/eclipse/higgins/idas/api/IAttribute.java	11 Sep 2007 21:04:20 -0000
@@ -122,4 +122,14 @@
 	 * @return boolean. When true, this object may be cast to an {@link ISingleValuedAttribute} 
 	 */
 	public boolean isSingleValued() throws IdASException;
+	
+	/**
+	 * Returns true if the passed attribute is equal to this one.
+	 * The Attribute id's are compared, the metadata sets are compared,
+	 * and all values are compared for equality
+	 * @param attr the attribute to be compared to this one
+	 * @return true if the passed attr is equal to this attr.
+	 * @throws IdASException
+	 */
+	public boolean equals(IAttribute attr) throws IdASException;
 }
Index: src/org/eclipse/higgins/idas/api/IHasAttributes.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.api/src/org/eclipse/higgins/idas/api/IHasAttributes.java,v
retrieving revision 1.2
diff -u -r1.2 IHasAttributes.java
--- src/org/eclipse/higgins/idas/api/IHasAttributes.java	14 Jun 2007 23:25:56 -0000	1.2
+++ src/org/eclipse/higgins/idas/api/IHasAttributes.java	11 Sep 2007 21:04:20 -0000
@@ -59,7 +59,7 @@
 	 * @throws {@link IdASException}
 	 * @throws {@link InvalidTypeException} when the type is invalid
 	 */
-	IAttribute addAttribute(URI attrID) throws IdASException, InvalidTypeException;	
+	public IAttribute addAttribute(URI attrID) throws IdASException, InvalidTypeException;	
 	
 	/**
 	 * Creates a new Attribute for this container of 
@@ -71,5 +71,52 @@
 	 * Attribute
 	 * @throws {@link IdASException}
 	 */
-	IAttribute addAttribute(IAttribute copyFrom) throws IdASException;	
+	public IAttribute addAttribute(IAttribute copyFrom) throws IdASException;
+	
+	/**
+	 * Deletes the specified attrID. 
+	 * On one hand, this is a convenience method (in that the caller can
+	 * call this rather than fetching the attribute using 
+	 * {@link #getAttribute(URI)} and then calling remove on the returned IAttribute. 
+	 * More importantly however is that this method allows
+	 * an attribute to be removed when the caller has permissions 
+	 * to remove, but no permissions to read that attribute.
+	 * @param attrID identifies the attribute to be removed
+	 */
+	public void removeAttribute (URI attrID) throws IdASException;
+
+	/**
+	 * Deletes the specified value from the specified attrID. 
+	 * On one hand, this is a convenience method (in that the caller can
+	 * call this rather than fetching the attribute using 
+	 * {@link #getAttribute(URI)}, then fetching the 
+	 * appropriate value from the returned IAttribute, 
+	 * and then calling remove on that value.
+	 * More importantly however is that this method allows
+	 * an attribute value to be removed when the caller has 
+	 * permissions to remove values, but no permissions to 
+	 * read that attribute or its values.
+	 * @param attrID identifies the attribute to be removed
+	 * @param value identifies the attribute value to be removed
+	 */
+	public void removeAttributeValue (URI attrID, Object value) throws IdASException;
+
+	/**
+	 * Deletes the specified value(s) from the specified attribute.
+	 * This is simply a convenience method which is equal to calling 
+	 * {@link #removeAttributeValue(URI, Object)} once for each value in attr.
+	 * @param attr Holds one or more values to be deleted from the 
+	 * attribute (named in attr)
+	 */
+	public void removeAttributeValue (IAttribute attr) throws IdASException;
+
+	/**
+	 * Returns true if the passed attribute set is equal to this one.
+	 * The sets are compared for size, and then each attribute 
+	 * in the set is compared for equality
+	 * @param attributes the set of attributes to compare to this one
+	 * @return true if the sets are equal, false otherwise.
+	 * @throws IdASException
+	 */
+	public boolean equals (IHasAttributes attributes) throws IdASException;
 }
Index: src/org/eclipse/higgins/idas/api/IAttributeValue.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.api/src/org/eclipse/higgins/idas/api/IAttributeValue.java,v
retrieving revision 1.1
diff -u -r1.1 IAttributeValue.java
--- src/org/eclipse/higgins/idas/api/IAttributeValue.java	23 May 2007 22:23:32 -0000	1.1
+++ src/org/eclipse/higgins/idas/api/IAttributeValue.java	11 Sep 2007 21:04:20 -0000
@@ -44,5 +44,11 @@
 	 * IContext.applyUpdates() is called.
 	 * @throws {@link IdASException}
 	 */
-	void remove() throws IdASException;
+	public void remove() throws IdASException;
+	
+	/**
+	 * returns true if this IAttributeValue is equal to the passed IAttributeValue
+	 * This should test the attribute ID, metadata, and the value for equality.
+	 */
+	public boolean equals(IAttributeValue value) throws IdASException;
 }
#P org.eclipse.higgins.idas.common
Index: src/org/eclipse/higgins/idas/common/AuthNNamePasswordMaterials.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.common/src/org/eclipse/higgins/idas/common/AuthNNamePasswordMaterials.java,v
retrieving revision 1.3
diff -u -r1.3 AuthNNamePasswordMaterials.java
--- src/org/eclipse/higgins/idas/common/AuthNNamePasswordMaterials.java	31 Aug 2007 00:30:49 -0000	1.3
+++ src/org/eclipse/higgins/idas/common/AuthNNamePasswordMaterials.java	11 Sep 2007 21:04:21 -0000
@@ -16,6 +16,7 @@
 import org.eclipse.higgins.idas.api.IAttribute;
 import org.eclipse.higgins.idas.api.IAuthNAttributesMaterials;
 import org.eclipse.higgins.idas.api.IContext;
+import org.eclipse.higgins.idas.api.IHasAttributes;
 import org.eclipse.higgins.idas.api.ISimpleAttrValue;
 import org.eclipse.higgins.idas.api.ISingleValuedAttribute;
 import org.eclipse.higgins.idas.api.ITypedValue;
@@ -154,6 +155,22 @@
 		return _impl.getSingleValuedAttribute(attrID);
 	}
 
+	public void removeAttribute(URI attrID)  throws IdASException{
+		_impl.removeAttribute(attrID);
+	}
+
+	public void removeAttributeValue(URI attrID, Object value)  throws IdASException{
+		_impl.removeAttributeValue(attrID, value);
+	}
+
+	public void removeAttributeValue(IAttribute attr)  throws IdASException{
+		_impl.removeAttributeValue(attr);
+	}
+
+	public boolean equals(IHasAttributes attributes) throws IdASException {
+		return _impl.equals(attributes);
+	}
+
 	public IAttribute getManagedAttr() {
 		return _managedAttr;
 	}
@@ -161,4 +178,5 @@
 	public URI getManagedAttrURI() {
 		return ATTR_MANAGED_URI;
 	}
+
 }
Index: src/org/eclipse/higgins/idas/common/AuthNSelfIssuedMaterials.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.common/src/org/eclipse/higgins/idas/common/AuthNSelfIssuedMaterials.java,v
retrieving revision 1.3
diff -u -r1.3 AuthNSelfIssuedMaterials.java
--- src/org/eclipse/higgins/idas/common/AuthNSelfIssuedMaterials.java	31 Aug 2007 00:30:49 -0000	1.3
+++ src/org/eclipse/higgins/idas/common/AuthNSelfIssuedMaterials.java	11 Sep 2007 21:04:21 -0000
@@ -18,6 +18,7 @@
 import org.eclipse.higgins.idas.api.IComplexAttrValue;
 import org.eclipse.higgins.idas.api.IContext;
 import org.eclipse.higgins.idas.api.IAttribute;
+import org.eclipse.higgins.idas.api.IHasAttributes;
 import org.eclipse.higgins.idas.api.ISimpleAttrValue;
 import org.eclipse.higgins.idas.api.ISingleValuedAttribute;
 import org.eclipse.higgins.idas.api.ITypedValue;
@@ -190,6 +191,22 @@
 		return _impl.getSingleValuedAttribute(attrID);
 	}
 
+	public void removeAttribute(URI attrID) throws IdASException{
+		_impl.removeAttribute(attrID);
+	}
+
+	public void removeAttributeValue(URI attrID, Object value) throws IdASException{
+		_impl.removeAttributeValue(attrID, value);
+	}
+
+	public void removeAttributeValue(IAttribute attr) throws IdASException {
+		_impl.removeAttributeValue(attr);
+	}
+
+	public boolean equals(IHasAttributes attributes) throws IdASException {
+		return _impl.equals(attributes);
+	}
+
 	public IAttribute getManagedAttr() {
 		return _managedAttr;
 	}
#P org.eclipse.higgins.idas.spi
Index: src/org/eclipse/higgins/idas/spi/BasicAttribute.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/BasicAttribute.java,v
retrieving revision 1.3
diff -u -r1.3 BasicAttribute.java
--- src/org/eclipse/higgins/idas/spi/BasicAttribute.java	22 Jun 2007 22:33:00 -0000	1.3
+++ src/org/eclipse/higgins/idas/spi/BasicAttribute.java	11 Sep 2007 21:04:21 -0000
@@ -48,16 +48,50 @@
 	}
 
 	/**
+	 * @param attrID the URI of the attribute's type
+	 * @param value an IAttributeValue (either simple or complex) to store with the attribute
+	 * @param container for purposes of notification of updates, the container of this attribute.  
+	 * May be null when there is no containing object
 	 * @throws IdASException 
 	 * 
 	 */
-	public BasicAttribute(URI type, IAttributeValue value, IAttributeContainer container) throws IdASException {
+	public BasicAttribute(URI attrID, IAttributeValue value, IAttributeContainer container) throws IdASException {
 		if (value != null) {
 			Vector v = new Vector(1);
 			v.add(value);
-			_init(type, v.iterator(), null, container);
+			_init(attrID, v.iterator(), null, container);
 		} else {
-			_init(type, null, null, container);
+			_init(attrID, null, null, container);
+		}
+	}
+
+	/**
+	 * @param attrID the URI of the attribute's type
+	 * @param data an Object to be used as a value for attribute. 
+	 * The Object is the data from which an {@link ISimpleAttrValue} 
+	 * will be created. We do this by looking at the model for the attribute (sepcified in attrID)
+	 * and associating that with the type of data object that is expected.
+	 * If the value passed is of the wrong type, the constructor will fail.
+	 * Note that this assumes the data will be used to construct a simple 
+	 * value, not a complex value.  If one wishes to construct a BasicAttribute with a 
+	 * complex value, then {@link #BasicAttribute(URI, IAttributeValue, IAttributeContainer)} is called.  
+	 * @param container for purposes of notification of updates, the container of this attribute.  
+	 * May be null when there is no containing object
+	 * @throws IdASException 
+	 * 
+	 */
+	public BasicAttribute(URI attrID, Object data, IAttributeContainer container) throws IdASException {
+		// Turn the value into an IAttribute 
+		IAttributeValueModel valueModel = this.getModel().getValueModel();
+		URI valueType = valueModel.getType();
+		ISimpleAttrValue value = BasicContext.createSimpleValue(valueType, data, this);
+		
+		if (value != null) {
+			Vector v = new Vector(1);
+			v.add(value);
+			_init(attrID, v.iterator(), null, container);
+		} else {
+			_init(attrID, null, null, container);
 		}
 	}
 
@@ -65,23 +99,23 @@
 	 * Note that the container's updateNotification is not called while 
 	 * the IValues in values are being added.
 	 * 
-	 * @param type
+	 * @param attrID
 	 * @param values Contains {@link IAttributeValue}s
 	 * @throws IdASException 
 	 */
-	public BasicAttribute(URI type, Iterator values, IAttributeContainer container) throws IdASException {
-		_init(type, values, null, container);
+	public BasicAttribute(URI attrID, Iterator values, IAttributeContainer container) throws IdASException {
+		_init(attrID, values, null, container);
 	}
 	
 	/**
 	 * Note that the container's updateNotification is not called while 
 	 * the passed values and metaSet are being added.
-	 * @param type
+	 * @param attrID
 	 * @param values Contains {@link IAttributeValue}s
 	 * @throws IdASException 
 	 */
-	private void _init(URI type, Iterator values, Iterator metaSet, IAttributeContainer container) throws IdASException {
-		_attrID = type;
+	private void _init(URI attrID, Iterator values, Iterator metaSet, IAttributeContainer container) throws IdASException {
+		_attrID = attrID;
 		_container = container;
 		_values = new Vector();
 		if (values != null) {
@@ -92,6 +126,27 @@
 		_metaSetImpl = new BasicMetadataSet(metaSet, this);
 	}
 
+	private void _addValue(IAttributeValue val) throws IdASException {
+		_values.add(val);
+		_log.debug("Sending value add notification - " + val.getType().toString());
+		AttributeValueNotification valueNotif = new AttributeValueNotification(val, AttributeValueNotification.UPDATE_ADD, null);
+		this.updateNotification(valueNotif);
+	}
+	
+	private boolean _containsValue (IAttributeValue value) throws IdASException {
+		Iterator iter = this.getValues();
+		IAttributeValue localVal;
+		boolean bRet = false;
+		while (iter.hasNext()) {
+			localVal = (IAttributeValue)iter.next();
+			if (localVal.equals(value)) {
+				bRet = true;
+				break;
+			}
+		}
+		return bRet;
+	}
+
 	public URI getAttrID() throws IdASException {
 		return _attrID;
 	}
@@ -109,15 +164,6 @@
 		throw new NotImplementedException("No associated context to obtain model");
 	}
 
-	private void _addValue(
-		IAttributeValue val) throws IdASException
-	{
-		_values.add(val);
-		_log.debug("Sending value add notification - " + val.getType().toString());
-		AttributeValueNotification valueNotif = new AttributeValueNotification(val, AttributeValueNotification.UPDATE_ADD, null);
-		this.updateNotification(valueNotif);
-	}
-
 	public IComplexAttrValue addComplexValue(URI type) throws IdASException, InvalidTypeException {
 		IComplexAttrValue val = new BasicComplexValue(type, null, this);
 		_addValue(val);
@@ -185,6 +231,10 @@
 		return _metaSetImpl.addMetadata(copyFrom);
 	}
 
+	public boolean equals(IHasMetadata metadataSet) throws IdASException {
+		return _metaSetImpl.equals(metadataSet);
+	}
+	
 	public void updateNotification(AttributeValueNotification attrValueNotif) throws IdASException {
 		_log.debug("Received attribute value notification - " + attrValueNotif.getAction() + ", " + attrValueNotif.getAttributeValue().toString());
 		_log.debug("_containter " + ((_container != null) ? _container.toString() : "null"));
@@ -212,4 +262,22 @@
 	public IAttributeContainer getContainer() {
 		return _container;
 	}
+
+	public boolean equals(IAttribute attr) throws IdASException {
+		boolean bRet;
+		if (attr.getAttrID() != this.getAttrID())
+			bRet = false;
+		else if ((bRet = this.equals((IHasMetadata)attr)) == true) {
+			Iterator iter = attr.getValues();
+			// Compare each passed value
+			while (iter.hasNext()) {
+				if (this._containsValue((IAttributeValue)iter.next()) == false) {
+					bRet = false;
+					break;
+				}					
+			}
+		}
+		return bRet;
+	}
+
 }
Index: src/org/eclipse/higgins/idas/spi/BasicAttributeSet.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/BasicAttributeSet.java,v
retrieving revision 1.3
diff -u -r1.3 BasicAttributeSet.java
--- src/org/eclipse/higgins/idas/spi/BasicAttributeSet.java	22 Jun 2007 22:33:00 -0000	1.3
+++ src/org/eclipse/higgins/idas/spi/BasicAttributeSet.java	11 Sep 2007 21:04:21 -0000
@@ -14,9 +14,11 @@
 import java.net.URI;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Vector;
 
 import org.apache.log4j.Logger;
 import org.eclipse.higgins.idas.api.IAttribute;
+import org.eclipse.higgins.idas.api.IAttributeValue;
 import org.eclipse.higgins.idas.api.IHasAttributes;
 import org.eclipse.higgins.idas.api.ISingleValuedAttribute;
 import org.eclipse.higgins.idas.api.IdASException;
@@ -79,6 +81,93 @@
 		return attr;
 	}
 
+	public void removeAttribute(URI attrID) throws IdASException {
+		/* By creating a BasicAttribute and setting its container to this
+		 * we can call remove on it and it will send us back the remove notification.
+		 * In our remove notification, we will attempt to remove the actual attribute
+		 * from our _attrs. If the attrID happens to point to an actual attr,
+		 * it will be removed. Otherwise it will silently fail to remove the attr
+		 * (which never existed in this set).  In either case, we get the notification
+		 * which should be used by the underlying CP to do whatever it needs.
+		 * 
+		 * Note that 'new'ing up the BasicAttribute does *not* add the attr
+		 * to our set.
+		 */
+		IAttribute attr = new BasicAttribute(attrID, (Iterator)null, this);
+		attr.remove();
+	}
+
+	public void removeAttributeValue(IAttribute attr) throws IdASException {
+		BasicAttribute basicAttr;
+		// First, let's see if this attribute exists in our set
+		IAttribute localAttr = this.getAttribute(attr.getAttrID());
+		if (localAttr != null) {
+			/* We have this attr, so now we need to remove the values 
+			 * (whether they exist or not)
+			 */
+			IAttributeValue passedVal, localVal;
+			Iterator passedVals = attr.getValues();
+			/* for each passed value, see if we have it.  If so,
+			 * remove it locally, otherwise notify of its removal
+			 * To notify, we'll store all the non-existant values
+			 * into a vector of IAttributeValue and notify as if the
+			 * attribute hadn't existed at all
+			 */
+			Vector nonExistantVals = new Vector();
+			while (passedVals.hasNext()) {
+				passedVal = (IAttributeValue)passedVals.next();
+				Iterator localVals = localAttr.getValues();
+				boolean bFoundLocalVal = false;
+				while (localVals.hasNext()) {
+					localVal = (IAttributeValue)localVals.next();
+					if (localVal.equals(passedVal)) {
+						localVal.remove();
+						bFoundLocalVal = true;
+						break;
+					}
+				}
+				if (bFoundLocalVal == false) {
+					// this passed value didn't exist, store for notification.
+					nonExistantVals.add(passedVal);
+				}
+			}
+			if (nonExistantVals.isEmpty() == false) {
+				// set up basicAttr to contain only those values which we did not find
+				basicAttr = new BasicAttribute(attr.getAttrID(), nonExistantVals.iterator(), null);
+			} else {
+				// we got them all, nothing left to do
+				return;
+			}			
+		} else {
+			// set up basicAttr to contain the passed attr
+			basicAttr = new BasicAttribute(attr, null);
+		}
+
+		/* We need to do this only after creating the basic attribute and
+		 * populating it with the values. Otherwise, the values will be seen
+		 * as additions and those additions will be sent as notifications back
+		 * to us. 
+		 */
+		basicAttr.setContainer(this);
+		
+		/* Now that we have the values to be deleted in a basic attribute 
+		 * and it thinks this is it's container, we can remove the values. 
+		 * This will cause remove notifications to be sent back to us.
+		 */
+		Iterator iter = basicAttr.getValues();
+		IAttributeValue val;
+		while (iter.hasNext()) {
+			val = (IAttributeValue)iter.next();
+			val.remove();
+		}
+	}
+
+	public void removeAttributeValue(URI attrID, Object value) throws IdASException {
+		IAttribute attr = new BasicAttribute(attrID, (Iterator)null, null);
+		this.removeAttributeValue(attr);		
+	}
+
+
 	public BasicAttribute addUnnotifiedAttribute(URI attrID) throws IdASException, InvalidTypeException {
 		BasicAttribute attr = new BasicAttribute(attrID, (Iterator) null, null);
 		insertAttribute(attr);
@@ -102,9 +191,9 @@
 		_attrs.put(attr.getAttrID(), attr);
 	}
 
-	private void removeAttribute(IAttribute attr) throws IdASException {
-		_log.debug("Removing attribute - " + attr.getAttrID());
-		_attrs.remove(attr.getAttrID());
+	private void _removeAttribute(URI attrID) throws IdASException {
+		_log.debug("Removing attribute - " + attrID);
+		_attrs.remove(attrID);
 	}
 
 	public void updateNotification(AttributeNotification attrNotif) throws IdASException {
@@ -112,7 +201,7 @@
 		if (attrNotif.getAction().equals(AttributeNotification.UPDATE_ADD)) {
 			insertAttribute(attrNotif.getAttr());
 		} else if (attrNotif.getAction().equals(AttributeNotification.UPDATE_REMOVE)) {
-			removeAttribute(attrNotif.getAttr());
+			_removeAttribute(attrNotif.getAttr().getAttrID());
 		}
 
 		/* Other actions are simply passed to the next container if it's different from
@@ -123,4 +212,34 @@
 			_attrContainer.updateNotification(attrNotif);
 		}
 	}
+
+	public boolean equals(IHasAttributes attributes) throws IdASException {
+		int localCount = 0, attrCount = 0;
+		Iterator iter = attributes.getAttributes();
+		while (iter.hasNext()) {
+			IAttribute attr = (IAttribute)iter.next();
+			if (this._contains(attr) == false) {
+				return false;
+			}
+			attrCount++;
+		}
+		
+		// everything we were given was found, make sure the sizes match
+		iter = this.getAttributes();
+		while (iter.hasNext()) {
+			iter.next();
+			localCount++;
+		}
+		return localCount == attrCount;
+	}
+
+	private boolean _contains(IAttribute attr) throws IdASException {
+		Iterator iter = this.getAttributes();
+		while (iter.hasNext()) {
+			if (((IAttribute)iter.next()).equals(attr))
+				return true;
+		}
+		return false;
+	}
+
 }
Index: src/org/eclipse/higgins/idas/spi/AbstractComplexValue.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/AbstractComplexValue.java,v
retrieving revision 1.1
diff -u -r1.1 AbstractComplexValue.java
--- src/org/eclipse/higgins/idas/spi/AbstractComplexValue.java	23 May 2007 22:27:10 -0000	1.1
+++ src/org/eclipse/higgins/idas/spi/AbstractComplexValue.java	11 Sep 2007 21:04:21 -0000
@@ -15,7 +15,10 @@
 import java.util.Iterator;
 
 import org.eclipse.higgins.idas.api.IAttribute;
+import org.eclipse.higgins.idas.api.IAttributeValue;
 import org.eclipse.higgins.idas.api.IComplexAttrValue;
+import org.eclipse.higgins.idas.api.IHasAttributes;
+import org.eclipse.higgins.idas.api.IHasMetadata;
 import org.eclipse.higgins.idas.api.IMetadata;
 import org.eclipse.higgins.idas.api.IdASException;
 import org.eclipse.higgins.idas.api.InvalidTypeException;
@@ -61,6 +64,22 @@
 		}
 	}
 
+	public boolean equals(IAttributeValue value) throws IdASException {
+		if (value.isSimple())
+			return false;
+		if (value.getType() != this.getType())
+			return false;
+		if (this.equals((IHasMetadata)value) == false)
+			return false;
+
+		IComplexAttrValue val = (IComplexAttrValue)value;
+		return ((BasicAttributeSet)this).equals((IHasAttributes)val);
+	}
+
+	public boolean equals(IHasMetadata metadataSet) throws IdASException {
+		return _metaSet.equals(metadataSet);
+	}
+
 	public IMetadata addMetadata(URI metadataID) throws IdASException, InvalidTypeException {
 		return _metaSet.addMetadata(metadataID);
 	}
@@ -76,5 +95,4 @@
 	public Iterator getMetadataSet() throws IdASException {
 		return _metaSet.getMetadataSet();
 	}
-
 }
Index: src/org/eclipse/higgins/idas/spi/BasicSimpleValue.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/BasicSimpleValue.java,v
retrieving revision 1.2
diff -u -r1.2 BasicSimpleValue.java
--- src/org/eclipse/higgins/idas/spi/BasicSimpleValue.java	22 Jun 2007 22:33:00 -0000	1.2
+++ src/org/eclipse/higgins/idas/spi/BasicSimpleValue.java	11 Sep 2007 21:04:21 -0000
@@ -39,7 +39,4 @@
 		super.init(type, null, container);
 	}
 
-	public boolean isSimple() throws IdASException {
-		return true;
-	}
 }
Index: src/org/eclipse/higgins/idas/spi/BasicComplexValue.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/BasicComplexValue.java,v
retrieving revision 1.1
diff -u -r1.1 BasicComplexValue.java
--- src/org/eclipse/higgins/idas/spi/BasicComplexValue.java	23 May 2007 22:27:10 -0000	1.1
+++ src/org/eclipse/higgins/idas/spi/BasicComplexValue.java	11 Sep 2007 21:04:21 -0000
@@ -46,4 +46,5 @@
 			throw new IdASException(e);
 		}
 	}
+
 }
Index: src/org/eclipse/higgins/idas/spi/BasicMetadataSet.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/BasicMetadataSet.java,v
retrieving revision 1.1
diff -u -r1.1 BasicMetadataSet.java
--- src/org/eclipse/higgins/idas/spi/BasicMetadataSet.java	23 May 2007 22:27:09 -0000	1.1
+++ src/org/eclipse/higgins/idas/spi/BasicMetadataSet.java	11 Sep 2007 21:04:21 -0000
@@ -14,6 +14,7 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 
+import org.eclipse.higgins.idas.api.IAttribute;
 import org.eclipse.higgins.idas.api.IMetadata;
 import org.eclipse.higgins.idas.api.IHasMetadata;
 import org.eclipse.higgins.idas.api.IdASException;
@@ -84,9 +85,38 @@
 	}
 
 	public void updateNotification(MetadataNotification metaNotif) throws IdASException {
-		// TODO Auto-generated method stub
 		if (_metaContainer != this) {
 			_metaContainer.updateNotification(metaNotif);
 		}
 	}
+
+	public boolean equals(IHasMetadata metadataSet) throws IdASException {
+		int localCount = 0, metadataCount = 0;
+		Iterator iter = metadataSet.getMetadataSet();
+		while (iter.hasNext()) {
+			IMetadata meta = (IMetadata)iter.next();
+			if (this._contains(meta) == false) {
+				return false;
+			}
+			metadataCount++;
+		}
+		
+		// everything we were given was found, make sure the sizes match
+		iter = this.getMetadataSet();
+		while (iter.hasNext()) {
+			iter.next();
+			localCount++;
+		}
+		return localCount == metadataCount;
+	}
+
+	private boolean _contains(IMetadata meta) throws IdASException {
+		Iterator iter = this.getMetadataSet();
+		while (iter.hasNext()) {
+			if (((IMetadata)iter.next()).equals(meta))
+				return true;
+		}
+		return false;
+	}
+	
 }
Index: src/org/eclipse/higgins/idas/spi/AbstractSimpleValue.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/AbstractSimpleValue.java,v
retrieving revision 1.1
diff -u -r1.1 AbstractSimpleValue.java
--- src/org/eclipse/higgins/idas/spi/AbstractSimpleValue.java	23 May 2007 22:27:10 -0000	1.1
+++ src/org/eclipse/higgins/idas/spi/AbstractSimpleValue.java	11 Sep 2007 21:04:21 -0000
@@ -13,6 +13,9 @@
 
 import java.net.URI;
 
+import org.eclipse.higgins.idas.api.IAttributeValue;
+import org.eclipse.higgins.idas.api.IComplexAttrValue;
+import org.eclipse.higgins.idas.api.IHasMetadata;
 import org.eclipse.higgins.idas.api.ISimpleAttrValue;
 import org.eclipse.higgins.idas.api.IdASException;
 
@@ -85,4 +88,15 @@
 			_container.updateNotification(attrValueNotif);
 		}
 	}
+	
+	public boolean equals(IAttributeValue value) throws IdASException {
+		if (value.isSimple() == false)
+			return false;
+		if (this.getType() != value.getType())
+			return false;
+		if (this.equals((IHasMetadata)value) == false)
+			return false;
+		ISimpleAttrValue val = (ISimpleAttrValue)value;
+		return this.getCanonical().equals(val.getCanonical());
+	}
 }
Index: src/org/eclipse/higgins/idas/spi/BasicDigitalSubject.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi/src/org/eclipse/higgins/idas/spi/BasicDigitalSubject.java,v
retrieving revision 1.2
diff -u -r1.2 BasicDigitalSubject.java
--- src/org/eclipse/higgins/idas/spi/BasicDigitalSubject.java	14 Jun 2007 23:25:58 -0000	1.2
+++ src/org/eclipse/higgins/idas/spi/BasicDigitalSubject.java	11 Sep 2007 21:04:21 -0000
@@ -16,6 +16,8 @@
 import org.eclipse.higgins.idas.api.IAttribute;
 import org.eclipse.higgins.idas.api.IContext;
 import org.eclipse.higgins.idas.api.IDigitalSubject;
+import org.eclipse.higgins.idas.api.IHasAttributes;
+import org.eclipse.higgins.idas.api.IHasMetadata;
 import org.eclipse.higgins.idas.api.IMetadata;
 import org.eclipse.higgins.idas.api.ISingleValuedAttribute;
 import org.eclipse.higgins.idas.api.IdASException;
@@ -217,9 +219,30 @@
 		return _attrs;
 	}
 
+	public void removeAttribute(URI attrID) throws IdASException {
+		_attrs.removeAttribute(attrID);
+	}
+
+	public void removeAttributeValue(URI attrID, Object value)
+	throws IdASException {
+		_attrs.removeAttributeValue(attrID, value);
+	}
+	
+	public void removeAttributeValue(IAttribute attr) throws IdASException {
+		_attrs.removeAttributeValue(attr);
+	}
+	
+	public boolean equals(IHasAttributes attributes) throws IdASException {
+		return _attrs.equals(attributes);
+	}
+
 	protected BasicMetadataSet getBasicMetadataSet()
 	{
 		return _metadata;
 	}
 
+	public boolean equals(IHasMetadata metadataSet) throws IdASException {
+		return _metadata.equals(metadataSet);
+	}
+	
 }

Back to the top