Ejemplo n.º 1
0
  private void setServiceDefinitionForWSDL2(org.apache.woden.wsdl20.Description definition, API api)
      throws APIManagementException {
    org.apache.woden.wsdl20.Service[] serviceMap = definition.getServices();
    URL addressURI;
    try {
      for (org.apache.woden.wsdl20.Service svc : serviceMap) {
        Endpoint[] portMap = svc.getEndpoints();
        for (Endpoint endpoint : portMap) {
          EndpointElement element = endpoint.toElement();

          addressURI = endpoint.getAddress().toURL();
          if (addressURI == null) {
            break;
          } else {
            String endpointTransport =
                determineURLTransport(endpoint.getAddress().getScheme(), api.getTransports());
            setAddressUrl(
                element,
                new URI(
                    APIUtil.getGatewayendpoint(endpointTransport)
                        + api.getContext()
                        + "/"
                        + api.getId().getVersion()));
          }
        }
      }

    } catch (Exception e) {
      log.error("Error occured while getting the wsdl address location", e);
      throw new APIManagementException(e);
    }
  }
  @Override
  public VelocityContext getContext() {
    VelocityContext context = super.getContext();
    if (api.getTransports().contains(",")) {
      List<String> transports =
          new ArrayList<String>(Arrays.asList(api.getTransports().split(",")));
      if (transports.contains(Constants.TRANSPORT_HTTP)
          && transports.contains(Constants.TRANSPORT_HTTPS)) {
        context.put("transport", "");
      }
    } else {
      context.put("transport", api.getTransports());
    }

    return context;
  }
Ejemplo n.º 3
0
  /**
   * Get the addressURl from the Extensibility element
   *
   * @param exElement - {@link ExtensibilityElement}
   * @throws APIManagementException
   */
  private void setAddressUrl(ExtensibilityElement exElement, String transports, API api)
      throws APIManagementException {

    if (exElement instanceof SOAP12AddressImpl) {
      ((SOAP12AddressImpl) exElement)
          .setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
    } else if (exElement instanceof SOAPAddressImpl) {
      ((SOAPAddressImpl) exElement)
          .setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
    } else if (exElement instanceof HTTPAddressImpl) {
      ((HTTPAddressImpl) exElement)
          .setLocationURI(APIUtil.getGatewayendpoint(transports) + api.getContext());
    } else {
      String msg = "Unsupported WSDL errors!";
      log.error(msg);
      throw new APIManagementException(msg);
    }
  }
Ejemplo n.º 4
0
  /**
   * Create the WSDL definition <javax.wsdl.Definition> from the baseURI of the WSDL
   *
   * @return {@link Definition} - WSDL4j definition constructed form the wsdl original baseuri
   * @throws APIManagementException
   * @throws WSDLException
   */
  private Definition readWSDLFile(API api) throws APIManagementException, WSDLException {
    WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
    // switch off the verbose mode
    reader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
    reader.setFeature("javax.wsdl.importDocuments", false);

    Definition wsdlDefinition;
    if (log.isDebugEnabled()) {
      log.debug("Reading  the WSDL. Base uri is " + baseURI);
    }
    wsdlDefinition = reader.readWSDL(api.getWsdlUrl());
    return wsdlDefinition;
  }
Ejemplo n.º 5
0
  /**
   * Clear the actual service Endpoint and use Gateway Endpoint instead of the actual Endpoint.
   *
   * @param definition - {@link Definition} - WSDL4j wsdl definition
   * @throws APIManagementException
   */
  private void setServiceDefinition(Definition definition, API api) throws APIManagementException {

    Map serviceMap = definition.getAllServices();
    Iterator serviceItr = serviceMap.entrySet().iterator();
    URL addressURI;
    try {
      while (serviceItr.hasNext()) {
        Map.Entry svcEntry = (Map.Entry) serviceItr.next();
        Service svc = (Service) svcEntry.getValue();
        Map portMap = svc.getPorts();
        Iterator portItr = portMap.entrySet().iterator();
        while (portItr.hasNext()) {
          Map.Entry portEntry = (Map.Entry) portItr.next();
          Port port = (Port) portEntry.getValue();

          List<ExtensibilityElement> extensibilityElementList = port.getExtensibilityElements();
          for (int i = 0; i < extensibilityElementList.size(); i++) {

            ExtensibilityElement extensibilityElement =
                (ExtensibilityElement) port.getExtensibilityElements().get(i);

            addressURI = new URL(getAddressUrl(extensibilityElement));
            if (addressURI == null) {
              break;
            } else {
              String endpointTransport =
                  determineURLTransport(addressURI.getProtocol(), api.getTransports());
              setAddressUrl(extensibilityElement, endpointTransport, api);
            }
          }
        }
      }
    } catch (Exception e) {
      log.error("Error occured while getting the wsdl address location", e);
      throw new APIManagementException(e);
    }
  }
Ejemplo n.º 6
0
 public int compare(API api1, API api2) {
   return api1.getId().getApiName().compareToIgnoreCase(api2.getId().getApiName());
 }