final String requestURIPath = requestURI.getPath(); final String root = application.getResources().get(0).getBase(); final UriBuilder extendedPath = root != null ? UriBuilder.fromPath(root).path("/application.wadl/") : UriBuilder.fromPath("./application.wadl/"); if (application.getGrammars() != null) { LOGGER.info(LocalizationMessages.ERROR_WADL_GRAMMAR_ALREADY_CONTAINS()); grammars = application.getGrammars(); } else { grammars = new Grammars(); application.setGrammars(grammars); final String schemaPath = rootURI != null ? requestURI.relativize(schemaURI).toString() : schemaURI.toString(); final Doc doc = new Doc(); doc.setLang("en"); doc.setTitle("Generated"); include.getDoc().add(doc);
@Override public Application createApplication() { return new Application(); }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }
/** * @return application * @see org.glassfish.jersey.server.wadl.WadlGenerator#createApplication() */ public Application createApplication() { final Application result = _delegate.createApplication(); if (result.getGrammars() != null && !overrideGrammars) { LOG.info("The wadl application created by the delegate (" + _delegate + ") already contains a grammars element," + " we're adding elements of the provided grammars file."); if (!_grammars.getAny().isEmpty()) { result.getGrammars().getAny().addAll(_grammars.getAny()); } if (!_grammars.getDoc().isEmpty()) { result.getGrammars().getDoc().addAll(_grammars.getDoc()); } if (!_grammars.getInclude().isEmpty()) { result.getGrammars().getInclude().addAll(_grammars.getInclude()); } } else { result.setGrammars(_grammars); } return result; }
@Override public Application getApplication(final UriInfo info, final org.glassfish.jersey.server.model.Resource resource, final boolean detailedWadl) { // Get the root application description // final ApplicationDescription description = getApplication(info, detailedWadl); final WadlGenerator wadlGenerator = wadlGeneratorConfig.createWadlGenerator(injectionManager); final Application application = new WadlBuilder(wadlGenerator, detailedWadl, info).generate(description, resource); if (application == null) { return null; } for (final Resources resources : application.getResources()) { resources.setBase(info.getBaseUri().toString()); } // Attach any grammar we may have attachExternalGrammar(application, description, info.getRequestUri()); for (final Resources resources : application.getResources()) { final Resource r = resources.getResource().get(0); r.setPath(info.getBaseUri().relativize(info.getAbsolutePath()).toString()); // remove path params since path is fixed at this point r.getParam().clear(); } return application; }
@Override public ApplicationDescription getApplication(UriInfo uriInfo) { ApplicationDescription a = getWadlBuilder().generate(providers,fap, uriInfo, rootResources); final Application application = a.getApplication(); for (Resources resources : application.getResources()) { if (resources.getBase() == null) { resources.setBase(uriInfo.getBaseUri().toString()); } } attachExternalGrammar(application, a, uriInfo.getRequestUri()); return a; }
private void addVersion(Application wadlApplication) { // Include Jersey version as doc element with generatedBy attribute Doc d = new Doc(); d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "generatedBy", "jersey"), Version.getBuildId()); wadlApplication.getDoc().add(d); }
/** * Generate WADL for a resource. * * @param resource the resource * @param description the overall application description so we can * @return the JAXB WADL application bean */ public Application generate( ApplicationDescription description, org.glassfish.jersey.server.model.Resource resource) { try { Application wadlApplication = _wadlGenerator.createApplication(); Resources wadlResources = _wadlGenerator.createResources(); Resource wadlResource = generateResource(resource, null); if (wadlResource == null) { return null; } wadlResources.getResource().add(wadlResource); wadlApplication.getResources().add(wadlResources); addVersion(wadlApplication); // Attach the data to the parts of the model _wadlGenerator.attachTypes(description); // Return the WADL return wadlApplication; } catch (Exception e) { throw new ProcessingException(LocalizationMessages.ERROR_WADL_BUILDER_GENERATION_RESOURCE(resource), e); } }
/** * @return the application * @see org.glassfish.jersey.server.wadl.WadlGenerator#createApplication() */ public Application createApplication() { final Application result = _delegate.createApplication(); if (_applicationDocs != null && _applicationDocs.getDocs() != null && !_applicationDocs.getDocs().isEmpty()) { result.getDoc().addAll(_applicationDocs.getDocs()); } return result; }
@Override public Application getApplication(final UriInfo info, final org.glassfish.jersey.server.model.Resource resource, final boolean detailedWadl) { // Get the root application description // final ApplicationDescription description = getApplication(info, detailedWadl); final WadlGenerator wadlGenerator = wadlGeneratorConfig.createWadlGenerator(injectionManager); final Application application = new WadlBuilder(wadlGenerator, detailedWadl, info).generate(description, resource); if (application == null) { return null; } for (final Resources resources : application.getResources()) { resources.setBase(info.getBaseUri().toString()); } // Attach any grammar we may have attachExternalGrammar(application, description, info.getRequestUri()); for (final Resources resources : application.getResources()) { final Resource r = resources.getResource().get(0); r.setPath(info.getBaseUri().relativize(info.getAbsolutePath()).toString()); // remove path params since path is fixed at this point r.getParam().clear(); } return application; }
@Override public ApplicationDescription getApplication(final UriInfo uriInfo, final boolean detailedWadl) { final ApplicationDescription applicationDescription = getWadlBuilder(detailedWadl, uriInfo) .generate(resourceContext.getResourceModel().getRootResources()); final Application application = applicationDescription.getApplication(); for (final Resources resources : application.getResources()) { if (resources.getBase() == null) { resources.setBase(uriInfo.getBaseUri().toString()); } } attachExternalGrammar(application, applicationDescription, uriInfo.getRequestUri()); return applicationDescription; }
private void addVersion(Application wadlApplication) { // Include Jersey version as doc element with generatedBy attribute Doc d = new Doc(); d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "generatedBy", "jersey"), Version.getBuildId()); wadlApplication.getDoc().add(d); }
/** * @return application * @see org.glassfish.jersey.server.wadl.WadlGenerator#createApplication() */ public Application createApplication() { final Application result = _delegate.createApplication(); if (result.getGrammars() != null && !overrideGrammars) { LOG.info("The wadl application created by the delegate (" + _delegate + ") already contains a grammars element," + " we're adding elements of the provided grammars file."); if (!_grammars.getAny().isEmpty()) { result.getGrammars().getAny().addAll(_grammars.getAny()); } if (!_grammars.getDoc().isEmpty()) { result.getGrammars().getDoc().addAll(_grammars.getDoc()); } if (!_grammars.getInclude().isEmpty()) { result.getGrammars().getInclude().addAll(_grammars.getInclude()); } } else { result.setGrammars(_grammars); } return result; }
/** * Generate WADL for a resource. * * @param resource the resource * @param description the overall application description so we can * @return the JAXB WADL application bean */ public Application generate( ApplicationDescription description, org.glassfish.jersey.server.model.Resource resource) { try { Application wadlApplication = _wadlGenerator.createApplication(); Resources wadlResources = _wadlGenerator.createResources(); Resource wadlResource = generateResource(resource, null); if (wadlResource == null) { return null; } wadlResources.getResource().add(wadlResource); wadlApplication.getResources().add(wadlResources); addVersion(wadlApplication); // Attach the data to the parts of the model _wadlGenerator.attachTypes(description); // Return the WADL return wadlApplication; } catch (Exception e) { throw new ProcessingException(LocalizationMessages.ERROR_WADL_BUILDER_GENERATION_RESOURCE(resource), e); } }
/** * @return the application * @see org.glassfish.jersey.server.wadl.WadlGenerator#createApplication() */ public Application createApplication() { final Application result = _delegate.createApplication(); if (_applicationDocs != null && _applicationDocs.getDocs() != null && !_applicationDocs.getDocs().isEmpty()) { result.getDoc().addAll(_applicationDocs.getDocs()); } return result; }
final String requestURIPath = requestURI.getPath(); final String root = application.getResources().get(0).getBase(); final UriBuilder extendedPath = root != null ? UriBuilder.fromPath(root).path("/application.wadl/") : UriBuilder.fromPath("./application.wadl/"); if (application.getGrammars() != null) { LOGGER.info(LocalizationMessages.ERROR_WADL_GRAMMAR_ALREADY_CONTAINS()); grammars = application.getGrammars(); } else { grammars = new Grammars(); application.setGrammars(grammars); final String schemaPath = rootURI != null ? requestURI.relativize(schemaURI).toString() : schemaURI.toString(); final Doc doc = new Doc(); doc.setLang("en"); doc.setTitle("Generated"); include.getDoc().add(doc);
@Override public Application getApplication(UriInfo info, AbstractResource resource, String path) { // Get the root application description // ApplicationDescription description = getApplication(info); WadlGenerator wadlGenerator = wadlGeneratorConfig.createWadlGenerator(); Application a = path == null ? new WadlBuilder( wadlGenerator ).generate(providers,fap,info, description,resource) : new WadlBuilder( wadlGenerator ).generate(providers, fap, info, description, resource, path); for (Resources resources : a.getResources()) { resources.setBase(info.getBaseUri().toString()); } // Attach any grammar we may have attachExternalGrammar(a, description, info.getRequestUri()); for (Resources resources : a.getResources()) { final Resource r = resources.getResource().get(0); r.setPath(info.getBaseUri().relativize(info.getAbsolutePath()).toString()); // remove path params since path is fixed at this point r.getParam().clear(); } return a; }
@Override public ApplicationDescription getApplication(final UriInfo uriInfo, final boolean detailedWadl) { final ApplicationDescription applicationDescription = getWadlBuilder(detailedWadl, uriInfo) .generate(resourceContext.getResourceModel().getRootResources()); final Application application = applicationDescription.getApplication(); for (final Resources resources : application.getResources()) { if (resources.getBase() == null) { resources.setBase(uriInfo.getBaseUri().toString()); } } attachExternalGrammar(application, applicationDescription, uriInfo.getRequestUri()); return applicationDescription; }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }
private void addVersion(Application wadlApplication) { // Include Jersey version as doc element with generatedBy attribute Doc d = new Doc(); d.getOtherAttributes().put(new QName("http://jersey.java.net/", "generatedBy", "jersey"), BuildId.getBuildId()); wadlApplication.getDoc().add(0, d); }