Skip to content

Commit db635b3

Browse files
authored
Merge branch 'master' into fix/bump-netty-framework
2 parents 6f90517 + 1c64eb4 commit db635b3

File tree

15 files changed

+214
-38
lines changed

15 files changed

+214
-38
lines changed

common/src/main/java/com/genexus/ApplicationContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public boolean checkIfResourceExist(String path)
132132
if (isSpringBootApp())
133133
return new ClassPathResource(path).exists();
134134
else
135-
return new File(path).exists();
135+
return new File(path).exists() || getClass().getClassLoader().getResource(path) != null;
136136
}
137137

138138
public void setEJBEngine(boolean isEJBEngine)

common/src/main/java/com/genexus/xml/XMLReader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,11 @@ public void open(String url)
785785
else
786786
{
787787
File xmlFile = new File(url);
788-
fileInputStream = new FileInputStream(xmlFile);
788+
if (xmlFile.exists())
789+
fileInputStream = new FileInputStream(xmlFile);
790+
else {
791+
fileInputStream = getClass().getClassLoader().getResourceAsStream(url);
792+
}
789793
}
790794
inputSource = new XMLInputSource(null, url, null, fileInputStream, null);
791795
if (documentEncoding.length() > 0)

gxcache-memcached/src/main/java/com/genexus/cache/memcached/Memcached.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public void clear(String cacheid, String key) {
121121
}
122122

123123
public void clearCache(String cacheid) {
124-
_cache.incr(cacheid, 1);
124+
Long newPrefix = CommonUtil.now(false, false).getTime();
125+
set(cacheid, newPrefix);
125126
}
126127

