From 5df77e0f8d905a81bec9709177932d5fb57c14db Mon Sep 17 00:00:00 2001
From: Torben Siegismund
<127193495+TorbenSiegismund-GIP@users.noreply.github.com>
Date: Fri, 30 Aug 2024 15:55:35 +0200
Subject: [PATCH] 1099 implement download python template endpoint (#1100)
---
blackedition/blackedition_lib.sh | 2 +-
modules/xmcp/gitIntegration/application.xml | 2 +-
modules/xmcp/guihttp/application.xml | 2 +-
.../actions/BuildServiceImplAction.java | 58 ++++++++++---------
modules/xmcp/xypilot/application.xml | 2 +-
.../xfractwfe/python/PythonGeneration.java | 3 +-
6 files changed, 38 insertions(+), 31 deletions(-)
diff --git a/blackedition/blackedition_lib.sh b/blackedition/blackedition_lib.sh
index cac0ef22e..7e9b14961 100755
--- a/blackedition/blackedition_lib.sh
+++ b/blackedition/blackedition_lib.sh
@@ -30,7 +30,7 @@ ALL_DATAMODELTYPES=("mib","tr069","xsd");
#ACHTUNG: Version auch bei addRequirement zu default workspace berücksichtigen
ALL_APPLICATIONS="Base Processing"; #Default-Applications, die immer installiert sein sollten
APPMGMTVERSION=1.0.10
-GUIHTTPVERSION=1.2.8
+GUIHTTPVERSION=1.2.9
SNMPSTATVERSION=1.0.3
PROCESSINGVERSION=1.0.21
ALL_REPOSITORYACCESSES=("svn");
diff --git a/modules/xmcp/gitIntegration/application.xml b/modules/xmcp/gitIntegration/application.xml
index a029ed64b..080e51f5f 100644
--- a/modules/xmcp/gitIntegration/application.xml
+++ b/modules/xmcp/gitIntegration/application.xml
@@ -20,7 +20,7 @@
GuiHttp
- 1.2.8
+ 1.2.9
diff --git a/modules/xmcp/guihttp/application.xml b/modules/xmcp/guihttp/application.xml
index 0b04d3035..800fb2e29 100644
--- a/modules/xmcp/guihttp/application.xml
+++ b/modules/xmcp/guihttp/application.xml
@@ -17,7 +17,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
-
+
GuiHTTPFilter
GuiHTTPFilter
diff --git a/modules/xmcp/guihttp/filterimpl/GUIHTTPFilter/src/com/gip/xyna/xact/trigger/actions/BuildServiceImplAction.java b/modules/xmcp/guihttp/filterimpl/GUIHTTPFilter/src/com/gip/xyna/xact/trigger/actions/BuildServiceImplAction.java
index b31d71762..040c74080 100644
--- a/modules/xmcp/guihttp/filterimpl/GUIHTTPFilter/src/com/gip/xyna/xact/trigger/actions/BuildServiceImplAction.java
+++ b/modules/xmcp/guihttp/filterimpl/GUIHTTPFilter/src/com/gip/xyna/xact/trigger/actions/BuildServiceImplAction.java
@@ -32,6 +32,7 @@
import com.gip.xyna.xact.trigger.HTTPTriggerConnection;
import com.gip.xyna.xdev.xfractmod.xmdm.ConnectionFilter.FilterResponse;
import com.gip.xyna.xfmg.xfctrl.revisionmgmt.RevisionManagement;
+import com.gip.xyna.xmcp.XynaMultiChannelPortalBase;
import com.gip.xyna.xprc.xfractwfe.generation.DOM;
import com.gip.xyna.xprc.xfractwfe.generation.GenerationBase;
import com.gip.xyna.xprc.xfractwfe.generation.GenerationBaseCache;
@@ -65,44 +66,49 @@ public FilterResponse act(Logger logger, HTTPTriggerConnection tc) throws XynaEx
logger.info("got service implementation template request");
String fqClassNameDOM = tc.getFirstValueOfParameter("datatype");
String workspaceName = tc.getFirstValueOfParameter("workspace");
+ String language = tc.getFirstValueOfParameter("language");
+ boolean isJava = "java".equals(language);
RevisionManagement revisionManagement = XynaFactory.getInstance().getFactoryManagement().getXynaFactoryControl().getRevisionManagement();
Long revision = revisionManagement.getRevision(null, null, workspaceName);
- GenerationBase gb = GenerationBase.getOrCreateInstance(fqClassNameDOM, new GenerationBaseCache(), revision);
- gb.parseGeneration(false/*saved*/, false, false);
+ DOM dom = DOM.getOrCreateInstance(fqClassNameDOM, new GenerationBaseCache(), revision);
+ dom.parseGeneration(false/*saved*/, false, false);
- if(gb instanceof DOM) {
- boolean containsServiceCall = false;
- boolean hasJavaInstanceMethod = false;
- DOM dom = (DOM)gb;
- List operations = dom.getOperations();
- for (Operation op : operations) {
- if(op instanceof JavaOperation && !op.isStatic()) {
- hasJavaInstanceMethod = true;
- JavaOperation jop = (JavaOperation)op;
- if(jop.getImpl() != null && jop.getImpl().contains("getImplementationOfInstanceMethods()")) {
- containsServiceCall = true;
- break;
- }
- }
- }
- if(hasJavaInstanceMethod && !containsServiceCall) {
- String log = "Datatype " + fqClassNameDOM + " has no member service with service call implementation.";
- tc.sendError(log);
- logger.error(log);
- return FilterResponse.responsibleWithoutXynaorder();
- }
+ if (isJava && !validateJava(dom)) {
+ String log = "Datatype " + fqClassNameDOM + " has no member service with service call implementation.";
+ tc.sendError(log);
+ logger.error(log);
+ return FilterResponse.responsibleWithoutXynaorder();
}
- try (InputStream is = XynaFactory.getInstance().getXynaMultiChannelPortal().getServiceImplTemplate(fqClassNameDOM, revision, true)){
+
+ XynaMultiChannelPortalBase multiChanelPortal = XynaFactory.getInstance().getXynaMultiChannelPortal();
+
+ try(InputStream is = isJava ?
+ multiChanelPortal.getServiceImplTemplate(fqClassNameDOM, revision, true) :
+ multiChanelPortal.getPythonServiceImplTemplate(fqClassNameDOM, revision, true)) {
logger.debug("sending built service implementation template");
tc.sendResponse(HTTPTriggerConnection.HTTP_OK, HTTPTriggerConnection.MIME_DEFAULT_BINARY, new Properties(), is);
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new Ex_FileAccessException("unknown", e);
- }
+ }
return FilterResponse.responsibleWithoutXynaorder();
}
-
+
+ private boolean validateJava(DOM dom) {
+ boolean hasJavaInstanceMethod = false;
+ List operations = dom.getOperations();
+ for (Operation op : operations) {
+ if(op instanceof JavaOperation && !op.isStatic()) {
+ hasJavaInstanceMethod = true;
+ JavaOperation jop = (JavaOperation)op;
+ if (jop.implementedInJavaLib()) {
+ return true;
+ }
+ }
+ }
+ return !hasJavaInstanceMethod;
+ }
}
diff --git a/modules/xmcp/xypilot/application.xml b/modules/xmcp/xypilot/application.xml
index 663730568..7ac06d3a0 100644
--- a/modules/xmcp/xypilot/application.xml
+++ b/modules/xmcp/xypilot/application.xml
@@ -20,7 +20,7 @@
GuiHttp
- 1.2.8
+ 1.2.9
XyPilotMetricsDefaults
diff --git a/server/src/com/gip/xyna/xprc/xfractwfe/python/PythonGeneration.java b/server/src/com/gip/xyna/xprc/xfractwfe/python/PythonGeneration.java
index e0438ccce..3418e356b 100644
--- a/server/src/com/gip/xyna/xprc/xfractwfe/python/PythonGeneration.java
+++ b/server/src/com/gip/xyna/xprc/xfractwfe/python/PythonGeneration.java
@@ -21,6 +21,7 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -82,7 +83,7 @@ public static List loadOperations(List operations)
public static List loadOperations(List operations, boolean addMdmPath) {
if (operations == null || operations.isEmpty()) {
- return null;
+ return Collections.emptyList();
}
List result = new ArrayList();
for (Operation op : operations) {