Avoid unnecessary exception when dealing with corrupted WSDL model.
1.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaWrapperModel.java Thu Sep 13 07:59:50 2007 +0000
1.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaWrapperModel.java Thu Sep 13 09:11:35 2007 +0000
1.3 @@ -573,7 +573,7 @@
1.4 casaConnections.addConnection(-1, casaConnection);
1.5 } finally {
1.6 if (isIntransaction()) {
1.7 - fireConnectionAdded(casaConnection);
1.8 + fireChangeEvent(casaConnection, PROPERTY_CONNECTION_ADDED);
1.9 endTransaction();
1.10 }
1.11 }
1.12 @@ -759,7 +759,7 @@
1.13 casaConnections.removeConnection(connection);
1.14 } finally {
1.15 if (isIntransaction()) {
1.16 - fireConnectionRemoved(connection);
1.17 + fireChangeEvent(connection, PROPERTY_CONNECTION_REMOVED);
1.18 endTransaction();
1.19 }
1.20 }
1.21 @@ -778,10 +778,10 @@
1.22 if (isIntransaction()) {
1.23 if (ConnectionState.UNCHANGED.getState().equals(initialState) &&
1.24 ConnectionState.DELETED.equals(state)) { // FIXME
1.25 - fireConnectionRemoved(casaConnection);
1.26 + fireChangeEvent(casaConnection, PROPERTY_CONNECTION_REMOVED);
1.27 } else if (ConnectionState.DELETED.getState().equals(initialState) &&
1.28 ConnectionState.UNCHANGED.equals(state)) {
1.29 - fireConnectionAdded(casaConnection);
1.30 + fireChangeEvent(casaConnection, PROPERTY_CONNECTION_ADDED);
1.31 } else {
1.32 assert false : "Uh? setConnectionState: " + initialState + "->" + state.getState(); // NOI18N
1.33 }
1.34 @@ -790,92 +790,10 @@
1.35 }
1.36 }
1.37
1.38 - private void fireConnectionRemoved(final CasaConnection connection) {
1.39 + // TODO: replace PropertyChangeListener by ChangeListener
1.40 + private void fireChangeEvent(final CasaComponent component, String type) {
1.41 firePropertyChangeEvent(new PropertyChangeEvent(
1.42 - connection,
1.43 - PROPERTY_CONNECTION_REMOVED,
1.44 - null, null));
1.45 - }
1.46 -
1.47 - private void fireConnectionAdded(final CasaConnection connection) {
1.48 - firePropertyChangeEvent(new PropertyChangeEvent(
1.49 - connection,
1.50 - PROPERTY_CONNECTION_ADDED,
1.51 - null, null));
1.52 - }
1.53 -
1.54 - private void fireCasaPortAdded(final CasaPort casaPort) {
1.55 - firePropertyChangeEvent(new PropertyChangeEvent(
1.56 - casaPort,
1.57 - PROPERTY_CASA_PORT_ADDED,
1.58 - null, null));
1.59 - }
1.60 -
1.61 - private void fireCasaPortRemoved(final CasaPort casaPort) {
1.62 - firePropertyChangeEvent(new PropertyChangeEvent(
1.63 - casaPort,
1.64 - PROPERTY_CASA_PORT_REMOVED,
1.65 - null, null));
1.66 - }
1.67 -
1.68 - private void fireCasaEndpointAdded(CasaEndpointRef casaEndpointRef) {
1.69 - firePropertyChangeEvent(new PropertyChangeEvent(
1.70 - casaEndpointRef,
1.71 - PROPERTY_ENDPOINT_ADDED,
1.72 - null, null));
1.73 - }
1.74 -
1.75 - private void fireCasaEndpointRemoved(final CasaEndpointRef endpointRef) {
1.76 - firePropertyChangeEvent(new PropertyChangeEvent(
1.77 - endpointRef,
1.78 - PROPERTY_ENDPOINT_REMOVED,
1.79 - null, null));
1.80 - }
1.81 -
1.82 - private void fireCasaEndpointRenamed(final CasaComponent component) {
1.83 - firePropertyChangeEvent(new PropertyChangeEvent(
1.84 - component,
1.85 - PROPERTY_ENDPOINT_NAME_CHANGED,
1.86 - null, null));
1.87 - }
1.88 -
1.89 - private void fireCasaEndpointInterfaceQNameChanged(
1.90 - final CasaComponent component) {
1.91 - firePropertyChangeEvent(new PropertyChangeEvent(
1.92 - component,
1.93 - PROPERTY_ENDPOINT_INTERFACE_QNAME_CHANGED,
1.94 - null, null));
1.95 - }
1.96 -
1.97 - private void fireCasaEndpointServiceQNameChanged(
1.98 - final CasaComponent component) {
1.99 - firePropertyChangeEvent(new PropertyChangeEvent(
1.100 - component,
1.101 - PROPERTY_ENDPOINT_SERVICE_QNAME_CHANGED,
1.102 - null, null));
1.103 - }
1.104 -
1.105 - private void fireServiceUnitRenamed(final CasaServiceUnit su) {
1.106 - firePropertyChangeEvent(new PropertyChangeEvent(
1.107 - su,
1.108 - PROPERTY_SERVICE_UNIT_RENAMED,
1.109 - null, null));
1.110 - }
1.111 -
1.112 - private void fireServiceEngineServiceUnitAdded(
1.113 - final CasaServiceEngineServiceUnit seSU) {
1.114 - firePropertyChangeEvent(new PropertyChangeEvent(
1.115 - seSU,
1.116 - PROPERTY_SERVICE_ENGINE_SERVICE_UNIT_ADDED,
1.117 - null, null));
1.118 - }
1.119 -
1.120 - private void fireServiceEngineServiceUnitRemoved(
1.121 - final CasaServiceEngineServiceUnit seSU) {
1.122 - firePropertyChangeEvent(new PropertyChangeEvent(
1.123 - seSU,
1.124 - PROPERTY_SERVICE_ENGINE_SERVICE_UNIT_REMOVED,
1.125 - null, null));
1.126 + component, type, null, null));
1.127 }
1.128
1.129 /**
1.130 @@ -1211,7 +1129,7 @@
1.131 sus.addServiceEngineServiceUnit(-1, seSU);
1.132 } finally {
1.133 if (isIntransaction()) {
1.134 - fireServiceEngineServiceUnitAdded(seSU);
1.135 + fireChangeEvent(seSU, PROPERTY_SERVICE_ENGINE_SERVICE_UNIT_ADDED);
1.136 endTransaction();
1.137 }
1.138 }
1.139 @@ -1526,7 +1444,7 @@
1.140
1.141 } finally {
1.142 if (isIntransaction()) {
1.143 - fireCasaPortAdded(casaPort);
1.144 + fireChangeEvent(casaPort, PROPERTY_CASA_PORT_ADDED);
1.145 endTransaction();
1.146 }
1.147 }
1.148 @@ -1592,7 +1510,7 @@
1.149 }
1.150 } finally {
1.151 if (isIntransaction()) {
1.152 - fireCasaPortRemoved(casaPort);
1.153 + fireChangeEvent(casaPort, PROPERTY_CASA_PORT_REMOVED);
1.154 endTransaction();
1.155 }
1.156 }
1.157 @@ -1623,9 +1541,18 @@
1.158 WSDLModel compAppWSDLModel = port.getModel();
1.159 compAppWSDLModel.startTransaction();
1.160 try {
1.161 - service.removePort(port);
1.162 - definitions.removeService(service);
1.163 - definitions.removeBinding(binding);
1.164 + // Added null-checking to avoid exception when dealing
1.165 + // with corrupted WSDL model (for example, a port w/o
1.166 + // binding).
1.167 + if (service != null) {
1.168 + if (port != null ) {
1.169 + service.removePort(port);
1.170 + }
1.171 + definitions.removeService(service);
1.172 + }
1.173 + if (binding != null) {
1.174 + definitions.removeBinding(binding);
1.175 + }
1.176 } finally {
1.177 if (compAppWSDLModel.isIntransaction()) {
1.178 compAppWSDLModel.endTransaction();
1.179 @@ -1681,11 +1608,11 @@
1.180 if (isIntransaction()) {
1.181 if (//CasaPortState.UNCHANGED.getState().equals(initialState) &&
1.182 CasaPortState.DELETED.equals(state)) { // FIXME
1.183 - fireCasaPortRemoved(casaPort);
1.184 + fireChangeEvent(casaPort, PROPERTY_CASA_PORT_REMOVED);
1.185 } else if (CasaPortState.DELETED.getState().equals(initialState) //&&
1.186 //ConnectionState.UNCHANGED.equals(state)
1.187 ) {
1.188 - fireCasaPortAdded(casaPort);
1.189 + fireChangeEvent(casaPort, PROPERTY_CASA_PORT_ADDED);
1.190 } else {
1.191 assert false : "Uh? setCasaPortState: " + initialState + "->" + state.getState(); // NOI18N
1.192 }
1.193 @@ -1727,7 +1654,7 @@
1.194 }
1.195 } finally {
1.196 if (isIntransaction()) {
1.197 - fireCasaEndpointRemoved(endpointRef);
1.198 + fireChangeEvent(endpointRef, PROPERTY_ENDPOINT_REMOVED);
1.199 endTransaction();
1.200 }
1.201 }
1.202 @@ -2010,7 +1937,7 @@
1.203 }
1.204 } finally {
1.205 if (isIntransaction()) {
1.206 - fireCasaEndpointAdded(endpointRef);
1.207 + fireChangeEvent(endpointRef, PROPERTY_ENDPOINT_ADDED);
1.208 endTransaction();
1.209 }
1.210 }
1.211 @@ -2223,7 +2150,7 @@
1.212 casaSUs.removeServiceEngineServiceUnit(seSU);
1.213 } finally {
1.214 if (isIntransaction()) {
1.215 - fireServiceEngineServiceUnitRemoved(seSU);
1.216 + fireChangeEvent(seSU, PROPERTY_SERVICE_ENGINE_SERVICE_UNIT_REMOVED);
1.217 endTransaction();
1.218 }
1.219 }
1.220 @@ -2693,7 +2620,7 @@
1.221 casaEndpoint.setEndpointName(endpointName);
1.222 } finally {
1.223 if (isIntransaction()) {
1.224 - fireCasaEndpointRenamed(component);
1.225 + fireChangeEvent(component, PROPERTY_ENDPOINT_NAME_CHANGED);
1.226 endTransaction();
1.227 }
1.228 }
1.229 @@ -2785,7 +2712,7 @@
1.230 }
1.231 } finally {
1.232 if (isIntransaction()) {
1.233 - fireCasaEndpointInterfaceQNameChanged(endpointRef);
1.234 + fireChangeEvent(endpointRef, PROPERTY_ENDPOINT_INTERFACE_QNAME_CHANGED);
1.235 endTransaction();
1.236 }
1.237 }
1.238 @@ -2837,7 +2764,8 @@
1.239 endpoint.setInterfaceQName(oldInterfaceQName);
1.240 } finally {
1.241 if (isIntransaction()) {
1.242 - fireCasaEndpointInterfaceQNameChanged(endpointRef);
1.243 + fireChangeEvent(endpointRef,
1.244 + PROPERTY_ENDPOINT_INTERFACE_QNAME_CHANGED);
1.245 endTransaction();
1.246 }
1.247 }
1.248 @@ -2865,7 +2793,7 @@
1.249 endpoint.setServiceQName(serviceQName);
1.250 } finally {
1.251 if (isIntransaction()) {
1.252 - fireCasaEndpointServiceQNameChanged(endpointRef);
1.253 + fireChangeEvent(endpointRef, PROPERTY_ENDPOINT_SERVICE_QNAME_CHANGED);
1.254 endTransaction();
1.255 }
1.256 }
1.257 @@ -2917,7 +2845,7 @@
1.258 su.setUnitName(unitName);
1.259 } finally {
1.260 if (isIntransaction()) {
1.261 - fireServiceUnitRenamed(su);
1.262 + fireChangeEvent(su, PROPERTY_SERVICE_UNIT_RENAMED);
1.263 endTransaction();
1.264 }
1.265 }