Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 167600 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/messages.properties (+1 lines)
Lines 53-58 Link Here
53
FILE_EXT_MUST_BE_CAP = File extension must be "{0}"
53
FILE_EXT_MUST_BE_CAP = File extension must be "{0}"
54
FILE_ALREADY_EXISTS = File already exists
54
FILE_ALREADY_EXISTS = File already exists
55
INVALID_FILE_NAME = Invalid file name
55
INVALID_FILE_NAME = Invalid file name
56
DUPLICATE_CAPABILITY = Duplicate capability : {0}
56
57
57
CAP_FILES = Capability files
58
CAP_FILES = Capability files
58
CAP_FILES_WIZ_PAGE_DESCRIPTION = This wizard will create following different files to represent capability.
59
CAP_FILES_WIZ_PAGE_DESCRIPTION = This wizard will create following different files to represent capability.
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/capability/internal/Messages.java (+1 lines)
Lines 61-66 Link Here
61
	   public static String FILE_EXT_MUST_BE_CAP;
61
	   public static String FILE_EXT_MUST_BE_CAP;
62
	   public static String FILE_ALREADY_EXISTS;
62
	   public static String FILE_ALREADY_EXISTS;
63
	   public static String INVALID_FILE_NAME;
63
	   public static String INVALID_FILE_NAME;
64
	   public static String DUPLICATE_CAPABILITY;
64
	   
65
	   
65
	   public static String SELECT_CAPABILITY_IMPORTER;
66
	   public static String SELECT_CAPABILITY_IMPORTER;
66
	   public static String CAPABILITY_IMPORTERS;
67
	   public static String CAPABILITY_IMPORTERS;
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/internal/CapabilityWSDLValidator.java (-2 / +31 lines)
Lines 162-181 Link Here
162
    private void performExtraValidation(Definition definition)
162
    private void performExtraValidation(Definition definition)
163
    {
163
    {
164
	String name = definition.getQName().getLocalPart();
164
	String name = definition.getQName().getLocalPart();
165
	String namespace = definition.getQName().getNamespaceURI();
165
	String namespace = definition.getTargetNamespace();
166
	
167
	// Validate capability name
166
	if (name == null || name.equals(""))
168
	if (name == null || name.equals(""))
167
	{
169
	{
168
	    IValidationMessage message = ValidationUtils
170
	    IValidationMessage message = ValidationUtils
169
		    .createNewErrorMessage(INVALID_CAPABILITY_NAME_MESSAGE);
171
		    .createNewErrorMessage(INVALID_CAPABILITY_NAME_MESSAGE);
170
	    _consolidatedReport.addValidationMessage(message);
172
	    _consolidatedReport.addValidationMessage(message);
171
	}
173
	}
174
	
175
	// Validate capability namespace
172
	if (!Validation.isNamespace(namespace))
176
	if (!Validation.isNamespace(namespace))
173
	{
177
	{
174
	    IValidationMessage message = ValidationUtils
178
	    IValidationMessage message = ValidationUtils
175
		    .createNewErrorMessage(INVALID_CAPABILITY_NAMESPACE_MESSAGE);
179
		    .createNewErrorMessage(INVALID_CAPABILITY_NAMESPACE_MESSAGE);
176
	    _consolidatedReport.addValidationMessage(message);
180
	    _consolidatedReport.addValidationMessage(message);
177
	}
181
	}
178
182
	
183
	// Validate Duplicate capability
184
	// NOTE : Fix for Bug 167600 "No validation, When Creating Duplicate Capability"
185
	// http://bugs.eclipse.org/bugs/show_bug.cgi?id=167600
186
	try {
187
		Map capabilitiesMap = CapUtils.getAllCapabilitiesMap();
188
		Object value = capabilitiesMap.get(namespace);
189
		if(value!=null){
190
			List list = (List) value;
191
			if(list.size()>1){
192
				IValidationMessage message = ValidationUtils
193
			    .createNewErrorMessage(Messages.bind(Messages.DUPLICATE_CAPABILITY, name));
194
				_consolidatedReport.addValidationMessage(message);	    
195
			}
196
		}
197
	} catch (Exception e) {
198
		IValidationMessage message = ValidationUtils
199
	    .createNewErrorMessage(e.getMessage());
200
		_consolidatedReport.addValidationMessage(message);
201
		return;
202
	}
203
	
204
	// Validate capability port type
179
	PortType pt = WsdlUtils.getPortType(definition);
205
	PortType pt = WsdlUtils.getPortType(definition);
180
	if (pt == null)
206
	if (pt == null)
181
	{
207
	{
Lines 186-191 Link Here
186
	}
212
	}
187
213
188
	Map map = WsdlUtils.getMetadataFromPortType(definition);
214
	Map map = WsdlUtils.getMetadataFromPortType(definition);
215
	
216
	// Check for Resource property element
189
	String resourceProperties = (String) map
217
	String resourceProperties = (String) map
190
		.get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY);
218
		.get(WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY);
191
	if (resourceProperties == null || resourceProperties.equals(""))
219
	if (resourceProperties == null || resourceProperties.equals(""))
Lines 195-200 Link Here
195
	    _consolidatedReport.addValidationMessage(message);
223
	    _consolidatedReport.addValidationMessage(message);
196
	}
