Skip to content

Commit

Permalink
Merge branch 'main' into 915-inline-generic-json-objects-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFey-GIP authored Nov 4, 2024
2 parents 07bf4e0 + 21540e6 commit 5ed3398
Show file tree
Hide file tree
Showing 25 changed files with 613 additions and 260 deletions.
2 changes: 1 addition & 1 deletion installation/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.0.0</version>
<version>9.1.0</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
Expand Down
2 changes: 1 addition & 1 deletion modules/xact/http/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<Application applicationName="Http" comment="" factoryVersion="" versionName="1.2.10" xmlVersion="1.1">
<Application applicationName="Http" comment="" factoryVersion="" versionName="1.3.0" xmlVersion="1.1">
<ApplicationInfo>
<Description Lang="DE">HTTP: Service und Trigger</Description>
<Description Lang="EN">HTTP: service and trigger</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ private Host getHost(HTTPTriggerConnection tc) {

private URLPath getURLPath(HTTPTriggerConnection tc) {
List<URLPathQuery> queries = new ArrayList<URLPathQuery>();
for (Entry<Object, Object> e : tc.getParas().entrySet()) {
queries.add(new URLPathQuery.Builder().attribute(String.valueOf(e.getKey())).value(String.valueOf(e.getValue())).instance());
for (String key : tc.getParameters().keySet()) {
for (String value : tc.getParameters().get(key)) {
queries.add(new URLPathQuery.Builder().attribute(key).value(value).instance());
}
}
return new URLPath.Builder().path(tc.getUri()).query(queries).instance();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Copyright 2022 Xyna GmbH, Germany
* Copyright 2024 Xyna GmbH, Germany
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,6 +44,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
Expand Down Expand Up @@ -81,11 +82,6 @@ public class HTTPTriggerConnection extends TriggerConnection {
private String method;
private Method methodEnum;
private Properties header;
@Deprecated
/**
* Use parameters instead
*/
private Properties paras;
private HashMap<String, List<String>> parameters;
private String payload;
private String charSet = Charset.defaultCharset().name();
Expand Down Expand Up @@ -444,8 +440,7 @@ private void readHeaders() throws IOException, InterruptedException, SocketNotAv


private void debugProperties(String fieldName, Properties properties, boolean onlyIfTraceDisabled) {

if (suppressLogging || !logger.isDebugEnabled() || (logger.isTraceEnabled() && onlyIfTraceDisabled)) {
if (!shouldDebugProperties(onlyIfTraceDisabled)) {
return;
}

Expand All @@ -465,6 +460,28 @@ private void debugProperties(String fieldName, Properties properties, boolean on
logger.debug(sb.toString());

}

private boolean shouldDebugProperties(boolean onlyIfTraceDisabled) {
return !suppressLogging && logger.isDebugEnabled() && (!logger.isTraceEnabled() || !onlyIfTraceDisabled);
}

private void debugParameters(Map<String, List<String>> data, boolean onlyIfTraceDisabled) {
if (!shouldDebugProperties(onlyIfTraceDisabled)) {
return;
}

StringBuilder sb = new StringBuilder();
sb.append("Parsed parameter fields: ");
int count = 0;
for (String key : data.keySet()) {
String value = String.join(", ", data.get(key));
sb.append("{").append(key).append(": ").append("[").append(value).append("]}");
count++;
if (count < data.size()) {
sb.append(", ");
}
}
}

private static final long timeoutFirstPartOfRequestLine = 5000; //TODO konfigurierbar?

Expand Down Expand Up @@ -544,11 +561,9 @@ private void readMethodAndUriAndParameters() throws IOException, InterruptedExce
}

// Decode parameters from the URI
paras = new Properties();
parameters = new HashMap<>();
int qmi = uri.indexOf('?');
if (qmi >= 0) {
decodeParas(uri.substring(qmi + 1), paras);
decodeParameters(uri.substring(qmi +1), parameters);
uri = decode(uri.substring(0, qmi));
} else {
Expand All @@ -559,7 +574,7 @@ private void readMethodAndUriAndParameters() throws IOException, InterruptedExce
logger.debug("Method: " + methodEnum + ", URI: " + uri);
}

debugProperties("parameter", paras, false);
debugParameters(parameters, false);

try {
this.socket.setSoTimeout(previousTimeout);
Expand Down Expand Up @@ -606,27 +621,6 @@ private void validateStartOfRequestLine(byte[] firstPartOfLine) throws SocketNot
}


/**
* Decodes parameters in percent-encoded URI-format ( e.g. "name=Jack%20Daniels&pass=Single%20Malt" ) and adds them to
* given Properties.
*/
private void decodeParas(String paras, Properties p) throws InterruptedException {
if (paras == null)
return;

StringTokenizer st = new StringTokenizer(paras, "&");
while (st.hasMoreTokens()) {
String e = st.nextToken();
int sep = e.indexOf('=');
if (sep >= 0) {
p.put(decode(e.substring(0, sep)).trim(), decode(e.substring(sep + 1)));
} else {
p.put(decode(e).trim(), "");
}
}
}


/**
* Decodes parameters in percent-encoded URI-format ( e.g. "name=default%20workspace&desc=a%20description" ) and adds
* them to given HashMap.
Expand Down Expand Up @@ -661,43 +655,6 @@ private static String decode(String string) {
}
}

/**
* Decodes the percent encoding scheme. <br/>
* For example: "an+example%20string" -> "an example string"
* @deprecated
*/
private String decodePercentX(String str) throws InterruptedException {
try {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
switch (c) {
case '+' :
sb.append(' ');
break;
case '%' :
sb.append((char) Integer.parseInt(str.substring(i + 1, i + 3), 16));
i += 2;
break;
default :
sb.append(c);
break;
}
}
return sb.toString();
} catch (Exception e) {
try {
logInvalidHttpRequest();
sendError(HTTP_BADREQUEST, "BAD REQUEST: Bad percent-encoding.");
} catch (SocketNotAvailableException e1) {
if (!suppressLogging) {
logger.error("socket was unexpectedly not available when trying to send errormessage to client", e1);
}
}
return null; // wird nicht ausgeführt
}
}


private void logInvalidHttpRequest() {
if (!suppressLogging && logger.isInfoEnabled() && socket.getInetAddress() != null) {
Expand Down Expand Up @@ -1018,7 +975,7 @@ private void writeHeader(String status, String mime, InputStream data, Long data
// workaround for multiple response header entries with the same name
Object complexValue = responseHeader.get(key);
if (complexValue instanceof List) {
for (Object singleValue : (List)complexValue) {
for (Object singleValue : (List<?>)complexValue) {
pw.print(key+": "+String.valueOf(singleValue)+CRLF);
}
}
Expand Down Expand Up @@ -1089,15 +1046,6 @@ public Method getMethodEnum() {
public Properties getHeader() {
return header;
}


@Deprecated
/**
* Use getParameters() or getFirstValueOfParameter() instead
*/
public Properties getParas() {
return paras;
}

public HashMap<String, List<String>> getParameters() {
return parameters;
Expand Down
3 changes: 2 additions & 1 deletion modules/xdev/yang/XMOM/xdev/yang/YangAppGeneration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@
<Data ID="5" Label="Workspace" ReferenceName="Workspace" ReferencePath="xprc.xpce" VariableName="workspace5"/>
<Data ID="8" Label="RPC" ReferenceName="Text" ReferencePath="base" VariableName="text8"/>
<Data ID="9" Label="Device Fqn" ReferenceName="Text" ReferencePath="base" VariableName="text9"/>
<Data ID="11" Label="Rpc Namespace" ReferenceName="Text" ReferencePath="base" VariableName="text11"/>
</Input>
<Output/>
<SourceCode>
<CodeSnippet Type="Java">xdev.yang.YangAppGenerationImpl.addUsecase(correlatedXynaOrder, text2, text3, workspace5, text8, text9);</CodeSnippet>
<CodeSnippet Type="Java">xdev.yang.YangAppGenerationImpl.addUsecase(correlatedXynaOrder, text2, text3, workspace5, text8, text9, text11);</CodeSnippet>
</SourceCode>
</Operation>
<Operation IsStatic="true" Label="Save Assignment" Name="saveAssignment" RequiresXynaOrder="true">
Expand Down
5 changes: 5 additions & 0 deletions modules/xdev/yang/XMOM/xmcp/yang/LoadYangAssignmentsData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@
<Type>String</Type>
</Meta>
</Data>
<Data Label="Total Namespaces" VariableName="totalNamespaces">
<Meta>
<Type>String</Type>
</Meta>
</Data>
</DataType>
5 changes: 5 additions & 0 deletions modules/xdev/yang/XMOM/xmcp/yang/UseCaseTableData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<Type>String</Type>
</Meta>
</Data>
<Data Label="Rpc Namespace" VariableName="rpcNamespace">
<Meta>
<Type>String</Type>
</Meta>
</Data>
<Data Label="Runtime Context" VariableName="runtimeContext">
<Meta>
<Type>String</Type>
Expand Down
7 changes: 7 additions & 0 deletions modules/xdev/yang/XMOM/xmcp/yang/fman/AddUseCase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<Data ID="111" Label="Workspace" ReferenceName="Workspace" ReferencePath="xprc.xpce" VariableName="workspace111"/>
<Data ID="112" Label="Text" ReferenceName="Text" ReferencePath="base" VariableName="text112"/>
<Data ID="129" Label="Text" ReferenceName="Text" ReferencePath="base" VariableName="text129"/>
<Data ID="162" Label="Text" ReferenceName="Text" ReferencePath="base" VariableName="text162"/>
</Input>
<Output/>
<ServiceReference ID="19" Label="Yang App Generation" ReferenceName="YangAppGeneration.YangAppGeneration" ReferencePath="xdev.yang">
Expand All @@ -36,6 +37,7 @@
<Source RefID="111"/>
<Source RefID="112"/>
<Source RefID="129"/>
<Source RefID="162"/>
<Target RefID="19"/>
<Invoke Operation="addUsecase" ServiceID="19">
<Source RefID="37">
Expand All @@ -59,6 +61,11 @@
<LinkType>UserConnected</LinkType>
</Meta>
</Source>
<Source RefID="162">
<Meta>
<LinkType>UserConnected</LinkType>
</Meta>
</Source>
</Invoke>
<Receive ServiceID="19"/>
</Function>
Expand Down
58 changes: 46 additions & 12 deletions modules/xdev/yang/XMOM/xmcp/yang/fman/DefineAddUsecaseDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Data ID="636" Label="Workspace" ReferenceName="Workspace" ReferencePath="xprc.xpce" VariableName="workspace636"/>
<Data ID="812" Label="RPC - Text" ReferenceName="Text" ReferencePath="base" VariableName="text812"/>
<Data ID="1127" Label="Device - Text" ReferenceName="Text" ReferencePath="base" VariableName="text1127"/>
<Data ID="1499" Label="Rpc Namespace - Text" ReferenceName="Text" ReferencePath="base" VariableName="text1499"/>
</Output>
<ServiceReference ID="752" Label="RuntimeContextService" ReferenceName="RuntimeContextService.RuntimeContextService" ReferencePath="xfmg.xfctrl.appmgmt">
<Source RefID="751"/>
Expand Down Expand Up @@ -76,6 +77,12 @@
</Data>
<Target RefID="1198"/>
</Output>
<Output>
<Data ID="1256" Label="Rpc Namespace - Text Input Definition" ReferenceName="TextInputDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="textInputDefinition1256">
<Source RefID="102"/>
</Data>
<Target RefID="1257"/>
</Output>
<Output>
<Data ID="457" Label="Start Order Button Definition" ReferenceName="StartOrderButtonDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="startOrderButtonDefinition457">
<Source RefID="102"/>
Expand All @@ -92,11 +99,13 @@
<Mapping>%4%.dataPath="%3%.text"</Mapping>
<Mapping>%5%.label="Device Fqn"</Mapping>
<Mapping>%5%.dataPath="%4%.text"</Mapping>
<Mapping>%6%.dataPath="%0%, %1%, %2%, %3%, %4%"</Mapping>
<Mapping>%6%.label="Create Usecase"</Mapping>
<Mapping>%6%.serviceRTC=%0%</Mapping>
<Mapping>%6%.serviceFQN="xmcp.yang.fman.AddUseCase"</Mapping>
<Mapping>%6%.synchronously="true"</Mapping>
<Mapping>%6%.label="(Optional) RPC Namespace"</Mapping>
<Mapping>%6%.dataPath="%5%.text"</Mapping>
<Mapping>%7%.dataPath="%0%, %1%, %2%, %3%, %4%, %5%"</Mapping>
<Mapping>%7%.label="Create Usecase"</Mapping>
<Mapping>%7%.serviceRTC=%0%</Mapping>
<Mapping>%7%.serviceFQN="xmcp.yang.fman.AddUseCase"</Mapping>
<Mapping>%7%.synchronously="true"</Mapping>
</Mappings>
<Mappings ID="27" Label="Mapping">
<Input>
Expand Down Expand Up @@ -149,6 +158,16 @@
</Meta>
</Source>
</Input>
<Input>
<Data ID="1418" Label="Rpc Namespace - Text Input Definition" ReferenceName="TextInputDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="textInputDefinition1418">
<Source RefID="27"/>
</Data>
<Source RefID="1257">
<Meta>
<LinkType>UserConnected</LinkType>
</Meta>
</Source>
</Input>
<Input>
<Data ID="448" Label="Start Order Button Definition" ReferenceName="StartOrderButtonDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="startOrderButtonDefinition448">
<Source RefID="27"/>
Expand All @@ -161,13 +180,14 @@
</Data>
<Target RefID="37"/>
</Output>
<Mapping>%6%.label="Add Usecase"</Mapping>
<Mapping>%6%.children["0"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%0%</Mapping>
<Mapping>%6%.children["1"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%1%</Mapping>
<Mapping>%6%.children["2"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%2%</Mapping>
<Mapping>%6%.children["3"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%3%</Mapping>
<Mapping>%6%.children["4"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%4%</Mapping>
<Mapping>%6%.children["5"]#cast("xmcp.forms.datatypes.StartOrderButtonDefinition")=%5%</Mapping>
<Mapping>%7%.label="Add Usecase"</Mapping>
<Mapping>%7%.children["0"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%0%</Mapping>
<Mapping>%7%.children["1"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%1%</Mapping>
<Mapping>%7%.children["2"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%2%</Mapping>
<Mapping>%7%.children["3"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%3%</Mapping>
<Mapping>%7%.children["4"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%4%</Mapping>
<Mapping>%7%.children["5"]#cast("xmcp.forms.datatypes.TextInputDefinition")=%5%</Mapping>
<Mapping>%7%.children["6"]#cast("xmcp.forms.datatypes.StartOrderButtonDefinition")=%6%</Mapping>
</Mappings>
<Data ID="37" Label="Form Definition" ReferenceName="FormDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="formDefinition37">
<Source RefID="27"/>
Expand Down Expand Up @@ -198,19 +218,25 @@
<Data ID="1198" Label="Text Input Definition" ReferenceName="TextInputDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="textInputDefinition1198">
<Source RefID="102"/>
</Data>
<Data ID="1257" Label="Device - Text Input Definition" ReferenceName="TextInputDefinition" ReferencePath="xmcp.forms.datatypes" VariableName="textInputDefinition1257">
<Source RefID="102"/>
</Data>
<Data ID="1536" Label="Text" ReferenceName="Text" ReferencePath="base" VariableName="const_Text1536"/>
<Assign ID="1">
<Source RefID="37"/>
<Source RefID="544"/>
<Source RefID="582"/>
<Source RefID="649"/>
<Source RefID="849"/>
<Source RefID="1164"/>
<Source RefID="1536"/>
<Target RefID="14"/>
<Target RefID="531"/>
<Target RefID="561"/>
<Target RefID="636"/>
<Target RefID="812"/>
<Target RefID="1127"/>
<Target RefID="1499"/>
<Copy>
<Source RefID="37"/>
<Target RefID="14"/>
Expand Down Expand Up @@ -255,6 +281,14 @@
</Source>
<Target RefID="1127"/>
</Copy>
<Copy>
<Source RefID="1536">
<Meta>
<LinkType>Constant</LinkType>
</Meta>
</Source>
<Target RefID="1499"/>
</Copy>
</Assign>
</Operation>
</Service>
Loading

0 comments on commit 5ed3398

Please sign in to comment.