use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class JmsMessageSerializer method createMessage.
@Override
public Message createMessage(T message, Session session) {
if (LOG.isTraceEnabled()) {
LOG.trace("creating JMS message: msgContent={}", message);
}
try {
BytesMessage jmsMessage = session.createBytesMessage();
jmsMessage.setJMSCorrelationID(CorrelationId.CURRENT.get());
jmsMessage.writeBytes(getObjectSerializer().serialize(message));
if (LOG.isTraceEnabled()) {
jmsMessage.setStringProperty(JMS_PROPERTY_TRACE_MESSAGE_CONTENT, message.toString());
}
return jmsMessage;
} catch (JMSException | IOException e) {
throw new ProcessingException("Unexpected Exception", e);
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class JmsMessageSerializer method extractMessage.
@Override
public T extractMessage(Message jmsMessage) {
if (LOG.isTraceEnabled()) {
try {
LOG.trace("extracting JMS message: jmsMessageId={}, messageContent={}", jmsMessage.getJMSMessageID(), jmsMessage.getStringProperty(JMS_PROPERTY_TRACE_MESSAGE_CONTENT));
} catch (JMSException e) {
LOG.trace("extracting JMS message: jmsMessageId=?, messageContent=?", e);
}
}
try {
if (!(jmsMessage instanceof BytesMessage)) {
LOG.warn("Received unexpect message content. Ignored.");
return null;
}
BytesMessage bm = (BytesMessage) jmsMessage;
long bodyLength = bm.getBodyLength();
if (bodyLength == Integer.MAX_VALUE) {
LOG.warn("received empty BytesMessage");
} else if (bodyLength > Integer.MAX_VALUE) {
LOG.warn("received BytesMessage is too large (length={})", bodyLength);
} else {
byte[] buffer = new byte[(int) bodyLength];
bm.readBytes(buffer);
return getObjectSerializer().deserialize(buffer, getMessageType());
}
return null;
} catch (ClassNotFoundException | JMSException | IOException e) {
throw new ProcessingException("Unexpected Exception", e);
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class AbstractJmsService method setupConnection.
protected synchronized void setupConnection() {
closeConnection();
ConnectionFactory connectionFactory = getConnectionFactory();
Connection con;
try {
con = connectionFactory.createConnection();
} catch (JMSException e) {
throw new ProcessingException("Failed creating JMS connection", e);
}
String clientId = null;
try {
// try to set clientId; might fail, ignore if happens
clientId = createClientId();
con.setClientID(clientId);
} catch (Exception e) {
LOG.info("Unable to set clientID '{}' for consumer connection, possibly because of running in J2EE container", clientId, LOG.isTraceEnabled() ? e : null);
}
m_connection = con;
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class AbstractColumn method setValue.
protected void setValue(ITableRow r, VALUE value, boolean updateValidDisplayText) {
try {
Cell cell = r.getCellForUpdate(this);
cell.removeErrorStatus(ValidationFailedStatus.class);
VALUE newValue = validateValue(r, value);
// set newValue into the cell only if there's no error.
if (!cell.hasError()) {
r.setCellValue(getColumnIndex(), newValue);
if (this instanceof ITableRowCustomValueContributor) {
((ITableRowCustomValueContributor) this).enrichCustomValues(r, r.getCustomValues());
}
}
ensureVisibileIfInvalid(r);
if (updateValidDisplayText) {
updateDisplayText(r, newValue);
}
} catch (ProcessingException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error setting column value ", e);
}
Cell cell = r.getCellForUpdate(this);
// add error
cell.addErrorStatus(new ValidationFailedStatus<VALUE>(e, value));
updateDisplayText(r, value);
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class AbstractColumn method editorValueToCell.
/**
* Map the values of a cell to the editing form field. The default implementation assumes a value field.
*
* @throws ProcessingException
* if the field is not a value field
*/
protected void editorValueToCell(ITableRow row, IFormField editorField) {
if (!(editorField instanceof IValueField<?>)) {
throw new ProcessingException("Expected a value field.");
} else {
@SuppressWarnings("unchecked") IValueField<VALUE> valueField = (IValueField<VALUE>) editorField;
LOG.debug("complete edit: [value={}, text={}, status={}]", valueField.getValue(), valueField.getDisplayText(), valueField.getErrorStatus());
String cellAction = "";
Cell cell = row.getCellForUpdate(this);
if (!contentEquals(cell, valueField)) {
// remove existing validation and parsing error (but don't remove other possible error-statuses)
cell.removeErrorStatus(ValidationFailedStatus.class);
cell.removeErrorStatus(ParsingFailedStatus.class);
if (valueField.getErrorStatus() == null) {
parseValueAndSet(row, valueField.getValue(), true);
cellAction = "parseAndSetValue";
} else {
cell.setText(valueField.getDisplayText());
cell.addErrorStatuses(valueField.getErrorStatus().getChildren());
cellAction = "setText/addErrorStatuses";
}
}
LOG.debug("cell updated: [value={}, text={}, status={}, cellAction={}]", cell.getValue(), cell.getText(), cell.getErrorStatus(), cellAction);
}
}
Aggregations