Project

General

Profile

« Previous | Next » 

Revision 40a41f9f

Added by Andreas Müller almost 4 years ago

cleanup

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/e4/ShowRemotingLoginWindowHandlerE4.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.taxeditor.handler.e4;
11 10

  
12 11
import javax.inject.Named;
......
23 22
import eu.etaxonomy.taxeditor.ui.dialog.RemotingLoginDialog;
24 23

  
25 24
/**
26
 *
27 25
 * @author pplitzner
28 26
 * @date 10.10.2017
29
 *
30 27
 */
31 28
public class ShowRemotingLoginWindowHandlerE4 {
32 29

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/e4/SwitchUserHandlerE4.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.taxeditor.handler.e4;
11 10

  
12 11
import java.util.Collection;
......
33 32
import eu.etaxonomy.taxeditor.ui.dialog.RemotingLoginDialog;
34 33

  
35 34
/**
36
 *
37 35
 * @author pplitzner
38 36
 * @date 10.10.2017
39
 *
40 37
 */
41 38
public class SwitchUserHandlerE4 {
42 39

  
......
50 47

  
51 48
        }
52 49

  
53

  
54 50
		RemotingLoginDialog loginDialog = new RemotingLoginDialog(shell,
55 51
		        SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
56 52

  
57 53
		loginDialog.open((CdmRemoteSource) CdmStore.getActiveCdmSource(), false, false);
58 54

  
59
		 IWorkbench workbench = PlatformUI.getWorkbench();
60
         IWorkbenchWindow window = workbench
55
		IWorkbench workbench = PlatformUI.getWorkbench();
56
        IWorkbenchWindow window = workbench
61 57
                 .getActiveWorkbenchWindow();
62 58

  
63
         IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
64
         IWorkbenchPage page = window.getActivePage();
65
         page.resetPerspective();
59
        IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
60
        IWorkbenchPage page = window.getActivePage();
61
        page.resetPerspective();
66 62
	}
67 63
}
68

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
16 16
 *
17 17
 */
