|
|
@ -391,6 +391,11 @@ public class OperationDAOUtil {
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param blob
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @throws SQLException
|
|
|
|
|
|
|
|
*/
|
|
|
|
public static JSONObject convertBlobToJsonObject(Blob blob) throws SQLException {
|
|
|
|
public static JSONObject convertBlobToJsonObject(Blob blob) throws SQLException {
|
|
|
|
String jsonString;
|
|
|
|
String jsonString;
|
|
|
|
try (InputStream inputStream = blob.getBinaryStream();
|
|
|
|
try (InputStream inputStream = blob.getBinaryStream();
|
|
|
@ -413,19 +418,24 @@ public class OperationDAOUtil {
|
|
|
|
jsonString = new JSONObject(obj).toString();
|
|
|
|
jsonString = new JSONObject(obj).toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
throw new SQLException("Failed to deserialize object from BLOB", e);
|
|
|
|
String msg = "Failed to deserialize object from BLOB";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new SQLException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// If not serialized, treat it as plain JSON string
|
|
|
|
// If not serialized, treat it as plain JSON string
|
|
|
|
jsonString = new String(blobBytes, "UTF-8");
|
|
|
|
jsonString = new String(blobBytes, "UTF-8");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new SQLException("Failed to convert BLOB to JSON string", e);
|
|
|
|
String msg = "Failed to convert BLOB to JSON string";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new SQLException(msg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Convert JSON string to JSONObject
|
|
|
|
// Convert JSON string to JSONObject
|
|
|
|
if (jsonString == null || jsonString.isEmpty()) {
|
|
|
|
if (jsonString == null || jsonString.isEmpty()) {
|
|
|
|
throw new SQLException("Converted JSON string is null or empty");
|
|
|
|
String msg = "Converted JSON string is null or empty";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new SQLException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new JSONObject(jsonString);
|
|
|
|
return new JSONObject(jsonString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|