You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ra...@apache.org on 2011/06/26 20:57:24 UTC

svn commit: r1139909 - in /incubator/airavata/services/trunk/xregistry/src: main/resources/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/airavata/ test/java/org/apache/airavata/xregistry/ test/resources/

Author: raminder
Date: Sun Jun 26 18:57:23 2011
New Revision: 1139909

URL: http://svn.apache.org/viewvc?rev=1139909&view=rev
Log:
Initial import.

Added:
    incubator/airavata/services/trunk/xregistry/src/main/resources/
    incubator/airavata/services/trunk/xregistry/src/main/resources/tables.sql
      - copied unchanged from r1139850, incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/tables.sql
    incubator/airavata/services/trunk/xregistry/src/main/resources/trusted_cas.pem
      - copied unchanged from r1139850, incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/trusted_cas.pem
    incubator/airavata/services/trunk/xregistry/src/main/resources/xregistry.properties
      - copied unchanged from r1139850, incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/xregistry.properties
    incubator/airavata/services/trunk/xregistry/src/main/resources/xregistry.wsdl
      - copied unchanged from r1139850, incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/xregistry.wsdl
    incubator/airavata/services/trunk/xregistry/src/main/resources/xregistry.xsdconfig
      - copied unchanged from r1139850, incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/xregistry.xsdconfig
    incubator/airavata/services/trunk/xregistry/src/test/
    incubator/airavata/services/trunk/xregistry/src/test/java/
    incubator/airavata/services/trunk/xregistry/src/test/java/org/
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AbstractXregistryTestCase.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AddRemoveFilesTest.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/EndtoEndAdminTest.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/FunctionalTest.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/SimpleEndtoEndTest.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/TestUtils.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/Tester.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/UserAndGroupTest.java
    incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/WSDLFixer.java
    incubator/airavata/services/trunk/xregistry/src/test/resources/

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AbstractXregistryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AbstractXregistryTestCase.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AbstractXregistryTestCase.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AbstractXregistryTestCase.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import junit.framework.TestCase;
+
+public class AbstractXregistryTestCase extends TestCase {
+
+    @Override
+    protected void setUp() throws Exception {
+        System.setProperty("log",XregistryConstants.LOGGER_NAME+":ALL");
+        //System.setProperty("log",":ALL");
+        //System.setProperty("showtime","false");
+        System.setProperty("log.multiline","true");
+    }
+
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AddRemoveFilesTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AddRemoveFilesTest.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AddRemoveFilesTest.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/AddRemoveFilesTest.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,118 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import java.util.List;
+
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.doc.DocData;
+import org.apache.airavata.xregistry.impl.XregistryImpl;
+import org.apache.airavata.xregistry.utils.Utils;
+import org.apache.xmlbeans.impl.tool.XSTCTester.TestCase;
+
+
+
+public class AddRemoveFilesTest extends TestCase{
+    
+    public void testAddRemoveAllDesc() throws Exception{
+        GlobalContext globalContext = new GlobalContext(false);
+        XregistryImpl mySqlRegistry = new XregistryImpl(globalContext);
+//        
+        //String user = "/C=US/O=National Center for Supercomputing Applications/CN=Hemapani Srinath Perera";
+        String user = "/O=LEAD Project/OU=Indiana University Extreme Lab/OU=linbox1.extreme.indiana.edu/OU=extreme.indiana.edu/CN=sshirasu/Email=sshirasu@cs.indiana.edu";
+        
+        List<DocData> list = mySqlRegistry.findServiceDesc(Utils.canonicalizeDN(user), "");
+        for(DocData dataitem:list){
+            System.out.println(dataitem.name);
+        }
+        
+        
+//        String otherUser = "/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru";
+//        
+//        String hostName = "rainier.extreme.indiana.edu";
+//        mySqlRegistry.registerHostDesc(user, Utils.readFile("samples/hosts/rainier.xml"));
+//        String hostDesc = mySqlRegistry.getHostDesc(otherUser, "rainier.extreme.indiana.edu");
+//        System.out.println(hostDesc);
+//        assertNotNull(hostDesc);
+//        String[] hostList = mySqlRegistry.findHosts(otherUser, "rainier.extreme.indiana.edu");
+//        TestUtils.testCantainment(hostList, "rainier.extreme.indiana.edu");
+//        
+//        hostList = mySqlRegistry.findHosts(otherUser, "");
+//        TestUtils.testCantainment(hostList, "rainier.extreme.indiana.edu");
+//        TestUtils.printList(hostList);
+//        mySqlRegistry.removeHostDesc(user, hostName);
+//        
+//        String appName = new QName("http://www.extreme.indiana.edu/lead","FILEBREED").toString();
+//         mySqlRegistry.registerAppDesc(user, Utils.readFile("samples/apps/filebreed-rainier.xml"));
+//      String appDesc = mySqlRegistry.getAppDesc(otherUser,appName, "rainier.extreme.indiana.edu");
+//      System.out.println(appDesc);
+//      assertNotNull(appDesc);
+//      String[][] appList = mySqlRegistry.findAppDesc(otherUser, "FILEBREED");
+//      TestUtils.printListArray(appList);  
+//      TestUtils.testCantainmentArray(appList, appName);
+//      
+//      appList = mySqlRegistry.findAppDesc(otherUser, "");
+//      TestUtils.printListArray(appList);  
+//        mySqlRegistry.removeAppDesc(user, appName, hostName);
+//        
+//        String serviceName = new QName("http://www.extreme.indiana.edu/lead","FilebreedServiceDrLead").toString();
+//      String serviceMapAsStr = Utils.readFile("samples/services/service-filebreed-drlead.xml");
+//      mySqlRegistry.registerServiceDesc(user, serviceMapAsStr,DocParser.createAWsdl(serviceMapAsStr));
+//      String serviceDesc = mySqlRegistry.getServiceDesc(otherUser,serviceName );
+//      System.out.println(serviceDesc);
+//      assertNotNull(serviceDesc);
+//      String[] serviceList = mySqlRegistry.findServiceDesc(otherUser, "Filebreed");
+//      TestUtils.testCantainment(serviceList, serviceName);
+//      
+//      hostList = mySqlRegistry.findServiceDesc(otherUser, "");
+//      TestUtils.testCantainment(serviceList, serviceName);
+//      TestUtils.printList(hostList);
+//      
+//      String awsdl = mySqlRegistry.getAbstractWsdl(otherUser, serviceName);
+//      System.out.println(awsdl);
+//        mySqlRegistry.removeServiceDesc(user, serviceName);
+        
+    }
+    
+    
+ 
+    
+    
+//    public void xtestAddHostDesc() throws XregistryException{
+//        GlobalContext globalContext = new GlobalContext();
+//        String user = "/C=US/O=National Center for Supercomputing Applications/CN=Hemapani Srinath Perera";
+//        String user1 = "/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru";
+//        //String hostName = "bigred.teragrid.iu.edu";
+//        DocRegistryImpl docRegistryImpl = new DocRegistryImpl(globalContext);
+////        String resourceID = docRegistryImpl.registerHostDesc(user, Utils.readFile("samples/hosts/chinkapin.xml"));
+////        System.out.println(resourceID);
+////        String hostDescAsStr = docRegistryImpl.getHostDesc(user, "chinkapin.cs.indiana.edu");
+////        assertNotNull(hostDescAsStr);
+////        System.out.println(hostDescAsStr);
+//        docRegistryImpl.removeHostDesc(user, "chinkapin.cs.indiana.edu");
+//        
+////        String resourceID = "urn:hostdesc:bigred.teragrid.iu.edu";
+//////        docRegistryImpl.authorizeResouce(user, resourceID, "extreme", false, AuthConstants.ACTION_ALL);
+////        
+////        
+////        GroupManager groupManager = new GroupManager(globalContext);
+////        AuthorizerImpl authorizer = new AuthorizerImpl(globalContext,groupManager);
+////        assertTrue(authorizer.isAuthorized(user1, resourceID, AuthConstants.ACTION_READ, false));
+//        
+//    }
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/EndtoEndAdminTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/EndtoEndAdminTest.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/EndtoEndAdminTest.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/EndtoEndAdminTest.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,120 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+//import javax.xml.namespace.QName;
+//
+//import xregistry.XregistryException;
+//import xregistry.client.DocumentRegistryClient;
+//import xregistry.context.GlobalContext;
+//import xregistry.doc.DocParser;
+//import xregistry.impl.XregistryServer;
+//import xregistry.utils.Utils;
+//
+//
+//
+//public class EndtoEndAdminTest extends AbstractXregistryTestCase{
+//
+//    @Override
+//    protected void setUp() throws Exception {
+//        super.setUp();
+//        Thread t = new Thread(new Runnable() {
+//            public void run() {
+//                    XregistryServer.main(new String[]{});
+//            }
+//        
+//        });
+//        t.setDaemon(true);
+//        t.start();
+//        Thread.sleep(2000);
+//    }
+//    
+//    
+////    public void testListing() throws XregistryException{
+////        GlobalContext context =  new GlobalContext(true);
+////        DocumentRegistryClient client = new DocumentRegistryClient(context,"http://linbox3.extreme.indiana.edu:6666/xregistry?wsdl");
+////        ArrayList<String> data = client.findHosts("");
+////        TestUtils.printList(data);
+////        
+////        data = client.findServiceDesc("");
+////        TestUtils.printList(data);
+////        
+////        
+////        data = client.findServiceInstance("");
+////        TestUtils.printList(data);
+////        
+////        
+////        
+////        
+////        
+////        ArrayList<String[]> apps = client.findAppDesc("");
+////        TestUtils.printListArray(apps);
+////    }
+//    
+//    
+//    public void testAddremoveDocTest() throws Exception{
+//        GlobalContext context =  new GlobalContext(true);
+//        DocumentRegistryClient client = new DocumentRegistryClient(context,"http://linbox3.extreme.indiana.edu:6666/xregistry?wsdl");
+//        String user = "/C=US/O=National Center for Supercomputing Applications/CN=Hemapani Srinath Perera";
+//        String otherUser = "/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru";
+//       String[] hostList;
+//        String hostName = "rainier.extreme.indiana.edu";
+//       client.registerHostDesc( Utils.readFile("samples/hosts/rainier.xml"));
+//        String hostDesc = client.getHostDesc("rainier.extreme.indiana.edu");
+//        System.out.println(hostDesc);
+//        assertNotNull(hostDesc);
+//        hostList = client.findHosts( "rainier.extreme.indiana.edu");
+//        TestUtils.testCantainment(hostList, "rainier.extreme.indiana.edu");
+//        
+//        hostList = client.findHosts( "");
+//        TestUtils.testCantainment(hostList, "rainier.extreme.indiana.edu");
+//        TestUtils.printList(hostList);
+//       
+//        client.removeHostDesc( hostName);
+//        
+//        String appName = new QName("http://www.extreme.indiana.edu/lead","FILEBREED").toString();
+//         client.registerAppDesc( Utils.readFile("samples/apps/filebreed-rainier.xml"));
+//      String appDesc = client.getAppDesc(appName, "rainier.extreme.indiana.edu");
+//      System.out.println(appDesc);
+//      assertNotNull(appDesc);
+//      String[][] appList = client.findAppDesc( "FILEBREED");
+//      TestUtils.printListArray(appList);  
+//      TestUtils.testCantainmentArray(appList, appName);
+//      
+//      appList = client.findAppDesc( "");
+//      TestUtils.printListArray(appList);  
+//        client.removeAppDesc(appName, hostName);
+//        
+//        String serviceName = new QName("http://www.extreme.indiana.edu/lead","FilebreedServiceDrLead").toString();
+//      String serviceMapAsStr = Utils.readFile("samples/services/service-filebreed-drlead.xml");
+//      client.registerServiceDesc(serviceMapAsStr,DocParser.createAWsdl(serviceMapAsStr));
+//      String serviceDesc = client.getServiceDesc(serviceName );
+//      System.out.println(serviceDesc);
+//      assertNotNull(serviceDesc);
+//      String[] serviceList = client.findServiceDesc( "Filebreed");
+//      TestUtils.testCantainment(serviceList, serviceName);
+//      
+//      hostList = client.findServiceDesc( "");
+//      TestUtils.testCantainment(serviceList, serviceName);
+//      TestUtils.printList(hostList);
+//      
+//      String awsdl = client.getAbstractWsdl( serviceName);
+//      System.out.println(awsdl);
+//        client.removeServiceDesc(serviceName);
+//    }
+//    
+//
+//}
+//

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/FunctionalTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/FunctionalTest.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/FunctionalTest.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/FunctionalTest.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,242 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.airavata.xregistry.client.DocumentRegistryClient;
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.doc.AppData;
+import org.apache.airavata.xregistry.doc.DocData;
+import org.apache.airavata.xregistry.doc.DocParser;
+import org.apache.airavata.xregistry.utils.ProxyRenewer;
+import org.apache.airavata.xregistry.utils.Utils;
+import org.globus.myproxy.MyProxy;
+
+
+
+public class FunctionalTest extends TestCase{
+    //private String regsitryURL = "https://tyr11.cs.indiana.edu:6666/xregistry?wsdl";
+    //private String regsitryURL = "https://tyr14.cs.indiana.edu:6666/xregistry?wsdl";
+    private String regsitryURL = "https://linbox3.extreme.indiana.edu:6666/xregistry?wsdl";
+    
+    public void testStatelessOperations() throws XregistryException{
+        
+        ProxyRenewer renewer = new ProxyRenewer("hperea","hperera1234",MyProxy.DEFAULT_PORT,14400,"portal.leadproject.org");
+        GlobalContext context = new GlobalContext(true);
+        context.setHostcertsKeyFile("/etc/lead/certificates/hostcertkey.pem.hperera");
+        //context.setCredential(renewer.renewProxy());
+        DocumentRegistryClient client = new DocumentRegistryClient(context,regsitryURL);
+        DocData[] data;
+        data  = client.findHosts("");
+        if(data != null){
+            for(DocData host:data){
+              verifyAllFeildsNotNull(host);
+              assertNotNull(client.getHostDesc(host.name.toString()));
+          }
+        }
+        data = client.findServiceDesc("");
+        if(data != null){
+            for(DocData item:data){
+              verifyAllFeildsNotNull(item);
+              assertNotNull(client.getServiceDesc(item.name));
+          }
+        }
+        data = client.findServiceInstance("");
+        if(data != null){
+            for(DocData item:data){
+              verifyAllFeildsNotNull(item);
+              assertNotNull(client.getConcreateWsdl(item.name));
+          }
+        }
+        AppData[] appdata = client.findAppDesc("");
+        if(data != null){
+            for(AppData item:appdata){
+              verifyAllFeildsNotNull(item);
+              assertNotNull(client.getAppDesc(item.name.toString(),item.secondryName));
+          }
+        }        
+        data = client.findResource("");
+        if(data != null){
+            for(DocData item:data){
+              verifyAllFeildsNotNull(item);
+              assertNotNull(client.getResource(item.name));
+          }
+        }
+        
+        QName nonExisitsResource = new QName("nonExisitsResource");
+        assertNull(client.getAppDesc(nonExisitsResource.toString(), "foo"));
+        assertNull(client.getHostDesc("foo123456"));
+        assertNull(client.getServiceDesc(nonExisitsResource));
+        assertNull(client.getConcreateWsdl(nonExisitsResource));
+        assertNull(client.getResource(nonExisitsResource));
+
+//        //client.registerResource(new QName("AFoo"), "bar");
+//        //System.out.println(client.getResource(new QName("AFoo")));
+//        client.removeResource(new QName("AFoo"));
+//        DocData[] data = client.findResource("");
+//        if(data != null){
+//            for(DocData user:data){
+//                System.out.println(user.name);
+//            }
+//        }
+        //CWSDL update the if there is a copy exists, so we keep it in statelss tests
+        String wsdlAsStr = DocParser.createWsdl(Utils.readFile("samples/services/service-filebreed-drlead.xml"), false);
+        //client.registerConcreteWsdl(wsdlAsStr, 1000);
+        //make sure you can update the Cwsdl
+       // client.registerConcreteWsdl(wsdlAsStr, 1000);
+
+    }
+    
+
+    
+    
+    private void verifyAllFeildsNotNull(DocData docData){
+        assertNotNull(docData.name);
+        assertNotNull(docData.resourceID);
+        assertNotNull(docData.allowedAction);
+        assertNotNull(docData.owner);
+        if(docData instanceof AppData){
+            assertNotNull(((AppData)docData).secondryName);
+        }
+    }
+    
+//    public void testAdminOperations() throws XregistryException{
+//        ProxyRenewer renewer = new ProxyRenewer("hperera","hperera1234",MyProxy.DEFAULT_PORT,14400,"portal.leadproject.org");
+//        GlobalContext context = new GlobalContext(true);
+//        context.setCredential(renewer.renewProxy());
+//        AdminClient client = new AdminClient(context,regsitryURL);
+//        
+//        String[] users = client.listGroups();
+//        assertNotNull(users);
+//        for(String user:users){
+//            client.listGroupsGivenAUser(user);
+//        }
+//        String[] groups = client.listGroups();
+//        assertNotNull(groups);
+//        for(String group:groups){
+//            client.listSubActorsGivenAGroup(group);
+//    }
+//        
+//        //client.registerResource(new QName("AFoo"), "bar");
+//        //System.out.println(client.getResource(new QName("AFoo")));
+//        client.removeResource(new QName("AFoo"));
+//        DocData[] data = client.findResource("");
+//        if(data != null){
+//            for(DocData user:data){
+//                System.out.println(user.name);
+//            }
+//        }
+  //  }
+    
+    
+    
+//    public void testAuthorization() throws Exception{
+//        DocumentRegistryClient client1 = new DocumentRegistryClient(createContext("hperera", "hperera1234"),regsitryURL);
+//        DocumentRegistryClient client2 = new DocumentRegistryClient(createContext("gfac", "gfac1234"),regsitryURL);
+//        QName resourceName = new QName("Resource"+System.currentTimeMillis());
+//        client1.registerResource(resourceName,"");
+//        assertTrue(hasResource(resourceName, client1.findResource("")));
+//        assertFalse(hasResource(resourceName, client2.findResource("")));
+//        
+//        client1.addCapability(resourceName.toString(), "lead", false, XregistryConstants.Action.Read.toString());
+//        assertTrue(hasResource(resourceName, client2.findResource("")));
+//        
+//        client1.removeCapability(resourceName.toString(), "lead");
+//        assertFalse(hasResource(resourceName, client2.findResource("")));
+//        client1.removeResource(resourceName);
+//        
+//        QName otherresourceName = new QName("Resource2"+System.currentTimeMillis());
+//        client2.registerResource(otherresourceName, "");
+//        assertTrue(hasResource(otherresourceName, client2.findResource(otherresourceName.toString())));
+//        assertFalse(hasResource(otherresourceName, client1.findResource(otherresourceName.toString())));
+//        
+//        String user1 = "/o=lead project/ou=portal.leadproject.org/ou=cs.indiana.edu/cn=hperera/email=hperera@cs.indiana.edu";
+//        client2.addCapability(otherresourceName.toString(),user1 , 
+//                true, XregistryConstants.Action.Read.toString());
+//        assertTrue(hasResource(otherresourceName, client1.findResource(otherresourceName.toString())));
+//        client2.removeCapability(otherresourceName.toString(), user1);
+//        assertFalse(hasResource(otherresourceName, client1.findResource(otherresourceName.toString())));
+//        client2.removeResource(otherresourceName);
+//        
+//    }
+    
+    
+    private GlobalContext createContext(String userName,String passwd) throws XregistryException{
+        ProxyRenewer renewer = new ProxyRenewer(userName,passwd,MyProxy.DEFAULT_PORT,14400,"portal.leadproject.org");
+        GlobalContext context = new GlobalContext(true);
+        context.setCredential(renewer.renewProxy());
+        return context;
+    }
+    
+    
+    private boolean hasResource(QName name,DocData[] datalist){
+        if(datalist == null){
+            return false;
+        }
+        for(DocData dataItem:datalist){
+            if(dataItem.name.equals(name)){
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    
+    
+    
+    
+    
+    
+    
+    
+//    public void testConnectUsingGridCredendials() throws Exception{
+//        ProxyRenewer renewer = new ProxyRenewer("hperera","hperera1234",MyProxy.DEFAULT_PORT,14400,"portal.leadproject.org");
+//        
+//        WSIFClient client;
+//        String certFile = "/etc/lead/certificates/iu_services_ca.pem";
+//        //String wsdlUrl = "https://129.79.246.108:20443/resource_catalog?wsdl";
+//        String wsdlUrl = "https://tyr14.cs.indiana.edu:6666/xregistry?wsdl";
+//        
+//        
+//        GSSCredential credential = renewer.renewProxy();
+//        
+//        SoapHttpDynamicInfosetInvoker invoker;
+//            //invoker = new PuretlsInvoker(keyfile, "", certFile);
+//        X509Certificate[] certs = CertUtil.loadCertificates(certFile);
+//        invoker = new GsiInvoker(credential,certs);
+//        
+//        WsdlResolver wsdlResolver = WsdlResolver.getInstance();
+//        wsdlResolver.setSecureInvoker(invoker);
+//        
+//        WsdlDefinitions def = wsdlResolver.loadWsdl(new URI(wsdlUrl));
+//        
+//        WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
+//        WSIFService serv = wsf.getService(def);
+//        serv.addLocalProvider(new Provider(invoker));
+//        client = XmlBeansWSIFRuntime.getDefault().newClientFor(serv.getPort());
+//        ((XsulSoapPort) client.getPort()).setInvoker(invoker);
+//        XregistryPortType proxy = (XregistryPortType)client.generateDynamicStub(XregistryPortType.class);
+//        System.out.println(proxy);
+//    }
+    
+    
+    
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/SimpleEndtoEndTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/SimpleEndtoEndTest.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/SimpleEndtoEndTest.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/SimpleEndtoEndTest.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,132 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import org.apache.airavata.xregistry.client.DocumentRegistryClient;
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.doc.DocData;
+import org.apache.airavata.xregistry.impl.XregistryServer;
+
+
+
+public class SimpleEndtoEndTest extends AbstractXregistryTestCase{
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        Thread t = new Thread(new Runnable() {
+            public void run() {
+                 XregistryServer.main(new String[]{"test/xregistry/xregistry.properties"});
+            }
+        
+        });
+        t.setDaemon(true);
+        t.start();
+        Thread.sleep(2000);
+    }
+    
+    
+//    public void testListing() throws XregistryException{
+//        GlobalContext context =  new GlobalContext(true);
+//        DocumentRegistryClient client = new DocumentRegistryClient(context,"http://linbox3.extreme.indiana.edu:6666/xregistry?wsdl");
+//        ArrayList<String> data = client.findHosts("");
+//        TestUtils.printList(data);
+//        
+//        data = client.findServiceDesc("");
+//        TestUtils.printList(data);
+//        
+//        
+//        data = client.findServiceInstance("");
+//        TestUtils.printList(data);
+//        
+//        
+//        
+//        
+//        
+//        ArrayList<String[]> apps = client.findAppDesc("");
+//        TestUtils.printListArray(apps);
+//    }
+    
+    
+    public void testAddremoveDocTest() throws Exception{
+        GlobalContext context =  new GlobalContext(true);
+        DocumentRegistryClient client = new DocumentRegistryClient(context,"http://linbox3.extreme.indiana.edu:6666/xregistry?wsdl");
+        //DocumentRegistryClient client = new DocumentRegistryClient(context,"https://tyr14.cs.indiana.edu:6666/xregistry?wsdl");
+        String user = "/C=US/O=National Center for Supercomputing Applications/CN=Hemapani Srinath Perera";
+        String otherUser = "/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru";
+        //String[] hostList;
+        
+        
+        //System.out.println(client.registerConcreteWsdl(Utils.readFile("/u/hperera/temp/xregistry.wsdl"), 60*60));
+        
+        String[] hosts = client.app2Hosts("{http://www.extreme.indiana.edu/lead}TestApp-1");
+        TestUtils.printList(hosts);
+//        String hostName = "rainier.extreme.indiana.edu";
+//       client.registerHostDesc(Utils.readFile("samples/hosts/rainier.xml"));
+//        String hostDesc = client.getHostDesc("rainier.extreme.indiana.edu");
+//        System.out.println(hostDesc);
+//        assertNotNull(hostDesc);
+//        hostList = client.findHosts( "rainier.extreme.indiana.edu");
+//        TestUtils.testCantainment(hostList, "rainier.extreme.indiana.edu");
+//        
+        DocData[] hostList = client.findHosts("");
+        client.findAppDesc("");
+        client.findServiceDesc("");
+        client.findServiceInstance("");
+        
+        for(DocData host:hostList){
+            System.out.println(host.name +" "+ host.owner);
+        }
+//        TestUtils.testCantainment(hostList, "rainier.extreme.indiana.edu");
+//        TestUtils.printList(hostList);
+//       
+//        client.removeHostDesc( hostName);
+//        
+//        String appName = new QName("http://www.extreme.indiana.edu/lead","FILEBREED").toString();
+//         client.registerAppDesc( Utils.readFile("samples/apps/filebreed-rainier.xml"));
+//      String appDesc = client.getAppDesc(appName, "rainier.extreme.indiana.edu");
+//      System.out.println(appDesc);
+//      assertNotNull(appDesc);
+//      String[][] appList = client.findAppDesc( "FILEBREED");
+//      TestUtils.printListArray(appList);  
+//      TestUtils.testCantainmentArray(appList, appName);
+//      
+//      appList = client.findAppDesc( "");
+//      TestUtils.printListArray(appList);  
+//        client.removeAppDesc(appName, hostName);
+//        
+//        String serviceName = new QName("http://www.extreme.indiana.edu/lead","FilebreedServiceDrLead").toString();
+//      String serviceMapAsStr = Utils.readFile("samples/services/service-filebreed-drlead.xml");
+      //client.registerServiceDesc( serviceMapAsStr,DocParser.createAWsdl(serviceMapAsStr));
+//      String serviceDesc = client.getServiceDesc(serviceName );
+//      System.out.println(serviceDesc);
+//      assertNotNull(serviceDesc);
+//      String[] serviceList = client.findServiceDesc( "Filebreed");
+//      TestUtils.testCantainment(serviceList, serviceName);
+//      
+//      hostList = client.findServiceDesc( "");
+//      TestUtils.testCantainment(serviceList, serviceName);
+//      TestUtils.printList(hostList);
+//      
+//      String awsdl = client.getAbstractWsdl( serviceName);
+//      System.out.println(awsdl);
+//        client.removeServiceDesc(serviceName);
+    }
+    
+
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/TestUtils.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/TestUtils.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/TestUtils.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,58 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+
+public class TestUtils {
+    public static void testCantainmentArray(String[][] names,String value) throws Exception{
+        for(String[] name:names){
+            if(name[0].equals(value)){
+                return; 
+            }
+        }
+        throw new Exception(value+ " Value is Not found ");
+    }
+   
+    
+    public static void testCantainment(String[] names,String value) throws Exception{
+        for(String name:names){
+            if(name.equals(value)){
+                return; 
+            }
+        }
+        throw new Exception(value+ " Value is Not found ");
+    }
+    
+    
+    public static void printList(String[] names){
+        System.out.println();
+        for(String name:names){
+            System.out.print(name + " ");
+        }
+    }
+    
+    public static void printListArray(String[][] names){
+        System.out.println();
+        for(String[] name:names){
+            System.out.print(name[0] + " "+ name[1]);
+        }
+    }
+    
+    
+    
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/Tester.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/Tester.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/Tester.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/Tester.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,100 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import org.apache.airavata.xregistry.client.DocumentRegistryClient;
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.utils.Utils;
+
+import edu.indiana.extreme.gfac.utils.GfacUtils;
+
+
+
+public class Tester {
+
+    /**
+     * @param args
+     * @throws XregistryException 
+     */
+    public static void main(String[] args) throws Exception {
+        GlobalContext globalContext = new GlobalContext(true);
+        DocumentRegistryClient client = new DocumentRegistryClient(globalContext,"https://tyr15.cs.indiana.edu:6666/xregistry?wsdl");
+        client.registerConcreteWsdl(GfacUtils.readFile("/u/hperera/temp/cwsdls/AdderService.wsdl"), 99999999);
+        
+        
+        System.out.println(Utils.canonicalizeDN("O=LEAD Project,OU=portal.leadprojec t.org,OU=cs.indiana.edu,CN=hperera/Email=hperera@cs.indiana.edu,CN=proxy"));
+        
+//        String actorsToAddStr = "#U/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru$Read";
+//        
+//        if(actorsToAddStr != null){
+//            Map<String,String> actorsToAdd = new HashMap<String,String>();
+//            
+//            String[] actorsToAddRaw = actorsToAddStr.split("#");
+//            for(String raw:actorsToAddRaw){
+//                if(raw != null && raw.trim().length() > 0){
+//                    System.out.println("raw ="+raw);
+//                    String[] data = raw.split("\\$");
+//                    actorsToAdd.put(data[0], data[1]);
+//                    boolean isUser = data[0].startsWith("U");
+//                    String actor = data[0].substring(1);
+//                }
+//            }
+//        }   
+//        
+        
+//        String file = Utils.readFile("src/IXregistry.xml");
+//        String prettywsdl = Utils.prettyPrint2String(XmlConstants.BUILDER.parseFragmentFromReader(new StringReader(file)));
+//        System.out.println(prettywsdl);
+//        
+//        FileWriter out = new FileWriter("src/Xregistry.xml");
+//        out.write(prettywsdl);
+//        out.close();
+        
+//        ProxyRenewer proxyRenewer = new ProxyRenewer("hperera", "hperera1234",
+//                MyProxy.DEFAULT_PORT, 1234, "portal.leadproject.org");
+//        
+//        GSSCredential credential = proxyRenewer.renewProxy();
+//        System.out.println(credential.getName());
+//        GlobalContext globalContext = new GlobalContext(true);
+//        globalContext.setTrustedCertsFile("/etc/lead/certificates/trusted_cas.pem");
+//        globalContext.setCredential(credential);
+//        //globalContext.setHostcertsKeyFile("/etc/lead/certificates/hostcertkey.pem.hperera");
+//        DocumentRegistryClient client = new DocumentRegistryClient(globalContext,"https://129.79.246.253:6666/xregistry?wsdl");
+//        //client.addCapability("urn:hostdesc:grid-hg.ncsa.teragrid.org", "extreme", false, XregistryConstants.Action.All.toString());
+//        
+//        DocData[] data = client.findHosts("");
+//        for(DocData doc:data){
+//            System.out.println(doc.name);
+//        }
+//        client.removeConcreteWsdl("{http://www.extreme.indiana.edu/namespaces/2004/01/gFac}SrinathLsService35_Thu_Jun_28_11_40_48_EDT_2007_941422");
+        
+        
+//        Scanner scanner = new Scanner(new File("src/xregistry/tables.sql"));
+//        scanner.useDelimiter(";");
+//        //Pattern pattern = Pattern.compile(".*\\;");
+//        
+//        while(scanner.hasNext()){
+//            String line = scanner.next();
+//            if(line.trim().length() > 0 && !line.startsWith("--")){
+//                System.out.println(line.trim()+"\n");
+//                //statement.executeUpdate(line.trim());
+//            }
+//        }
+    }
+
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/UserAndGroupTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/UserAndGroupTest.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/UserAndGroupTest.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/UserAndGroupTest.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,104 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.impl.XregistryImpl;
+
+
+
+public class UserAndGroupTest extends AbstractXregistryTestCase {
+
+    
+    public void testAddUser() throws Exception{
+        GlobalContext globalContext = new GlobalContext(true);
+        XregistryImpl registry = new XregistryImpl(globalContext);
+        
+        String user = "/C=US/O=National Center for Supercomputing Applications/CN=Hemapani Srinath Perera";
+        registry.createGroup(user, "group1", "group1");
+        registry.createGroup(user, "group2", "group1");
+        registry.createUser(user, "user1", "User1");
+        registry.createUser(user, "user2", "User1");
+        registry.createUser(user, "user3", "User1");
+        
+        registry.addUsertoGroup(user, "group1", "user1");
+        registry.addUsertoGroup(user, "group1", "user2");
+        registry.addUsertoGroup(user, "group2", "user3");
+//        
+        //registry.addAGroupToGroup(user, "group1", "group2");
+        
+        String[] data = registry.listGroups(user);
+        TestUtils.testCantainment(data, "group1");
+        TestUtils.testCantainment(data, "group2");
+        
+        data = registry.listGroupsGivenAUser(user, "user1");
+        TestUtils.testCantainment(data, "group1");
+        
+//        data = registry.listUsersGivenAGroup(user, "group1");
+//        TestUtils.testCantainment(data, "user1");
+//        TestUtils.testCantainment(data, "user2");
+//        
+//        
+//        registry.removeUserFromGroup(user, "group1", "user1");
+//        data = registry.listUsersGivenAGroup(user, "group1");
+//        TestUtils.testCantainment(data, "user2");
+        
+        
+        registry.deleteGroup(user, "group1");
+        data = registry.listGroups(user);
+        TestUtils.printList(data);
+        
+        registry.deleteGroup(user, "group2");
+        registry.deleteUser(user, "user1");
+        registry.deleteUser(user, "user2");
+        registry.deleteUser(user, "user3");
+        
+        
+        
+//        String groupName = "extreme";
+//        
+//        String user1 = "/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru";
+//        GroupManager manager = new GroupManager(globalContext);
+//        //manager.createGroup(groupName, "Group for extreme Users");
+//        manager.createUser(user1, user1,false);
+//        //manager.addUsertoGroup(groupName, user1);
+//        //
+//        
+//        String[] users;
+//        String[] groups = manager.listGroups();
+//        for(String group:groups){
+//            System.out.print(group+":");
+//            users = manager.listUsersGivenAGroup(group);
+//            for(String usert:users){
+//                System.out.print(usert+ " ");
+//            }
+//            System.out.println();
+//        }
+//        
+//        users = manager.listUsers();
+//        for(String usert:users){
+//            System.out.print(usert+":");
+//            groups = manager.listGroupsGivenAUser(usert);
+//            for(String group:groups){
+//                System.out.print(group+" ");
+//            }
+//            System.out.println();
+//        }
+    }
+    
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/WSDLFixer.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/WSDLFixer.java?rev=1139909&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/WSDLFixer.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/test/java/org/apache/airavata/xregistry/WSDLFixer.java Sun Jun 26 18:57:23 2011
@@ -0,0 +1,211 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry;
+
+import java.io.StringReader;
+import java.util.Iterator;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.PortType;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.xregistry.utils.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+import com.ibm.wsdl.BindingOutputImpl;
+import com.ibm.wsdl.MessageImpl;
+import com.ibm.wsdl.OutputImpl;
+import com.ibm.wsdl.PartImpl;
+import com.ibm.wsdl.extensions.schema.SchemaImpl;
+import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
+
+
+
+public class WSDLFixer {
+    
+    private Binding binding;
+    private Element types;
+    private Definition definition;
+    private WSDLFactory factory;
+    
+    
+    public void fixBindingOperation(String name,BindingOperation operation){
+        BindingOutput out = new BindingOutputImpl();
+        SOAPBodyImpl bodyImpl = new SOAPBodyImpl();
+        bodyImpl.setUse("literal");
+        bodyImpl.setNamespaceURI("http://extreme.indiana.edu/xregistry2/2007_02_21");
+        operation.setBindingOutput(out);
+    }
+
+    public void fixOperation(Message message,Operation op){
+        Output output = new OutputImpl();
+        output.setMessage(message);
+        op.setOutput(output);
+
+    }
+    
+    
+    public Element createType(String name,Document doc){
+        Element ele = doc.createElement("xs:element");
+        ele.setAttribute("name",name+"Response");
+        ele.appendChild(doc.createElement("xs:complexType"));
+        return ele;
+    }
+//    <wsdl:message name="listGroupsResponseMessage">
+//    <wsdl:part name="part1" element="ns:listGroupsResponse" />
+//</wsdl:message>
+    
+    public Message createMessage(String name){
+        Message message =  new MessageImpl();
+        message.setQName(new QName("http://extreme.indiana.edu/xregistry2/2007_02_21",name+"ResponseMessage","msgns"));
+        Part part = new PartImpl();
+        part.setElementName(new QName("http://extreme.indiana.edu/xregistry2/2007_02_21",name+"Response","ns"));
+        message.addPart(part);
+        return message;
+    }
+    
+    
+    
+    public static void main(String[] args) throws Exception{
+        WSDLFixer fixer = new WSDLFixer();
+        fixer.fix();
+//        javax.xml.parsers.DocumentBuilderFactory domfactory =
+//            javax.xml.parsers.DocumentBuilderFactory.newInstance();
+//        javax.xml.parsers.DocumentBuilder builder =  domfactory.newDocumentBuilder();
+//        
+//
+//        DOMImplementation dImpl = builder.getDOMImplementation();
+
+    }
+    
+    public void fix() throws Exception{
+        
+        
+        String targetNs = "http://extreme.indiana.edu/xregistry2/2007_02_21";
+        //Document doc = dImpl.createDocument(targetNs, "factoryServices", null);
+        
+        
+        String wsdlAsStr = Utils.readFile("src/xregistry.wsdl");
+       
+
+        WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+        Definition olddefinition = reader.readWSDL(null, new InputSource(new StringReader(wsdlAsStr)));
+        //Definition definition = reader.readWSDL(null, new InputSource(new StringReader(wsdlAsStr)));;
+        Definition definition = WSDLFactory.newInstance().newDefinition();
+        
+        Iterator ns = olddefinition.getNamespaces().keySet().iterator();
+        while(ns.hasNext()){
+            String prefix = (String)ns.next();
+            String nsURI = (String)olddefinition.getNamespaces().get(prefix);
+            definition.addNamespace(prefix,nsURI);
+        }
+        Iterator bs = olddefinition.getBindings().values().iterator();
+        while(bs.hasNext()){
+            definition.addBinding((Binding)bs.next());
+        }
+        
+        Iterator pts = olddefinition.getPortTypes().values().iterator();
+        while(pts.hasNext()){
+            definition.addPortType((PortType)pts.next());
+        }
+        
+        Iterator msgs = olddefinition.getMessages().values().iterator();
+        while(msgs.hasNext()){
+            definition.addMessage((Message)msgs.next());
+        }
+        
+        Iterator ss = olddefinition.getServices().values().iterator();
+        while(ss.hasNext()){
+            definition.addService((javax.wsdl.Service)ss.next());
+        }
+        definition.setTypes(olddefinition.getTypes());
+        
+        
+        
+        Binding binding = definition.getBinding(new QName(targetNs,"IXregistrySOAP11Binding"));
+        SchemaImpl impl;
+        Document doc = null;
+        
+        Iterator it = definition.getTypes().getExtensibilityElements().iterator();
+        if(it.hasNext()){
+            impl = (SchemaImpl)it.next();
+            types = impl.getElement();
+            
+            doc = types.getOwnerDocument();
+            
+            
+        }
+        
+       // System.out.println(binding.toString());
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        Iterator ops = binding.getPortType().getOperations().iterator();
+        while(ops.hasNext()){
+            Operation op = (Operation)ops.next();
+            if(op.getOutput() == null){
+                
+                String name = op.getName();
+                //System.out.println("Fixed ="+name);
+                //System.out.println("<wsdl:message name=\""+name+"ResponseMessage\">\n<wsdl:part name=\"part1\" element=\"ns:"+name+"Response\" />\n</wsdl:message>");
+                System.out.println("<wsdl:operation name=\""+name+"\">\n<soap:operation soapAction=\"urn:addCapability\" style=\"document\" />\n<wsdl:input><soap:body use=\"literal\" namespace=\"http://extreme.indiana.edu/xregistry2/2007_02_21\" /></wsdl:input></wsdl:operation>");
+            
+                
+                Element ele = createType(name, doc);
+                types.appendChild(ele);
+                Message message = createMessage(name);
+                definition.addMessage(message);
+                fixOperation(message, op);
+                fixBindingOperation(name, binding.getBindingOperation(name, null, null));
+            }
+        }
+        
+        
+        
+        WSDLWriter w =  WSDLFactory.newInstance().newWSDLWriter();
+        
+        w.writeWSDL(definition, System.out);
+        
+    }
+    
+    
+    
+//    public static Message createMessage(){
+//        
+//    }
+    
+}
+