/**
   * Creates endpoint element for REST service
   *
   * @param requestContext information about current request.
   * @param wadlElement wadl document.
   * @param version wadl version.
   * @return Endpoint Path.
   * @throws RegistryException If fails to create endpoint element.
   */
  private String createEndpointElement(
      RequestContext requestContext, OMElement wadlElement, String version)
      throws RegistryException {
    OMNamespace wadlNamespace = wadlElement.getNamespace();
    String wadlNamespaceURI = wadlNamespace.getNamespaceURI();
    String wadlNamespacePrefix = wadlNamespace.getPrefix();
    OMElement resourcesElement =
        wadlElement.getFirstChildWithName(
            new QName(wadlNamespaceURI, "resources", wadlNamespacePrefix));
    if (resourcesElement != null) {
      String endpointUrl = resourcesElement.getAttributeValue(new QName("base"));
      if (endpointUrl != null) {
        String endpointPath = EndpointUtils.deriveEndpointFromUrl(endpointUrl);
        String endpointName = EndpointUtils.deriveEndpointNameFromUrl(endpointUrl);
        String endpointContent =
            EndpointUtils.getEndpointContentWithOverview(
                endpointUrl, endpointPath, endpointName, version);
        OMElement endpointElement;
        try {
          endpointElement = AXIOMUtil.stringToOM(endpointContent);
        } catch (XMLStreamException e) {
          throw new RegistryException("Error in creating the endpoint element. ", e);
        }

        return RESTServiceUtils.addEndpointToRegistry(
            requestContext, endpointElement, endpointPath);
      } else {
        log.warn("Base path does not exist. endpoint creation may fail. ");
      }
    } else {
      log.warn("Resources element is null. ");
    }
    return null;
  }