def getMessage(self): content, message, info, parameter = self._current if message is not None and self.isModified(): # store original so we can revert if needed original = message.SerializeToString() message.Clear() try: merge_message(self.editor.getText().tostring(), message) headers = info.getHeaders() serialized = message.SerializeToString() if parameter is not None: rules = self.extender.table.getParameterRules().get( parameter.getName(), {}) for rule in rules.get('after', []): try: serialized = rule(serialized) except Exception as error: traceback.print_exc( file=self.callbacks.getStderr()) raise error param = self.helpers.buildParameter( parameter.getName(), serialized, parameter.getType()) return self.helpers.updateParameter(content, param) else: return self.helpers.buildHttpMessage(headers, serialized) except Exception as error: JOptionPane.showMessageDialog(self.getUiComponent(), error.message, 'Error parsing message!', JOptionPane.ERROR_MESSAGE) # an error occurred while re-serializing the message, # revert back to the original message.Clear() message.MergeFromString(original) return content
def getMessage(self): content, message, info, parameter = self._current if message is not None and self.isModified(): # store original so we can revert if needed original = message.SerializeToString() message.Clear() try: merge_message(self.editor.getText().tostring(), message) headers = info.getHeaders() serialized = message.SerializeToString() if parameter is not None: rules = self.extender.table.getParameterRules().get(parameter.getName(), {}) for rule in rules.get('after', []): try: serialized = rule(serialized) except Exception as error: traceback.print_exc(file=self.callbacks.getStderr()) raise error param = self.helpers.buildParameter( parameter.getName(), serialized, parameter.getType()) return self.helpers.updateParameter(content, param) else: return self.helpers.buildHttpMessage(headers, serialized) except Exception as error: JOptionPane.showMessageDialog(self.getUiComponent(), error.message, 'Error parsing message!', JOptionPane.ERROR_MESSAGE) # an error occurred while re-serializing the message, # revert back to the original message.Clear() message.MergeFromString(original) return content