callPT = partnerRolePT;
} // end if
// No interfaces mean an error - throw an exception
if( callPT == null && callbackPT == null ) {
error("MyRolePartnerRoleNull", theInterfaces);
throw new ContributionResolveException("Error: myRole and partnerRole port types are both null");
} // end if
// Set the name of the reference to the supplied name and the multiplicity of the reference
// to 1..1
// TODO: support other multiplicities
reference.setName(name);
reference.setMultiplicity(Multiplicity.ONE_ONE);
if ( callPT != null ) {
// Set the call interface and, if present, the callback interface
WSDLInterface callInterface = null;
for( WSDLInterface anInterface : theInterfaces ) {
if( anInterface.getPortType().getQName().equals(callPT.getQName())) callInterface = anInterface;
} // end for
// Throw an exception if no interface is found
if( callInterface == null ) {
error("NoInterfaceForPortType", theInterfaces, callPT.getQName().toString());
throw new ContributionResolveException("Interface not found for port type " +
callPT.getQName().toString() );
} else
reference.getInterfaceContract().setInterface(callInterface);
}
// There is a callback if the partner role is not null and if the partner role port type
// is not the same as the port type for my role
if ( callbackPT != null ) {
WSDLInterface callbackInterface = null;
for( WSDLInterface anInterface : theInterfaces ) {
if( anInterface.getPortType().getQName().equals(callbackPT.getQName())) callbackInterface = anInterface;
} // end for
// Throw an exception if no interface is found
if( callbackInterface == null ) {
error("NoInterfaceForPortType", theInterfaces, callbackPT.getQName().toString());
throw new ContributionResolveException("Interface not found for port type " +
callbackPT.getQName().toString() );
} else
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
} // end if