Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions java/src/main/java/com/genexus/db/driver/GXDBMSpostgresql.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,44 @@ public boolean ReferentialIntegrity(SQLException e)
return false;
}

private static String safeSQLState(SQLException e)
{
String s = (e == null) ? null : e.getSQLState();
return (s == null) ? "" : s.toLowerCase();
}

private static String safeMessage(SQLException e)
{
String m = (e == null) ? null : e.getMessage();
return (m == null) ? "" : m.toLowerCase();
}

public boolean DuplicateKeyValue(SQLException e)
{
String sqlstate = e.getSQLState().toLowerCase();
String sqlstate = safeSQLState(e);
//23505 duplicate key violates unique constraint xxx
if (sqlstate.indexOf("23505")>=0){
return true;
}else
{
String msg = e.getMessage().toLowerCase();
String msg = safeMessage(e);
return (msg.indexOf("duplicate key") >= 0 && msg.indexOf("unique") >= 0);
}
}

public boolean ObjectLocked(SQLException e)
{
String sqlstate = e.getSQLState().toLowerCase();
String sqlstate = safeSQLState(e);
String sqlstateCause = "";
if (e.getCause() != null && e.getCause() instanceof SQLException)
sqlstateCause = ((SQLException)e.getCause()).getSQLState().toLowerCase();
sqlstateCause = safeSQLState((SQLException)e.getCause());
return sqlstate.contains("55p03") || sqlstateCause.contains("55p03");
}

public boolean ObjectNotFound(SQLException e)
{
String sqlstate = e.getSQLState().toLowerCase();
String msg = e.getMessage().toLowerCase();
String sqlstate = safeSQLState(e);
String msg = safeMessage(e);
//42704 index xxx does not exist
//42P01 relation tableName does not exist
//42p06 schema already exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,9 @@ public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws
if (webContext instanceof com.genexus.webpanels.HttpContextWeb) {
if (ApplicationContext.getInstance().isSpringBootApp() && ! new File(fileName).isAbsolute())
{
if (fileName.startsWith(webContext.getContextPath()))
fileName = fileName.replaceFirst(webContext.getContextPath(), "").substring(1);
String ctxPath = webContext.getContextPath();
if (ctxPath != null && !ctxPath.isEmpty() && fileName.startsWith(ctxPath))
fileName = fileName.substring(ctxPath.length() + 1);
}
else
fileName = ((com.genexus.webpanels.HttpContextWeb) webContext).getRealPath(fileName);
Expand All @@ -1424,9 +1425,10 @@ public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws
{
if (!webContext.getDefaultPath().isEmpty() && ! new File(fileName).isAbsolute())
{
if (fileName.startsWith(webContext.getContextPath()))
String ctxPath = webContext.getContextPath();
if (ctxPath != null && !ctxPath.isEmpty() && fileName.startsWith(ctxPath))
{
fileName = fileName.substring(webContext.getContextPath().length() +1);
fileName = fileName.substring(ctxPath.length() +1);
}

fileName = webContext.getDefaultPath() + File.separator + fileName;
Expand Down
Loading