Search in sources :

Example 1 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class DocumentChangeMessage method deserialize.

public static DocumentChangeMessage deserialize(byte[] bytes) throws SerializationException {
    try {
        final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
        final ObjectInputStream oins = new ObjectInputStream(bins);
        return (DocumentChangeMessage) oins.readObject();
    } catch (final Exception e) {
        throw new SerializationException("Exception deserializing DocumentChangeMessage", e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) ByteArrayInputStream(java.io.ByteArrayInputStream) SerializationException(org.eclipse.ecf.sync.SerializationException) IOException(java.io.IOException) ModelUpdateException(org.eclipse.ecf.sync.ModelUpdateException) BadLocationException(org.eclipse.jface.text.BadLocationException) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class Message method serialize.

public byte[] serialize() throws SerializationException {
    try {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(this);
        return bos.toByteArray();
    } catch (final Exception e) {
        throw new SerializationException(Messages.DocShare_EXCEPTION_DESERIALIZING_MESSAGE0, e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) SerializationException(org.eclipse.ecf.sync.SerializationException)

Example 3 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class Message method deserialize.

/**
 * Deserialize in to message
 * @param bytes
 * @return IModelChangeMessage
 * @throws SerializationException
 */
public static IModelChangeMessage deserialize(byte[] bytes) throws SerializationException {
    try {
        final ByteArrayInputStream bins = new ByteArrayInputStream(bytes);
        final ObjectInputStream oins = new ObjectInputStream(bins);
        return (IModelChangeMessage) oins.readObject();
    } catch (final Exception e) {
        throw new SerializationException(Messages.DocShare_EXCEPTION_DESERIALIZING_MESSAGE0, e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) IModelChangeMessage(org.eclipse.ecf.sync.IModelChangeMessage) SerializationException(org.eclipse.ecf.sync.SerializationException)

Example 4 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class FileSystemDocumentChangeMessage method serialize.

public byte[] serialize() throws SerializationException {
    try {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(this);
        return bos.toByteArray();
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) SerializationException(org.eclipse.ecf.sync.SerializationException)

Example 5 with SerializationException

use of org.eclipse.ecf.sync.SerializationException in project ecf by eclipse.

the class DocShare method handleMessage.

protected void handleMessage(ID fromContainerID, byte[] data) {
    try {
        IModelChangeMessage message = Message.deserialize(data);
        Assert.isNotNull(message);
        if (message instanceof SelectionMessage) {
            handleSelectionMessage((SelectionMessage) message);
        } else if (message instanceof FileSystemDocumentChangeMessage) {
            handleFileSystemDocumentChangeMessage((FileSystemDocumentChangeMessage) message);
        } else if (message instanceof StartMessage) {
            handleStartMessage((StartMessage) message);
        } else if (message instanceof StopMessage) {
            handleStopMessage((StopMessage) message);
        }
    } catch (SerializationException e) {
        // $NON-NLS-1$
        DocShareActivator.log(new Status(IStatus.ERROR, DocShareActivator.PLUGIN_ID, "Could not deserialize message from " + fromContainerID, e));
    } catch (CoreException e) {
        // $NON-NLS-1$
        DocShareActivator.log(new Status(IStatus.ERROR, DocShareActivator.PLUGIN_ID, "Could not connect to file buffer", e));
    } catch (RuntimeException e) {
        // $NON-NLS-1$
        DocShareActivator.log(new Status(IStatus.ERROR, DocShareActivator.PLUGIN_ID, "Runtime exception has occurred while handling message from " + fromContainerID, e));
    }
}
Also used : SerializationException(org.eclipse.ecf.sync.SerializationException) IModelChangeMessage(org.eclipse.ecf.sync.IModelChangeMessage)

Aggregations

SerializationException (org.eclipse.ecf.sync.SerializationException)9 IModelChangeMessage (org.eclipse.ecf.sync.IModelChangeMessage)3 IOException (java.io.IOException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 IModelChange (org.eclipse.ecf.sync.IModelChange)1 ModelUpdateException (org.eclipse.ecf.sync.ModelUpdateException)1 IDocumentChange (org.eclipse.ecf.sync.doc.IDocumentChange)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1