127128
public void clearKey(String key) {

gxcryptocommon/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<dependency>
2828
<groupId>org.apache.santuario</groupId>
2929
<artifactId>xmlsec</artifactId>
30-
<version>2.2.3</version>
30+
<version>${xmlsec.version}</version>
3131
<exclusions>
3232
<exclusion>
3333
<groupId>*</groupId>

gxoffice/src/main/java/com/genexus/gxoffice/ExcelDoc.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ public IExcelDocument getDocument() {
5656
public void checkExcelDocument() {
5757
if (document == null) {
5858
try {
59-
if (excelFileName.endsWith(".xlsx") || excelFileName.endsWith(".xlsm")
60-
|| excelFileName.endsWith(".xlsb") || excelFileName.endsWith(".xlam")
61-
|| isXlsx(excelFileName)) {
59+
if (excelFileName.endsWith(".xls") || excelFileName.endsWith(".xlm")
60+
|| excelFileName.endsWith(".xlb") || excelFileName.endsWith(".xlm")) {
61+
Class.forName("org.apache.poi.hssf.usermodel.HSSFWorkbook");
62+
document = new com.genexus.gxoffice.poi.hssf.ExcelDocument();
63+
} else {
6264
if (bufferedStreaming) {
6365
Class.forName("org.apache.poi.xssf.streaming.SXSSFWorkbook");
6466
document = new com.genexus.gxoffice.poi.sxssf.ExcelDocument();
6567
} else {
6668
Class.forName("org.apache.poi.xssf.usermodel.XSSFWorkbook");
6769
document = new com.genexus.gxoffice.poi.xssf.ExcelDocument();
6870
}
69-
} else {
70-
Class.forName("org.apache.poi.hssf.usermodel.HSSFWorkbook");
71-
document = new com.genexus.gxoffice.poi.hssf.ExcelDocument();
7271
}
7372
} catch (Throwable e) {
7473
document = new com.genexus.gxoffice.ExcelDocument();

java/src/main/java/com/genexus/GXProcedure.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.ArrayList;
66
import java.util.Date;
77

8-
import com.fasterxml.jackson.databind.ObjectMapper;
98
import com.genexus.db.Namespace;
109
import com.genexus.db.UserInformation;
1110
import com.genexus.diagnostics.GXDebugInfo;
@@ -18,8 +17,8 @@
1817
import com.genexus.util.*;
1918
import com.genexus.util.saia.OpenAIRequest;
2019
import com.genexus.util.saia.OpenAIResponse;
20+
import com.genexus.util.saia.SaiaEvents;
2121
import com.genexus.util.saia.SaiaService;
22-
import org.json.JSONObject;
2322

2423
public abstract class GXProcedure implements IErrorHandler, ISubmitteable {
2524
public abstract void initialize();
@@ -275,13 +274,19 @@ protected String callAssistant(String agent, GXProperties properties, ArrayList<
275274
}
276275

277276
protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList<OpenAIResponse.Message> messages, CallResult result) {
277+
return chatAgent(agent, properties, messages, null, result);
278+
}
279+
280+
protected ChatResult chatAgent(String agent, GXProperties properties, ArrayList<OpenAIResponse.Message> messages, GXExternalCollection<?> history, CallResult result) {
278281
ChatResult chatResult = new ChatResult();
279282

280283
new Thread(() -> {
281284
try {
282285
context.setThreadModelContext(context);
283286
callAgent(agent, true, properties, messages, result, chatResult);
284287
} finally {
288+
if (history != null)
289+
history.setExternalInstance(messages);
285290
chatResult.markDone();
286291
}
287292
}).start();
@@ -321,16 +326,18 @@ protected String callAgent(String agent, boolean stream, GXProperties properties
321326

322327
public String processNotChunkedResponse(String agent, boolean stream, GXProperties properties, ArrayList<OpenAIResponse.Message> messages, CallResult result, ChatResult chatResult, ArrayList<OpenAIResponse.ToolCall> toolCalls) {
323328
for (OpenAIResponse.ToolCall tollCall : toolCalls) {
324-
processToolCall(tollCall, messages);
329+
processToolCall(tollCall, messages, chatResult);
325330
}
326331
return callAgent(agent, stream, properties, messages, result, chatResult);
327332
}
328333

329-
private void processToolCall(OpenAIResponse.ToolCall toolCall, ArrayList<OpenAIResponse.Message> messages) {
334+
private void processToolCall(OpenAIResponse.ToolCall toolCall, ArrayList<OpenAIResponse.Message> messages, ChatResult chatResult) {
330335
String result;
331336
String functionName = toolCall.getFunction().getName();
332337
try {
338+
addToolCallChunk(chatResult, toolCall, "saia.metadata.tool.started", "started", null);
333339
result = callTool(functionName, toolCall.getFunction().getArguments());
340+
addToolCallChunk(chatResult, toolCall, "saia.metadata.tool.finished", "finished_successfully", result);
334341
}
335342
catch (Throwable e) {
336343
result = String.format("Error calling tool %s", functionName);
@@ -341,4 +348,13 @@ private void processToolCall(OpenAIResponse.ToolCall toolCall, ArrayList<OpenAIR
341348
toolCallMessage.setToolCallId(toolCall.getId());
342349
messages.add(toolCallMessage);
343350
}
351+
352+
private void addToolCallChunk(ChatResult chatResult, OpenAIResponse.ToolCall toolCall, String event, String tollStatus, String result) {
353+
if (chatResult != null) {
354+
SaiaEvents saiaToolStarted = new SaiaEvents();
355+
String eventJson = saiaToolStarted.serializeSaiaEvent(toolCall, event, tollStatus, result);
356+
if (eventJson != null)
357+
chatResult.addChunk("data: " + eventJson);
358+
}
359+
}
344360
}

java/src/main/java/com/genexus/GXutil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
import com.genexus.common.interfaces.SpecificImplementation;
1111
import com.genexus.db.DataStoreProvider;
1212
import com.genexus.db.GXEmbedding;
13+
import com.genexus.internet.HttpClient;
1314
import com.genexus.internet.HttpContext;
1415
import com.genexus.internet.StringCollection;
1516
import com.genexus.platform.INativeFunctions;
1617
import com.genexus.platform.NativeFunctions;
1718
import com.genexus.util.*;
1819

20+
import org.apache.commons.io.IOUtils;
1921
import org.json.JSONObject;
2022
import org.apache.commons.lang3.StringUtils;
2123

@@ -1782,4 +1784,11 @@ public static String embeddingToStr(GXEmbedding embedding) {
17821784
return embedding.toString();
17831785
}
17841786

1787+
public static byte[] ImageUrlToBytes(String url) throws IOException{
1788+
HttpClient httpClient = new HttpClient();
1789+
httpClient.execute( "GET", url);
1790+
try (InputStream in = httpClient.getInputStream()) {
1791+
return IOUtils.toByteArray(in);
1792+
}
1793+
}
17851794
}

java/src/main/java/com/genexus/db/driver/GXPreparedStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,10 +1391,10 @@ public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws
13911391
int queryIndex = fileName.lastIndexOf('?');
13921392
if (queryIndex > -1)
13931393
fileName = fileName.substring(0, queryIndex + 1) + PrivateUtilities.encodeURL(fileName.substring(queryIndex + 1));
1394-
URL fileURL = new URL(fileName);
1394+
String fileURL = fileName;
13951395
String blobPath = com.genexus.Preferences.getDefaultPreferences().getBLOB_PATH();
13961396
fileName = com.genexus.PrivateUtilities.getTempFileName(blobPath, CommonUtil.getFileName(fileName), CommonUtil.getFileType(fileName), true);
1397-
com.genexus.PrivateUtilities.InputStreamToFile(fileURL.openStream() ,fileName);
1397+
new com.genexus.util.GXFile(fileName).fromBytes(GXutil.ImageUrlToBytes(fileURL));
13981398
}
13991399
}
14001400
catch(MalformedURLException e)

java/src/main/java/com/genexus/internet/HttpClientJavaLib.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public HttpClientJavaLib() {
9393
if (isFirstIpDnsEnabled()) {
9494
builder.setDnsResolver(FIRST_IP_DNS_RESOLVER);
9595
}
96+
String userAgent = clientCfg.getProperty("Client", "UserAgentHeader", "");
97+
if (!userAgent.isEmpty()) {
98+
builder.setUserAgent(userAgent);
99+
}
96100
httpClientBuilder = builder;
97101
cookies = new BasicCookieStore();
98102
streamsToClose = new Vector<>();

java/src/main/java/com/genexus/reports/PDFReportItext2.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.genexus.ApplicationContext;
1111
import com.genexus.CommonUtil;
12+
import com.genexus.GXutil;
1213
import com.genexus.ModelContext;
1314
import com.genexus.platform.NativeFunctions;
1415
import com.genexus.webpanels.HttpContextWeb;
@@ -396,9 +397,8 @@ public void GxDrawBitMap(String bitmap, int left, int top, int right, int bottom
396397
}
397398
}
398399
}
399-
catch(java.lang.IllegalArgumentException ex) {//Puede ser una url absoluta
400-
java.net.URL url= new java.net.URL(bitmap);
401-
image = com.lowagie.text.Image.getInstance(url);
400+
catch(java.lang.IllegalArgumentException | IOException ex) {//Puede ser una url absoluta
401+
image = com.lowagie.text.Image.getInstance(GXutil.ImageUrlToBytes(bitmap));
402402
}
403403

404404
if (documentImages == null) {
@@ -443,9 +443,6 @@ public void GxDrawBitMap(String bitmap, int left, int top, int right, int bottom
443443
catch(DocumentException de) {
444444
log.error("GxDrawBitMap failed:", de);
445445
}
446-
catch(IOException ioe) {
447-
log.error("GxDrawBitMap failed:", ioe);
448-
}
449446
catch(Exception e) {
450447
log.error("GxDrawBitMap failed:", e);
451448
}

0 commit comments

Comments
 (0)