use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class JaxrsModule method call.
@Override
public void call(EnunciateContext context) {
jaxrsContext = new EnunciateJaxrsContext(context, isDisableExamples());
DataTypeDetectionStrategy detectionStrategy = getDataTypeDetectionStrategy();
String relativeContextPath = "";
if (detectionStrategy != DataTypeDetectionStrategy.passive) {
Set<? extends Element> elements = detectionStrategy == DataTypeDetectionStrategy.local ? context.getLocalApiElements() : context.getApiElements();
for (Element declaration : elements) {
LinkedList<Element> contextStack = new LinkedList<>();
contextStack.push(declaration);
try {
if (declaration instanceof TypeElement) {
TypeElement element = (TypeElement) declaration;
if ("org.glassfish.jersey.server.wadl.internal.WadlResource".equals(element.getQualifiedName().toString())) {
// known internal wadl resource not to be documented.
continue;
}
if (isIgnored(declaration)) {
continue;
}
javax.ws.rs.Path pathInfo = declaration.getAnnotation(javax.ws.rs.Path.class);
jakarta.ws.rs.Path pathInfo2 = declaration.getAnnotation(jakarta.ws.rs.Path.class);
if (pathInfo != null || pathInfo2 != null) {
// add root resource.
RootResource rootResource = new RootResource(element, jaxrsContext);
jaxrsContext.add(rootResource);
for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
addReferencedDataTypeDefinitions(resourceMethod, contextStack);
}
}
javax.ws.rs.ext.Provider providerInfo = declaration.getAnnotation(javax.ws.rs.ext.Provider.class);
jakarta.ws.rs.ext.Provider providerInfo2 = declaration.getAnnotation(jakarta.ws.rs.ext.Provider.class);
if (providerInfo != null || providerInfo2 != null) {
// add jax-rs provider
jaxrsContext.addJAXRSProvider(element);
}
javax.ws.rs.ApplicationPath applicationPathInfo = declaration.getAnnotation(javax.ws.rs.ApplicationPath.class);
jakarta.ws.rs.ApplicationPath applicationPathInfo2 = declaration.getAnnotation(jakarta.ws.rs.ApplicationPath.class);
if (applicationPathInfo != null || applicationPathInfo2 != null) {
relativeContextPath = applicationPathInfo != null ? applicationPathInfo.value() : applicationPathInfo2.value();
}
}
} catch (RuntimeException e) {
if (e.getClass().getName().endsWith("CompletionFailure")) {
throw new CompletionFailureException(contextStack, e);
}
throw e;
} finally {
contextStack.pop();
}
}
}
// tidy up the application path.
relativeContextPath = this.config.getString("application[@path]", relativeContextPath);
relativeContextPath = sanitizeContextPath(relativeContextPath);
jaxrsContext.setRelativeContextPath(relativeContextPath);
jaxrsContext.setGroupingStrategy(getGroupingStrategy());
jaxrsContext.setPathSortStrategy(getPathSortStrategy());
if (jaxrsContext.getRootResources().size() > 0) {
this.enunciate.addArtifact(new JaxrsRootResourceClassListArtifact(this.jaxrsContext));
}
if (this.jaxrsContext.getProviders().size() > 0) {
this.enunciate.addArtifact(new JaxrsProviderClassListArtifact(this.jaxrsContext));
}
}
use of com.webcohesion.enunciate.CompletionFailureException in project enunciate by stoicflame.
the class JaxwsModule method addReferencedTypeDefinitions.
protected void addReferencedTypeDefinitions(WebMethod webMethod, LinkedList<Element> contextStack) {
contextStack.push(webMethod);
try {
WebResult result = webMethod.getWebResult();
this.jaxbModule.getJaxbContext().addReferencedTypeDefinitions(result.isAdapted() ? result.getAdapterType() : result.getType(), contextStack);
for (WebParam webParam : webMethod.getWebParameters()) {
this.jaxbModule.getJaxbContext().addReferencedTypeDefinitions(webParam.isAdapted() ? webParam.getAdapterType() : webParam.getType(), contextStack);
}
for (WebFault webFault : webMethod.getWebFaults()) {
addReferencedTypeDefinitions(webFault, 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 addReferencedDataTypeDefinitions.
protected void addReferencedDataTypeDefinitions(EndpointInterface ei) {
LinkedList<Element> contextStack = new LinkedList<>();
contextStack.push(ei);
try {
for (WebMethod webMethod : ei.getWebMethods()) {
addReferencedTypeDefinitions(webMethod, 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 JaxbModule method addPotentialJaxbElement.
public void addPotentialJaxbElement(Element declaration, LinkedList<Element> contextStack) {
try {
if (declaration instanceof TypeElement) {
XmlRegistry registryMetadata = declaration.getAnnotation(XmlRegistry.class);
if (registryMetadata != null) {
Registry registry = new Registry((TypeElement) declaration, jaxbContext);
this.jaxbContext.add(registry);
} else if (!this.jaxbContext.isKnownTypeDefinition((TypeElement) declaration) && isExplicitTypeDefinition(declaration)) {
this.jaxbContext.add(this.jaxbContext.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 JaxrsModule method addReferencedDataTypeDefinitions.
/**
* Add the referenced type definitions for the specified resource method.
*
* @param resourceMethod The resource method.
*/
protected void addReferencedDataTypeDefinitions(ResourceMethod resourceMethod, LinkedList<Element> contextStack) {
if (AnnotationUtils.isIgnored(resourceMethod)) {
return;
}
ResourceEntityParameter ep = resourceMethod.getEntityParameter();
if (ep != null) {
Set<com.webcohesion.enunciate.modules.jaxrs.model.util.MediaType> consumesMt = resourceMethod.getConsumesMediaTypes();
Set<String> consumes = new TreeSet<>();
for (MediaType mediaType : consumesMt) {
consumes.add(mediaType.getMediaType());
}
contextStack.push(ep.getDelegate());
TypeMirror type = ep.getType();
contextStack.push(resourceMethod);
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 = resourceMethod.getRepresentationMetadata();
if (outputPayload != null) {
TypeMirror type = outputPayload.getDelegate();
Set<com.webcohesion.enunciate.modules.jaxrs.model.util.MediaType> producesMt = resourceMethod.getProducesMediaTypes();
Set<String> produces = new TreeSet<>();
for (MediaType mediaType : producesMt) {
produces.add(mediaType.getMediaType());
}
contextStack.push(resourceMethod);
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 = resourceMethod.getStatusCodes();
if (statusCodes != null) {
for (ResponseCode statusCode : statusCodes) {
TypeMirror type = statusCode.getType();
if (type != null) {
Set<com.webcohesion.enunciate.modules.jaxrs.model.util.MediaType> producesMt = resourceMethod.getProducesMediaTypes();
Set<String> produces = new TreeSet<>();
for (MediaType mediaType : producesMt) {
produces.add(mediaType.getMediaType());
}
contextStack.push(resourceMethod);
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();
}
}
}
}
}
Aggregations