use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class URIDomainExpressionTest method mockInfoObjects.
private void mockInfoObjects() {
si = control.createMock(ServiceInfo.class);
ei = control.createMock(EndpointInfo.class);
boi = control.createMock(BindingOperationInfo.class);
bmi = control.createMock(BindingMessageInfo.class);
bfi = control.createMock(BindingFaultInfo.class);
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getTargetNamespace()).andReturn(TARGET_NAMESPACE).anyTimes();
EasyMock.expect(si.getName()).andReturn(SERVICE_QNAME).anyTimes();
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
EasyMock.expect(ii.getName()).andReturn(INTERFACE_QNAME).anyTimes();
EasyMock.expect(ei.getName()).andReturn(PORT_QNAME).anyTimes();
EasyMock.expect(ei.getService()).andReturn(si).anyTimes();
BindingInfo bi = control.createMock(BindingInfo.class);
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(boi.getName()).andReturn(OPERATION_QNAME).anyTimes();
EasyMock.expect(boi.getBinding()).andReturn(bi).anyTimes();
EasyMock.expect(bi.getName()).andReturn(BINDING_QNAME).anyTimes();
EasyMock.expect(boi.getOperationInfo()).andReturn(oi).anyTimes();
EasyMock.expect(oi.getInterface()).andReturn(ii).anyTimes();
EasyMock.expect(oi.getName()).andReturn(OPERATION_QNAME).anyTimes();
mi = control.createMock(MessageInfo.class);
EasyMock.expect(bmi.getMessageInfo()).andReturn(mi).anyTimes();
EasyMock.expect(mi.getName()).andReturn(MESSAGE_QNAME).anyTimes();
EasyMock.expect(bmi.getBindingOperation()).andReturn(boi).anyTimes();
FaultInfo fi = control.createMock(FaultInfo.class);
bfi = control.createMock(BindingFaultInfo.class);
EasyMock.expect(bfi.getBindingOperation()).andReturn(boi).anyTimes();
EasyMock.expect(bfi.getFaultInfo()).andReturn(fi).anyTimes();
EasyMock.expect(fi.getFaultName()).andReturn(FAULT_QNAME).anyTimes();
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.
public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
DescriptionInfo di = si.getDescription();
Policy p = getElementPolicy(bfi, false, di);
FaultInfo fi = bfi.getFaultInfo();
p = mergePolicies(p, getElementPolicy(fi, true, di));
Extensible ex = getMessageTypeInfo(fi.getName(), di);
p = mergePolicies(p, getElementPolicy(ex, false, di));
return p;
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class OperationProcessor method process.
public void process(JavaInterface intf, OperationInfo operation) throws ToolException {
JavaMethod method = new MethodMapper().map(operation);
method.setInterface(intf);
processMethod(method, operation);
Collection<FaultInfo> faults = operation.getFaults();
FaultProcessor faultProcessor = new FaultProcessor(context);
faultProcessor.process(method, faults);
method.annotate(new WSActionAnnotator(operation));
intf.addMethod(method);
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class WSActionAnnotator method annotate.
public void annotate(JavaAnnotatable ja) {
JavaMethod method;
if (ja instanceof JavaMethod) {
method = (JavaMethod) ja;
} else {
throw new RuntimeException("Action can only annotate JavaMethod");
}
boolean required = false;
JavaInterface intf = method.getInterface();
MessageInfo inputMessage = operation.getInput();
MessageInfo outputMessage = operation.getOutput();
JAnnotation actionAnnotation = new JAnnotation(Action.class);
if (inputMessage.getExtensionAttributes() != null) {
String inputAction = getAction(inputMessage);
if (inputAction != null) {
actionAnnotation.addElement(new JAnnotationElement("input", inputAction));
required = true;
}
}
if (outputMessage != null && outputMessage.getExtensionAttributes() != null) {
String outputAction = getAction(outputMessage);
if (outputAction != null) {
actionAnnotation.addElement(new JAnnotationElement("output", outputAction));
required = true;
}
}
if (operation.hasFaults()) {
List<JAnnotation> faultAnnotations = new ArrayList<>();
for (FaultInfo faultInfo : operation.getFaults()) {
if (faultInfo.getExtensionAttributes() != null) {
String faultAction = getAction(faultInfo);
if (faultAction == null) {
continue;
}
JavaException exceptionClass = getExceptionClass(method, faultInfo);
if (!StringUtils.isEmpty(exceptionClass.getPackageName()) && !exceptionClass.getPackageName().equals(intf.getPackageName())) {
intf.addImport(exceptionClass.getClassName());
}
JAnnotation faultAnnotation = new JAnnotation(FaultAction.class);
faultAnnotation.addElement(new JAnnotationElement("className", exceptionClass));
faultAnnotation.addElement(new JAnnotationElement("value", faultAction));
faultAnnotations.add(faultAnnotation);
required = true;
}
}
actionAnnotation.addElement(new JAnnotationElement("fault", faultAnnotations));
}
if (required) {
method.addAnnotation("Action", actionAnnotation);
}
}
use of org.apache.cxf.service.model.FaultInfo in project cxf by apache.
the class CorbaStreamFaultInInterceptor method handleMessage.
public void handleMessage(Message msg) {
CorbaMessage message = (CorbaMessage) msg;
try {
SystemException sysEx = message.getSystemException();
if (sysEx != null) {
message.setContent(Exception.class, sysEx);
return;
}
CorbaStreamable exStreamable = message.getStreamableException();
if (exStreamable != null) {
DataReader<XMLStreamReader> reader = getDataReader(message);
BindingOperationInfo bopInfo = message.getExchange().getBindingOperationInfo();
OperationInfo opInfo = bopInfo.getOperationInfo();
ServiceInfo service = message.getExchange().getEndpoint().getEndpointInfo().getService();
org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
if (orb == null) {
orb = message.getExchange().get(org.omg.CORBA.ORB.class);
}
QName elName = new QName("", exStreamable.getName());
FaultInfo fault = getFaultInfo(opInfo, elName);
CorbaTypeEventProducer faultEventProducer = CorbaHandlerUtils.getTypeEventProducer(exStreamable.getObject(), service, orb);
CorbaStreamReader streamReader = new CorbaStreamReader(faultEventProducer);
Object e = reader.read(fault.getMessageParts().get(0), streamReader);
if (!(e instanceof Exception)) {
Class<?> exClass = fault.getProperty(Class.class.getName(), Class.class);
if (exClass != null) {
Class<?> beanClass = e.getClass();
Constructor<?> constructor = exClass.getConstructor(new Class[] { String.class, beanClass });
String repId = (message.getStreamableException()._type().id() != null) ? message.getStreamableException()._type().id() : "";
e = constructor.newInstance(new Object[] { repId, e });
} else {
// Get the Fault
Fault faultEx = (Fault) message.getContent(Exception.class);
if (e instanceof Document) {
createFaultDetail((Document) e, fault, faultEx);
}
e = faultEx;
}
}
message.setContent(Exception.class, e);
}
} catch (java.lang.Exception ex) {
LOG.log(Level.SEVERE, "CORBA unmarshalFault exception", ex);
throw new CorbaBindingException("CORBA unmarshalFault exception", ex);
}
}
Aggregations