224
	}
197
225
226
	// Check for Metadescriptor element
198
	String metadataDescriptorLocation = (String) map
227
	String metadataDescriptorLocation = (String) map
199
		.get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY);
228
		.get(WsdlUtils.METADATA_DESCRIPTOR_LOCATION_KEY);
200
	if (metadataDescriptorLocation == null
229
	if (metadataDescriptorLocation == null
(-)src/org/eclipse/tptp/wsdm/tooling/util/internal/CapUtils.java (+74 lines)
Lines 16-27 Link Here
16
import java.io.StringWriter;
16
import java.io.StringWriter;
17
import java.util.ArrayList;
17
import java.util.ArrayList;
18
import java.util.Arrays;
18
import java.util.Arrays;
19
import java.util.HashMap;
19
import java.util.LinkedList;
20
import java.util.LinkedList;
20
import java.util.List;
21
import java.util.List;
22
import java.util.Map;
21
23
22
import org.apache.muse.util.xml.XmlUtils;
24
import org.apache.muse.util.xml.XmlUtils;
23
import org.apache.xml.serialize.OutputFormat;
25
import org.apache.xml.serialize.OutputFormat;
24
import org.apache.xml.serialize.XMLSerializer;
26
import org.apache.xml.serialize.XMLSerializer;
27
import org.eclipse.core.resources.IFile;
28
import org.eclipse.core.resources.IWorkspaceRoot;
29
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.EList;
26
import org.eclipse.osgi.util.NLS;
31
import org.eclipse.osgi.util.NLS;
27
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
32
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
Lines 62-67 Link Here
62
	    "static", "void", "class", "finally", "long", "strictfp",
67
	    "static", "void", "class", "finally", "long", "strictfp",
63
	    "volatile", "const", "float", "native", "super", "while", "true",
68
	    "volatile", "const", "float", "native", "super", "while", "true",
64
	    "false", "null" });
69
	    "false", "null" });
70
    
71
    // This map will contain Capability URI as key and List of Capability WSDL Definition as value  
72
    // all of which have the same capability uri 
73
    private static Map standardCapabilityMap = null;
65
74
66
    /**
75
    /**
67
         * This method will retun the root topic , provided any child topic or
76
         * This method will retun the root topic , provided any child topic or
Lines 498-501 Link Here
498
	}
507
	}
499
	return (Element[]) result.toArray(new Element[result.size()]);
508
	return (Element[]) result.toArray(new Element[result.size()]);
500
    }
509
    }
510
    
511
    /**
512
     * Returns the Map of All capabilites available (Standarad+Workspace).
513
     * Key will be Capability URI and Value will be List of Capability WSDL Definition 
514
     * which maps to same Capability URI. 
515
     * @throws Exception 
516
     */
517
    public static Map getAllCapabilitiesMap() throws Exception{
518
    	if(standardCapabilityMap == null){
519
    		standardCapabilityMap = new HashMap();
520
    		// Get All ManagementCapabilities
521
    		Definition[] caps = (Definition[]) MrtUtils.getManagementCapabilities().toArray(new Definition[0]);
522
    		poplulateCapabilityMap(standardCapabilityMap, caps);
523
    		// Get All ManagementRelatedCapabilities
524
    		caps = (Definition[]) MrtUtils.getManagementRelatedCapabilities().toArray(new Definition[0]);
525
    		poplulateCapabilityMap(standardCapabilityMap, caps);
526
    		// Get All ResourcePropertyCapabilities
527
    		caps = (Definition[]) MrtUtils.getResourcePropertyCapabilities().toArray(new Definition[0]);
528
    		poplulateCapabilityMap(standardCapabilityMap, caps);
529
    		// Get All ResourceLifetimeCapabilities
530
    		caps = (Definition[]) MrtUtils.getResourceLifetimeCapabilities().toArray(new Definition[0]);
531
    		poplulateCapabilityMap(standardCapabilityMap, caps);
532
    	}    	
533
    	Map allCapabilities = new HashMap();
534
    	allCapabilities.putAll(standardCapabilityMap);
535
    	// Get All WorkspaceCapabilities
536
    	Definition[] workspaceCapabilities = getAllWorkspaceCapabilities();
537
    	poplulateCapabilityMap(allCapabilities, workspaceCapabilities);
538
    	return allCapabilities;
539
    }
