Project

General

Profile

« Previous | Next » 

Revision 6c58d852

Added by Katja Luther about 5 years ago

ref #7993: handle exception when user has no role remoting

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
203 203
                                    try {
204 204
                                        // create new security context
205 205
                                        CdmStore.getLoginManager().doAuthenticate(loginDialog.getUsername(), loginDialog.getPassword());
206
                                        loginDialog.onComplete();
206
                                        //loginDialog.onComplete();
207 207
                                        CdmStore.getContextManager().notifyContextStart();
208
                                        loginDialog.onComplete();
208 209
                                        getInstance(Rank.class).resetTerms();
209 210
                                        getInstance(NomenclaturalStatusType.class).resetTerms();
210 211
                                        Rank.initDefaultTerms();
211 212
                                        NomenclaturalStatusType.initDefaultTerms();
212 213
                                    } catch(CdmAuthenticationException cae) {
213 214
                                        loginDialog.hide(false);
214
                                        loginDialog.setMessage(cae.getMessage());
215
                                        loginDialog.setMessage("You are logged in now but you are not permitted to use the TaxEditor with the data source "+ cdmSource.getName());
215 216
                                    }
216 217

  
217 218
                                }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
61 61
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
62 62
import eu.etaxonomy.cdm.api.service.IUserService;
63 63
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
64
import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
64 65
import eu.etaxonomy.taxeditor.l10n.Messages;
65 66
import eu.etaxonomy.taxeditor.model.MessagingUtils;
66 67
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
......
209 210
        Display display = getParent().getDisplay();
210 211

  
211 212
        while (!shlConnect.isDisposed()) {
212
            if (!display.readAndDispatch()) {
213
                display.sleep();
213
            if (!display.isDisposed()){
214
                if (!display.readAndDispatch()) {
215
                    display.sleep();
216
                }
214 217
            }
215 218
        }
216 219

  
......
481 484
			startManagedServer();
482 485
		} else {
483 486
			connect();
484
			if (CdmStore.isActive()){
487
			if (CdmStore.isActive() && CdmStore.currentAuthentiationHasOneOfRoles(Role.ROLE_REMOTING)){
485 488
			    PreferencesUtil.setNomenclaturalCodePreferences();
486 489
			}
487 490

  
......
1030 1033

  
1031 1034
    public void setMessage(String message) {
1032 1035
        if(message != null && !message.isEmpty()) {
1033
            if(message.length() > 60) {
1036
            if(message.length() > 50) {
1034 1037
                styledTxtMessage.setToolTipText(message);
1035
                message = message.substring(0, 60) + "..."; //$NON-NLS-1$
1038
                message = message.substring(0,50) + "..."; //$NON-NLS-1$
1036 1039
            }
1037 1040
            styledTxtMessage.setText(message);
1038 1041
            styledTxtMessage.setVisible(true);
......
1040 1043
            shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
1041 1044
            shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
1042 1045
        } else {
1043
            styledTxtMessage.setText(""); //$NON-NLS-1$
1044
            styledTxtMessage.setVisible(false);
1045
            ((GridData)styledTxtMessage.getLayoutData()).exclude = true;
1046
            shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
1047
            shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
1046
            if (!styledTxtMessage.isDisposed()){
1047
                styledTxtMessage.setText(""); //$NON-NLS-1$
1048
                styledTxtMessage.setVisible(false);
1049
                ((GridData)styledTxtMessage.getLayoutData()).exclude = true;
1050
            }
1051
            if(!shlConnect.isDisposed()){
1052
                shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
1053
                shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
1054
            }
1055
        }
1056
        if (!remotingComposite.isDisposed()){
1057
            remotingComposite.layout();
1048 1058
        }
1049
        remotingComposite.layout();
1050 1059
    }
1051 1060

  
1052 1061
    private int getHeightWithoutMessage() {
......
1059 1068

  
1060 1069

  
1061 1070
    public void hide(boolean isHidden) {
1062
        if(shlConnect != null && shlConnect.getDisplay() != null) {
1063
            shlConnect.setVisible(!isHidden);
1071
        if (!shlConnect.isDisposed()){
1072
            if(shlConnect != null && shlConnect.getDisplay() != null) {
1073
                shlConnect.setVisible(!isHidden);
1074
            }
1064 1075
        }
1065 1076
    }
1066 1077
    public void dispose() {
1067
        if(shlConnect != null && shlConnect.getDisplay() != null) {
1068
            shlConnect.dispose();
1078
        if (!shlConnect.isDisposed()){
1079
            if(shlConnect != null && shlConnect.getDisplay() != null) {
1080
                shlConnect.dispose();
1081
            }
1069 1082
        }
1070 1083
    }
1071 1084

  

Also available in: Unified diff