Skip to content

Commit

Permalink
Merge pull request hpcc-systems#17349 from kenrowland/HPCC-29381
Browse files Browse the repository at this point in the history
HPCC-29381 Improve XSD generation for ESP services
  • Loading branch information
GordonSmith authored Jul 13, 2023
2 parents c9bd9c5 + 8a7a098 commit 75bc83c
Show file tree
Hide file tree
Showing 20 changed files with 894 additions and 183 deletions.
1 change: 1 addition & 0 deletions esp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ HPCC_ADD_SUBDIRECTORY (test "PLATFORM")
HPCC_ADD_SUBDIRECTORY (tools "CLIENTTOOLS")
HPCC_ADD_SUBDIRECTORY (xslt)
HPCC_ADD_SUBDIRECTORY (esdllib)
HPCC_ADD_SUBDIRECTORY (esdlscriptlib)
HPCC_ADD_SUBDIRECTORY (applications)
HPCC_ADD_SUBDIRECTORY (espcommon)
if (LOGGING_SERVICE)
Expand Down
300 changes: 151 additions & 149 deletions esp/bindings/http/platform/httpbinding.cpp

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion esp/bindings/http/platform/httpbinding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ interface IEspWsdlSections
// virtual MethodInfoArray & queryQualifiedNames(IEspContext& ctx)=0;
virtual int getQualifiedNames(IEspContext& ctx, MethodInfoArray & methods)=0;
virtual int getXsdDefinition(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda)=0;
virtual int getXmlFilename(StringBuffer &filename)=0;
virtual int getWsdlMessages(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda)=0;
virtual int getWsdlPorts(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda)=0;
virtual int getWsdlBindings(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda)=0;
Expand Down Expand Up @@ -344,6 +345,7 @@ class esp_http_decl EspHttpBinding :
// MethodInfoArray &queryQualifiedNames(IEspContext& ctx) { m_methods.popAll(); getQualifiedNames(ctx,m_methods); return m_methods;};

int getXsdDefinition(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda){return 0;};
int getXmlFilename(StringBuffer &filename) {return 0;};
int getWsdlMessages(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda);
int getWsdlPorts(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda);
int getWsdlBindings(IEspContext &context, CHttpRequest *request, StringBuffer &content, const char *service, const char *method, bool mda);
Expand Down Expand Up @@ -427,9 +429,21 @@ class esp_http_decl EspHttpBinding :

static void escapeSingleQuote(StringBuffer& src, StringBuffer& escaped);

virtual bool getDefaultClientVersion(double &ver) {ver=0; return true;}

double getVersion(IEspContext &context)
{
double version = context.getClientVersion();
if (version == 0.0)
{
getDefaultClientVersion(version);
}
return version;
}

