updated to work with the final JMI interfaces (now uses the new CompositionViolationException to pass TCK for 100%)
a few bugfixes
1.1 --- a/mdr/build.xml Mon Jul 15 15:09:03 2002 +0000
1.2 +++ b/mdr/build.xml Wed Jul 17 11:50:37 2002 +0000
1.3 @@ -410,7 +410,7 @@
1.4 <delete file="manifest-mof-subst.mf"/>
1.5 <delete file="manifest-explorer-subst.mf"/>
1.6 <delete file="mdr.nbm"/>
1.7 - <delete file="mdrtoolkit.nbm"/>
1.8 + <delete file="mdrapi.nbm"/><delete file="mdrtoolkit.nbm"/>
1.9 <delete file="mof.nbm"/>
1.10 <delete file="jmi.nbm"/>
1.11 <delete file="mdrexplorer.nbm"/>
2.1 --- a/mdr/src/org/netbeans/mdr/handlers/AssociationHandler.java Mon Jul 15 15:09:03 2002 +0000
2.2 +++ b/mdr/src/org/netbeans/mdr/handlers/AssociationHandler.java Wed Jul 17 11:50:37 2002 +0000
2.3 @@ -327,7 +327,7 @@
2.4 oeip = thisEnd.refOutermostPackage();
2.5
2.6 String name = ((javax.jmi.model.Association)associationHandler.refMetaObject()).getName();
2.7 - RefAssociation oea = oeip.refAssociation (name);
2.8 + RefAssociation oea = _findAssociation(oeip, name);
2.9 if (oea instanceof AssociationHandler) {
2.10 boolean failed = true;
2.11 Boolean result = null;
2.12 @@ -367,6 +367,7 @@
2.13 }
2.14 }
2.15
2.16 + // [PENDING] (MaM) This is wrong! Method needs to use FQN to find the association
2.17 private static RefAssociation _findAssociation (RefPackage opkg, String name) {
2.18 ArrayList list = new ArrayList ();
2.19 list.add (opkg);
2.20 @@ -374,9 +375,8 @@
2.21 RefPackage pkg = (RefPackage) list.remove (0);
2.22 try {
2.23 RefAssociation oea = pkg.refAssociation (name);
2.24 - if (oea != null)
2.25 - return oea;
2.26 - } catch (javax.jmi.reflect.InvalidCallException invalidCall) {
2.27 + return oea;
2.28 + } catch (javax.jmi.reflect.InvalidNameException invalidName) {
2.29 }
2.30 Object innerPackages = pkg.refAllPackages();
2.31 if (innerPackages instanceof RefPackage) {
3.1 --- a/mdr/src/org/netbeans/mdr/handlers/ClassProxyHandler.java Mon Jul 15 15:09:03 2002 +0000
3.2 +++ b/mdr/src/org/netbeans/mdr/handlers/ClassProxyHandler.java Wed Jul 17 11:50:37 2002 +0000
3.3 @@ -179,7 +179,7 @@
3.4 RefObject result = null;
3.5
3.6 if (getClassDelegate().isAbstract()) {
3.7 - throw new InvalidCallException(this, null);
3.8 + throw new InvalidCallException(this, null, "Cannot create instance of an abstract class.");
3.9 }
3.10 Object params[] = (args == null ? null : args.toArray());
3.11
3.12 @@ -203,13 +203,25 @@
3.13 result = _handleEnum(enumName, name);
3.14 fail = false;
3.15 return result;
3.16 + } catch (NullPointerException e) {
3.17 + throw new InvalidNameException(enumName);
3.18 } finally {
3.19 _postEnum(result, extraInfo, fail);
3.20 }
3.21 }
3.22
3.23 public final RefEnum refGetEnum(RefObject enum, String name) {
3.24 - return refGetEnum(((EnumerationType) enum).getName(), name);
3.25 + EnumerationType et;
3.26 + try {
3.27 + et = (EnumerationType) enum;
3.28 + } catch (ClassCastException e) {
3.29 + throw new InvalidCallException(this, enum, "Invalid enumeration designator: " + enum);
3.30 + }
3.31 + try {
3.32 + return refGetEnum(et.getName(), name);
3.33 + } catch (InvalidNameException e) {
3.34 + throw new InvalidCallException(this, enum);
3.35 + }
3.36 }
3.37
3.38 public final RefStruct refCreateStruct(String structName, java.util.List params) {
3.39 @@ -222,15 +234,27 @@
3.40 result = _handleStruct(structName, args);
3.41 fail = false;
3.42 return result;
3.43 + } catch (NullPointerException e) {
3.44 + throw new InvalidNameException(structName);
3.45 } finally {
3.46 _postStruct(result, extraInfo, fail);
3.47 }
3.48 }
3.49
3.50 public final RefStruct refCreateStruct(RefObject struct, List params) {
3.51 - return refCreateStruct(((StructureType) struct).getName(), params);
3.52 + StructureType st;
3.53 + try {
3.54 + st = (StructureType) struct;
3.55 + } catch (ClassCastException e) {
3.56 + throw new InvalidCallException(this, struct, "Invalid structure designator: " + struct);
3.57 + }
3.58 + try {
3.59 + return refCreateStruct(st.getName(), params);
3.60 + } catch (InvalidNameException e) {
3.61 + throw new InvalidCallException(this, struct);
3.62 + }
3.63 }
3.64 -
3.65 +
3.66 /* -------------------------------------------------------------------- */
3.67 /* -- Implementation of org.netbeans.api.mdr.events.MDRChangeSource --- */
3.68 /* -------------------------------------------------------------------- */
4.1 --- a/mdr/src/org/netbeans/mdr/handlers/EnumResolver.java Mon Jul 15 15:09:03 2002 +0000
4.2 +++ b/mdr/src/org/netbeans/mdr/handlers/EnumResolver.java Wed Jul 17 11:50:37 2002 +0000
4.3 @@ -59,6 +59,8 @@
4.4 Field f = cl.getField(org.netbeans.mdr.handlers.gen.TagSupport.mapEnumLiteral(label));
4.5 enum = (RefEnum) f.get(null);
4.6 enumCache.put(enumKey, enum);
4.7 + } catch (NoSuchFieldException e) {
4.8 + throw new InvalidNameException(label, "Invalid literal name '" + label + "' for enumeration " + ifcName);
4.9 } catch (Exception e) {
4.10 e.printStackTrace();
4.11 throw new DebugException(e.toString());
5.1 --- a/mdr/src/org/netbeans/mdr/handlers/InstanceHandler.java Mon Jul 15 15:09:03 2002 +0000
5.2 +++ b/mdr/src/org/netbeans/mdr/handlers/InstanceHandler.java Wed Jul 17 11:50:37 2002 +0000
5.3 @@ -54,6 +54,9 @@
5.4 extraInfo = _preSetR(name, value);
5.5 _handleSetR(name, value);
5.6 fail = false;
5.7 + } catch (NullPointerException e) {
5.8 + // reference descriptor was not found
5.9 + throw new InvalidNameException(name);
5.10 } finally {
5.11 _postSetR(extraInfo, fail);
5.12 }
5.13 @@ -68,6 +71,9 @@
5.14 result = _handleGetR(name);
5.15 fail = false;
5.16 return result;
5.17 + } catch (NullPointerException e) {
5.18 + // reference descriptor was not found
5.19 + throw new InvalidNameException(name);
5.20 } finally {
5.21 _postGetR(result, extraInfo, fail);
5.22 }
5.23 @@ -92,11 +98,20 @@
5.24 }
5.25
5.26 protected final Object _handleGetR(String featureName) {
5.27 + StorableClass.ReferenceDescriptor reference = null;
5.28 try {
5.29 - StorableClass.ReferenceDescriptor reference = getInstanceDelegate().getClassProxy().getReferenceDescriptor(featureName);
5.30 + reference = getInstanceDelegate().getClassProxy().getReferenceDescriptor(featureName);
5.31 AssociationHandler assoc = (AssociationHandler) getHandler(reference.getAssociation());
5.32 //System.out.println("getting reference " + featureName + " for end: " + reference.getEndName());
5.33 return assoc._query(reference.getEndName(), (RefObject) this);
5.34 + } catch (ClassCastException e) {
5.35 + // this will throw TypeMismatchException or DebugException if the mismatch is not found
5.36 + if (reference.isFirstEnd()) {
5.37 + reference.getAssociation().checkType(null, this);
5.38 + } else {
5.39 + reference.getAssociation().checkType(this, null);
5.40 + }
5.41 + return null;
5.42 } catch (StorageException e) {
5.43 e.printStackTrace();
5.44 throw new DebugException();
5.45 @@ -123,11 +138,39 @@
5.46
5.47 // remove old link and add the new one
5.48 if (reference.isFirstEnd()) {
5.49 - if (oldValue != null) assoc._remove((RefObject) oldValue, (RefObject) this);
5.50 - if (newValue != null) assoc._add((RefObject) newValue, (RefObject) this);
5.51 + if (oldValue != null) try {
5.52 + assoc._remove((RefObject) oldValue, (RefObject) this);
5.53 + } catch (ClassCastException e) {
5.54 + // this will throw TypeMismatchException or DebugException if the mismatch is not found
5.55 + ((StorableAssociation) assoc._getDelegate()).checkType(oldValue, this);
5.56 + // this is here only to make the compiler happy
5.57 + return;
5.58 + }
5.59 + if (newValue != null) try {
5.60 + assoc._add((RefObject) newValue, (RefObject) this);
5.61 + } catch (ClassCastException e) {
5.62 + // this will throw TypeMismatchException or DebugException if the mismatch is not found
5.63 + ((StorableAssociation) assoc._getDelegate()).checkType(newValue, this);
5.64 + // this is here only to make the compiler happy
5.65 + return;
5.66 + }
5.67 } else {
5.68 - if (oldValue != null) assoc._remove((RefObject) this, (RefObject) oldValue);
5.69 - if (newValue != null) assoc._add((RefObject) this, (RefObject) newValue);
5.70 + if (oldValue != null) try {
5.71 + assoc._remove((RefObject) this, (RefObject) oldValue);
5.72 + } catch (ClassCastException e) {
5.73 + // this will throw TypeMismatchException or DebugException if the mismatch is not found
5.74 + ((StorableAssociation) assoc._getDelegate()).checkType(this, oldValue);
5.75 + // this is here only to make the compiler happy
5.76 + return;
5.77 + }
5.78 + if (newValue != null) try {
5.79 + assoc._add((RefObject) this, (RefObject) newValue);
5.80 + } catch (ClassCastException e) {
5.81 + // this will throw TypeMismatchException or DebugException if the mismatch is not found
5.82 + ((StorableAssociation) assoc._getDelegate()).checkType(this, newValue);
5.83 + // this is here only to make the compiler happy
5.84 + return;
5.85 + }
5.86 }
5.87
5.88 // [PENDING] should add replace operation into an association
6.1 --- a/mdr/src/org/netbeans/mdr/handlers/PackageProxyHandler.java Mon Jul 15 15:09:03 2002 +0000
6.2 +++ b/mdr/src/org/netbeans/mdr/handlers/PackageProxyHandler.java Wed Jul 17 11:50:37 2002 +0000
6.3 @@ -202,6 +202,9 @@
6.4 try {
6.5 extraInfo = _preGetAssociationProxy(assocName);
6.6 result = _handleGetAssociationProxy(assocName);
6.7 + if (result == null) {
6.8 + throw new InvalidNameException(assocName);
6.9 + }
6.10 fail = false;
6.11 return result;
6.12 } finally {
6.13 @@ -210,7 +213,17 @@
6.14 }
6.15
6.16 public final RefAssociation refAssociation(RefObject assoc) {
6.17 - return refAssociation(((Association) assoc).getName());
6.18 + Association a;
6.19 + try {
6.20 + a = (Association) assoc;
6.21 + } catch (ClassCastException e) {
6.22 + throw new InvalidCallException(this, assoc, "Invalid association designator: " + assoc);
6.23 + }
6.24 + try {
6.25 + return refAssociation(a.getName());
6.26 + } catch (InvalidNameException e) {
6.27 + throw new InvalidCallException(this, assoc);
6.28 + }
6.29 }
6.30
6.31 public final RefPackage refPackage(String name) {
6.32 @@ -220,6 +233,9 @@
6.33 try {
6.34 extraInfo = _preGetPackageProxy(name);
6.35 result = _handleGetPackageProxy(name);
6.36 + if (result == null) {
6.37 + throw new InvalidNameException(name);
6.38 + }
6.39 fail = false;
6.40 return result;
6.41 } finally {
6.42 @@ -228,16 +244,24 @@
6.43 }
6.44
6.45 public final RefPackage refPackage(RefObject nestedPackage) {
6.46 + MofPackage pkg;
6.47 + try {
6.48 + pkg = (MofPackage) nestedPackage;
6.49 + } catch (ClassCastException e) {
6.50 + throw new InvalidCallException(this, nestedPackage, "Invalid package designator: " + nestedPackage);
6.51 + }
6.52 try {
6.53 _lock(false);
6.54 checkClustered();
6.55 - String name = (String) clusteredPackages.get(((MofPackage) nestedPackage).refMofId());
6.56 + String name = (String) clusteredPackages.get(pkg.refMofId());
6.57
6.58 if (name == null) {
6.59 - name = ((MofPackage) nestedPackage).getName();
6.60 + name = pkg.getName();
6.61 }
6.62
6.63 return refPackage(name);
6.64 + } catch (InvalidNameException e) {
6.65 + throw new InvalidCallException(this, nestedPackage);
6.66 } finally {
6.67 _unlock();
6.68 }
6.69 @@ -250,6 +274,9 @@
6.70 try {
6.71 extraInfo = _preGetClassProxy(name);
6.72 result = _handleGetClassProxy(name);
6.73 + if (result == null) {
6.74 + throw new InvalidNameException(name);
6.75 + }
6.76 fail = false;
6.77 return result;
6.78 } finally {
6.79 @@ -258,7 +285,17 @@
6.80 }
6.81
6.82 public final RefClass refClass(RefObject type) {
6.83 - return refClass(((MofClass) type).getName());
6.84 + MofClass cls;
6.85 + try {
6.86 + cls = (MofClass) type;
6.87 + } catch (ClassCastException e) {
6.88 + throw new InvalidCallException(this, type, "Invalid class designator: " + type);
6.89 + }
6.90 + try {
6.91 + return refClass(cls.getName());
6.92 + } catch (InvalidNameException e) {
6.93 + throw new InvalidCallException(this, type);
6.94 + }
6.95 }
6.96
6.97 public final RefEnum refGetEnum(String enumName, java.lang.String name) {
6.98 @@ -270,13 +307,25 @@
6.99 result = _handleEnum(enumName, name);
6.100 fail = false;
6.101 return result;
6.102 + } catch (NullPointerException e) {
6.103 + throw new InvalidNameException(enumName);
6.104 } finally {
6.105 _postEnum(result, extraInfo, fail);
6.106 }
6.107 }
6.108
6.109 public final RefEnum refGetEnum(RefObject enum, String name) {
6.110 - return refGetEnum(((EnumerationType) enum).getName(), name);
6.111 + EnumerationType et;
6.112 + try {
6.113 + et = (EnumerationType) enum;
6.114 + } catch (ClassCastException e) {
6.115 + throw new InvalidCallException(this, enum, "Invalid enumeration designator: " + enum);
6.116 + }
6.117 + try {
6.118 + return refGetEnum(et.getName(), name);
6.119 + } catch (InvalidNameException e) {
6.120 + throw new InvalidCallException(this, enum);
6.121 + }
6.122 }
6.123
6.124 public final RefStruct refCreateStruct(String structName, java.util.List params) {
6.125 @@ -289,13 +338,25 @@
6.126 result = _handleStruct(structName, args);
6.127 fail = false;
6.128 return result;
6.129 + } catch (NullPointerException e) {
6.130 + throw new InvalidNameException(structName);
6.131 } finally {
6.132 _postStruct(result, extraInfo, fail);
6.133 }
6.134 }
6.135
6.136 public final RefStruct refCreateStruct(RefObject struct, List params) {
6.137 - return refCreateStruct(((StructureType) struct).getName(), params);
6.138 + StructureType st;
6.139 + try {
6.140 + st = (StructureType) struct;
6.141 + } catch (ClassCastException e) {
6.142 + throw new InvalidCallException(this, struct, "Invalid structure designator: " + struct);
6.143 + }
6.144 + try {
6.145 + return refCreateStruct(st.getName(), params);
6.146 + } catch (InvalidNameException e) {
6.147 + throw new InvalidCallException(this, struct);
6.148 + }
6.149 }
6.150
6.151 public void refDelete() {
7.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/StorableObject.java Mon Jul 15 15:09:03 2002 +0000
7.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/StorableObject.java Wed Jul 17 11:50:37 2002 +0000
7.3 @@ -239,9 +239,7 @@
7.4 if (id != attribComposite) {
7.5 // check for Composition Violation
7.6 if (attribComposite != null) {
7.7 -// [PENDING] uncomment this after the final JMI gets released
7.8 -// throw new javax.jmi.reflect.CompositionViolationException(BaseObjectHandler.getHandler(this), (RefObject) BaseObjectHandler.getHandler(getMdrStorage().getObject(elementId)));
7.9 - throw new DebugException("Instance already has a composite: " + getMofId()); // object is already contained in another object
7.10 + throw new javax.jmi.reflect.CompositionViolationException(BaseObjectHandler.getHandler(this), (RefObject) BaseObjectHandler.getHandler(getMdrStorage().getObject(elementId)));
7.11 }
7.12 // check for Composition Cycle
7.13 if ((composite instanceof StorableObject) && (((StorableObject) composite).getOutermostComposite().equals(this))) {
8.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/StorablePackage.java Mon Jul 15 15:09:03 2002 +0000
8.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/StorablePackage.java Wed Jul 17 11:50:37 2002 +0000
8.3 @@ -144,7 +144,7 @@
8.4 getMdrStorage().dropContext(context, getMofId());
8.5 deleteRecursive();
8.6 } else {
8.7 - throw new DebugException("Not an outermost package.");
8.8 + throw new InvalidCallException(org.netbeans.mdr.handlers.BaseObjectHandler.getHandler(this), null, "Not an outermost package.");
8.9 }
8.10 }
8.11