private void deployToServerBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deployToServerBActionPerformed
String moduleName = targetModuleTF.getText();
final ArrayList<DeployedModel> deploymentInfo = new ArrayList();
WorldManager wm = ClientContextJME.getWorldManager();
final ServerSessionManager targetServer =
(ServerSessionManager) targetServerSelector.getSelectedItem();
// Check we are not about to overwrite an existing module
String url = targetServer.getServerURL();
ModuleList moduleList = ModuleUtils.fetchModuleList(url);
ModuleInfo[] modules = moduleList.getModuleInfos();
if (modules != null) {
boolean conflict = false;
for (int i = 0; i < modules.length && !conflict; i++) {
if (moduleName.equals(modules[i].getName())) {
conflict = true;
}
}
if (conflict) {
int ret = JOptionPane.showConfirmDialog(this,
BUNDLE.getString("Module_Conflict_Message"),
BUNDLE.getString("Module_Conflict"),
JOptionPane.YES_NO_OPTION);
if (ret == JOptionPane.NO_OPTION) {
return;
}
}
}
final File moduleJar = createModuleJar(deploymentInfo, null);
// Now deploy to server
Thread t = new Thread() {
private JDialog uploadingDialog;
@Override
public void run() {
try {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
uploadingDialog = new JDialog(ImportSessionFrame.this);
uploadingDialog.setLayout(new BorderLayout());
uploadingDialog.add(loadingDialogPanel, BorderLayout.CENTER);
uploadingDialog.pack();
uploadingDialog.setSize(200, 100);
uploadingDialog.setVisible(true);
uploadingDialog.setAlwaysOnTop(true);
}
});
} catch (InterruptedException ex) {
Logger.getLogger(ImportSessionFrame.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(ImportSessionFrame.class.getName()).log(Level.SEVERE, null, ex);
}
ModuleUploader uploader = new ModuleUploader(new URL(targetServer.getServerURL()));
// if the authentication type is NONE, don't authenticate,
// since the upload will only accept modules from an
// administrator.
// XXX TODO: we should fix this so that upload writes to
// the content repository, so that non-admin users can
// upload art when authenication is turned on XXX
if (targetServer.getDetails().getAuthInfo().getType() !=
AuthenticationInfo.Type.NONE)
{
uploader.setAuthURL(targetServer.getCredentialManager().getAuthenticationURL());
}
uploader.upload(moduleJar);
} catch (MalformedURLException ex) {
LOGGER.log(Level.SEVERE, "MalformedURL " + targetServer.getServerURL(), ex);
return;
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "IO Exception during upload", e);
return;
} catch (Throwable t) {
LOGGER.log(Level.SEVERE, "Exception during upload", t);
return;
}
// Now create the cells for the new content
WonderlandSession session =
LoginManager.getPrimary().getPrimarySession();
CellEditChannelConnection connection =
(CellEditChannelConnection) session.getConnection(
CellEditConnectionType.CLIENT_TYPE);
for (DeployedModel info : deploymentInfo) {
CellID parentCellID = null;
CellCreateMessage msg = new CellCreateMessage(
parentCellID, info.getCellServerState());
connection.send(msg);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
uploadingDialog.setVisible(false);
uploadingDialog.dispose();
}
});
}
};
t.start();
// Remove entities, once we create the cells on the server we
// will be sent the client cells
for (ImportedModel model : imports) {
wm.removeEntity(model.getEntity());
}
tableModel.setRowCount(0);
imports.clear();
}