Search in sources :

Example 86 with ProcessingException

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);
    }
}
Also used : BytesMessage(javax.jms.BytesMessage) JMSException(javax.jms.JMSException) IOException(java.io.IOException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 87 with ProcessingException

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);
    }
}
Also used : JMSException(javax.jms.JMSException) BytesMessage(javax.jms.BytesMessage) IOException(java.io.IOException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 88 with ProcessingException

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;
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) Connection(javax.jms.Connection) JMSException(javax.jms.JMSException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) JMSException(javax.jms.JMSException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 89 with ProcessingException

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);
    }
}
Also used : ITableRowCustomValueContributor(org.eclipse.scout.rt.client.ui.basic.table.ITableRowCustomValueContributor) ValidationFailedStatus(org.eclipse.scout.rt.client.ui.form.fields.ValidationFailedStatus) Cell(org.eclipse.scout.rt.client.ui.basic.cell.Cell) IHeaderCell(org.eclipse.scout.rt.client.ui.basic.table.IHeaderCell) HeaderCell(org.eclipse.scout.rt.client.ui.basic.table.HeaderCell) ICell(org.eclipse.scout.rt.client.ui.basic.cell.ICell) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 90 with ProcessingException

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);
    }
}
Also used : IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField) Cell(org.eclipse.scout.rt.client.ui.basic.cell.Cell) IHeaderCell(org.eclipse.scout.rt.client.ui.basic.table.IHeaderCell) HeaderCell(org.eclipse.scout.rt.client.ui.basic.table.HeaderCell) ICell(org.eclipse.scout.rt.client.ui.basic.cell.ICell) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)142 IOException (java.io.IOException)48 MessagingException (javax.mail.MessagingException)21 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)17 File (java.io.File)14 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)12 Folder (javax.mail.Folder)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 RemoteFile (org.eclipse.scout.rt.shared.services.common.file.RemoteFile)9 NoSuchProviderException (java.security.NoSuchProviderException)8 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)8 FileInputStream (java.io.FileInputStream)7 InputStream (java.io.InputStream)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FileOutputStream (java.io.FileOutputStream)6 Message (javax.mail.Message)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStream (java.io.OutputStream)5 HashMap (java.util.HashMap)5