use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class JaxwsModule method addReferencedTypeDefinitions.
protected void addReferencedTypeDefinitions(WebFault webFault, LinkedList<Element> contextStack) {
contextStack.push(webFault);
try {
if (webFault.isImplicitSchemaElement()) {
for (ImplicitChildElement childElement : webFault.getChildElements()) {
WebFault.FaultBeanChildElement fbce = (WebFault.FaultBeanChildElement) childElement;
this.jaxbModule.getJaxbContext().addReferencedTypeDefinitions(fbce.isAdapted() ? fbce.getAdapterType() : fbce.getType(), contextStack);
}
} else {
DeclaredType faultBeanType = webFault.getExplicitFaultBeanType();
if (faultBeanType != null) {
this.jaxbModule.getJaxbContext().addReferencedTypeDefinitions(faultBeanType, contextStack);
}
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(contextStack, e);
}
throw e;
} finally {
contextStack.pop();
}
}
use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class JaxwsModule method call.
@Override
public void call(EnunciateContext context) {
jaxwsContext = new EnunciateJaxwsContext(this.jaxbModule.getJaxbContext(), isUseSourceParameterNames());
boolean aggressiveWebMethodExcludePolicy = isAggressiveWebMethodExcludePolicy();
Map<String, String> eiPaths = new HashMap<>();
File sunJaxwsXmlFile = getSunJaxwsXmlFile();
if (sunJaxwsXmlFile != null) {
XMLConfiguration config;
try {
config = new XMLConfiguration(sunJaxwsXmlFile);
} catch (ConfigurationException e) {
throw new EnunciateException(e);
}
List<HierarchicalConfiguration> endpoints = config.configurationsAt("endpoint");
for (HierarchicalConfiguration endpoint : endpoints) {
String impl = endpoint.getString("[@implementation]", null);
String urlPattern = endpoint.getString("[@url-pattern]", null);
if (impl != null && urlPattern != null) {
eiPaths.put(impl, urlPattern);
}
}
}
DataTypeDetectionStrategy detectionStrategy = getDataTypeDetectionStrategy();
if (detectionStrategy != DataTypeDetectionStrategy.passive) {
Set<? extends Element> elements = detectionStrategy == DataTypeDetectionStrategy.local ? context.getLocalApiElements() : context.getApiElements();
for (Element declaration : elements) {
try {
if (declaration instanceof TypeElement) {
TypeElement element = (TypeElement) declaration;
XmlRegistry registryMetadata = declaration.getAnnotation(XmlRegistry.class);
if (registryMetadata != null) {
this.jaxbModule.addPotentialJaxbElement(element, new LinkedList<>());
}
if (isEndpointInterface(element)) {
EndpointInterface ei = new EndpointInterface(element, elements, aggressiveWebMethodExcludePolicy, jaxwsContext);
for (EndpointImplementation implementation : ei.getEndpointImplementations()) {
String urlPattern = eiPaths.get(implementation.getQualifiedName().toString());
if (urlPattern != null) {
if (!urlPattern.startsWith("/")) {
urlPattern = "/" + urlPattern;
}
if (urlPattern.endsWith("/*")) {
urlPattern = urlPattern.substring(0, urlPattern.length() - 2) + ei.getServiceName();
}
implementation.setPath(urlPattern);
}
}
jaxwsContext.add(ei);
addReferencedDataTypeDefinitions(ei);
}
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(Collections.singletonList(declaration), e);
}
throw e;
}
}
}
}
use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class Jackson1Module method addPotentialJacksonElement.
protected void addPotentialJacksonElement(Element declaration, LinkedList<Element> contextStack) {
try {
if (declaration instanceof TypeElement) {
if (!this.jacksonContext.isKnownTypeDefinition((TypeElement) declaration) && isExplicitTypeDefinition(declaration, this.jacksonContext.isHonorJaxb())) {
OneTimeLogMessage.JACKSON_1_DEPRECATED.log(this.context);
this.jacksonContext.add(this.jacksonContext.createTypeDefinition((TypeElement) declaration), contextStack);
}
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
contextStack = new LinkedList<>(contextStack);
contextStack.push(declaration);
throw new CompletionFailureException(contextStack, e);
}
throw e;
}
}
use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class SpringWebModule method addReferencedDataTypeDefinitions.
/**
* Add the referenced type definitions for the specified resource method.
*
* @param requestMapping The resource method.
*/
protected void addReferencedDataTypeDefinitions(RequestMapping requestMapping, LinkedList<Element> contextStack) {
ResourceEntityParameter ep = requestMapping.getEntityParameter();
if (ep != null) {
Set<String> consumes = requestMapping.getConsumesMediaTypes();
contextStack.push(ep.getDelegate());
TypeMirror type = ep.getType();
contextStack.push(requestMapping);
try {
for (MediaTypeDefinitionModule mediaTypeModule : this.mediaTypeModules) {
mediaTypeModule.addDataTypeDefinitions(type, consumes, contextStack);
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(contextStack, e);
}
throw e;
} finally {
contextStack.pop();
}
}
ResourceRepresentationMetadata outputPayload = requestMapping.getRepresentationMetadata();
if (outputPayload != null) {
TypeMirror type = outputPayload.getDelegate();
Set<String> produces = requestMapping.getProducesMediaTypes();
contextStack.push(requestMapping);
try {
for (MediaTypeDefinitionModule mediaTypeModule : this.mediaTypeModules) {
mediaTypeModule.addDataTypeDefinitions(type, produces, contextStack);
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(contextStack, e);
}
throw e;
} finally {
contextStack.pop();
}
}
List<? extends ResponseCode> statusCodes = requestMapping.getStatusCodes();
if (statusCodes != null) {
for (ResponseCode statusCode : statusCodes) {
TypeMirror type = statusCode.getType();
if (type != null) {
Set<String> produces = requestMapping.getProducesMediaTypes();
contextStack.push(requestMapping);
try {
for (MediaTypeDefinitionModule mediaTypeModule : this.mediaTypeModules) {
mediaTypeModule.addDataTypeDefinitions(type, produces, contextStack);
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(contextStack, e);
}
throw e;
} finally {
contextStack.pop();
}
}
}
}
}
use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class SpringWebModule method call.
@Override
public void call(EnunciateContext context) {
springContext = new EnunciateSpringWebContext(context, isDisableExamples());
DataTypeDetectionStrategy detectionStrategy = getDataTypeDetectionStrategy();
if (detectionStrategy != DataTypeDetectionStrategy.passive) {
Set<? extends Element> elements = detectionStrategy == DataTypeDetectionStrategy.local ? context.getLocalApiElements() : context.getApiElements();
for (Element declaration : elements) {
try {
// first loop through and gather all the controller advice.
if (declaration instanceof TypeElement) {
TypeElement element = (TypeElement) declaration;
Controller controllerInfo = AnnotationUtils.getMetaAnnotation(Controller.class, declaration);
if (controllerInfo != null || AnnotationUtils.getMetaAnnotation(ControllerAdvice.class, declaration) != null) {
springContext.add(new SpringControllerAdvice(element, springContext));
}
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(Collections.singletonList(declaration), e);
}
throw e;
}
}
for (Element declaration : elements) {
LinkedList<Element> contextStack = new LinkedList<>();
contextStack.push(declaration);
try {
if (declaration instanceof TypeElement) {
TypeElement element = (TypeElement) declaration;
Controller controllerInfo = AnnotationUtils.getMetaAnnotation(Controller.class, declaration);
if (controllerInfo != null) {
// add root resource.
SpringController springController = new SpringController(element, springContext);
List<RequestMapping> requestMappings = springController.getRequestMappings();
if (!requestMappings.isEmpty()) {
springContext.add(springController);
for (RequestMapping requestMapping : requestMappings) {
addReferencedDataTypeDefinitions(requestMapping, contextStack);
}
}
}
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(contextStack, e);
}
throw e;
} finally {
contextStack.pop();
}
}
}
// tidy up the application path.
String relativeContextPath = this.config.getString("application[@path]", "");
while (relativeContextPath.startsWith("/")) {
relativeContextPath = relativeContextPath.substring(1);
}
while (relativeContextPath.endsWith("/")) {
// trim off any leading slashes
relativeContextPath = relativeContextPath.substring(0, relativeContextPath.length() - 1);
}
springContext.setRelativeContextPath(relativeContextPath);
springContext.setGroupingStrategy(getGroupingStrategy());
springContext.setPathSortStrategy(getPathSortStrategy());
}
Aggregations