protected Iterator<EndpointInterface> getLoop(TemplateModel model) throws TemplateException { WsdlInfo wsdl = this.wsdl; if (wsdl == null) { throw new MissingParameterException("wsdl"); } return wsdl.getEndpointInterfaces().iterator(); }
@Override public TemplateModel get(String key) throws TemplateModelException { if (("filename".equals(key)) || ("location".equals(key)) || ("inlineSchema".equals(key))) { return wrap(wsdlInfo.getProperty(key)); } else if ("importedNamespaces".equals(key)) { Set<String> importedNamespaces = wsdlInfo.getImportedNamespaces(); SchemaInfo associatedSchema = wsdlInfo.getAssociatedSchema(); Boolean inlineSchema = (Boolean) wsdlInfo.getProperty("inlineSchema"); if (associatedSchema != null && inlineSchema != null && inlineSchema) { importedNamespaces.addAll(associatedSchema.getReferencedNamespaces()); } return wrap(importedNamespaces); } else if ("importedSchemas".equals(key)) { TreeSet<SchemaInfo> schemas = new TreeSet<SchemaInfo>(new SchemaInfoComparator()); schemas.addAll(wsdlInfo.getImportedSchemas()); SchemaInfo associatedSchema = wsdlInfo.getAssociatedSchema(); Boolean inlineSchema = (Boolean) wsdlInfo.getProperty("inlineSchema"); if (associatedSchema != null && inlineSchema != null && inlineSchema) { schemas.addAll(associatedSchema.getImportedSchemas()); } return wrap(schemas); } return super.get(key); } }
/** * The namespace to schema map. * * @return The namespace to schema map. */ protected Map<String, SchemaInfo> getNamespacesToSchemas() { return getModel().getNamespacesToSchemas(); }
/** * The list of imported schemas. * * @return The list of imported schemas. */ public List<SchemaInfo> getImportedSchemas() { Set<String> importedNamespaces = getImportedNamespaces(); importedNamespaces.remove(getTargetNamespace()); //the "associated" schema is either inlined or included, but not imported. List<SchemaInfo> schemas = new ArrayList<SchemaInfo>(); for (String ns : importedNamespaces) { SchemaInfo schema = lookupSchema(ns); if (schema != null) { schemas.add(schema); } } return schemas; }
/** * Get the imported namespaces used by this WSDL. * * @return The imported namespaces used by this WSDL. */ public Set<String> getImportedNamespaces() { Collection<EndpointInterface> endpointInterfaces = getEndpointInterfaces(); if ((endpointInterfaces == null) || (endpointInterfaces.size() == 0)) { throw new IllegalStateException("WSDL for " + getTargetNamespace() + " has no endpoint interfaces!"); } HashSet<String> importedNamespaces = new HashSet<String>(); //always import the list of known namespaces. importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/"); importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/http/"); importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/mime/"); importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/soap/"); importedNamespaces.add("http://schemas.xmlsoap.org/soap/encoding/"); importedNamespaces.add("http://www.w3.org/2001/XMLSchema"); for (EndpointInterface endpointInterface : endpointInterfaces) { importedNamespaces.addAll(endpointInterface.getReferencedNamespaces()); } return importedNamespaces; }
wsdlInfo = new WsdlInfo(); wsdlInfo.setId(prefix); namespacesToWsdls.put(namespace, wsdlInfo); wsdlInfo.setTargetNamespace(namespace); wsdlInfo.getEndpointInterfaces().add(ei); this.endpointInterfaces.add(ei);
for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) { if (FacetFilter.accept(ei)) { for (WebMethod webMethod : ei.getWebMethods()) { if (wsdlInfo.getProperty("filename") == null) { throw new EnunciateException("WSDL " + wsdlInfo.getId() + " doesn't have a filename."); model.put("wsdlFileName", wsdlInfo.getProperty("filename")); for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) { if (FacetFilter.accept(ei)) { model.put("endpointInterface", ei);
String prefix = ns2prefix.get(wsdlInfo.getTargetNamespace()); if (prefix != null) { String file = prefix + ".wsdl"; wsdlInfo.setProperty("filename", file); wsdlInfo.setProperty("inlineSchema", inlineWSDLSchemas); wsdlInfo.setProperty("filename", customConfig.getFile()); wsdlInfo.setProperty("inlineSchema", customConfig.isInlineSchema()); String file = (String) wsdl.getProperty("filename"); File wsdlFile = new File(artifactDir, file); wsdl.setProperty("file", wsdlFile); FileArtifact wsdlArtifact = new FileArtifact(getName(), wsdl.getId() + ".wsdl", wsdlFile); wsdlArtifact.setDescription("WSDL file for namespace " + wsdl.getTargetNamespace()); getEnunciate().addArtifact(wsdlArtifact);
@Override public void initModel(EnunciateFreemarkerModel model) { super.initModel(model); if (!getModelInternal().getNamespacesToWSDLs().isEmpty()) { String docsDir = getDocsDir() == null ? "" : getDocsDir(); if (!docsDir.startsWith("/")) { docsDir = "/" + docsDir; } while (docsDir.endsWith("/")) { docsDir = docsDir.substring(0, docsDir.length() - 1); } for (WsdlInfo wsdlInfo : getModelInternal().getNamespacesToWSDLs().values()) { Object filename = wsdlInfo.getProperty("filename"); if (filename != null) { wsdlInfo.setProperty("redirectLocation", docsDir + "/" + filename); } } } EnunciateConfiguration config = model.getEnunciateConfig(); for (RootResource resource : model.getRootResources()) { for (ResourceMethod resourceMethod : resource.getResourceMethods(true)) { if (!resourceMethod.getMetaData().containsKey("defaultSubcontext")) { //if we don't have the defaultSubcontext set by some other jax-rs implementation provider module //then we need to set it ourselves. resourceMethod.putMetaData("defaultSubcontext", config == null ? "/rest" : config.getDefaultRestSubcontext()); } } } }
if (wsdlInfo.getProperty("file") != null) { File from = (File) wsdlInfo.getProperty("file"); String filename = wsdlInfo.getProperty("filename") != null ? (String) wsdlInfo.getProperty("filename") : from.getName(); File to = new File(getDocsBuildDir(), filename); enunciate.copyFile(from, to);
/** * Convenience method to lookup a namespace schema given a namespace. * * @param namespace The namespace for which to lookup the schema. * @return The schema info. */ protected SchemaInfo lookupSchema(String namespace) { if ("".equals(namespace)) { namespace = null; } return getNamespacesToSchemas().get(namespace); }
wsdlInfo = new WsdlInfo(); wsdlInfo.setId(prefix); namespacesToWsdls.put(namespace, wsdlInfo); wsdlInfo.setTargetNamespace(namespace); wsdlInfo.getEndpointInterfaces().add(ei); this.endpointInterfaces.add(ei);
/** * Get the imported namespaces used by this WSDL. * * @return The imported namespaces used by this WSDL. */ public Set<String> getImportedNamespaces() { Collection<EndpointInterface> endpointInterfaces = getEndpointInterfaces(); if ((endpointInterfaces == null) || (endpointInterfaces.size() == 0)) { throw new IllegalStateException("WSDL for " + getTargetNamespace() + " has no endpoint interfaces!"); } HashSet<String> importedNamespaces = new HashSet<String>(); //always import the list of known namespaces. importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/"); importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/http/"); importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/mime/"); importedNamespaces.add("http://schemas.xmlsoap.org/wsdl/soap/"); importedNamespaces.add("http://schemas.xmlsoap.org/soap/encoding/"); importedNamespaces.add("http://www.w3.org/2001/XMLSchema"); for (EndpointInterface endpointInterface : endpointInterfaces) { importedNamespaces.addAll(endpointInterface.getReferencedNamespaces()); } return importedNamespaces; }
/** * The list of imported schemas. * * @return The list of imported schemas. */ public List<SchemaInfo> getImportedSchemas() { Set<String> importedNamespaces = getImportedNamespaces(); importedNamespaces.remove(getTargetNamespace()); //the "associated" schema is either inlined or included, but not imported. List<SchemaInfo> schemas = new ArrayList<SchemaInfo>(); for (String ns : importedNamespaces) { SchemaInfo schema = lookupSchema(ns); if (schema != null) { schemas.add(schema); } } return schemas; }
if (wsdlInfo.getProperty("file") != null) { File from = (File) wsdlInfo.getProperty("file"); String filename = wsdlInfo.getProperty("filename") != null ? (String) wsdlInfo.getProperty("filename") : from.getName(); File to = new File(getBuildDir(), filename); enunciate.copyFile(from, to);
/** * Convenience method to lookup a namespace schema given a namespace. * * @param namespace The namespace for which to lookup the schema. * @return The schema info. */ protected SchemaInfo lookupSchema(String namespace) { if ("".equals(namespace)) { namespace = null; } return getNamespacesToSchemas().get(namespace); }
protected Iterator<ServiceEndpoint> getLoop(TemplateModel model) throws TemplateException { Set<ServiceEndpoint> interfaces = new TreeSet<ServiceEndpoint>(new Comparator<ServiceEndpoint>() { public int compare(ServiceEndpoint e1, ServiceEndpoint e2) { return e1.getServiceEndpointId().compareTo(e2.getServiceEndpointId()); } }); Collection<WsdlInfo> wsdls = getNamespacesToWSDLs().values(); for (WsdlInfo wsdl : wsdls) { for (EndpointInterface endpointInterface : wsdl.getEndpointInterfaces()) { for (EndpointImplementation impl : endpointInterface.getEndpointImplementations()) { interfaces.add(impl); } } } return interfaces.iterator(); }
String wsdlLocation = (String) wsdlInfo.getProperty("redirectLocation"); if (wsdlLocation != null) { wsdls.add(wsdlLocation);
/** * The namespace to schema map. * * @return The namespace to schema map. */ protected Map<String, SchemaInfo> getNamespacesToSchemas() { return getModel().getNamespacesToSchemas(); }
protected Iterator<EndpointInterface> getLoop(TemplateModel model) throws TemplateException { WsdlInfo wsdl = this.wsdl; if (wsdl == null) { throw new MissingParameterException("wsdl"); } Collection<EndpointInterface> eis = new ArrayList<EndpointInterface>(wsdl.getEndpointInterfaces()); if (considerFacets) { Iterator<EndpointInterface> vit = eis.iterator(); while (vit.hasNext()) { EndpointInterface next = vit.next(); if (!FacetFilter.accept(next)) { vit.remove(); } } } return eis.iterator(); }