Skip to content

Commit

Permalink
1099 implement download python template endpoint (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenSiegismund-GIP authored Aug 30, 2024
1 parent d35bcfe commit 5df77e0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
2 changes: 1 addition & 1 deletion blackedition/blackedition_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion modules/xmcp/gitIntegration/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RuntimeContextRequirements>
<RuntimeContextRequirement>
<ApplicationName>GuiHttp</ApplicationName>
<VersionName>1.2.8</VersionName>
<VersionName>1.2.9</VersionName>
</RuntimeContextRequirement>
</RuntimeContextRequirements>
</ApplicationInfo>
Expand Down
2 changes: 1 addition & 1 deletion modules/xmcp/guihttp/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<!-- ################# Version auch in blackedition_lib.sh updaten ########### -->
<Application applicationName="GuiHttp" comment="" factoryVersion="" versionName="1.2.8" xmlVersion="1.1">
<Application applicationName="GuiHttp" comment="" factoryVersion="" versionName="1.2.9" xmlVersion="1.1">
<ApplicationInfo>
<Description Lang="DE">GuiHTTPFilter</Description>
<Description Lang="EN">GuiHTTPFilter</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Operation> 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<Operation> 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;
}
}
2 changes: 1 addition & 1 deletion modules/xmcp/xypilot/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RuntimeContextRequirements>
<RuntimeContextRequirement>
<ApplicationName>GuiHttp</ApplicationName>
<VersionName>1.2.8</VersionName>
<VersionName>1.2.9</VersionName>
</RuntimeContextRequirement>
<RuntimeContextRequirement>
<ApplicationName>XyPilotMetricsDefaults</ApplicationName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,7 +83,7 @@ public static List<MethodInformation> loadOperations(List<Operation> operations)

public static List<MethodInformation> loadOperations(List<Operation> operations, boolean addMdmPath) {
if (operations == null || operations.isEmpty()) {
return null;
return Collections.emptyList();
}
List<MethodInformation> result = new ArrayList<MethodInformation>();
for (Operation op : operations) {
Expand Down

0 comments on commit 5df77e0

Please sign in to comment.