18 18
public class Messages extends NLS {
19
    private static final String BUNDLE_NAME = "src/main/java/eu.etaxonomy.taxeditor.l10n.messages"; //$NON-NLS-1$
20 19

  
20
    private static final String BUNDLE_NAME = "src/main/java/eu.etaxonomy.taxeditor.l10n.messages"; //$NON-NLS-1$
21 21

  
22 22
    public static String AuthenticatedUserBar_LOGGED_IN_AS;
23 23
    public static String AuthenticatedUserBar_NOT_LOGGED_IN;
......
26 26
    public static String LanguageEditorPreferencePage_PleaseRestart;
27 27
    public static String LanguageEditorPreferencePage_RestartRequired;
28 28

  
29

  
30 29
    public static String LanguageMenuPreferences_configure;
31 30
    public static String CommonNameLanguageMenuPreferences_configure;
32 31

  
......
745 744
    public static String CommonNameVocabularyPreferencePage_description;
746 745
    public static String CommonNameLanguagePreferencePage_description;
747 746

  
748

  
749 747
    public static String AggregationWizardPage_WITHOUT_CHILDREN;
750 748

  
751 749

  
752

  
753

  
754

  
755 750
    static {
756 751
        // initialize resource bundle
757 752
        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/security/AuthenticationSourceProvider.java
22 22
 * variable {@code eu.etaxonomy.taxeditor.security.userRoles}
23 23
 *
24 24
 * @author a.kohlbecker
25
 *
26 25
 */
27 26
public class AuthenticationSourceProvider extends AbstractSourceProvider implements Observer {
28 27

  
......
68 67
		return stateMap;
69 68
	}
70 69

  
71
	/**
72
     * @return
73
     */
74 70
    private String getCurrentAutheticationName() {
75 71
        Authentication authentication = CdmStore.getCurrentAuthentiation();
76 72
        if (authentication != null) {
......
96 92
	 */
97 93
	private List<Role> getCurrentAuthenticationsRoles() {
98 94

  
99
		List<Role> roles = new ArrayList<Role>();
95
		List<Role> roles = new ArrayList<>();
100 96
		Authentication authentication = CdmStore.getCurrentAuthentiation();
101 97
		if (authentication == null) {
102 98
			return roles;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
17 17
import org.slf4j.Marker;
18 18
import org.springframework.core.io.ClassPathResource;
19 19
import org.springframework.core.io.Resource;
20
import org.springframework.security.access.PermissionEvaluator;
21 20
import org.springframework.security.authentication.AuthenticationManager;
22 21
import org.springframework.security.core.Authentication;
23 22
import org.springframework.security.core.GrantedAuthority;
......
113 112
 *
114 113
 * @author n.hoffmann
115 114
 * @created 17.03.2009
116
 * @version 1.0
117 115
 */
118 116
public class CdmStore {
119 117

  
120 118
    private static final Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource(
121 119
            "/eu/etaxonomy/cdm/editorApplicationContext.xml",
122 120
            TaxeditorStorePlugin.class);
121

  
123 122
    private static final DbSchemaValidation DEFAULT_DB_SCHEMA_VALIDATION = DbSchemaValidation.VALIDATE;
124 123

  
125 124
    private static CdmStore instance;
......
151 150

  
152 151

  
153 152
    /**
154
     * <p>
155
     * getDefault
156
     * </p>
157
     *
158 153
     * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
159 154
     */
160 155
    protected static CdmStore getDefault(boolean connecting){
......
166 161
            }else{
167 162
                MessagingUtils.noDataSourceWarningDialog(instance);
168 163
            }
169

  
170

  
171 164
            return null;
172 165
        }
173 166
    }
167

  
174 168
    /**
175 169
     * <p>
176 170
     * getDefault
......
423 417
     */
424 418
    public static ICommonService getCommonService() {
425 419
        return CdmApplicationState.getCommonService();
426

  
427 420
    }
428 421

  
429
    /**
430
     * <p>
431
     * getAuthenticationManager
432
     * </p>
433
     *
434
     * @return a
435
     *         {@link org.springframework.security.authentication.ProviderManager}
436
     *         object.
437
     */
438 422
    public static AuthenticationManager getAuthenticationManager() {
439 423
        return getCurrentApplicationConfiguration().getAuthenticationManager();
440 424
    }
441 425

  
442
    /**
443
     * <p>
444
     * getAuthenticationManager
445
     * </p>
446
     *
447
     * @return a
448
     *         {@link ICdmPermissionEvaluator} object.
449
     */
450 426
    public static ICdmPermissionEvaluator getPermissionEvaluator() {
451 427
        return getCurrentApplicationConfiguration().getPermissionEvaluator();
452 428
    }
......
466 442
    public static boolean currentAuthentiationHasPermission(CdmBase targetDomainObject, EnumSet<CRUD> permission){
467 443
        //TODO use getCurrentApplicationConfiguration().currentAuthentiationHasPermission(CdmBase targetDomainObject, Operation permission) instead
468 444
        SecurityContext context = SecurityContextHolder.getContext();
469
        PermissionEvaluator pe = getPermissionEvaluator();
470 445
        boolean hasPermission = false;
471 446
        try {
472 447
            hasPermission = getPermissionEvaluator().hasPermission(context.getAuthentication(), targetDomainObject,
......
656 631
    }
657 632

  
658 633

  
634
    @SuppressWarnings("unchecked")
659 635
    public static <T extends CdmBase> IService<T> getService(T cdmBase){
660 636
        IService<T> service = null;
661 637
        if(cdmBase!=null){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
36 36
import eu.etaxonomy.taxeditor.event.EventUtility;
37 37
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
38 38
import eu.etaxonomy.taxeditor.l10n.Messages;
39
import eu.etaxonomy.taxeditor.model.AbstractUtility;
39 40
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
40 41
import eu.etaxonomy.taxeditor.model.MessagingUtils;
41 42
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
......
53 54
    private DbSchemaValidation dbSchemaValidation;
54 55
    private final Resource applicationContextBean;
55 56

  
56
    /**
57
     * @param datasource
58
     * @param dbSchemaValidation
59
     * @param applicationContextBean
60
     */
61 57
    public CdmStoreConnector(Display display,
62 58
            ICdmSource cdmSource,
63 59
            DbSchemaValidation dbSchemaValidation,
......
134 130
        loginDialog.setMessage(null);
135 131
        loginDialog.hide(true);
136 132

  
137
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell());
133
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(AbstractUtility.getShell());
138 134

  
139 135
        try {
140 136
            dialog.run(true, true, new IRunnableWithProgress() {
......
159 155
                        cdmSource.closeOpenConnections();
160 156

  
161 157
                        display.syncExec(new Runnable() {
162
                            /*
163
                             * (non-Javadoc)
164
                             *
165
                             * @see java.lang.Runnable#run()
166
                             */
167 158
                            @Override
168 159
                            public void run() {
169 160
                                // close the current context
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/LoginManager.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.taxeditor.store;
11 10

  
12 11
import java.util.Observable;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/StoreUtil.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.store;
11 11

  
12
import java.util.UUID;
13

  
14 12
import org.eclipse.core.commands.operations.IOperationHistory;
15 13
import org.eclipse.core.commands.operations.IUndoContext;
16 14
import org.eclipse.core.runtime.NullProgressMonitor;
......
43 41
 *
44 42
 * @author n.hoffmann
45 43
 * @created 11.05.2009
46
 * @version 1.0
47 44
 */
48 45
public class StoreUtil extends AbstractUtility {
49 46

  
50
	/**
51
	 * <p>checktaxonExists</p>
52
	 *
53
	 * @param fromString a {@link java.util.UUID} object.
54
	 */
55
	public static void checktaxonExists(UUID fromString) {
56
//        if (CdmStore.getTaxonService().getTaxonByUuid(UUID.fromString(uuid)) == null) {
57
//        	logger.warn("Couldn't find taxon with UUID " + uuid);
58
//        	return null;
59
//        }
60
	}
61

  
62 47
	/**
63 48
	 * If the object given is already a {@link CdmBase} then it is returned.<br>
64 49
	 * If it is a kind of "container" for CDM objects then it is asked for its "responsible" CdmBase entity.<br>
......
83 68
        throw new IllegalArgumentException("Object " + object.toString() + " is neither a CdmBase nor a CDM \"container\"");
84 69
	}
85 70

  
86
	/**
87
	 * <p>getOperationHistory</p>
88
	 *
89
	 * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
90
	 */
91 71
	public static IOperationHistory getOperationHistory() {
92 72
		return TaxeditorStorePlugin.getDefault().getWorkbench().
93 73
					getOperationSupport().getOperationHistory();
94 74
	}
95 75

  
96
	/**
97
	 * <p>setStatusLineManager</p>
98
	 *
99
	 * @param manager a {@link org.eclipse.jface.action.IStatusLineManager} object.
100
	 */
101 76
	public static void setStatusLineManager(IStatusLineManager manager) {
102 77
		statusLineManager = manager;
103 78
	}
......
115 90
        }
116 91
    }
117 92

  
118

  
119
	/**
120
	 * <p>getUndoContext</p>
121
	 *
122
	 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
123
	 */
124 93
	public static IUndoContext getUndoContext(){
125 94
		return IOperationHistory.GLOBAL_UNDO_CONTEXT;
126 95
	}
127 96

  
128
	/**
129
	 * <p>getPluginId</p>
130
	 *
131
	 * @return a {@link java.lang.String} object.
132
	 */
133 97
	public static String getPluginId(){
134 98
		return TaxeditorStorePlugin.PLUGIN_ID;
135 99
	}
......
240 204
        return style;
241 205
    }
242 206

  
243
    public static String getPath(TermNode node){
207
    public static String getPath(TermNode<?> node){
244 208
        String path = node.getTerm().getLabel();
245
        TermNode parent = node.getParent();
209
        TermNode<?> parent = node.getParent();
246 210
        while(parent != null && parent.getTerm()!=null){
247 211
            path = parent.getTerm().getLabel() + "/" + path;
248 212
            parent = parent.getParent();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
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
}

Also available in: Unified diff