1 19 20 package org.netbeans.modules.j2ee.sun.ide.j2ee; 21 22 import java.beans.FeatureDescriptor ; 23 import java.beans.PropertyChangeListener ; 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.util.ArrayList ; 27 import java.util.Enumeration ; 28 import java.util.List ; 29 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 30 import org.netbeans.modules.j2ee.sun.api.ServerLocationManager; 31 import org.netbeans.modules.xml.api.model.GrammarEnvironment; 32 import org.netbeans.modules.xml.api.model.GrammarQuery; 33 import org.openide.util.NbBundle; 34 import org.openide.util.Utilities; 35 import org.w3c.dom.Element ; 36 import org.w3c.dom.Node ; 37 import org.netbeans.modules.xml.api.model.DTDUtil; 38 import org.netbeans.api.xml.services.UserCatalog; 39 import org.netbeans.modules.xml.api.model.GrammarQueryManager; 40 import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor; 41 import org.netbeans.modules.xml.catalog.spi.CatalogListener; 42 import org.netbeans.modules.xml.catalog.spi.CatalogReader; 43 import org.xml.sax.EntityResolver ; 44 import org.xml.sax.InputSource ; 45 import org.xml.sax.SAXException ; 46 47 48 52 53 public class RunTimeDDCatalog extends GrammarQueryManager implements CatalogReader, CatalogDescriptor,org.xml.sax.EntityResolver { 54 55 private static final String XML_XSD="http://www.w3.org/2001/xml.xsd"; private static final String XML_XSD_DEF="<?xml version='1.0'?><xs:schema targetNamespace=\"http://www.w3.org/XML/1998/namespace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"en\"><xs:attribute name=\"lang\" type=\"xs:language\"><xs:annotation><xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter codes as the enumerated possible values . . .</xs:documentation></xs:annotation></xs:attribute></xs:schema>"; private static final String TypeToURLMap[] = { 58 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 J2EE Application 1.3//EN" , "sun-application_1_3-0.dtd" , 59 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 J2EE Application 1.4//EN" , "sun-application_1_4-0.dtd" , "-//Sun Microsystems, Inc.//DTD Application Server 8.0 J2EE Application 1.4//EN" , "sun-application_1_4-0.dtd" , 61 "-//Sun Microsystems, Inc.//DTD Application Server 8.1 J2EE Application 1.4//EN" , "sun-application_1_4-0.dtd" , 62 "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Java EE Application 5.0//EN" , "sun-application_5_0-0.dtd", 63 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN" , "sun-ejb-jar_2_0-0.dtd" , 64 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 EJB 2.1//EN" , "sun-ejb-jar_2_1-0.dtd" , "-//Sun Microsystems, Inc.//DTD Application Server 8.0 EJB 2.1//EN" , "sun-ejb-jar_2_1-0.dtd" , 66 "-//Sun Microsystems, Inc.//DTD Application Server 8.1 EJB 2.1//EN" , "sun-ejb-jar_2_1-1.dtd" , 67 "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" , "sun-ejb-jar_3_0-0.dtd", 68 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Application Client 1.3//EN" , "sun-application-client_1_3-0.dtd" , 69 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 Application Client 1.4//EN" , "sun-application-client_1_4-0.dtd" , "-//Sun Microsystems, Inc.//DTD Application Server 8.0 Application Client 1.4//EN" , "sun-application-client_1_4-0.dtd" , 71 "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Application Client 1.4//EN" , "sun-application-client_1_4-1.dtd" , 72 "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Application Client 5.0//EN" , "sun-application-client_5_0-0.dtd" , 73 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Connector 1.0//EN" , "sun-connector_1_0-0.dtd" , 74 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Servlet 2.3//EN" , "sun-web-app_2_3-0.dtd" , 75 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 8.0 Servlet 2.4//EN" , "sun-web-app_2_4-0.dtd" , "-//Sun Microsystems, Inc.//DTD Application Server 8.0 Servlet 2.4//EN" , "sun-web-app_2_4-0.dtd" , 77 "-//Sun Microsystems, Inc.//DTD Sun ONE Web Server 6.1 Servlet 2.3//EN" , "sun-web-app_2_3-1.dtd" , 78 "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" , "sun-web-app_2_4-1.dtd" , 79 "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" , "sun-web-app_2_5-0.dtd" , 80 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Application Client Container 1.0//EN" , "sun-application-client-container_1_0.dtd" , 81 "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 OR Mapping //EN" , "sun-cmp-mapping_1_0.dtd" , 82 "-//Sun Microsystems, Inc.//DTD Application Server 8.0 OR Mapping//EN" , "sun-cmp-mapping_1_1.dtd" , 83 "-//Sun Microsystems, Inc.//DTD Application Server 8.1 OR Mapping//EN" , "sun-cmp-mapping_1_2.dtd" , 84 "-//Sun Microsystems, Inc.//DTD Application Server 8.0 Domain//EN" , "sun-domain_1_0.dtd" , 85 "-//Sun Microsystems Inc.//DTD Application Server 8.0 Application Client Container//EN" , "sun-application-client-container_1_2.dtd" , 86 "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Application Client Container //EN" , "sun-application-client-container_1_1.dtd" , 87 "-//Sun Microsystems Inc.//DTD Application Server 8.0 Domain//EN" ,"sun-domain_1_1.dtd", 88 "-//Sun Microsystems Inc.//DTD Application Server 8.1 Domain//EN" ,"sun-domain_1_1.dtd", 89 90 "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" , "application_1_3.dtd", 91 "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" , "application_1_2.dtd", 92 "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" , "ejb-jar_2_0.dtd", 93 "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" , "ejb-jar_1_1.dtd", 94 "-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN" , "application-client_1_3.dtd", 95 "-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.2//EN" , "application-client_1_2.dtd", 96 "-//Sun Microsystems, Inc.//DTD Connector 1.0//EN" , "connector_1_0.dtd", 97 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" , "web-app_2_3.dtd", 98 "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" , "web-app_2_2.dtd", 99 "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" , "web-jsptaglibrary_1_2.dtd", 100 "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" , "web-jsptaglibrary_1_1.dtd", 101 }; 102 103 104 private static final String SchemaToURLMap[] = { 105 106 "SCHEMA:http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" , "ejb-jar_2_1", 107 108 "SCHEMA:http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd" , "application-client_1_4", 109 "SCHEMA:http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" , "application_1_4", 110 "SCHEMA:http://java.sun.com/xml/ns/j2ee/jax-rpc-ri-config.xsd" , "jax-rpc-ri-config", 111 "SCHEMA:http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" , "connector_1_5", 112 "SCHEMA:http://java.sun.com/xml/ns/j2ee/j2ee_jaxrpc_mapping_1_1.xsd" , "j2ee_jaxrpc_mapping_1_1", 118 "SCHEMA:http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd" ,"j2ee_web_services_1_1", 119 "SCHEMA:http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" , "ejb-jar_3_0", 121 "SCHEMA:http://java.sun.com/xml/ns/javaee/application-client_5.xsd" , "application-client_5", 122 "SCHEMA:http://java.sun.com/xml/ns/javaee/application_5.xsd" , "application_5", 123 "SCHEMA:http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" , "orm_1_0", 124 "SCHEMA:http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" , "persistence_1_0", 125 126 }; 127 128 File platformRootDir=null; 129 130 131 public RunTimeDDCatalog() { 132 InstanceProperties.getInstanceList(); 134 PluginProperties.configureDefaultServerInstance(); 135 platformRootDir = ServerLocationManager.getLatestPlatformLocation(); 136 } 137 private static RunTimeDDCatalog ddCatalog; 138 139 140 public static synchronized RunTimeDDCatalog getRunTimeDDCatalog(){ 141 if (ddCatalog==null) { 142 ddCatalog = new RunTimeDDCatalog(); 143 } 144 return ddCatalog; 145 } 146 150 public java.util.Iterator getPublicIDs() { 151 if (platformRootDir == null) { 152 return null; 153 } 154 if (!platformRootDir.exists()) { 155 return null; 156 } 157 158 String installRoot = platformRootDir.getAbsolutePath(); 159 if (installRoot == null) { 160 return null; 161 } 162 163 java.util.List list = new java.util.ArrayList (); 164 for (int i=0;i<TypeToURLMap.length;i = i+2){ 165 list.add(TypeToURLMap[i]); 166 } 167 for (int i=0;i<SchemaToURLMap.length;i = i+2){ 168 list.add(SchemaToURLMap[i]); 169 } 170 171 return list.listIterator(); 172 } 173 174 178 public String getSystemID(String publicId) { 179 if (platformRootDir == null) { 180 return null; 181 } 182 if (!platformRootDir.exists()) { 183 return null; 184 } 185 186 String installRoot = platformRootDir.getAbsolutePath(); if (installRoot == null) { 188 return null; 189 } 190 String loc="dtds"; 191 for (int i=0;i<TypeToURLMap.length;i = i+2){ 192 if (TypeToURLMap[i].equals(publicId)){ 193 File file = new File (installRoot+"/lib/"+loc+"/"+TypeToURLMap[i+1]); 194 try{ 195 return file.toURI().toURL().toExternalForm(); 196 }catch(Exception e){ 197 return ""; 198 } 199 } 200 } 201 loc="schemas"; 202 for (int i=0;i<SchemaToURLMap.length;i = i+2){ 203 if (SchemaToURLMap[i].equals(publicId)){ 204 return "nbres:/org/netbeans/modules/j2ee/sun/ide/resources/"+SchemaToURLMap[i+1]+".dtd"; 205 206 207 } 208 } 209 return null; 210 } 211 212 215 public void refresh() { 216 File newLoc = ServerLocationManager.getLatestPlatformLocation(); 217 if (platformRootDir!=newLoc){ 218 platformRootDir = newLoc; 219 getRunTimeDDCatalog().fireCatalogListeners(); 220 } 221 222 } 223 224 private List catalogListeners = new ArrayList (1); 225 226 230 public void addCatalogListener(CatalogListener l) { 231 if (null == l) 232 return; 233 if (catalogListeners.contains(l)) 234 return; 235 catalogListeners.add(l); 236 } 237 238 242 public void removeCatalogListener(CatalogListener l) { 243 if (null == l) 244 return; 245 if (catalogListeners.contains(l)) 246 catalogListeners.remove(l); 247 } 248 249 public void fireCatalogListeners() { 250 platformRootDir = ServerLocationManager.getLatestPlatformLocation(); 251 java.util.Iterator iter = catalogListeners.iterator(); 252 while (iter.hasNext()) { 253 CatalogListener l = (CatalogListener) iter.next(); 254 l.notifyInvalidate(); 255 } 256 } 257 258 259 public void addPropertyChangeListener(PropertyChangeListener l) { 260 } 261 262 265 public String getDisplayName() { 266 return NbBundle.getMessage(RunTimeDDCatalog.class, "LBL_RunTimeDDCatalog"); 267 } 268 269 274 public java.awt.Image getIcon(int type) { 275 return Utilities.loadImage("org/netbeans/modules/j2ee/sun/ide/resources/ServerInstanceIcon.png"); } 277 278 281 public String getShortDescription() { 282 return NbBundle.getMessage(RunTimeDDCatalog.class, "DESC_RunTimeDDCatalog"); 283 } 284 285 286 public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 287 } 288 289 public static final String J2EE_NS = "http://java.sun.com/xml/ns/j2ee"; public static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee"; public static final String RI_CONFIG_NS = "http://java.sun.com/xml/ns/jax-rpc/ri/config"; 293 public static final String IBM_J2EE_NS = "http://www.ibm.com/webservices/xsd"; private static final String XMLNS_ATTR="xmlns"; private static final String EJB_JAR_TAG="ejb-jar"; private static final String EJBJAR_2_1_XSD="ejb-jar_2_1.xsd"; private static final String EJBJAR_2_1 = J2EE_NS+"/"+EJBJAR_2_1_XSD; public static final String EJBJAR_2_1_ID = "SCHEMA:"+EJBJAR_2_1; 303 private static final String EJBJAR_3_0_XSD="ejb-jar_3_0.xsd"; private static final String EJBJAR_3_0 = JAVAEE_NS+"/"+EJBJAR_3_0_XSD; public static final String EJBJAR_3_0_ID = "SCHEMA:"+EJBJAR_3_0; 307 private static final String APP_TAG="application"; private static final String APP_1_4_XSD="application_1_4.xsd"; private static final String APP_1_4= J2EE_NS+"/"+APP_1_4_XSD; public static final String APP_1_4_ID = "SCHEMA:"+APP_1_4; 312 private static final String APP_5_XSD="application_5.xsd"; private static final String APP_5= JAVAEE_NS+"/"+APP_5_XSD; public static final String APP_5_ID = "SCHEMA:"+APP_5; 316 317 private static final String APPCLIENT_TAG="application-client"; private static final String APPCLIENT_1_4_XSD="application-client_1_4.xsd"; private static final String APPCLIENT_1_4= J2EE_NS+"/"+APPCLIENT_1_4_XSD; public static final String APPCLIENT_1_4_ID = "SCHEMA:"+APPCLIENT_1_4; 322 private static final String APPCLIENT_5_XSD="application-client_5.xsd"; private static final String APPCLIENT_5= JAVAEE_NS+"/"+APPCLIENT_5_XSD; public static final String APPCLIENT_5_ID = "SCHEMA:"+APPCLIENT_5; 326 327 private static final String WEBSERVICES_TAG="webservices"; private static final String WEBSERVICES_1_1_XSD="j2ee_web_services_1_1.xsd"; private static final String WEBSERVICES_1_1= IBM_J2EE_NS+"/"+WEBSERVICES_1_1_XSD; public static final String WEBSERVICES_1_1_ID = "SCHEMA:"+WEBSERVICES_1_1; 332 private static final String WEBSERVICES_1_2_XSD="javaee_web_services_1_2.xsd"; private static final String WEBSERVICES_1_2= JAVAEE_NS+"/"+WEBSERVICES_1_2_XSD; public static final String WEBSERVICES_1_2_ID = "SCHEMA:"+WEBSERVICES_1_2; 336 private static final String WEBAPP_TAG="web-app"; private static final String WEBAPP_2_5_XSD="web-app_2_5.xsd"; private static final String WEBAPP_2_5 = JAVAEE_NS+"/"+WEBAPP_2_5_XSD; public static final String WEBAPP_2_5_ID = "SCHEMA:"+WEBAPP_2_5; 341 public static final String PERSISTENCE_NS = "http://java.sun.com/xml/ns/persistence"; private static final String PERSISTENCE_TAG="persistence"; private static final String PERSISTENCE_XSD="persistence_1_0.xsd"; private static final String PERSISTENCE = PERSISTENCE_NS+"/"+PERSISTENCE_XSD; public static final String PERSISTENCE_ID = "SCHEMA:"+PERSISTENCE; 347 public static final String PERSISTENCEORM_NS = "http://java.sun.com/xml/ns/persistence/orm"; private static final String PERSISTENCEORM_TAG="entity-mappings"; private static final String PERSISTENCEORM_XSD="orm_1_0.xsd"; private static final String PERSISTENCEORM = PERSISTENCE_NS+"/"+PERSISTENCEORM_XSD; public static final String PERSISTENCEORM_ID = "SCHEMA:"+PERSISTENCEORM; 353 354 355 356 public String getFullURLFromSystemId(String systemId){ 357 return null; 358 359 } 360 361 private static String SCHEMASLOCATION=null; 362 368 public InputSource resolveEntity(String publicId, String systemId) throws SAXException , IOException { 369 370 if (SCHEMASLOCATION == null) { 371 if (platformRootDir == null) { 372 return null; 373 } 374 if (!platformRootDir.exists()) { 375 return null; 376 } 377 378 String installRoot = platformRootDir.getAbsolutePath(); if (installRoot==null) 380 return null; 381 File f = new File (installRoot); 382 if (f.exists()==false) 383 return null; 384 File file = new File (installRoot+"/lib/schemas/"); 385 SCHEMASLOCATION = ""; 386 try{ 387 SCHEMASLOCATION= file.toURI().toURL().toExternalForm(); 388 }catch(Exception e){ 389 390 } 391 392 393 } 394 if (systemId!=null && systemId.endsWith(EJBJAR_2_1_XSD)) { 395 return new org.xml.sax.InputSource (SCHEMASLOCATION+EJBJAR_2_1_XSD); 396 } 397 else if (systemId!=null && systemId.endsWith(EJBJAR_3_0_XSD)) { 398 return new org.xml.sax.InputSource (SCHEMASLOCATION+EJBJAR_3_0_XSD); 399 } 400 else if (systemId!=null && systemId.endsWith(APP_1_4_XSD)) { 401 return new org.xml.sax.InputSource (SCHEMASLOCATION+APP_1_4_XSD); 402 } 403 else if (systemId!=null && systemId.endsWith(WEBAPP_2_5_XSD)) { 404 return new org.xml.sax.InputSource (SCHEMASLOCATION+WEBAPP_2_5_XSD); 405 } 406 else if (systemId!=null && systemId.endsWith(APP_5_XSD)) { 407 return new org.xml.sax.InputSource (SCHEMASLOCATION+APP_5_XSD); 408 } 409 else if (systemId!=null && systemId.endsWith(PERSISTENCEORM_XSD)) { 410 return new org.xml.sax.InputSource (SCHEMASLOCATION+PERSISTENCEORM_XSD); 411 } 412 else if (systemId!=null && systemId.endsWith(PERSISTENCE_XSD)) { 413 return new org.xml.sax.InputSource (SCHEMASLOCATION+PERSISTENCE_XSD); 414 } 415 else if (systemId!=null && systemId.endsWith(WEBSERVICES_1_1_XSD)) { 416 return new org.xml.sax.InputSource (SCHEMASLOCATION+WEBSERVICES_1_1_XSD); 417 } 418 else if (systemId!=null && systemId.endsWith(WEBSERVICES_1_2_XSD)) { 419 return new org.xml.sax.InputSource (SCHEMASLOCATION+WEBSERVICES_1_2_XSD); 420 } else if (XML_XSD.equals(systemId)) { 421 return new org.xml.sax.InputSource (new java.io.StringReader (XML_XSD_DEF)); 422 } 423 else { 424 return null; 425 } 426 } 427 428 429 430 public Enumeration enabled(GrammarEnvironment ctx) { 431 if (ctx.getFileObject() == null) return null; 432 InputSource is= ctx.getInputSource(); 433 java.util.Enumeration en = ctx.getDocumentChildren(); 434 while (en.hasMoreElements()) { 435 Node next = (Node ) en.nextElement(); 436 if (next.getNodeType() == next.DOCUMENT_TYPE_NODE) { 437 return null; } else if (next.getNodeType() == next.ELEMENT_NODE) { 439 Element element = (Element ) next; 440 String tag = element.getTagName(); 441 if (EJB_JAR_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 443 if (xmlns!=null && J2EE_NS.equals(xmlns)) { 444 java.util.Vector v = new java.util.Vector (); 445 v.add(next); 446 return v.elements(); 447 } 449 else if (xmlns!=null && JAVAEE_NS.equals(xmlns)) { 450 java.util.Vector v = new java.util.Vector (); 451 v.add(next); 452 return v.elements(); 453 } 455 } 456 457 if (APP_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 459 if (xmlns!=null && J2EE_NS.equals(xmlns)) { 460 java.util.Vector v = new java.util.Vector (); 461 v.add(next); 462 return v.elements(); 463 } 465 else if (xmlns!=null && JAVAEE_NS.equals(xmlns)) { 466 java.util.Vector v = new java.util.Vector (); 467 v.add(next); 468 return v.elements(); 469 } 471 } 472 if (WEBAPP_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 474 if (xmlns!=null && JAVAEE_NS.equals(xmlns)) { 475 java.util.Vector v = new java.util.Vector (); 476 v.add(next); 477 return v.elements(); 478 } 480 481 } 482 if (APPCLIENT_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 484 if (xmlns!=null && J2EE_NS.equals(xmlns)) { 485 java.util.Vector v = new java.util.Vector (); 486 v.add(next); 487 return v.elements(); 488 } 490 else if (xmlns!=null && JAVAEE_NS.equals(xmlns)) { 491 java.util.Vector v = new java.util.Vector (); 492 v.add(next); 493 return v.elements(); 494 } 496 } 497 if (PERSISTENCEORM_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 499 if (xmlns!=null && PERSISTENCEORM_NS.equals(xmlns)) { 500 java.util.Vector v = new java.util.Vector (); 501 v.add(next); 502 return v.elements(); 503 } 505 506 } 507 508 if (PERSISTENCE_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 510 if (xmlns!=null && PERSISTENCE_NS.equals(xmlns)) { 511 java.util.Vector v = new java.util.Vector (); 512 v.add(next); 513 return v.elements(); 514 } 516 517 } 518 519 if (WEBSERVICES_TAG.equals(tag)) { String xmlns = element.getAttribute(XMLNS_ATTR); 521 if (xmlns!=null && J2EE_NS.equals(xmlns)) { 522 java.util.Vector v = new java.util.Vector (); 523 v.add(next); 524 return v.elements(); 525 } else if (xmlns!=null && JAVAEE_NS.equals(xmlns)) { 527 java.util.Vector v = new java.util.Vector (); 528 v.add(next); 529 return v.elements(); 530 } 532 else if (xmlns!=null && IBM_J2EE_NS.equals(xmlns)) { 533 java.util.Vector v = new java.util.Vector (); 534 v.add(next); 535 return v.elements(); 536 } 538 } 539 } 540 } 541 542 return null; 543 } 544 545 public FeatureDescriptor getDescriptor() { 546 return new FeatureDescriptor (); 547 } 548 549 551 public GrammarQuery getGrammar(GrammarEnvironment ctx) { 552 UserCatalog catalog = UserCatalog.getDefault(); 553 InputSource is= ctx.getInputSource(); 555 if (catalog != null) { 559 560 EntityResolver resolver = catalog.getEntityResolver(); 561 if (resolver != null) { 562 try { 563 564 565 if (ctx.getFileObject() == null) { 566 return null; 567 } 568 InputSource inputSource = null; 569 570 String mimeType = ctx.getFileObject().getMIMEType(); 571 if (mimeType==null){ 572 return null; 573 } 574 if (mimeType.equals("text/x-dd-ejbjar3.0")){ inputSource = resolver.resolveEntity(EJBJAR_3_0_ID, ""); 576 } else if (mimeType.equals("text/x-dd-ejbjar2.1")) { inputSource = resolver.resolveEntity(EJBJAR_2_1_ID, ""); 578 } else if (mimeType.equals("text/x-dd-application5.0")) { inputSource = resolver.resolveEntity(APP_5_ID, ""); 580 }else if (mimeType.equals("text/x-dd-application1.4")) { inputSource = resolver.resolveEntity(APP_1_4_ID, ""); 582 }else if (mimeType.equals("text/x-dd-client5.0")) { inputSource = resolver.resolveEntity(APPCLIENT_5_ID, ""); 584 }else if (mimeType.equals("text/x-dd-client1.4")) { inputSource = resolver.resolveEntity(APPCLIENT_1_4_ID, ""); 586 }else if (mimeType.equals("text/x-persistence1.0")) { inputSource = resolver.resolveEntity(PERSISTENCE_ID, ""); 588 }else if (mimeType.equals("text/x-orm1.0")) { inputSource = resolver.resolveEntity(PERSISTENCEORM_ID, ""); 590 } 591 592 if (inputSource!=null) { 593 return DTDUtil.parseDTD(true, inputSource); 594 } 595 596 597 if (is.getSystemId().endsWith("webservices.xml") ) { inputSource = resolver.resolveEntity(WEBSERVICES_1_1_ID, ""); 600 if (inputSource!=null) { 601 return DTDUtil.parseDTD(true, inputSource); 602 } 603 604 605 } 606 607 } catch(SAXException e) { 608 } catch(java.io.IOException e) { 609 e.printStackTrace(); 611 } 612 } 613 } 614 return null; 615 } 616 617 621 public String resolveURI(String name) { 622 if (platformRootDir == null) { 624 return null; 625 } 626 if (!platformRootDir.exists()) { 627 return null; 628 } 629 String installRoot = platformRootDir.getAbsolutePath(); 630 String prefix =""; 631 File file = new File (installRoot+"/lib/schemas/"); 632 try{ 633 prefix= file.toURI().toURL().toExternalForm(); 634 }catch(Exception e){ 635 636 } 637 if (name.equals("http://java.sun.com/xml/ns/jax-rpc/ri/config")){ 638 return prefix +"jax-rpc-ri-config.xsd"; 639 } 640 if (name.equals("http://java.sun.com/xml/ns/j2eeppppppp")){ 646 return prefix +"j2ee_web_services_1_1.xsd"; 647 } 648 649 return null; 650 } 651 655 public String resolvePublic(String publicId) { 656 return null; 657 } 658 } 659 | Popular Tags |