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);
}
}
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);
}
}
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);
}
}
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);
}
}
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));
}
}
Aggregations