Project

General

Profile

« Previous | Next » 

Revision fa8083dd

Added by Andreas Müller over 6 years ago

fix #6961 fix further potential NPEs in TreeNodeDropAdapter and TreeNodeDropAdapterAssistant and cleanup

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapter.java
141 141
		        			CdmStore.currentAuthentiationHasPermission(targetNode.getTaxon(), UPDATE);
142 142

  
143 143
                if(logger.isDebugEnabled()){
144
                    logger.debug("target: " + targetNode.getTaxon().getTitleCache()); //$NON-NLS-1$
144
                    logger.debug("target: " + targetNode.getTaxon() == null? "-" : targetNode.getTaxon().getTitleCache()); //$NON-NLS-1$
145 145
                }
146 146

  
147 147
		        if(!hasTargetNodePermission || ! hasTargetNodePermission){
......
155 155
		    // do not allow to drop onto itself and
156 156
		    // check users permissions with all selected taxon nodes and taxa
157 157
		    for(TaxonNode taxonNode : getSelectedTaxa()){
158
			    logger.debug("selectedTaxa: " + taxonNode.getTaxon().getTitleCache()); //$NON-NLS-1$
158
			    if (logger.isDebugEnabled()){
159
			    	logger.debug("selectedTaxa: " + taxonNode.getTaxon() == null? "-" : taxonNode.getTaxon().getTitleCache()); //$NON-NLS-1$
160
			    }
159 161
			    boolean isSameTaxonNode = taxonNode.equals(target);
160 162
				boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(taxonNode, UPDATE);
161 163
				boolean hasTaxonPermission = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), UPDATE);
......
274 276
		}
275 277
	}
276 278

  
277
	/* (non-Javadoc)
278
	 * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
279
	 */
280 279
	/** {@inheritDoc} */
281 280
	@Override
282 281
    public boolean postOperation(CdmBase objectAffectedByOperation) {
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapterAssistant.java
90 90
		ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
91 91
		if (selection instanceof TreeSelection) {
92 92

  
93
			Iterator selectionIterator = ((TreeSelection) selection).iterator();
93
			Iterator<?> selectionIterator = ((TreeSelection) selection).iterator();
94 94

  
95 95
			while (selectionIterator.hasNext()){
96 96
				Object object = selectionIterator.next();
......
118 118
	        			CdmStore.currentAuthentiationHasPermission(targetNode.getTaxon(), UPDATE);
119 119

  
120 120
                if(logger.isDebugEnabled()){
121
                    logger.debug("target: " + targetNode.getTaxon().getTitleCache()); //$NON-NLS-1$
121
                    logger.debug("target: " + targetNode.getTaxon() == null? "-" : targetNode.getTaxon().getTitleCache()); //$NON-NLS-1$
122 122
                }
123 123

  
124 124
		        if(!hasTargetNodePermission || ! hasTargetNodePermission){
125 125
		            if(logger.isDebugEnabled()){
126
		                logger.debug("CANCEL_STATUS for target node: " + hasTargetNodePermission + " " + hasTargetTaxonPermission + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
126
		                logger.debug("CANCEL_STATUS for target node: " + hasTargetNodePermission + " " + hasTargetTaxonPermission + " "); //$NON-NLS-1$
127 127
		            }
128 128
		            return Status.CANCEL_STATUS;
129 129
		        }
......
132 132
		    // do not allow to drop onto itself and
133 133
		    // check users permissions with all selected taxon nodes and taxa
134 134
		    for(TaxonNode taxonNode : getSelectedTaxa()){
135
			    logger.debug("selectedTaxa: " + taxonNode.getTaxon().getTitleCache()); //$NON-NLS-1$
135
			    if (logger.isDebugEnabled()){
136
			    	logger.debug("selectedTaxa: " + taxonNode.getTaxon() == null? "-" : taxonNode.getTaxon().getTitleCache());
137
			    }
136 138
				boolean isSameTaxonNode = taxonNode.equals(target);
137 139
				boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(taxonNode, UPDATE);
138 140
				boolean hasTaxonPermission = CdmStore.currentAuthentiationHasPermission(taxonNode.getTaxon(), UPDATE);
......
147 149
					return Status.CANCEL_STATUS;
148 150
				}
149 151
			}
150
			logger.debug("OK_STATUS"); //$NON-NLS-1$
152
		    if (logger.isDebugEnabled()){logger.debug("OK_STATUS");} //$NON-NLS-1$
151 153
			return Status.OK_STATUS;
152 154
		}
153
		logger.debug("CANCEL_STATUS"); //$NON-NLS-1$
155
		if (logger.isDebugEnabled()){logger.debug("CANCEL_STATUS");} //$NON-NLS-1$
154 156
		return Status.CANCEL_STATUS;
155 157
	}
156 158

  
......
168 170
		if(targetITaxonTreeNode instanceof TaxonNode){
169 171

  
170 172
			TaxonNode targetTaxonNode = (TaxonNode) targetITaxonTreeNode;
171
		// Make sure parent taxon does not have unsaved changes
173
		    // Make sure parent taxon does not have unsaved changes
172 174
			if (NavigationUtil.isDirty(targetTaxonNode)){
173 175
				MessageDialog.openWarning(NavigationUtil.getShell(), TreeNodeDropAdapter.TREE_NODE_DROP_ADAPTER_UNSAVED_PARENT, TreeNodeDropAdapter.TREE_NODE_DROP_ADAPTER_UNSAVED_PARENT_MESSAGE);
174 176
				return Status.CANCEL_STATUS;
......
176 178

  
177 179
		}
178 180
		Iterator<TaxonNode> taxIterator = taxonNodes.iterator();
179
        Set<UUID> uuids = new HashSet<UUID>();
181
        Set<UUID> uuids = new HashSet<>();
180 182
        TaxonNode node = null;
181 183
        while(taxIterator.hasNext()){
182 184
            node = taxIterator.next();
......
247 249
            } else{
248 250
				return Status.CANCEL_STATUS;
249 251
			}
250

  
251

  
252 252
		}
253 253
	}
254 254

  

Also available in: Unified diff