540
    
541
    private static void poplulateCapabilityMap(Map map, Definition[] capabilities){
542
    	for(int i=0;i<capabilities.length;i++){
543
			String key = capabilities[i].getNamespace("capabilityURI");
544
			if(key == null)
545
				key = capabilities[i].getTargetNamespace();
546
			Object value = map.get(key);
547
			if(value == null){
548
				List list = new LinkedList();
549
				list.add(capabilities[i]);
550
				map.put(key, list);							
551
			}
552
			else{
553
				List list = (List) value;
554
				list.add(capabilities[i]);
555
			}			
556
		}
557
    }
558
    
559
    
560
    /**
561
     * Returns all the Workspace capabilities. 
562
     */
563
    public static Definition[] getAllWorkspaceCapabilities() throws Exception{
564
    	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
565
    	List allWSDLs = new LinkedList();
566
    	List wsdls = EclipseUtils.getResourcesOfExtension(root, "mcap");
567
    	for (int i=0;i<wsdls.size();i++) {
568
			IFile wsdlFile = (IFile)wsdls.get(i);
569
			Definition wsdlDef = WsdlUtils.getWSDLDefinition(wsdlFile);
570
			if(wsdlDef!=null)
571
				allWSDLs.add(wsdlDef);
572
		}
573
    	return (Definition[]) allWSDLs.toArray(new Definition[allWSDLs.size()]);
574
    }
501
}
575
}
(-)src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizardPage.java (-3 / +22 lines)
Lines 12-24 Link Here
12
12
13
package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal;
13
package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal;
14
14
15
import java.util.Map;
16
15
import org.eclipse.core.resources.IContainer;
17
import org.eclipse.core.resources.IContainer;
16
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.Path;
20
import org.eclipse.core.runtime.Path;
19
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.ISelection;
20
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.wizard.IWizardPage;
22
import org.eclipse.jface.wizard.WizardPage;
23
import org.eclipse.jface.wizard.WizardPage;
23
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
Lines 36-41 Link Here
36
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
37
import org.eclipse.tptp.wsdm.tooling.util.internal.CapUtils;
37
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
38
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
38
import org.eclipse.tptp.wsdm.tooling.util.internal.Validation;
39
import org.eclipse.tptp.wsdm.tooling.util.internal.Validation;
40
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
39
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
41
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
40
42
41
/**
43
/**
Lines 60-65 Link Here
60
    private NewCapabilityWizard _wizard;
62
    private NewCapabilityWizard _wizard;
61
63
62
    private String _oldCapname;
64
    private String _oldCapname;
65
    
66
    private Map _allCapabilitiesMap;
63
67
64
    /**
68
    /**
65
     * Creates new object of this class. 
69
     * Creates new object of this class. 
Lines 173-178 Link Here
173
	_qNameWgt.getNamespaceText().setText(nsDefault + getFileName());
177
	_qNameWgt.getNamespaceText().setText(nsDefault + getFileName());
174
	
178
	
175
	_oldCapname = getFileName();
179
	_oldCapname = getFileName();
180
	
181
	try {
182
		_allCapabilitiesMap = CapUtils.getAllCapabilitiesMap();
183
	} catch (Exception e) {
184
		WsdmToolingLog.logError(e.getMessage(), e);
185
	}
176
    }
186
    }
177
187
178
    /**
188
    /**
Lines 203-209 Link Here
203
    {
213
    {
204
	String prefix = getPrefix();
214
	String prefix = getPrefix();
205
	String name = getCapabilityName();
215
	String name = getCapabilityName();
206
	String ns = getNamespace();
216
	final String ns = getNamespace();
207
	String container = getContainerName();
217
	String container = getContainerName();
208
	String fileName = getTargetFileName();
218
	String fileName = getTargetFileName();
209
219
Lines 289-295 Link Here
289
	    updateStatus(Messages.INVALID_FILE_NAME);
299
	    updateStatus(Messages.INVALID_FILE_NAME);
290
	    return;
300
	    return;
291
	}
301
	}
292
302
	
303
	// NOTE : Fix for Bug 167600 "No validation, When Creating Duplicate Capability"
304
	// http://bugs.eclipse.org/bugs/show_bug.cgi?id=167600
305
	if(_allCapabilitiesMap!=null){
306
		if(_allCapabilitiesMap.get(ns)!=null){
307
			updateStatus(Messages.bind(Messages.DUPLICATE_CAPABILITY, ns));
308
		    return;
309
		}
310
	}
311
	
293
	updateStatus(null);
312
	updateStatus(null);
294
    }
313
    }
295
314

Return to bug 167600