Search in sources :

Example 1 with Doc

use of com.sun.research.ws.wadl.Doc in project jersey by jersey.

the class WadlGeneratorResourceDocSupport method createMethod.

/**
     * @param resource Jersey resource component.
     * @param resourceMethod resource method.
     * @return the enhanced {@link com.sun.research.ws.wadl.Method}.
     * @see org.glassfish.jersey.server.wadl.WadlGenerator#createMethod(org.glassfish.jersey.server.model.Resource,
     * org.glassfish.jersey.server.model.ResourceMethod)
     */
public Method createMethod(final org.glassfish.jersey.server.model.Resource resource, final ResourceMethod resourceMethod) {
    final Method result = delegate.createMethod(resource, resourceMethod);
    final java.lang.reflect.Method method = resourceMethod.getInvocable().getDefinitionMethod();
    final MethodDocType methodDoc = resourceDoc.getMethodDoc(method.getDeclaringClass(), method);
    if (methodDoc != null && !isEmpty(methodDoc.getCommentText())) {
        final Doc doc = new Doc();
        doc.getContent().add(methodDoc.getCommentText());
        // doc.getOtherAttributes().put( new QName( "xmlns" ), "http://www.w3.org/1999/xhtml" );
        result.getDoc().add(doc);
    }
    return result;
}
Also used : MethodDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.MethodDocType) Doc(com.sun.research.ws.wadl.Doc) ResourceMethod(org.glassfish.jersey.server.model.ResourceMethod) Method(com.sun.research.ws.wadl.Method)

Example 2 with Doc

use of com.sun.research.ws.wadl.Doc in project jersey by jersey.

the class WadlGeneratorResourceDocSupport method createResource.

/**
     * @param r Jersey resource component for which the WADL reource is to be created.
     * @param path path where the resource is exposed.
     * @return the enhanced {@link com.sun.research.ws.wadl.Resource}.
     * @see org.glassfish.jersey.server.wadl.WadlGenerator#createResource(org.glassfish.jersey.server.model.Resource, String)
     */
public Resource createResource(final org.glassfish.jersey.server.model.Resource r, final String path) {
    final Resource result = delegate.createResource(r, path);
    for (final Class<?> resourceClass : r.getHandlerClasses()) {
        final ClassDocType classDoc = resourceDoc.getClassDoc(resourceClass);
        if (classDoc != null && !isEmpty(classDoc.getCommentText())) {
            final Doc doc = new Doc();
            doc.getContent().add(classDoc.getCommentText());
            result.getDoc().add(doc);
        }
    }
    return result;
}
Also used : ClassDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ClassDocType) Resource(com.sun.research.ws.wadl.Resource) Doc(com.sun.research.ws.wadl.Doc)

Example 3 with Doc

use of com.sun.research.ws.wadl.Doc in project jersey by jersey.

the class WadlGeneratorResourceDocSupport method addDoc.

private void addDoc(final List<Doc> docs, final String text) {
    if (!isEmpty(text)) {
        final Doc doc = new Doc();
        doc.getContent().add(text);
        docs.add(doc);
    }
}
Also used : Doc(com.sun.research.ws.wadl.Doc)

Example 4 with Doc

use of com.sun.research.ws.wadl.Doc in project jersey by jersey.

the class WadlApplicationContextImpl method attachExternalGrammar.

/**
     * Update the application object to include the generated grammar objects.
     */
private void attachExternalGrammar(final Application application, final ApplicationDescription applicationDescription, URI requestURI) {
    try {
        final String requestURIPath = requestURI.getPath();
        if (requestURIPath.endsWith("application.wadl")) {
            requestURI = UriBuilder.fromUri(requestURI).replacePath(requestURIPath.substring(0, requestURIPath.lastIndexOf('/') + 1)).build();
        }
        final String root = application.getResources().get(0).getBase();
        final UriBuilder extendedPath = root != null ? UriBuilder.fromPath(root).path("/application.wadl/") : UriBuilder.fromPath("./application.wadl/");
        final URI rootURI = root != null ? UriBuilder.fromPath(root).build() : null;
        // Add a reference to this grammar
        //
        final Grammars grammars;
        if (application.getGrammars() != null) {
            LOGGER.info(LocalizationMessages.ERROR_WADL_GRAMMAR_ALREADY_CONTAINS());
            grammars = application.getGrammars();
        } else {
            grammars = new Grammars();
            application.setGrammars(grammars);
        }
        for (final String path : applicationDescription.getExternalMetadataKeys()) {
            final URI schemaURI = extendedPath.clone().path(path).build();
            final String schemaPath = rootURI != null ? requestURI.relativize(schemaURI).toString() : schemaURI.toString();
            final Include include = new Include();
            include.setHref(schemaPath);
            final Doc doc = new Doc();
            doc.setLang("en");
            doc.setTitle("Generated");
            include.getDoc().add(doc);
            // Finally add to list
            grammars.getInclude().add(include);
        }
    } catch (final Exception e) {
        throw new ProcessingException(LocalizationMessages.ERROR_WADL_EXTERNAL_GRAMMAR(), e);
    }
}
Also used : Include(com.sun.research.ws.wadl.Include) Doc(com.sun.research.ws.wadl.Doc) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI) Grammars(com.sun.research.ws.wadl.Grammars) JAXBException(javax.xml.bind.JAXBException) ProcessingException(javax.ws.rs.ProcessingException) ProcessingException(javax.ws.rs.ProcessingException)

Example 5 with Doc

use of com.sun.research.ws.wadl.Doc in project jersey by jersey.

the class WadlGeneratorResourceDocSupport method addDocForExample.

private void addDocForExample(final List<Doc> docs, final String example) {
    if (!isEmpty(example)) {
        final Doc doc = new Doc();
        final Elements pElement = Elements.el("p").add(Elements.val("h6", "Example")).add(Elements.el("pre").add(Elements.val("code", example)));
        doc.getContent().add(pElement);
        docs.add(doc);
    }
}
Also used : Doc(com.sun.research.ws.wadl.Doc) Elements(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.xhtml.Elements)

Aggregations

Doc (com.sun.research.ws.wadl.Doc)8 QName (javax.xml.namespace.QName)2 Grammars (com.sun.research.ws.wadl.Grammars)1 Include (com.sun.research.ws.wadl.Include)1 Method (com.sun.research.ws.wadl.Method)1 Param (com.sun.research.ws.wadl.Param)1 Resource (com.sun.research.ws.wadl.Resource)1 URI (java.net.URI)1 ProcessingException (javax.ws.rs.ProcessingException)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 JAXBException (javax.xml.bind.JAXBException)1 ResourceMethod (org.glassfish.jersey.server.model.ResourceMethod)1 ClassDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ClassDocType)1 MethodDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.MethodDocType)1 ParamDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType)1 Elements (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.xhtml.Elements)1