60 |
60 |
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
|
61 |
61 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
62 |
62 |
import eu.etaxonomy.cdm.api.service.IUserService;
|
|
63 |
import eu.etaxonomy.cdm.common.CdmUtils;
|
|
64 |
import eu.etaxonomy.cdm.config.CdmSourceException;
|
63 |
65 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
|
64 |
66 |
import eu.etaxonomy.cdm.persistence.permission.Role;
|
65 |
67 |
import eu.etaxonomy.taxeditor.l10n.Messages;
|
... | ... | |
111 |
113 |
|
112 |
114 |
private final static String MESG_COMPATIBLE_EDITOR_OLD = Messages.RemotingLoginDialog_UPDATE_EDITOR;
|
113 |
115 |
private final static String MESG_COMPATIBLE_SERVER_OLD = Messages.RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER;
|
|
116 |
private final static String MESG_SCHEMA_MISSING = Messages.RemotingLoginDialog_SCHEMA_MISSING;
|
|
117 |
private final static String MESG_NO_SCHEMA = Messages.RemotingLoginDialog_NO_SCHEMA;
|
|
118 |
|
|
119 |
private final static String LABEL_CONNECT = Messages.RemotingLoginDialog_LABEL_CONNECT;
|
|
120 |
private final static String LABEL_CREATE_SCHEMA = Messages.RemotingLoginDialog_LABEL_CREATE_SCHEMA;
|
|
121 |
private final static String LABEL_UPDATE_SCHEMA_VERSION = Messages.RemotingLoginDialog_LABEL_UPDATE_SCHEMA_VERSION;
|
|
122 |
private final static String MESG_UPDATE_SCHEMA_VERSION = Messages.RemotingLoginDialog_MSG_UPDATE_SCHEMA_VERSION;
|
114 |
123 |
|
115 |
124 |
private final static String STORE_PREFERENCES_NODE = "eu.etaxonomy.taxeditor.store"; //$NON-NLS-1$
|
116 |
125 |
|
... | ... | |
123 |
132 |
private final static String LAST_INSTANCE_KEY = "lastInstanceKey"; //$NON-NLS-1$
|
124 |
133 |
|
125 |
134 |
private Composite remotingComposite;
|
126 |
|
private CdmServerInfo selectedCsii;
|
|
135 |
private CdmServerInfo selectedServerInfo;
|
127 |
136 |
private CdmInstanceInfo selectedCdmInstance;
|
128 |
137 |
private Button btnCdmServerRefresh;
|
129 |
138 |
private Button btnCdmInstanceRefresh;
|
... | ... | |
139 |
148 |
private Text txtPort;
|
140 |
149 |
private Label lblServerVersion;
|
141 |
150 |
private Text txtServerVersion;
|
142 |
|
private ExpandableComposite xpndblcmpstAdvanced;
|
|
151 |
private ExpandableComposite expandableCompositeAdvanced;
|
143 |
152 |
private StyledText styledTxtMessage;
|
144 |
153 |
|
145 |
154 |
// private final int MIN_WIDTH = 530;
|
... | ... | |
149 |
158 |
private final int MESSAGE_HEIGHT = 50;
|
150 |
159 |
private Label lblEditorVersion;
|
151 |
160 |
private Text txtEditorVersion;
|
152 |
|
private Label lblServerCDMVersion;
|
153 |
|
private Text txtServerCDMVersion;
|
154 |
|
private Label lblEditorCDMVersion;
|
155 |
|
private Text txtEditorCDMVersion;
|
|
161 |
private Label lblServerCdmVersion;
|
|
162 |
private Text txtServerCdmVersion;
|
|
163 |
private Label lblEditorCdmVersion;
|
|
164 |
private Text txtEditorCdmVersion;
|
156 |
165 |
|
157 |
166 |
private String serverName, instanceName;
|
158 |
167 |
private boolean autoConnect = false;
|
... | ... | |
178 |
187 |
return open(serverName, instanceName, loadLoginPrefs, autoConnect);
|
179 |
188 |
}
|
180 |
189 |
|
181 |
|
|
182 |
190 |
public Object open(String serverName, String instanceName, boolean loadLoginPrefs, boolean autoConnect) {
|
183 |
191 |
this.serverName = serverName;
|
184 |
192 |
this.instanceName = instanceName;
|
... | ... | |
203 |
211 |
shlConnect.pack(true);
|
204 |
212 |
shlConnect.open();
|
205 |
213 |
|
206 |
|
xpndblcmpstAdvanced.setExpanded(false);
|
|
214 |
expandableCompositeAdvanced.setExpanded(false);
|
207 |
215 |
|
208 |
216 |
Display display = getParent().getDisplay();
|
209 |
217 |
|
... | ... | |
223 |
231 |
*/
|
224 |
232 |
private void createContents() {
|
225 |
233 |
shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
|
226 |
|
shlConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
|
|
234 |
shlConnect.setText(LABEL_CONNECT);
|
227 |
235 |
shlConnect.setLayout(new FillLayout(SWT.HORIZONTAL));
|
228 |
236 |
|
229 |
237 |
remotingComposite = new Composite(shlConnect, SWT.NONE);
|
230 |
238 |
remotingComposite.setLayout(new GridLayout(1, false));
|
231 |
239 |
|
|
240 |
//server
|
232 |
241 |
Composite cdmServerComposite = new Composite(remotingComposite, SWT.NONE);
|
233 |
242 |
GridData gd_cdmServerComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
234 |
243 |
cdmServerComposite.setLayoutData(gd_cdmServerComposite);
|
... | ... | |
267 |
276 |
btnCdmServerRefresh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
268 |
277 |
btnCdmServerRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
|
269 |
278 |
|
|
279 |
//instance
|
270 |
280 |
Label lblCdmInstance = new Label(cdmServerComposite, SWT.NONE);
|
271 |
281 |
GridData gd_lblCdmInstance = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
|
272 |
282 |
//gd_lblCdmInstance.heightHint = 30;
|
... | ... | |
302 |
312 |
btnCdmInstanceRefresh.setLayoutData(gd_btnCdmInstanceRefresh);
|
303 |
313 |
btnCdmInstanceRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH);
|
304 |
314 |
|
|
315 |
//login
|
305 |
316 |
loginComposite = new Composite(remotingComposite, SWT.NONE);
|
306 |
317 |
GridData gd_loginComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
307 |
318 |
loginComposite.setLayoutData(gd_loginComposite);
|
... | ... | |
329 |
340 |
GridData gd_txtPassword = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
|
330 |
341 |
gd_txtPassword.minimumWidth = 80;
|
331 |
342 |
txtPassword.setLayoutData(gd_txtPassword);
|
332 |
|
new Label(loginComposite, SWT.NONE);
|
|
343 |
@SuppressWarnings("unused")
|
|
344 |
Label nope = new Label(loginComposite, SWT.NONE);
|
333 |
345 |
txtPassword.addKeyListener(new KeyAdapter() {
|
334 |
346 |
@Override
|
335 |
347 |
public void keyPressed(KeyEvent e) {
|
... | ... | |
347 |
359 |
connectButtonPressed();
|
348 |
360 |
}
|
349 |
361 |
});
|
350 |
|
btnConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
|
|
362 |
btnConnect.setText(LABEL_CONNECT);
|
351 |
363 |
|
352 |
364 |
btnRememberMe = new Button(loginComposite, SWT.CHECK);
|
353 |
365 |
btnRememberMe.setSelection(true);
|
... | ... | |
375 |
387 |
|
376 |
388 |
styledTxtMessage.setLayoutData(gd_styledTxtMessage);
|
377 |
389 |
|
378 |
|
xpndblcmpstAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE);
|
|
390 |
//Advanced
|
|
391 |
expandableCompositeAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE);
|
379 |
392 |
GridData gd_xpndblcmpstAdvanced = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
|
380 |
|
xpndblcmpstAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
|
381 |
|
xpndblcmpstAdvanced.addExpansionListener(new IExpansionListener() {
|
|
393 |
expandableCompositeAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
|
|
394 |
expandableCompositeAdvanced.addExpansionListener(new IExpansionListener() {
|
382 |
395 |
@Override
|
383 |
396 |
public void expansionStateChanged(ExpansionEvent e) {
|
384 |
397 |
shlConnect.pack(true);
|
... | ... | |
387 |
400 |
public void expansionStateChanging(ExpansionEvent e) {
|
388 |
401 |
}
|
389 |
402 |
});
|
390 |
|
xpndblcmpstAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
|
391 |
|
xpndblcmpstAdvanced.setExpanded(true);
|
|
403 |
expandableCompositeAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
|
|
404 |
expandableCompositeAdvanced.setExpanded(true);
|
392 |
405 |
|
393 |
|
compAdvanced = new Composite(xpndblcmpstAdvanced, SWT.NONE);
|
394 |
|
xpndblcmpstAdvanced.setClient(compAdvanced);
|
|
406 |
compAdvanced = new Composite(expandableCompositeAdvanced, SWT.NONE);
|
|
407 |
expandableCompositeAdvanced.setClient(compAdvanced);
|
395 |
408 |
compAdvanced.setLayout(new GridLayout(4, false));
|
396 |
409 |
|
397 |
410 |
lblPort = new Label(compAdvanced, SWT.CENTER);
|
... | ... | |
432 |
445 |
txtEditorVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
433 |
446 |
addEmptyCells(2);
|
434 |
447 |
|
435 |
|
lblServerCDMVersion = new Label(compAdvanced, SWT.CENTER);
|
436 |
|
lblServerCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
437 |
|
lblServerCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
|
438 |
|
lblServerCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
448 |
lblServerCdmVersion = new Label(compAdvanced, SWT.CENTER);
|
|
449 |
lblServerCdmVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
450 |
lblServerCdmVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
|
|
451 |
lblServerCdmVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
439 |
452 |
|
440 |
|
txtServerCDMVersion = new Text(compAdvanced, SWT.BORDER);
|
441 |
|
txtServerCDMVersion.setEditable(false);
|
442 |
|
txtServerCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER , true, false, 1, 1));
|
|
453 |
txtServerCdmVersion = new Text(compAdvanced, SWT.BORDER);
|
|
454 |
txtServerCdmVersion.setEditable(false);
|
|
455 |
txtServerCdmVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
443 |
456 |
addEmptyCells(2);
|
444 |
457 |
|
445 |
|
lblEditorCDMVersion = new Label(compAdvanced, SWT.CENTER);
|
446 |
|
lblEditorCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
447 |
|
lblEditorCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
|
448 |
|
lblEditorCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
458 |
lblEditorCdmVersion = new Label(compAdvanced, SWT.CENTER);
|
|
459 |
lblEditorCdmVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
460 |
lblEditorCdmVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
|
|
461 |
lblEditorCdmVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
449 |
462 |
|
450 |
|
txtEditorCDMVersion = new Text(compAdvanced, SWT.BORDER);
|
451 |
|
txtEditorCDMVersion.setEditable(false);
|
452 |
|
txtEditorCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
|
463 |
txtEditorCdmVersion = new Text(compAdvanced, SWT.BORDER);
|
|
464 |
txtEditorCdmVersion.setEditable(false);
|
|
465 |
txtEditorCdmVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
453 |
466 |
}
|
454 |
467 |
|
455 |
468 |
@SuppressWarnings("unused")
|
... | ... | |
460 |
473 |
}
|
461 |
474 |
|
462 |
475 |
private void connectButtonPressed() {
|
463 |
|
if(selectedCsii.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
|
|
476 |
if(selectedServerInfo.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
|
464 |
477 |
startManagedServer();
|
465 |
478 |
} else {
|
466 |
479 |
connect();
|
... | ... | |
534 |
547 |
private void updateSelectedCdmServer() {
|
535 |
548 |
int selIndex = comboCdmServer.getSelectionIndex();
|
536 |
549 |
if(selIndex != -1) {
|
537 |
|
selectedCsii = csiiMap.get(comboCdmServer.getItem(selIndex));
|
|
550 |
selectedServerInfo = csiiMap.get(comboCdmServer.getItem(selIndex));
|
538 |
551 |
}
|
539 |
552 |
}
|
540 |
553 |
|
541 |
554 |
private void updatePort() {
|
542 |
555 |
txtPort.setText(""); //$NON-NLS-1$
|
543 |
|
if(selectedCsii != null) {
|
544 |
|
int port = selectedCsii.getPort();
|
|
556 |
if(selectedServerInfo != null) {
|
|
557 |
int port = selectedServerInfo.getPort();
|
545 |
558 |
if(port == CdmServerInfo.NULL_PORT) {
|
546 |
559 |
txtPort.setText(CdmServerInfo.NULL_PORT_STRING);
|
547 |
560 |
} else {
|
... | ... | |
564 |
577 |
|
565 |
578 |
private void checkSelectedCdmServer() {
|
566 |
579 |
try{
|
567 |
|
if(selectedCsii != null) {
|
568 |
|
if(selectedCsii.isLocalhost()) {
|
|
580 |
if(selectedServerInfo != null) {
|
|
581 |
if(selectedServerInfo.isLocalhost()) {
|
569 |
582 |
txtPort.setEditable(true);
|
570 |
583 |
txtPort.setEnabled(true);
|
571 |
584 |
}
|
572 |
585 |
try {
|
573 |
|
if(selectedCsii.pingServer()) {
|
|
586 |
if(selectedServerInfo.pingServer()) {
|
574 |
587 |
txtCdmServerStatus.setText(STATUS_AVAILABLE);
|
575 |
588 |
populateCdmInstanceCombo(true);
|
576 |
|
String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
|
577 |
|
txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
|
|
589 |
String serverVersionTimestamp = generateLastModifiedTooltip(selectedServerInfo.getCdmlibLastModified());
|
|
590 |
txtServerVersion.setText(selectedServerInfo.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
|
578 |
591 |
} else {
|
579 |
592 |
txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
|
580 |
593 |
comboCdmInstance.removeAll();
|
... | ... | |
615 |
628 |
@Override
|
616 |
629 |
protected IStatus run(IProgressMonitor monitor) {
|
617 |
630 |
try {
|
618 |
|
if(selectedCsii != null) {
|
|
631 |
if(selectedServerInfo != null) {
|
619 |
632 |
if(forceRefresh) {
|
620 |
|
selectedCsii.refreshInstances();
|
|
633 |
selectedServerInfo.refreshInstances();
|
621 |
634 |
}
|
622 |
|
final List<CdmInstanceInfo> instances = selectedCsii.getInstances();
|
|
635 |
final List<CdmInstanceInfo> instances = selectedServerInfo.getInstances();
|
623 |
636 |
Display.getDefault().asyncExec(new Runnable() {
|
624 |
637 |
@Override
|
625 |
638 |
public void run() {
|
... | ... | |
688 |
701 |
private void updateSelectedCdmInstance() {
|
689 |
702 |
int selIndex = comboCdmInstance.getSelectionIndex();
|
690 |
703 |
if(selIndex != -1) {
|
691 |
|
selectedCdmInstance = selectedCsii.getInstanceFromName(comboCdmInstance.getItem(selIndex));
|
692 |
|
|
|
704 |
selectedCdmInstance = selectedServerInfo.getInstanceFromName(comboCdmInstance.getItem(selIndex));
|
693 |
705 |
if(loadLoginPrefs) {
|
694 |
706 |
readPrefCredentials();
|
695 |
707 |
}
|
... | ... | |
697 |
709 |
}
|
698 |
710 |
|
699 |
711 |
private void updateManagedServerControls() {
|
700 |
|
if(selectedCsii.isLocalhostMgd()) {
|
|
712 |
if(selectedServerInfo.isLocalhostMgd()) {
|
701 |
713 |
if(isSelectedCdmInstanceRunningInManagedServer()) {
|
702 |
714 |
txtCdmInstanceStatus.setText(STATUS_STARTED);
|
703 |
715 |
} else {
|
704 |
716 |
txtCdmInstanceStatus.setText(STATUS_NOT_STARTED);
|
705 |
717 |
}
|
706 |
718 |
btnConnect.setEnabled(true);
|
707 |
|
selectedCsii.setPort(getManagedServerPort());
|
|
719 |
selectedServerInfo.setPort(getManagedServerPort());
|
708 |
720 |
updatePort();
|
709 |
721 |
}
|
710 |
722 |
|
... | ... | |
722 |
734 |
private boolean isSelectedCdmInstanceRunningInManagedServer() {
|
723 |
735 |
return CdmStore.getManagedServer() != null &&
|
724 |
736 |
CdmStore.getManagedServer().isAlive() &&
|
725 |
|
selectedCsii.isLocalhostMgd() &&
|
|
737 |
selectedServerInfo.isLocalhostMgd() &&
|
726 |
738 |
CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName());
|
727 |
739 |
}
|
728 |
740 |
|
... | ... | |
740 |
752 |
}
|
741 |
753 |
}
|
742 |
754 |
|
|
755 |
boolean forceSchemaCreate = !schemaExists(selectedCdmInstance);
|
|
756 |
boolean forceSchemaUpdate = LABEL_UPDATE_SCHEMA_VERSION.equals(btnConnect.getText());
|
|
757 |
|
743 |
758 |
Job job = new Job(Messages.RemotingLoginDialog_JOB_SERVER_LAUNCH) {
|
744 |
759 |
|
745 |
760 |
@Override
|
... | ... | |
752 |
767 |
monitor.subTask(String.format(Messages.RemotingLoginDialog_GENERATING_CONFIG_FILE, selectedCdmInstance.getName()));
|
753 |
768 |
File managedServerConfigFile = CdmServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
|
754 |
769 |
monitor.worked(1);
|
755 |
|
boolean forceSchemaCreate = CdmStore.getManagedServer() != null
|
756 |
|
&& CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName())
|
757 |
|
&& CdmStore.getManagedServer().isForceSchemaCreate();
|
758 |
|
CdmStore.setManagedServer(new CdmServer(selectedCdmInstance.getName(), managedServerConfigFile));
|
759 |
|
CdmStore.getManagedServer().setForceSchemaCreate(forceSchemaCreate);
|
|
770 |
CdmServer cdmServer = new CdmServer(selectedCdmInstance.getName(), managedServerConfigFile);
|
|
771 |
// boolean forceSchemaCreate = CdmStore.getManagedServer() != null
|
|
772 |
// && CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName())
|
|
773 |
// && CdmStore.getManagedServer().isForceSchemaCreate();
|
|
774 |
cdmServer.setForceSchemaCreate(forceSchemaCreate);
|
|
775 |
cdmServer.setForceSchemaUpdate(forceSchemaUpdate);
|
|
776 |
CdmStore.setManagedServer(cdmServer);
|
760 |
777 |
monitor.subTask(Messages.RemotingLoginDialog_STARTING_MGD_SERVER);
|
761 |
|
CdmStore.getManagedServer().start(false, RemotingLoginDialog.this);
|
|
778 |
cdmServer.start(false, RemotingLoginDialog.this);
|
762 |
779 |
int serverUnits = 0;
|
763 |
780 |
|
764 |
781 |
// the following loop is a 'fake' progress monitoring where the progress
|
... | ... | |
803 |
820 |
|
804 |
821 |
return Status.OK_STATUS;
|
805 |
822 |
}
|
806 |
|
};
|
|
823 |
|
|
824 |
};
|
807 |
825 |
|
808 |
826 |
// configure the job
|
809 |
827 |
job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
|
... | ... | |
813 |
831 |
job.schedule();
|
814 |
832 |
}
|
815 |
833 |
|
|
834 |
private boolean schemaExists(CdmInstanceInfo instanceInfo) {
|
|
835 |
if (instanceInfo.getDataSource() != null){
|
|
836 |
try {
|
|
837 |
//TODO we need a new method in cdmlib to check for existing schema
|
|
838 |
String schemaVersion = instanceInfo.getDataSource().getDbSchemaVersion();
|
|
839 |
return schemaVersion != null;
|
|
840 |
} catch (CdmSourceException e) {
|
|
841 |
return false;
|
|
842 |
}
|
|
843 |
}else{
|
|
844 |
return true;
|
|
845 |
}
|
|
846 |
}
|
|
847 |
|
|
848 |
private String managedSchemaVersion(CdmInstanceInfo instanceInfo) throws CdmSourceException{
|
|
849 |
if (instanceInfo.getDataSource() != null){
|
|
850 |
return instanceInfo.getDataSource().getDbSchemaVersion();
|
|
851 |
}else{
|
|
852 |
throw new RuntimeException("ManagedSchemaVersion only available for managed server instances.");
|
|
853 |
}
|
|
854 |
}
|
|
855 |
private int compareSchemaVersion(CdmInstanceInfo instanceInfo) throws CdmSourceException {
|
|
856 |
return CdmMetaData.compareVersion(managedSchemaVersion(instanceInfo), CdmMetaData.getDbSchemaVersion(), 3, null);
|
|
857 |
}
|
|
858 |
|
816 |
859 |
@Override
|
817 |
860 |
public void handleError(final Throwable t) {
|
818 |
861 |
|
819 |
862 |
if(CdmStore.getManagedServer().isFailed() && CdmStore.getManagedServer().isPotentiallyMissingSchema()) {
|
820 |
863 |
CdmStore.getManagedServer().setForceSchemaCreate(true);
|
821 |
864 |
// we are in a separate thread here, thus update the screen via
|
822 |
|
Display.getDefault().asyncExec(new Runnable() {
|
823 |
|
@Override
|
824 |
|
public void run() {
|
825 |
|
btnConnect.setEnabled(true);
|
826 |
|
btnConnect.setText("Create Schema");
|
827 |
|
btnConnect.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
|
828 |
|
btnConnect.requestLayout();
|
829 |
|
}
|
830 |
|
});
|
|
865 |
checkManagedSelectedInstance();
|
831 |
866 |
} else {
|
832 |
867 |
Display.getDefault().syncExec(new Runnable() {
|
833 |
868 |
@Override
|
... | ... | |
868 |
903 |
}
|
869 |
904 |
|
870 |
905 |
private void checkSelectedCdmInstance() {
|
871 |
|
boolean available = false;
|
872 |
|
String status = STATUS_NOT_AVAILABLE;
|
873 |
|
String message = null;
|
874 |
906 |
|
875 |
|
if(txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) {
|
|
907 |
if (selectedServerInfo.isLocalhostMgd()){
|
|
908 |
checkManagedSelectedInstance();
|
|
909 |
}else if (txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) {
|
|
910 |
boolean available = false;
|
|
911 |
String instanceStatus = STATUS_NOT_AVAILABLE;
|
|
912 |
String message = null;
|
876 |
913 |
try {
|
877 |
|
if(selectedCsii.pingInstance(selectedCdmInstance, getPort())) {
|
878 |
|
status = STATUS_AVAILABLE;
|
|
914 |
if(selectedServerInfo.pingInstance(selectedCdmInstance, getPort())) {
|
|
915 |
instanceStatus = STATUS_AVAILABLE;
|
879 |
916 |
available = true;
|
880 |
917 |
} else {
|
881 |
|
status = STATUS_NOT_AVAILABLE;
|
|
918 |
instanceStatus = STATUS_NOT_AVAILABLE;
|
882 |
919 |
available = false;
|
883 |
920 |
}
|
884 |
921 |
|
885 |
922 |
if(available) {
|
886 |
|
txtServerCDMVersion.setText(selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion());
|
887 |
|
int compareDbSchemaVersion = selectedCsii.compareDbSchemaVersion(selectedCdmInstance, getPort());
|
|
923 |
txtServerCdmVersion.setText(selectedServerInfo.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion());
|
|
924 |
|
|
925 |
int compareDbSchemaVersion = selectedServerInfo.compareDbSchemaVersion(selectedCdmInstance, getPort());
|
|
926 |
|
888 |
927 |
int compareCdmlibServicesVersion = 0;
|
889 |
928 |
boolean disableServicesApiTimestampCheck =
|
890 |
929 |
PreferencesUtil.getBooleanValue((IPreferenceKeys.DISABLE_SERVICES_API_TIMESTAMP_CHECK));
|
891 |
930 |
if(!disableServicesApiTimestampCheck) {
|
892 |
|
compareCdmlibServicesVersion = selectedCsii.compareCdmlibServicesVersion();
|
|
931 |
compareCdmlibServicesVersion = selectedServerInfo.compareCdmlibServicesVersion();
|
893 |
932 |
}
|
|
933 |
|
894 |
934 |
if(compareDbSchemaVersion > 0 || compareCdmlibServicesVersion > 0) {
|
895 |
|
status = STATUS_NOT_COMPATIBLE;
|
|
935 |
instanceStatus = STATUS_NOT_COMPATIBLE;
|
896 |
936 |
available = false;
|
897 |
937 |
message = MESG_COMPATIBLE_EDITOR_OLD;
|
898 |
938 |
} else if(compareDbSchemaVersion < 0 || compareCdmlibServicesVersion < 0) {
|
899 |
|
status = STATUS_NOT_COMPATIBLE;
|
|
939 |
instanceStatus = STATUS_NOT_COMPATIBLE;
|
900 |
940 |
available = false;
|
901 |
941 |
message = MESG_COMPATIBLE_SERVER_OLD;
|
902 |
942 |
} else {
|
903 |
|
status = STATUS_AVAILABLE;
|
|
943 |
instanceStatus = STATUS_AVAILABLE;
|
904 |
944 |
available = true;
|
905 |
945 |
message = ""; //$NON-NLS-1$
|
906 |
946 |
}
|
... | ... | |
909 |
949 |
txtCdmInstanceStatus.setToolTipText(e.getMessage());
|
910 |
950 |
} finally {
|
911 |
951 |
btnConnect.setEnabled(available);
|
912 |
|
txtCdmInstanceStatus.setText(status);
|
|
952 |
txtCdmInstanceStatus.setText(instanceStatus);
|
913 |
953 |
if(!StringUtils.isBlank(message)) {
|
914 |
954 |
setMessage(message);
|
915 |
955 |
}
|
... | ... | |
917 |
957 |
}
|
918 |
958 |
}
|
919 |
959 |
|
|
960 |
private void checkManagedSelectedInstance() {
|
|
961 |
boolean available = false;
|
|
962 |
String instanceStatus = STATUS_NOT_AVAILABLE;
|
|
963 |
String message = null;
|
|
964 |
String connect = LABEL_CONNECT;
|
|
965 |
int color = SWT.COLOR_BLACK;
|
|
966 |
String schemaVersion = CdmMetaData.getDbSchemaVersion();
|
|
967 |
|
|
968 |
if (!schemaExists(selectedCdmInstance)){
|
|
969 |
message = MESG_SCHEMA_MISSING;
|
|
970 |
connect = LABEL_CREATE_SCHEMA;
|
|
971 |
color = SWT.COLOR_RED;
|
|
972 |
schemaVersion = MESG_NO_SCHEMA;
|
|
973 |
} else {
|
|
974 |
int compare;
|
|
975 |
try {
|
|
976 |
schemaVersion = managedSchemaVersion(selectedCdmInstance);
|
|
977 |
compare = compareSchemaVersion(selectedCdmInstance);
|
|
978 |
if (compare > 0){
|
|
979 |
instanceStatus = STATUS_NOT_COMPATIBLE;
|
|
980 |
message = MESG_COMPATIBLE_EDITOR_OLD;
|
|
981 |
available = false;
|
|
982 |
}else if (compare < 0){
|
|
983 |
instanceStatus = STATUS_NOT_COMPATIBLE;
|
|
984 |
message = MESG_UPDATE_SCHEMA_VERSION;
|
|
985 |
available = true;
|
|
986 |
connect = LABEL_UPDATE_SCHEMA_VERSION;
|
|
987 |
color = SWT.COLOR_RED;
|
|
988 |
}else{
|
|
989 |
available = true;
|
|
990 |
}
|
|
991 |
} catch (CdmSourceException e) {
|
|
992 |
available = false;
|
|
993 |
}
|
|
994 |
}
|
|
995 |
|
|
996 |
// Display.getDefault().asyncExec(()->{
|
|
997 |
btnConnect.setEnabled(available);
|
|
998 |
btnConnect.setText(connect);
|
|
999 |
btnConnect.setBackground(Display.getCurrent().getSystemColor(color));
|
|
1000 |
btnConnect.requestLayout();
|
|
1001 |
txtCdmInstanceStatus.setText(instanceStatus);
|
|
1002 |
txtServerCdmVersion.setText(schemaVersion);
|
|
1003 |
|
|
1004 |
// });
|
|
1005 |
|
|
1006 |
// if(!StringUtils.isBlank(message)) {
|
|
1007 |
setMessage(message);
|
|
1008 |
// }
|
|
1009 |
}
|
|
1010 |
|
920 |
1011 |
private void connect() {
|
921 |
1012 |
checkSelectedCdmInstance();
|
922 |
1013 |
|
... | ... | |
924 |
1015 |
return;
|
925 |
1016 |
}
|
926 |
1017 |
|
927 |
|
ICdmRemoteSource source = selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort());
|
|
1018 |
ICdmRemoteSource source = selectedServerInfo.getCdmRemoteSource(selectedCdmInstance, getPort());
|
928 |
1019 |
|
929 |
1020 |
if(!validateLogin(source)) {
|
930 |
1021 |
return;
|
... | ... | |
947 |
1038 |
IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
|
948 |
1039 |
Preferences lastServerInstancePrefs = preferences.node(LAST_SERVER_INSTANCE_NODE);
|
949 |
1040 |
|
950 |
|
lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedCsii.getName());
|
|
1041 |
lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedServerInfo.getName());
|
951 |
1042 |
lastServerInstancePrefs.put(LAST_INSTANCE_KEY, selectedCdmInstance.getName());
|
952 |
1043 |
|
953 |
1044 |
flushPreferences(lastServerInstancePrefs);
|
... | ... | |
1012 |
1103 |
}
|
1013 |
1104 |
|
1014 |
1105 |
private String getUsernamePrefKey() {
|
1015 |
|
return selectedCsii.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + USERNAME_SUFFIX;
|
|
1106 |
return selectedServerInfo.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + USERNAME_SUFFIX;
|
1016 |
1107 |
}
|
1017 |
1108 |
|
1018 |
1109 |
private String getPasswordPrefKey() {
|
1019 |
|
return selectedCsii.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + PASSWORD_SUFFIX;
|
|
1110 |
return selectedServerInfo.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + PASSWORD_SUFFIX;
|
1020 |
1111 |
}
|
1021 |
1112 |
|
1022 |
1113 |
private boolean validateLogin(ICdmRemoteSource remoteSource) {
|
... | ... | |
1055 |
1146 |
}
|
1056 |
1147 |
|
1057 |
1148 |
public void setMessage(String message) {
|
1058 |
|
if(message != null && !message.isEmpty()) {
|
|
1149 |
if(CdmUtils.isNotBlank(message)) {
|
1059 |
1150 |
// if(message.length() > 50) {
|
1060 |
1151 |
// styledTxtMessage.setToolTipText(message);
|
1061 |
1152 |
// message = message.substring(0,50) + "..."; //$NON-NLS-1$
|
... | ... | |
1136 |
1227 |
}
|
1137 |
1228 |
|
1138 |
1229 |
private void setEditorInfo() {
|
1139 |
|
txtEditorCDMVersion.setText(CdmMetaData.getDbSchemaVersion());
|
|
1230 |
txtEditorCdmVersion.setText(CdmMetaData.getDbSchemaVersion());
|
1140 |
1231 |
String editorVersionTimestamp = generateLastModifiedTooltip(CdmApplicationState.getCdmlibLastModified());
|
1141 |
1232 |
txtEditorVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$
|
1142 |
1233 |
}
|
1143 |
1234 |
|
1144 |
1235 |
private void clearOnServerChange() {
|
1145 |
1236 |
setMessage(""); //$NON-NLS-1$
|
1146 |
|
txtServerCDMVersion.setText(""); //$NON-NLS-1$
|
|
1237 |
txtServerCdmVersion.setText(""); //$NON-NLS-1$
|
1147 |
1238 |
txtServerVersion.setText(""); //$NON-NLS-1$
|
1148 |
1239 |
txtServerVersion.setToolTipText(""); //$NON-NLS-1$
|
1149 |
|
txtServerCDMVersion.setText(""); //$NON-NLS-1$
|
|
1240 |
txtServerCdmVersion.setText(""); //$NON-NLS-1$
|
1150 |
1241 |
comboCdmInstance.removeAll();
|
1151 |
1242 |
txtCdmInstanceStatus.setText(""); //$NON-NLS-1$
|
1152 |
1243 |
txtPort.setEditable(false);
|
... | ... | |
1155 |
1246 |
|
1156 |
1247 |
private void clearOnInstanceChange() {
|
1157 |
1248 |
setMessage(""); //$NON-NLS-1$
|
1158 |
|
txtServerCDMVersion.setText(""); //$NON-NLS-1$
|
|
1249 |
txtServerCdmVersion.setText(""); //$NON-NLS-1$
|
1159 |
1250 |
}
|
1160 |
1251 |
}
|
cleanup