use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ContainerStore method store.
/* (non-Javadoc)
* @see org.eclipse.ecf.storage.IContainerStore#store(org.eclipse.ecf.storage.IStorableContainerAdapter)
*/
public IContainerEntry store(IStorableContainerAdapter containerAdapter) throws StorageException {
String factoryName = containerAdapter.getContainerFactoryName();
Assert.isNotNull(factoryName);
ID containerID = containerAdapter.getID();
Assert.isNotNull(containerID);
IIDEntry idEntry = idStore.store(containerID);
ContainerEntry containerEntry = new ContainerEntry(idEntry);
try {
containerEntry.setFactoryName(containerAdapter.getContainerFactoryName(), containerAdapter.storeEncrypted());
containerAdapter.store(containerEntry.getPreferences());
return containerEntry;
} catch (StorageException e) {
// Undo and return null
containerEntry.delete();
throw e;
}
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class BaseChannel method initializeReplicaChannel.
/**
* Initialize replicas of this channel. This method is only called if
* isPrimary() returns false. It is called from within the initialize
* method, immediately after super.initialize but before the listener for
* this channel is notified of initialization. If this method throws a
* SharedObjectInitException, then initialization of the replica is halted
* and the remote transaction creating the replica will be aborted.
* <p>
* Note that this implementation checks for the existence of the
* RECEIVER_ID_PROPERTY on the replica's properties, and if the property
* contains a valid ID will
* <ul>
* <li>lookup the IChannel on the given container via
* IChannelContainerAdapter.getID(ID)</li>
* <li>call IChannel.getListener() to retrieve the listener for the channel
* returned</li>
* <li>set the listener for this object to the value returned from
* IChannel.getListener()</li>
* </ul>
*
* @throws SharedObjectInitException
* if the replica initialization should fail
*/
protected void initializeReplicaChannel() throws SharedObjectInitException {
Map properties = getConfig().getProperties();
ID rcvr = null;
try {
rcvr = (ID) properties.get(RECEIVER_ID_PROPERTY);
} catch (ClassCastException e) {
// $NON-NLS-1$
throw new SharedObjectInitException("Receiver ID property value must be of type ID", e);
}
if (rcvr != null) {
// Now...get local channel container first...throw if we can't get
// it
IChannelContainerAdapter container = (IChannelContainerAdapter) getContext().getAdapter(IChannelContainerAdapter.class);
if (container == null)
// $NON-NLS-1$
throw new SharedObjectInitException("channel container adapter must not be null");
// Now get receiver IChannel...throw if we can't get it
final IChannel receiver = container.getChannel(rcvr);
if (receiver == null)
// $NON-NLS-1$
throw new SharedObjectInitException("channel receiver must not be null");
setChannelListener(receiver.getListener());
}
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ChatComposite method sendImage.
private void sendImage(final IUser toUser) {
if (MessageDialog.openQuestion(null, MessageLoader.getString("ChatComposite.DIALOG_SCREEN_CAPTURE_TITLE"), MessageLoader.getString("ChatComposite.DIALOG_SCREEN_CAPTURE_TEXT"))) {
// $NON-NLS-1$ //$NON-NLS-2$
final Job job = new ScreenCaptureJob(getDisplay(), toUser.getID(), toUser.getNickname(), new IImageSender() {
public void sendImage(ID targetID, ImageData imageData) {
view.lch.sendImage(toUser.getID(), imageData);
}
});
job.schedule(5000);
}
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ChatComposite method startProgram.
protected void startProgram(IUser ud) {
String res = null;
ID receiver = null;
if (ud == null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
res = getID(MessageLoader.getString("ChatComposite.START_PROGRAM_GROUP_TITLE"), MessageLoader.getString("ChatComposite.START_PROGRAM_GROUP_TEXT"), "");
} else {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
res = getID(MessageLoader.getFormattedString("ChatComposite.START_PROGRAM_TITLE", ud.getNickname()), MessageLoader.getFormattedString("ChatComposite.START_PROGRAM_TEXT", ud.getNickname()) + ":", "");
receiver = ud.getID();
}
if (res != null)
this.view.runProgram(receiver, res, null);
}
use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.
the class ChatComposite method readStreamAndSend.
protected void readStreamAndSend(java.io.InputStream local, String fileName, Date startDate, ID target, final boolean launch) {
try {
final ID eclipseStageID = IDFactory.getDefault().createStringID(org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject.ID);
final java.io.BufferedInputStream ins = new java.io.BufferedInputStream(local);
final java.io.File remoteFile = new File((new File(fileName)).getName());
final FileTransferParams sp = new FileTransferParams(remoteFile, getChunkPreference(), getDelayPreference(), null, true, -1, null);
final Object[] args = { view, target, ins, sp, eclipseStageID };
// Do it
new Thread(new Runnable() {
public void run() {
if (launch) {
ChatComposite.this.view.createObject(null, org.eclipse.ecf.example.collab.share.io.EclipseFileTransferAndLaunch.class.getName(), new String[] { FileSenderUI.class.getName(), ID.class.getName(), java.io.InputStream.class.getName(), FileTransferParams.class.getName(), ID.class.getName() }, args);
} else {
ChatComposite.this.view.createObject(null, org.eclipse.ecf.example.collab.share.io.EclipseFileTransfer.class.getName(), new String[] { FileSenderUI.class.getName(), ID.class.getName(), java.io.InputStream.class.getName(), FileTransferParams.class.getName(), ID.class.getName() }, args);
}
}
}, "FileRepObject creator").start();
} catch (final Exception e) {
if (this.view.lch != null)
// $NON-NLS-1$
this.view.lch.chatException(e, "readStreamAndSend()");
}
}
Aggregations