protected:
virtual bool basicAuth(IEspContext* ctx);
int getWsdlOrXsd(IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method, bool isWsdl);
int getServiceWsdlOrXsd(IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method, bool isWsdl);
virtual bool getSchema(StringBuffer& schema, IEspContext &ctx, CHttpRequest* req, const char *service, const char *method,bool standalone);
virtual void appendSchemaNamespaces(IPropertyTree *namespaces, IEspContext &ctx, CHttpRequest* req, const char *service, const char *method){}
void generateSampleXml(bool isRequest, IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *serv, const char *method);
Expand Down
16 changes: 2 additions & 14 deletions esp/esdllib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include_directories (
${HPCC_SOURCE_DIR}/system/include
${HPCC_SOURCE_DIR}/esp/esdllib
${HPCC_SOURCE_DIR}/esp/services/common
${HPCC_SOURCE_DIR}/esp/esdlscriptlib
${HPCC_SOURCE_DIR}/system/jlib
${HPCC_SOURCE_DIR}/system/security/shared
${HPCC_SOURCE_DIR}/rtl/eclrtl
Expand All @@ -43,23 +44,11 @@ set ( SRCS
esdl_def.cpp
esdl_def_helper.cpp
esdl_transformer2.cpp
esdl_script.cpp
params2xml.cpp
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/xpp/fxpp/FragmentedXmlPullParser.cpp;
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/xpp/xpp/xpputils.cpp
${HPCC_SOURCE_DIR}/esp/services/common/wsexcept.cpp
)

if (USE_LIBXSLT)
list (APPEND SRCS
esdl_xpath_extensions_libxml.cpp
)
else()
list (APPEND SRCS
esdl_xpath_extensions_unsupported.cpp
)
endif()

HPCC_ADD_LIBRARY( esdllib SHARED ${SRCS}
${HEADERS}
)
Expand All @@ -71,8 +60,7 @@ add_dependencies ( esdllib jlib espscm)
target_link_libraries ( esdllib
jlib
xmllib
thorhelper
esphttp
dllserver
)

IF (USE_LIBXSLT)
Expand Down
72 changes: 72 additions & 0 deletions esp/esdlscriptlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
################################################################################
# HPCC SYSTEMS software Copyright (C) 2013 HPCC Systems®.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
# Component: esdllib

project( esdllib )

include_directories (
${HPCC_SOURCE_DIR}/system/xmllib
${HPCC_SOURCE_DIR}/esp/bindings
${HPCC_SOURCE_DIR}/esp/bindings/http/client
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/xpp
${HPCC_SOURCE_DIR}/esp/platform
${HPCC_SOURCE_DIR}/system/include
${HPCC_SOURCE_DIR}/esp/services/common
${HPCC_SOURCE_DIR}/system/jlib
${HPCC_SOURCE_DIR}/system/security/shared
${HPCC_SOURCE_DIR}/rtl/eclrtl
${HPCC_SOURCE_DIR}/rtl/include #IXMLWriter
${HPCC_SOURCE_DIR}/common/dllserver #loading plugins
${HPCC_SOURCE_DIR}/system/masking/include
)

ADD_DEFINITIONS ( -D_USRDLL -DESDLSCRIPTLIB_EXPORTS )

set ( SRCS
esdl_script.cpp
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/xpp/fxpp/FragmentedXmlPullParser.cpp;
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/xpp/xpp/xpputils.cpp
)

if (USE_LIBXSLT)
list (APPEND SRCS
esdl_xpath_extensions_libxml.cpp
)
else()
list (APPEND SRCS
esdl_xpath_extensions_unsupported.cpp
)
endif()

HPCC_ADD_LIBRARY( esdlscriptlib SHARED ${SRCS}
${HEADERS}
)

install ( TARGETS esdlscriptlib RUNTIME DESTINATION bin LIBRARY DESTINATION lib )

add_dependencies ( esdlscriptlib jlib espscm)

target_link_libraries ( esdlscriptlib
jlib
dllserver
esphttp
)

IF (USE_LIBXSLT)
include_directories (
${LIBXML2_INCLUDE_DIR}
)
ENDIF()
Original file line number Diff line number Diff line change
Expand Up @@ -3133,7 +3133,7 @@ class CEsdlTransformOperationSetTraceOptions : public CEsdlTransformOperationWit
const char* locked = stag.getValue("locked");
if (!isEmptyString(locked))
m_locked.setown(compileXpath(locked));

if (!m_enabled && !m_locked)
recordError(ESDL_SCRIPT_MissingOperationAttr, "missing all options");
}
Expand Down Expand Up @@ -3911,11 +3911,11 @@ class CEsdlTransformMethodMap : public CInterfaceOf<IEsdlTransformMethodMap>
}
};

