User: dsundstrom
  Date: 01/12/12 11:45:10

  Modified:    src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge
                        RelationSet.java
  Log:
  Added code to throw an exception if user attempts to alter the set on a
  readonly cmr field.
  
  Revision  Changes    Path
  1.4       +30 -1     
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
  
  Index: RelationSet.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RelationSet.java  2001/09/01 22:03:16     1.3
  +++ RelationSet.java  2001/12/12 19:45:10     1.4
  @@ -11,6 +11,7 @@
   import java.util.HashSet; 
   import java.util.Iterator; 
   import java.util.Set; 
  +import javax.ejb.EJBException; 
   import javax.ejb.EJBLocalObject; 
   import org.jboss.ejb.EntityEnterpriseContext; 
   import org.jboss.ejb.LocalContainerInvoker; 
  @@ -23,7 +24,7 @@
    * or the responsibilities of this class.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dain Sundstrom</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */                            
   public class RelationSet implements Set {
      private JDBCCMRFieldBridge cmrField;
  @@ -70,6 +71,10 @@
   
      public boolean add(Object o) {
         Set idSet = getIdSet();
  +      if(cmrField.isReadOnly()) {
  +         throw new EJBException("Field is read-only: " + 
  +               cmrField.getFieldName());
  +      }
   
         if(!relatedLocalInterface.isInstance(o)) {
            throw new IllegalArgumentException("Object must be an instance of " + 
relatedLocalInterface.getName());
  @@ -85,6 +90,10 @@
      
      public boolean addAll(Collection c) {
         Set idSet = getIdSet();
  +      if(cmrField.isReadOnly()) {
  +         throw new EJBException("Field is read-only: " + 
  +               cmrField.getFieldName());
  +      }
   
         if(c == null) {
            throw new IllegalArgumentException("Collection is null");
  @@ -101,6 +110,10 @@
   
      public boolean remove(Object o) {
         Set idSet = getIdSet();
  +      if(cmrField.isReadOnly()) {
  +         throw new EJBException("Field is read-only: " + 
  +               cmrField.getFieldName());
  +      }
   
         if(!relatedLocalInterface.isInstance(o)) {
            throw new IllegalArgumentException("Object must be an instance of " + 
relatedLocalInterface.getName());
  @@ -116,6 +129,10 @@
   
      public boolean removeAll(Collection c) {
         Set idSet = getIdSet();
  +      if(cmrField.isReadOnly()) {
  +         throw new EJBException("Field is read-only: " + 
  +               cmrField.getFieldName());
  +      }
   
         if(c == null) {
            throw new IllegalArgumentException("Collection is null");
  @@ -132,6 +149,10 @@
   
      public void clear() {
         Set idSet = getIdSet();
  +      if(cmrField.isReadOnly()) {
  +         throw new EJBException("Field is read-only: " + 
  +               cmrField.getFieldName());
  +      }
   
         Iterator iterator = (new HashSet(idSet)).iterator();
         while(iterator.hasNext()) {
  @@ -141,6 +162,10 @@
   
      public boolean retainAll(Collection c) {
         Set idSet = getIdSet();
  +      if(cmrField.isReadOnly()) {
  +         throw new EJBException("Field is read-only: " + 
  +               cmrField.getFieldName());
  +      }
   
         if(c == null) {
            throw new IllegalArgumentException("Collection is null");
  @@ -256,6 +281,10 @@
            
            public void remove() {
               verifyIteratorIsValid();
  +            if(cmrField.isReadOnly()) {
  +               throw new EJBException("Field is read-only: " + 
  +                     cmrField.getFieldName());
  +            }
   
               try {
                  idIterator.remove();
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to