1 package org.netbeans.modules.xml.wsdl.model; 2 3 import java.io.File ; 4 import java.net.URI ; 5 import java.net.URISyntaxException ; 6 import org.netbeans.modules.xml.xam.ModelSource; 7 import org.openide.cookies.SaveCookie; 8 import org.openide.filesystems.FileObject; 9 import org.openide.filesystems.FileUtil; 10 import org.openide.loaders.DataObject; 11 12 16 public enum NamespaceLocation { 17 HOTEL("http://www.sun.com/javaone/05/HotelReservationService", "resources/HotelReservationService.wsdl"), 18 AIRLINE("http://www.sun.com/javaone/05/AirlineReservationService", "resources/AirlineReservationService.wsdl"), 19 EMPTY_TRAVEL("http://www.sun.com/javaone/05/TravelReservationService", "resources/emptyTravel.wsdl"), 20 TRAVEL("http://www.sun.com/javaone/05/TravelReservationService", "resources/TravelReservationService.wsdl"), 21 VEHICLE("http://www.sun.com/javaone/05/VehicleReservationService", "resources/VehicleReservationService.wsdl"), 22 OTA("http://www.opentravel.org/OTA/2003/05", "resources/OTA_TravelItinerary.xsd"), 23 TESTOP("test/operations", "resources/TestOperations.wsdl"), 24 TESTIMPORT("http://com.stc.database/pointbase/purchaseOrder", "resources/testImports.wsdl"), 25 PO_1("http://com.stc.database/pointbase/purchaseOrder", "resources/purchaseOrder_1.xsd"), 26 PO("http://www.w3.org/2001/XMLSchema", "resources/PurchaseOrder.xsd"), 27 SCHEMA_NS_IN_WSDL("http://new.webservice.namespace", "resources/schemaUsingNamespaceFromWsdlRoot.wsdl"), 28 ECHO("http://localhost/echo/echo", "resources/echo.wsdl"), 29 ECHOCONCAT("http://stc.com/echoConcat", "resources/echoConcat.wsdl"), 30 PARKING("urn:ParkingLotManager/wsdl", "resources/ParkingLotManager.wsdl"); 31 32 private String namespace; 33 private String resourcePath; 34 private String location; 35 36 37 NamespaceLocation(String namespace, String resourcePath) { 38 this.namespace = namespace; 39 this.resourcePath = resourcePath; 40 this.location = resourcePath.substring(resourcePath.lastIndexOf("resources/")+10); 41 } 42 public String getNamespace() { return namespace; } 43 public String getResourcePath() { return resourcePath; } 44 public URI getLocationURI() throws URISyntaxException { 45 return new URI (getLocation()); 46 } 47 public String getLocation() { return location; } 48 public URI getNamespaceURI() throws URISyntaxException { return new URI (getNamespace()); } 49 public static File wsdlTestDir = null; 50 public static File getSchemaTestTempDir() throws Exception { 51 if (wsdlTestDir == null) { 52 wsdlTestDir = Util.getTempDir("wsdltest"); 53 } 54 return wsdlTestDir; 55 } 56 public File getResourceFile() throws Exception { 57 return new File (getSchemaTestTempDir(), Util.getFileName(getResourcePath())); 58 } 59 public void refreshResourceFile() throws Exception { 60 if (getResourceFile().exists()) { 61 ModelSource source = TestCatalogModel.getDefault().getModelSource(getLocationURI()); 62 DataObject dobj = (DataObject) source.getLookup().lookup(DataObject.class); 63 SaveCookie save = (SaveCookie) dobj.getCookie(SaveCookie.class); 64 if (save != null) save.save(); 65 FileObject fo = (FileObject) source.getLookup().lookup(FileObject.class); 66 fo.delete(); 67 } 68 Util.copyResource(getResourcePath(), FileUtil.toFileObject(getSchemaTestTempDir().getCanonicalFile())); 69 } 70 public URI getResourceURI() throws Exception { 71 return getResourceFile().toURI(); 72 } 73 public static NamespaceLocation valueFromResourcePath(String resourcePath) { 74 for (NamespaceLocation nl : values()) { 75 if (nl.getResourcePath().equals(resourcePath)) { 76 return nl; 77 } 78 } 79 return null; 80 } 81 } 82 | Popular Tags |