esdl_decl IEsdlScriptContext* createEsdlScriptContext(IEspContext* espCtx, IEsdlFunctionRegister* functionRegister, IDataMaskingEngine* engine)
esdlscript_decl IEsdlScriptContext* createEsdlScriptContext(IEspContext* espCtx, IEsdlFunctionRegister* functionRegister, IDataMaskingEngine* engine)
{
return new CEsdlScriptContext(espCtx, functionRegister, engine);
}
esdl_decl IEsdlTransformMethodMap *createEsdlTransformMethodMap()
esdlscript_decl IEsdlTransformMethodMap *createEsdlTransformMethodMap()
{
return new CEsdlTransformMethodMap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#ifndef ESDL_SCRIPT_HPP_
#define ESDL_SCRIPT_HPP_

#ifdef ESDLLIB_EXPORTS
#define esdl_decl DECL_EXPORT
#ifdef ESDLSCRIPTLIB_EXPORTS
#define esdlscript_decl DECL_EXPORT
#else
#define esdl_decl
#define esdlscript_decl
#endif

#include "jlib.hpp"
Expand All @@ -30,7 +30,7 @@
#include "jlog.hpp"
#include "esp.hpp"

#include "esdl_def.hpp"
//#include "esdl_def.hpp"

#include "datamaskingengine.hpp"
#include "tracer.h"
Expand Down Expand Up @@ -163,7 +163,7 @@ interface IEsdlScriptContext : extends ISectionalXmlDocModel
* The absence of a sectional document model in the parameter list implies the returned instance
* is responsible for creating its own model.
*/
extern "C" esdl_decl IEsdlScriptContext* createEsdlScriptContext(IEspContext* espCtx, IEsdlFunctionRegister* functionRegister, IDataMaskingEngine* engine);
extern "C" esdlscript_decl IEsdlScriptContext* createEsdlScriptContext(IEspContext* espCtx, IEsdlFunctionRegister* functionRegister, IDataMaskingEngine* engine);

interface IEsdlCustomTransform : extends IInterface
{
Expand Down Expand Up @@ -229,11 +229,11 @@ interface IEsdlTransformMethodMap : extends IInterface
virtual void bindFunctionCalls() = 0;
};

esdl_decl IEsdlTransformMethodMap *createEsdlTransformMethodMap();
esdlscript_decl IEsdlTransformMethodMap *createEsdlTransformMethodMap();

esdl_decl IEsdlCustomTransform *createEsdlCustomTransform(const char *scriptXml, const char *ns_prefix);
esdlscript_decl IEsdlCustomTransform *createEsdlCustomTransform(const char *scriptXml, const char *ns_prefix);

esdl_decl void processServiceAndMethodTransforms(IEsdlScriptContext * scriptCtx, std::initializer_list<IEsdlTransformSet *> const &transforms, const char *srcSection, const char *tgtSection);
esdl_decl void registerEsdlXPathExtensions(IXpathContext *xpathCtx, IEsdlScriptContext *scriptCtx, const StringArray &prefixes);
esdlscript_decl void processServiceAndMethodTransforms(IEsdlScriptContext * scriptCtx, std::initializer_list<IEsdlTransformSet *> const &transforms, const char *srcSection, const char *tgtSection);
esdlscript_decl void registerEsdlXPathExtensions(IXpathContext *xpathCtx, IEsdlScriptContext *scriptCtx, const StringArray &prefixes);

#endif /* ESDL_SCRIPT_HPP_ */
3 changes: 2 additions & 1 deletion esp/logging/logginglib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ include_directories (
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/Platform #CSoapRequestBinding
${HPCC_SOURCE_DIR}/esp/clients #edwin.h in generated/ws_loggingservice.esp
${HPCC_SOURCE_DIR}/esp/esdllib
${HPCC_SOURCE_DIR}/esp/esdlscriptlib
${HPCC_SOURCE_DIR}/common/thorhelper
)

Expand All @@ -58,5 +59,5 @@ target_link_libraries ( logginglib
jlib
xmllib
esphttp
esdllib
esdlscriptlib
)
5 changes: 4 additions & 1 deletion esp/protocols/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ include_directories(
./../../../system/security/shared
./../../../system/security/LdapSecurity
./../../../system/security/zcrypt
./../../../system/mp
./../../../system/mp
./../../../dali/base
./../../../common/workunit
${HPCC_SOURCE_DIR}/common/thorhelper
${HPCC_SOURCE_DIR}/esp/esdllib
)

add_definitions(-DESPHTTP_EXPORTS -DESP_TIMING -D_USRDLL -DESP_PLUGIN -DTXSUMMARY_EXPORTS)
Expand All @@ -76,6 +77,7 @@ if(USE_OPENLDAP)
endif()
HPCC_ADD_LIBRARY(esphttp SHARED ${SRCS})
add_dependencies(esphttp espscm)

install(TARGETS esphttp RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR})
target_link_libraries(
esphttp
Expand All @@ -86,6 +88,7 @@ target_link_libraries(
dalibase
thorhelper # this should not be dependent on the engine helper dll
workunit # neither should it be dependent on the wokunit dll
esdllib
)

if(LIBMEMCACHED_FOUND)
Expand Down
3 changes: 3 additions & 0 deletions esp/scm/additional.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ foreach ( loop_var ${ESPSCM_SRCS} )
set_source_files_properties(${ESPSCM_GENERATED_DIR}/${result}_esp.ipp PROPERTIES GENERATED TRUE)
set_source_files_properties(${ESPSCM_GENERATED_DIR}/${result}.xml PROPERTIES GENERATED TRUE)
set ( ESP_GENERATED_INCLUDES ${ESP_GENERATED_INCLUDES} ${ESPSCM_GENERATED_DIR}/${result}.esp ${ESPSCM_GENERATED_DIR}/${result}.hpp ${ESPSCM_GENERATED_DIR}/${result}.ipp ${ESPSCM_GENERATED_DIR}/${result}_esp.ipp ${ESPSCM_GENERATED_DIR}/${result}.xml )
if ( PLATFORM )
Install( FILES ${ESPSCM_GENERATED_DIR}/${result}.xml DESTINATION componentfiles/esdl_files COMPONENT Runtime )
endif ( PLATFORM )
endforeach ( loop_var ${ESPSCM_SRCS} )

include_directories ( ${ESPSCM_GENERATED_DIR} ${HPCC_SOURCE_DIR}/esp/espcommon)
3 changes: 3 additions & 0 deletions esp/scm/smcscm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ foreach ( loop_var ${ESPSCM_SRCS} )
set_source_files_properties(${ESPSCM_GENERATED_DIR}/${result}_esp.ipp PROPERTIES GENERATED TRUE)
set_source_files_properties(${ESPSCM_GENERATED_DIR}/${result}.xml PROPERTIES GENERATED TRUE)
set ( ESP_GENERATED_INCLUDES ${ESP_GENERATED_INCLUDES} ${ESPSCM_GENERATED_DIR}/${result}.esp ${ESPSCM_GENERATED_DIR}/${result}.hpp ${ESPSCM_GENERATED_DIR}/${result}.ipp ${ESPSCM_GENERATED_DIR}/${result}_esp.ipp ${ESPSCM_GENERATED_DIR}/${result}.xml )
if ( PLATFORM )
Install( FILES ${ESPSCM_GENERATED_DIR}/${result}.xml DESTINATION componentfiles/esdl_files COMPONENT Runtime )
endif ( PLATFORM )
endforeach ( loop_var ${ESPSCM_SRCS} )

include_directories ( ${ESPSCM_GENERATED_DIR} ${HPCC_SOURCE_DIR}/esp/espcommon )
2 changes: 2 additions & 0 deletions esp/services/esdl_svc_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ include_directories (
${HPCC_SOURCE_DIR}/rtl/eclrtl
${HPCC_SOURCE_DIR}/rtl/include
${HPCC_SOURCE_DIR}/esp/esdllib
${HPCC_SOURCE_DIR}/esp/esdlscriptlib
${HPCC_SOURCE_DIR}/esp/logging/logginglib
${HPCC_SOURCE_DIR}/esp/logging/loggingmanager
${CMAKE_BINARY_DIR}
Expand All @@ -86,6 +87,7 @@ target_link_libraries ( esdl_svc_engine
remote
dalibase
esdllib
esdlscriptlib
dllserver
dalibase
${COMMON_ESP_SERVICE_LIBS}
Expand Down
1 change: 1 addition & 0 deletions esp/services/ws_esdlconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ include_directories (
${HPCC_SOURCE_DIR}/esp/smc/SMCLib
${HPCC_SOURCE_DIR}/esp/services/esdl_svc_engine
${HPCC_SOURCE_DIR}/esp/esdllib
${HPCC_SOURCE_DIR}/esp/esdlscriptlib
${HPCC_SOURCE_DIR}/esp/logging/logginglib
${HPCC_SOURCE_DIR}/esp/logging/loggingmanager
${HPCC_SOURCE_DIR}/common/thorhelper
Expand Down
1 change: 1 addition & 0 deletions esp/xslt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ FOREACH( iFILES
${CMAKE_CURRENT_SOURCE_DIR}/esdl2monitor.xslt
${CMAKE_CURRENT_SOURCE_DIR}/esdl2monitor_cassandra.xslt
${CMAKE_CURRENT_SOURCE_DIR}/esxdl2xsd.xslt
${CMAKE_CURRENT_SOURCE_DIR}/esp_service_xml2xsd.xslt
${CMAKE_CURRENT_SOURCE_DIR}/esdl2java_srvbase.xslt
${CMAKE_CURRENT_SOURCE_DIR}/esdl2java_srvdummy.xslt
${CMAKE_CURRENT_SOURCE_DIR}/esdl2cpp_srvbasehpp.xslt
Expand Down
Loading

0 comments on commit 75bc83c

Please sign in to comment.