|
Lines 22-27
Link Here
|
| 22 |
import org.apache.muse.ws.metadata.remote.MetadataExchangeClient; |
22 |
import org.apache.muse.ws.metadata.remote.MetadataExchangeClient; |
| 23 |
import org.apache.muse.ws.notification.WsnConstants; |
23 |
import org.apache.muse.ws.notification.WsnConstants; |
| 24 |
import org.apache.muse.ws.resource.remote.WsResourceClient; |
24 |
import org.apache.muse.ws.resource.remote.WsResourceClient; |
|
|
25 |
import org.apache.muse.ws.resource.sg.WssgConstants; |
| 25 |
import org.eclipse.core.runtime.IStatus; |
26 |
import org.eclipse.core.runtime.IStatus; |
| 26 |
import org.eclipse.tptp.monitoring.managedagent.wsdm.agents.provisional.runtime.WSDMRuntime; |
27 |
import org.eclipse.tptp.monitoring.managedagent.wsdm.agents.provisional.runtime.WSDMRuntime; |
| 27 |
import org.w3c.dom.Document; |
28 |
import org.w3c.dom.Document; |
|
Lines 48-64
Link Here
|
| 48 |
} |
49 |
} |
| 49 |
|
50 |
|
| 50 |
public boolean connect(String epr) throws Exception { |
51 |
public boolean connect(String epr) throws Exception { |
|
|
52 |
boolean emptyWSDL = false; |
| 51 |
try{ |
53 |
try{ |
| 52 |
Document doc = XmlUtils.createDocument(epr); |
54 |
Document doc = XmlUtils.createDocument(epr); |
| 53 |
Element eprEl = XmlUtils.getFirstElement(doc); |
55 |
Element eprEl = XmlUtils.getFirstElement(doc); |
| 54 |
_epr = new EndpointReference(eprEl); |
56 |
_epr = new EndpointReference(eprEl); |
| 55 |
_resource = new WsResourceClient(_epr); |
57 |
_resource = new WsResourceClient(_epr); |
| 56 |
|
58 |
|
| 57 |
// try to get the resource properties document to check the connection |
59 |
// 167535: all WS-resource may not have resource property documents so we cannot |
| 58 |
_resource.getResourcePropertyDocument(); |
60 |
// rely on getResourcePropertyDocument as a ping mechanism |
|
|
61 |
// _resource.getResourcePropertyDocument(); |
| 62 |
|
| 63 |
// first check to see if resource is SG, since SGs may not support MEX (double check) |
| 64 |
try{ |
| 65 |
_resource.getResourceProperty(WssgConstants.ENTRY_QNAME); |
| 66 |
return true; |
| 67 |
}catch(Exception exc){ |
| 68 |
System.out.println("Resource is not a service group"); |
| 69 |
} |
| 70 |
|
| 71 |
// however MAX is guaranteed to work only with resources that support MEX |
| 72 |
// hence we will try to get the WSDL using MEX and use that as the ping |
| 73 |
MetadataExchangeClient mdxClient = new MetadataExchangeClient(_resource.getDestination()); |
| 74 |
//mdxClient.setTrace(true); |
| 75 |
Element wsdl = mdxClient.getWSDL(); |
| 76 |
if(wsdl==null){ |
| 77 |
emptyWSDL=true; |
| 78 |
throw new Exception(); |
| 79 |
}else{ |
| 80 |
// reuse the WSDL that was retrieved and avoid having to do a new call for the WSDL |
| 81 |
_mHelper.putWSDL(_epr, wsdl); |
| 82 |
} |
| 83 |
|
| 59 |
//_resource.setTrace(true); |
84 |
//_resource.setTrace(true); |
| 60 |
}catch(Throwable t){ |
85 |
}catch(Throwable t){ |
| 61 |
MuseRuntimePlugin.getDefault().log(Messages.getString("MuseRuntime.CANT_CONN.ERROR."), t, IStatus.ERROR); //$NON-NLS-1$ |
86 |
if(emptyWSDL){ |
|
|
87 |
MuseRuntimePlugin.getDefault().log(Messages.getString("MuseRuntime.BAD_WSDL.ERROR."), t, IStatus.ERROR); //$NON-NLS-1$ |
| 88 |
}else{ |
| 89 |
MuseRuntimePlugin.getDefault().log(Messages.getString("MuseRuntime.CANT_CONN.ERROR."), t, IStatus.ERROR); //$NON-NLS-1$ |
| 90 |
} |
| 62 |
return false; |
91 |
return false; |
| 63 |
} |
92 |
} |
| 64 |
return true; |
93 |
return true; |
|
Lines 157-166
Link Here
|
| 157 |
if(_resource==null) return null; |
186 |
if(_resource==null) return null; |
| 158 |
// providesCapability works only for WSDM resources, but this has to be a wsdm resource to |
187 |
// providesCapability works only for WSDM resources, but this has to be a wsdm resource to |
| 159 |
// have relationships (MUWS Part 2) |
188 |
// have relationships (MUWS Part 2) |
| 160 |
if(!CommonUtils.providesCapability(_resource, MuwsConstants.RELATIONSHIP_RESOURCE_URI)){ |
189 |
/* if(!CommonUtils.providesCapability(_resource, MuwsConstants.RELATIONSHIP_RESOURCE_URI)){ |
| 161 |
System.out.println("This is not a relationships resource"); //$NON-NLS-1$ |
190 |
System.out.println("This is not a relationships resource"); //$NON-NLS-1$ |
| 162 |
//throw new Exception("Not a relationship resource"); |
191 |
//throw new Exception("Not a relationship resource"); |
| 163 |
} |
192 |
}*/ |
| 164 |
return _rHelper.getRelationships(_resource); |
193 |
return _rHelper.getRelationships(_resource); |
| 165 |
} |
194 |
} |
| 166 |
|
195 |
|
|
Lines 168-177
Link Here
|
| 168 |
if(_resource==null) return null; |
197 |
if(_resource==null) return null; |
| 169 |
|
198 |
|
| 170 |
Element[] els = _resource.getResourceProperty(WsnConstants.TOPIC_EXPRESSION_QNAME); |
199 |
Element[] els = _resource.getResourceProperty(WsnConstants.TOPIC_EXPRESSION_QNAME); |
| 171 |
if( els == null || els.length <= 0 ){ |
|
|
| 172 |
System.out.println("No topics defined"); |
| 173 |
} |
| 174 |
|
| 175 |
return _tHelper.getTopics(_resource); |
200 |
return _tHelper.getTopics(_resource); |
| 176 |
} |
201 |
} |
| 177 |
} |
202 |
} |