You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2013/12/31 16:32:50 UTC

svn commit: r1554541 - in /juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool: App.java Export.java Import.java

Author: alexoree
Date: Tue Dec 31 15:32:50 2013
New Revision: 1554541

URL: http://svn.apache.org/r1554541
Log:
JUDDI-729 adding a feature to strip digital signatures (branch 3.3)

Modified:
    juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java
    juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java
    juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java

Modified: juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java
URL: http://svn.apache.org/viewvc/juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java?rev=1554541&r1=1554540&r2=1554541&view=diff
==============================================================================
--- juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java (original)
+++ juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java Tue Dec 31 15:32:50 2013
@@ -53,6 +53,7 @@ public class App {
         options.addOption("myItemsOnly", false, "Export option, Only export items owned by yourself");
         options.addOption("preserveOwnership", false, "Im/Export option, saves owership data to the 'mappings' file");
         options.addOption("credFile", true, "Import option with -preserveOwnership, this is a properties file mapping with user=pass");
+        options.addOption("stripSignatures", false, "Im/Export option, removes digital signatures from all signed items, default is false");
 
 
         // create the parser
@@ -71,6 +72,7 @@ public class App {
                 return;
             }
             String config = line.getOptionValue("config", "uddi.xml");
+            boolean stripSig = line.hasOption("stripSignatures");
             String node = line.getOptionValue("node", "default");
 
             String pass = line.getOptionValue("pass", null);
@@ -90,7 +92,7 @@ public class App {
             if (line.hasOption("export")) //CommandLine cmd = parser.parse(options, args);
             {
                 System.out.println("Exporting...");
-                new Export().Execute(config, node, user, pass, tmodel, business, juddi, safe, publishers, myItemsOnly, mappings, preserveOwnership, credFile);
+                new Export().Execute(config, node, user, pass, tmodel, business, juddi, safe, publishers, myItemsOnly, mappings, preserveOwnership, credFile,stripSig);
                 System.out.println();
                 if (preserveOwnership) {
                     System.out.println("Next step(s), Edit the " + credFile + " and make any adjustments that are necessary.");
@@ -101,7 +103,7 @@ public class App {
             if (line.hasOption("import")) //CommandLine cmd = parser.parse(options, args);
             {
                 System.out.println("Importing...");
-                new Import().Execute(config, node, user, pass, tmodel, business, juddi, safe, publishers, preserveOwnership, mappings, credFile);
+                new Import().Execute(config, node, user, pass, tmodel, business, juddi, safe, publishers, preserveOwnership, mappings, credFile,stripSig);
             }
 
 

Modified: juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java
URL: http://svn.apache.org/viewvc/juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java?rev=1554541&r1=1554540&r2=1554541&view=diff
==============================================================================
--- juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java (original)
+++ juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java Tue Dec 31 15:32:50 2013
@@ -58,247 +58,288 @@ import org.uddi.v3_service.UDDISecurityP
  */
 public class Export {
 
-    private static UDDISecurityPortType security = null;
-    private static JUDDIApiPortType juddiApi = null;
-    private static UDDIPublicationPortType publish = null;
-    private static UDDIInquiryPortType inquiry;
-    private JUDDIApiPortType juddi;
-    String token = null;
-    String username = null;
-    String tmodelfile = null;
-    String businessfile = null;
-    String publishersfile = null;
-    String mappingsfile = null;
-    boolean safemode = false;
-    boolean myitemsonly = false;
-    boolean preserveOwnership;
-    String credFile;
-    Set<String> usernames = new HashSet<String>();
-    Properties mapping = new Properties();
-
-    public void Execute(String config, String name, String user, String pass,
-            String tmodelout, String businessOut,
-            boolean isJuddi, boolean safe, String publishersFile,
-            boolean myItemsOnly,
-            String mappingsfile,
-            boolean preserveOwnership, String credFile) throws Exception {
-        // create a manager and read the config in the archive; 
-        // you can use your config file name
-        this.publishersfile = publishersFile;
-        this.tmodelfile = tmodelout;
-        this.businessfile = businessOut;
-        this.myitemsonly = myItemsOnly;
-        this.mappingsfile = mappingsfile;
-        this.credFile = credFile;
-        this.preserveOwnership = preserveOwnership;
-
-        UDDIClient clerkManager = new UDDIClient(config);
-        clerkManager.start();
-        UDDIClerk clerk = clerkManager.getClerk(name);
-
-        // register the clerkManager with the client side container
-        UDDIClientContainer.addClient(clerkManager);            // a ClerkManager can be a client to multiple UDDI nodes, so 
-        // a ClerkManager can be a client to multiple UDDI nodes, so 
-        // supply the nodeName (defined in your uddi.xml.
-        // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
-        Transport transport = clerkManager.getTransport(name);
-        // Now you create a reference to the UDDI API
-        security = transport.getUDDISecurityService();
-        publish = transport.getUDDIPublishService();
-        inquiry = transport.getUDDIInquiryService();
-        juddi = transport.getJUDDIApiService();
-        this.username = user;
-        if (username == null || pass == null) {
-            username = clerk.getPublisher();
-            pass = clerk.getPassword();
-        }
-        if (username != null && pass != null
-                || username.length() != 0 && pass.length() != 0) {
-            GetAuthToken getAuthTokenRoot = new GetAuthToken();
-            getAuthTokenRoot.setUserID(username);
-            getAuthTokenRoot.setCred(pass);
-            token = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
-        } else {
-            System.out.println("No credentials are available. This will probably fail spectacularly");
-
-        }
-
-
-        ExportTmodels();
-        ExportBusiness();
-
-        if (isJuddi) {
-            //optional juddi
-            ExportNodes();
-            ExportClerks();
-            ExportPublishers();
-        }
-        if (preserveOwnership) {
-            SaveProperties();
-            SaveCredFileTemplate();
-        }
-        clerkManager.stop();
-    }
-
-    private void ExportBusiness() throws Exception {
-        FileOutputStream fos = new FileOutputStream(businessfile);
-        FindBusiness req = new FindBusiness();
-        req.setAuthInfo(token);
-        req.getName().add(new Name(UDDIConstants.WILDCARD, null));
-        req.setFindQualifiers(new FindQualifiers());
-        req.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
-        int offset = 0;
-        int maxrows = 20;
-
-        req.setMaxRows(maxrows);
-        req.setListHead(offset);
-        BusinessList findTModel = null;
-        SaveBusiness sb = new SaveBusiness();
-        do {
-            findTModel = inquiry.findBusiness(req);
-            if (findTModel.getBusinessInfos() != null) {
-                for (int i = 0; i < findTModel.getBusinessInfos().getBusinessInfo().size(); i++) {
-                    boolean go = true;
-                    String owner = Common.GetOwner(findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey(), token, inquiry);
-                    if (!usernames.contains(owner)) {
-                        usernames.add(owner);
-                    }
-                    if (myitemsonly) {
-                        if (owner == null || !owner.equalsIgnoreCase(username)) {
-                            go = false;
-                            System.out.println("skipping " + findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey() + " owned by " + owner);
-                        }
-                    }
-                    if (go) {
-                        mapping.setProperty(findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey(), owner);
-                        System.out.println("Exporting " + findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey());
-                        sb.getBusinessEntity().add(GetBusiness(findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey(), token));
-                    }
-                }
-            }
-            //do stuff
-            offset = offset + maxrows;
-            req.setListHead(offset);
-
-        } while (findTModel.getListDescription().getIncludeCount() > 0);
-        System.out.println("Saving to disk");
-        JAXB.marshal(sb, fos);
-        fos.close();
-        System.out.println("Done with businesses");
-    }
-
-    private void ExportTmodels() throws Exception {
-        FileOutputStream fos = new FileOutputStream(tmodelfile);
-        FindTModel req = new FindTModel();
-        req.setName(new Name(UDDIConstants.WILDCARD, null));
-        req.setAuthInfo(token);
-        req.setFindQualifiers(new FindQualifiers());
-        req.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
-        int offset = 0;
-        int maxrows = 20;
-
-        req.setMaxRows(maxrows);
-        req.setListHead(offset);
-        TModelList findTModel = null;
-        SaveTModel stm = new SaveTModel();
-        do {
-            findTModel = inquiry.findTModel(req);
-            if (findTModel.getTModelInfos() != null) {
-                for (int i = 0; i < findTModel.getTModelInfos().getTModelInfo().size(); i++) {
-                    boolean go = true;
-                    String owner = Common.GetOwner(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey(), token, inquiry);
-                    if (!usernames.contains(owner)) {
-                        usernames.add(owner);
-                    }
-                    if (myitemsonly) {
-                        if (owner == null || !owner.equalsIgnoreCase(username)) {
-                            go = false;
-                        }
-                    }
-                    if (go) {
-                        mapping.setProperty(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey(), owner);
-                        System.out.println("Exporting " + findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey());
-                        stm.getTModel().add(GetTmodel(findTModel.getTModelInfos().getTModelInfo().get(i), token));
-                    }
-                }
-            }
-            offset = offset + maxrows;
-            req.setListHead(offset);
-        } while (findTModel.getListDescription().getIncludeCount() > 0);
-        System.out.println("Storing to disk ");
-        JAXB.marshal(stm, fos);
-        fos.close();
-        System.out.println("Done with tModels");
-    }
-
-    private TModel GetTmodel(TModelInfo get, String token) throws Exception {
-        GetTModelDetail r = new GetTModelDetail();
-        r.setAuthInfo(token);
-        r.getTModelKey().add(get.getTModelKey());
-        return inquiry.getTModelDetail(r).getTModel().get(0);
-    }
-
-    private BusinessEntity GetBusiness(String businessKey, String token) throws Exception {
-        GetBusinessDetail r = new GetBusinessDetail();
-        r.getBusinessKey().add(businessKey);
-        r.setAuthInfo(token);
-        return inquiry.getBusinessDetail(r).getBusinessEntity().get(0);
-    }
-
-    private void ExportNodes() {
-        //TODO wait for JUDDI-706
-    }
-
-    private void ExportClerks() {
-        //TODO wait for JUDDI-706
-    }
-
-    private void ExportPublishers() throws Exception {
-        FileOutputStream fos = new FileOutputStream(publishersfile);
-
-        GetAllPublisherDetail r = new GetAllPublisherDetail();
-        r.setAuthInfo(token);
-        PublisherDetail allPublisherDetail = juddi.getAllPublisherDetail(r);
-        SavePublisher saver = new SavePublisher();
-        saver.getPublisher().addAll(allPublisherDetail.getPublisher());
-        System.out.println("Storing to disk ");
-        JAXB.marshal(saver, fos);
-        fos.close();
-        System.out.println("Done with Publishers");
-    }
-
-    private void SaveProperties() throws FileNotFoundException {
-        StringBuilder sb = new StringBuilder();
-        Iterator<String> it = usernames.iterator();
-        while (it.hasNext()) {
-            sb.append(it.next());
-            if (it.hasNext()) {
-                sb.append(",");
-            }
-        }
-        mapping.put("usernames", sb.toString());
-        try {
-            FileOutputStream fos = new FileOutputStream(mappingsfile);
-            mapping.store(fos, "no comments");
-            fos.close();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    private void SaveCredFileTemplate() {
-        Iterator<String> it = usernames.iterator();
-        Properties p = new Properties();
-        while (it.hasNext()) {
-            String s = it.next();
-            p.setProperty(s, s);
-        }
-        try {
-            FileOutputStream fos = new FileOutputStream(credFile);
-            mapping.store(fos, "no comments");
-            fos.close();
-        } catch (Exception ex) {
-            ex.printStackTrace();
+        private static UDDISecurityPortType security = null;
+        private static JUDDIApiPortType juddiApi = null;
+        private static UDDIPublicationPortType publish = null;
+        private static UDDIInquiryPortType inquiry;
+        private JUDDIApiPortType juddi;
+        String token = null;
+        String username = null;
+        String tmodelfile = null;
+        String businessfile = null;
+        String publishersfile = null;
+        String mappingsfile = null;
+        boolean safemode = false;
+        boolean myitemsonly = false;
+        boolean preserveOwnership;
+        String credFile;
+        Set<String> usernames = new HashSet<String>();
+        Properties mapping = new Properties();
+        boolean stripSig = false;
+
+        public void Execute(String config, String name, String user, String pass,
+                String tmodelout, String businessOut,
+                boolean isJuddi, boolean safe, String publishersFile,
+                boolean myItemsOnly,
+                String mappingsfile,
+                boolean preserveOwnership, String credFile, boolean stripSig) throws Exception {
+                // create a manager and read the config in the archive; 
+                // you can use your config file name
+                this.stripSig = stripSig;
+                this.publishersfile = publishersFile;
+                this.tmodelfile = tmodelout;
+                this.businessfile = businessOut;
+                this.myitemsonly = myItemsOnly;
+                this.mappingsfile = mappingsfile;
+                this.credFile = credFile;
+                this.preserveOwnership = preserveOwnership;
+
+                UDDIClient clerkManager = new UDDIClient(config);
+                clerkManager.start();
+                UDDIClerk clerk = clerkManager.getClerk(name);
+
+                // register the clerkManager with the client side container
+                UDDIClientContainer.addClient(clerkManager);            // a ClerkManager can be a client to multiple UDDI nodes, so 
+                // a ClerkManager can be a client to multiple UDDI nodes, so 
+                // supply the nodeName (defined in your uddi.xml.
+                // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
+                Transport transport = clerkManager.getTransport(name);
+                // Now you create a reference to the UDDI API
+                security = transport.getUDDISecurityService();
+                publish = transport.getUDDIPublishService();
+                inquiry = transport.getUDDIInquiryService();
+                juddi = transport.getJUDDIApiService();
+                this.username = user;
+                if (username == null || pass == null) {
+                        username = clerk.getPublisher();
+                        pass = clerk.getPassword();
+                }
+                if (username != null && pass != null
+                        || username.length() != 0 && pass.length() != 0) {
+                        GetAuthToken getAuthTokenRoot = new GetAuthToken();
+                        getAuthTokenRoot.setUserID(username);
+                        getAuthTokenRoot.setCred(pass);
+                        token = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+                } else {
+                        System.out.println("No credentials are available. This will probably fail spectacularly");
+
+                }
+
+
+                ExportTmodels();
+                ExportBusiness();
+
+                if (isJuddi) {
+                        //optional juddi
+                        ExportNodes();
+                        ExportClerks();
+                        ExportPublishers();
+                }
+                if (preserveOwnership) {
+                        SaveProperties();
+                        SaveCredFileTemplate();
+                }
+                clerkManager.stop();
+        }
+
+        private void ExportBusiness() throws Exception {
+                FileOutputStream fos = new FileOutputStream(businessfile);
+                FindBusiness req = new FindBusiness();
+                req.setAuthInfo(token);
+                req.getName().add(new Name(UDDIConstants.WILDCARD, null));
+                req.setFindQualifiers(new FindQualifiers());
+                req.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+                int offset = 0;
+                int maxrows = 20;
+
+                req.setMaxRows(maxrows);
+                req.setListHead(offset);
+                BusinessList findTModel = null;
+                SaveBusiness sb = new SaveBusiness();
+                do {
+                        findTModel = inquiry.findBusiness(req);
+                        if (findTModel.getBusinessInfos() != null) {
+                                for (int i = 0; i < findTModel.getBusinessInfos().getBusinessInfo().size(); i++) {
+                                        boolean go = true;
+                                        String owner = Common.GetOwner(findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey(), token, inquiry);
+                                        if (!usernames.contains(owner)) {
+                                                usernames.add(owner);
+                                        }
+                                        if (myitemsonly) {
+                                                if (owner == null || !owner.equalsIgnoreCase(username)) {
+                                                        go = false;
+                                                        System.out.println("skipping " + findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey() + " owned by " + owner);
+                                                }
+                                        }
+                                        if (go) {
+                                                mapping.setProperty(findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey(), owner);
+                                                System.out.println("Exporting " + findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey());
+                                                sb.getBusinessEntity().add(GetBusiness(findTModel.getBusinessInfos().getBusinessInfo().get(i).getBusinessKey(), token));
+                                        }
+                                }
+                        }
+                        //do stuff
+                        offset = offset + maxrows;
+                        req.setListHead(offset);
+
+                } while (findTModel.getListDescription().getIncludeCount() > 0);
+
+                if (stripSig) {
+                        int x=0;
+                        
+                        for (int i = 0; i < sb.getBusinessEntity().size(); i++) {
+                                x+=sb.getBusinessEntity().get(i).getSignature().size();
+                                sb.getBusinessEntity().get(i).getSignature().clear();
+                                if (sb.getBusinessEntity().get(i).getBusinessServices() != null) {
+                                        for (int i2 = 0; i2 < sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().size(); i2++) {
+                                                x+=sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getSignature().size();
+                                                sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getSignature().clear();
+                                                
+                                                if (sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates() != null) {
+                                                        for (int i3 = 0; i3 < sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates().getBindingTemplate().size(); i3++) {
+                                                                x+=sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates().getBindingTemplate().get(i3).getSignature().size();
+                                                                sb.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates().getBindingTemplate().get(i3).getSignature().clear();
+                                                        }
+                                                }
+                                        }
+                                }
+                        }
+                        System.out.println(x + " signatures stripped");
+                }
+
+                System.out.println("Saving to disk");
+                JAXB.marshal(sb, fos);
+                fos.close();
+                System.out.println("Done with businesses");
+        }
+
+        private void ExportTmodels() throws Exception {
+                FileOutputStream fos = new FileOutputStream(tmodelfile);
+                FindTModel req = new FindTModel();
+                req.setName(new Name(UDDIConstants.WILDCARD, null));
+                req.setAuthInfo(token);
+                req.setFindQualifiers(new FindQualifiers());
+                req.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+                int offset = 0;
+                int maxrows = 20;
+
+                req.setMaxRows(maxrows);
+                req.setListHead(offset);
+                TModelList findTModel = null;
+                SaveTModel stm = new SaveTModel();
+                do {
+                        findTModel = inquiry.findTModel(req);
+                        if (findTModel.getTModelInfos() != null) {
+                                for (int i = 0; i < findTModel.getTModelInfos().getTModelInfo().size(); i++) {
+                                        boolean go = true;
+                                        String owner = Common.GetOwner(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey(), token, inquiry);
+                                        if (!usernames.contains(owner)) {
+                                                usernames.add(owner);
+                                        }
+                                        if (myitemsonly) {
+                                                if (owner == null || !owner.equalsIgnoreCase(username)) {
+                                                        go = false;
+                                                }
+                                        }
+                                        if (go) {
+                                                mapping.setProperty(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey(), owner);
+                                                System.out.println("Exporting " + findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey());
+                                                stm.getTModel().add(GetTmodel(findTModel.getTModelInfos().getTModelInfo().get(i), token));
+                                        }
+                                }
+                        }
+                        offset = offset + maxrows;
+                        req.setListHead(offset);
+                } while (findTModel.getListDescription().getIncludeCount() > 0);
+                
+                if (stripSig) {
+                        int x=0;
+                        for (int i = 0; i < stm.getTModel().size(); i++) {
+                                x+=stm.getTModel().get(i).getSignature().size();
+                                stm.getTModel().get(i).getSignature().clear();
+                        }
+                        System.out.println(x + " signatures stripped");
+                }
+                
+                System.out.println("Storing to disk ");
+                JAXB.marshal(stm, fos);
+                fos.close();
+                System.out.println("Done with tModels");
+        }
+
+        private TModel GetTmodel(TModelInfo get, String token) throws Exception {
+                GetTModelDetail r = new GetTModelDetail();
+                r.setAuthInfo(token);
+                r.getTModelKey().add(get.getTModelKey());
+                return inquiry.getTModelDetail(r).getTModel().get(0);
+        }
+
+        private BusinessEntity GetBusiness(String businessKey, String token) throws Exception {
+                GetBusinessDetail r = new GetBusinessDetail();
+                r.getBusinessKey().add(businessKey);
+                r.setAuthInfo(token);
+                return inquiry.getBusinessDetail(r).getBusinessEntity().get(0);
+        }
+
+        private void ExportNodes() {
+                //TODO wait for JUDDI-706
+        }
+
+        private void ExportClerks() {
+                //TODO wait for JUDDI-706
+        }
+
+        private void ExportPublishers() throws Exception {
+                FileOutputStream fos = new FileOutputStream(publishersfile);
+
+                GetAllPublisherDetail r = new GetAllPublisherDetail();
+                r.setAuthInfo(token);
+                PublisherDetail allPublisherDetail = juddi.getAllPublisherDetail(r);
+                if (stripSig) {
+                        for (int i = 0; i < allPublisherDetail.getPublisher().size(); i++) {
+                                allPublisherDetail.getPublisher().get(i).getSignature().clear();
+                        }
+                }
+                SavePublisher saver = new SavePublisher();
+                saver.getPublisher().addAll(allPublisherDetail.getPublisher());
+                System.out.println("Storing to disk ");
+                JAXB.marshal(saver, fos);
+                fos.close();
+                System.out.println("Done with Publishers");
+        }
+
+        private void SaveProperties() throws FileNotFoundException {
+                StringBuilder sb = new StringBuilder();
+                Iterator<String> it = usernames.iterator();
+                while (it.hasNext()) {
+                        sb.append(it.next());
+                        if (it.hasNext()) {
+                                sb.append(",");
+                        }
+                }
+                mapping.put("usernames", sb.toString());
+                try {
+                        FileOutputStream fos = new FileOutputStream(mappingsfile);
+                        mapping.store(fos, "no comments");
+                        fos.close();
+                } catch (Exception ex) {
+                        ex.printStackTrace();
+                }
+        }
+
+        private void SaveCredFileTemplate() {
+                Iterator<String> it = usernames.iterator();
+                Properties p = new Properties();
+                while (it.hasNext()) {
+                        String s = it.next();
+                        p.setProperty(s, s);
+                }
+                try {
+                        FileOutputStream fos = new FileOutputStream(credFile);
+                        mapping.store(fos, "no comments");
+                        fos.close();
+                } catch (Exception ex) {
+                        ex.printStackTrace();
+                }
         }
-    }
 }

Modified: juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java
URL: http://svn.apache.org/viewvc/juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java?rev=1554541&r1=1554540&r2=1554541&view=diff
==============================================================================
--- juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java (original)
+++ juddi/branches/juddi-3.3.x/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java Tue Dec 31 15:32:50 2013
@@ -49,250 +49,289 @@ import org.uddi.v3_service.UDDISecurityP
  */
 public class Import {
 
-    private static UDDISecurityPortType security = null;
-    private static JUDDIApiPortType juddiApi = null;
-    private static UDDIPublicationPortType publish = null;
-    private static UDDIInquiryPortType inquiry;
-    private JUDDIApiPortType juddi;
-    String token = null;
-    String username = null;
-    String tmodelfile = null;
-    String businessfile = null;
-    String publishersfile = null;
-    String mappingsfile = null;
-    boolean safemode = false;
-    boolean preserveOwnership = false;
-    Set<String> usernames = new HashSet<String>();
-    /**
-     * item to user
-     */
-    Properties mapping = new Properties();
-    /**
-     * user to password
-     */
-    Properties userpwd = new Properties();
-    String credFile;
-
-    public void Execute(String config, String name, String username, String pass,
-            String tmodelIn, String businessIn,
-            boolean isJuddi, boolean safe, String publishersFile,
-            boolean preserveOwnership,
-            String mappingsfile, String credFile) throws Exception {
-
-        this.credFile = credFile;
-        this.publishersfile = publishersFile;
-        this.tmodelfile = tmodelIn;
-        this.businessfile = businessIn;
-        this.preserveOwnership = preserveOwnership;
-        this.mappingsfile = mappingsfile;
-
-        // create a manager and read the config in the archive; 
-        // you can use your config file name
-        UDDIClient clerkManager = new UDDIClient(config);
-        clerkManager.start();
-        UDDIClerk clerk = clerkManager.getClerk(name);
-        // register the clerkManager with the client side container
-        UDDIClientContainer.addClient(clerkManager);            // a ClerkManager can be a client to multiple UDDI nodes, so 
-        // a ClerkManager can be a client to multiple UDDI nodes, so 
-        // supply the nodeName (defined in your uddi.xml.
-        // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
-        Transport transport = clerkManager.getTransport(name);
-        // Now you create a reference to the UDDI API
-        security = transport.getUDDISecurityService();
-        publish = transport.getUDDIPublishService();
-        inquiry = transport.getUDDIInquiryService();
-        juddi = transport.getJUDDIApiService();
+        private static UDDISecurityPortType security = null;
+        private static JUDDIApiPortType juddiApi = null;
+        private static UDDIPublicationPortType publish = null;
+        private static UDDIInquiryPortType inquiry;
+        private JUDDIApiPortType juddi;
         String token = null;
-        if (username == null || pass == null) {
-            username = clerk.getPublisher();
-            pass = clerk.getPassword();
-        }
-        if (username != null && pass != null) {
-        }
+        String username = null;
+        String tmodelfile = null;
+        String businessfile = null;
+        String publishersfile = null;
+        String mappingsfile = null;
+        boolean safemode = false;
+        boolean stripSig = false;
+        boolean preserveOwnership = false;
+        Set<String> usernames = new HashSet<String>();
+        /**
+         * item to user
+         */
+        Properties mapping = new Properties();
+        /**
+         * user to password
+         */
+        Properties userpwd = new Properties();
+        String credFile;
+
+        public void Execute(String config, String name, String username, String pass,
+                String tmodelIn, String businessIn,
+                boolean isJuddi, boolean safe, String publishersFile,
+                boolean preserveOwnership,
+                String mappingsfile, String credFile, boolean stripSig) throws Exception {
+
+                this.credFile = credFile;
+                this.stripSig = stripSig;
+                this.publishersfile = publishersFile;
+                this.tmodelfile = tmodelIn;
+                this.businessfile = businessIn;
+                this.preserveOwnership = preserveOwnership;
+                this.mappingsfile = mappingsfile;
+
+                // create a manager and read the config in the archive; 
+                // you can use your config file name
+                UDDIClient clerkManager = new UDDIClient(config);
+                clerkManager.start();
+                UDDIClerk clerk = clerkManager.getClerk(name);
+                // register the clerkManager with the client side container
+                UDDIClientContainer.addClient(clerkManager);            // a ClerkManager can be a client to multiple UDDI nodes, so 
+                // a ClerkManager can be a client to multiple UDDI nodes, so 
+                // supply the nodeName (defined in your uddi.xml.
+                // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
+                Transport transport = clerkManager.getTransport(name);
+                // Now you create a reference to the UDDI API
+                security = transport.getUDDISecurityService();
+                publish = transport.getUDDIPublishService();
+                inquiry = transport.getUDDIInquiryService();
+                juddi = transport.getJUDDIApiService();
+                String token = null;
+                if (username == null || pass == null) {
+                        username = clerk.getPublisher();
+                        pass = clerk.getPassword();
+                }
+                if (username != null && pass != null) {
+                }
 
 
-        //load mapping files
-        //prompt for credentials
-        LoadProperties();
+                //load mapping files
+                //prompt for credentials
+                LoadProperties();
 
-        if (isJuddi) {
-            ImportPublishers();
-        }
+                if (isJuddi) {
+                        ImportPublishers();
+                }
 
-        if (preserveOwnership) {
-            //we'll need credentials for all the users
-            EnsureCredentials();
-        }
+                if (preserveOwnership) {
+                        //we'll need credentials for all the users
+                        EnsureCredentials();
+                }
 
 
 
-        ImportTmodels();
-        ImportBusiness();
+                ImportTmodels();
+                ImportBusiness();
 
 
 
-    }
+        }
+
+        public String GetOwner(String key) {
+                return mapping.getProperty(key);
+        }
 
-    public String GetOwner(String key) {
-        return mapping.getProperty(key);
-    }
+        public String GetPwd(String username) {
+                return userpwd.getProperty(username);
+        }
 
-    public String GetPwd(String username) {
-        return userpwd.getProperty(username);
-    }
+        private void ImportTmodels() throws Exception {
+                SaveTModel stm = JAXB.unmarshal(new File(tmodelfile), SaveTModel.class);
+                if (stripSig) {
+                        int x=0;
+                        for (int i = 0; i < stm.getTModel().size(); i++) {
+                                x+=stm.getTModel().get(i).getSignature().size();
+                                stm.getTModel().get(i).getSignature().clear();
+                        }
+                        System.out.println(x + " signatures stripped");
+                }
 
-    private void ImportTmodels() throws Exception {
-        SaveTModel stm = JAXB.unmarshal(new File(tmodelfile), SaveTModel.class);
-        if (safemode) {
-            for (int i = 0; i < stm.getTModel().size(); i++) {
-                if (!TModelExists(stm.getTModel().get(i).getTModelKey(), token)) {
-                    SaveTModel stm2 = new SaveTModel();
-                    if (preserveOwnership) {
-                        stm2.setAuthInfo(Common.GetAuthToken(
-                                GetOwner(stm.getTModel().get(i).getTModelKey()), 
-                                GetPwd(GetOwner(stm.getTModel().get(i).getTModelKey())), security));
-                    } else {
-                        stm2.setAuthInfo(token);
-                    }
-                    stm2.getTModel().add(stm.getTModel().get(i));
-                    try {
-                        publish.saveTModel(stm2);
-                        System.out.println(stm.getTModel().get(i).getTModelKey() + " saved");
-                    } catch (Exception ex) {
-                        System.out.println("Error saving " + stm.getTModel().get(i).getTModelKey() + " " + ex.getMessage());
-                    }
+                if (safemode) {
+                        for (int i = 0; i < stm.getTModel().size(); i++) {
+                                if (!TModelExists(stm.getTModel().get(i).getTModelKey(), token)) {
+                                        SaveTModel stm2 = new SaveTModel();
+                                        if (preserveOwnership) {
+                                                stm2.setAuthInfo(Common.GetAuthToken(
+                                                        GetOwner(stm.getTModel().get(i).getTModelKey()),
+                                                        GetPwd(GetOwner(stm.getTModel().get(i).getTModelKey())), security));
+                                        } else {
+                                                stm2.setAuthInfo(token);
+                                        }
+                                        stm2.getTModel().add(stm.getTModel().get(i));
+                                        try {
+                                                publish.saveTModel(stm2);
+                                                System.out.println(stm.getTModel().get(i).getTModelKey() + " saved");
+                                        } catch (Exception ex) {
+                                                System.out.println("Error saving " + stm.getTModel().get(i).getTModelKey() + " " + ex.getMessage());
+                                        }
+                                } else {
+                                        System.out.println(stm.getTModel().get(i).getTModelKey() + " skipped, it exists already");
+                                }
+                        }
                 } else {
-                    System.out.println(stm.getTModel().get(i).getTModelKey() + " skipped, it exists already");
+                        stm.setAuthInfo(token);
+
+                        publish.saveTModel(stm);
+                        System.out.println("All " + stm.getTModel().size() + " saved!");
                 }
-            }
-        } else {
-            stm.setAuthInfo(token);
-            publish.saveTModel(stm);
-            System.out.println("All " + stm.getTModel().size() + " saved!");
-        }
-
-    }
-
-    private void ImportBusiness() throws Exception {
-        SaveBusiness stm = JAXB.unmarshal(new File(businessfile), SaveBusiness.class);
-        if (safemode) {
-            for (int i = 0; i < stm.getBusinessEntity().size(); i++) {
-                if (!BusinessExists(stm.getBusinessEntity().get(i).getBusinessKey(), token)) {
-                    SaveBusiness stm2 = new SaveBusiness();
-                    if (preserveOwnership) {
-                        stm2.setAuthInfo(Common.GetAuthToken(GetOwner(stm.getBusinessEntity().get(i).getBusinessKey()), GetPwd(GetOwner(stm.getBusinessEntity().get(i).getBusinessKey())), security));
-                    } else {
-                        stm2.setAuthInfo(token);
-                    }
-                    stm2.getBusinessEntity().add(stm.getBusinessEntity().get(i));
-                    try {
-                        publish.saveBusiness(stm2);
-                        System.out.println(stm.getBusinessEntity().get(i).getBusinessKey() + " saved");
-                    } catch (Exception ex) {
-                        System.out.println("Error saving " + stm.getBusinessEntity().get(i).getBusinessKey() + " " + ex.getMessage());
-                    }
+
+        }
+
+        private void ImportBusiness() throws Exception {
+                SaveBusiness stm = JAXB.unmarshal(new File(businessfile), SaveBusiness.class);
+                if (stripSig) {
+                        int x=0;
+                        for (int i = 0; i < stm.getBusinessEntity().size(); i++) {
+                                x +=  stm.getBusinessEntity().get(i).getSignature().size();
+                                stm.getBusinessEntity().get(i).getSignature().clear();
+                                if (stm.getBusinessEntity().get(i).getBusinessServices() != null) {
+                                        for (int i2 = 0; i2 < stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().size(); i2++) {
+                                                x +=  stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getSignature().size();
+                                                stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getSignature().clear();
+                                                if (stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates() != null) {
+                                                        for (int i3 = 0; i3 < stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates().getBindingTemplate().size(); i3++) {
+                                                                x += stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates().getBindingTemplate().get(i3).getSignature().size();
+                                                                stm.getBusinessEntity().get(i).getBusinessServices().getBusinessService().get(i2).getBindingTemplates().getBindingTemplate().get(i3).getSignature().clear();
+                                                        }
+                                                }
+                                        }
+                                }
+                        }
+                        System.out.println(x + " signatures stripped");
+                }
+
+                if (safemode) {
+                        for (int i = 0; i < stm.getBusinessEntity().size(); i++) {
+                                if (!BusinessExists(stm.getBusinessEntity().get(i).getBusinessKey(), token)) {
+                                        SaveBusiness stm2 = new SaveBusiness();
+                                        if (preserveOwnership) {
+                                                stm2.setAuthInfo(Common.GetAuthToken(GetOwner(stm.getBusinessEntity().get(i).getBusinessKey()), GetPwd(GetOwner(stm.getBusinessEntity().get(i).getBusinessKey())), security));
+                                        } else {
+                                                stm2.setAuthInfo(token);
+                                        }
+                                        stm2.getBusinessEntity().add(stm.getBusinessEntity().get(i));
+                                        try {
+                                                publish.saveBusiness(stm2);
+                                                System.out.println(stm.getBusinessEntity().get(i).getBusinessKey() + " saved");
+                                        } catch (Exception ex) {
+                                                System.out.println("Error saving " + stm.getBusinessEntity().get(i).getBusinessKey() + " " + ex.getMessage());
+                                        }
+                                } else {
+                                        System.out.println(stm.getBusinessEntity().get(i).getBusinessKey() + " skipped, it exists already");
+                                }
+                        }
                 } else {
-                    System.out.println(stm.getBusinessEntity().get(i).getBusinessKey() + " skipped, it exists already");
+                        stm.setAuthInfo(token);
+                        publish.saveBusiness(stm);
+                        System.out.println("All " + stm.getBusinessEntity().size() + " businesses aved!");
+                }
+        }
+
+        private boolean TModelExists(String tModelKey, String token) {
+                GetTModelDetail r = new GetTModelDetail();
+                r.setAuthInfo(token);
+                r.getTModelKey().add(tModelKey);
+                try {
+                        TModelDetail tModelDetail = inquiry.getTModelDetail(r);
+                        if (tModelDetail != null && !tModelDetail.getTModel().isEmpty()) {
+                                return true;
+                        }
+                } catch (Exception ex) {
                 }
-            }
-        } else {
-            stm.setAuthInfo(token);
-            publish.saveBusiness(stm);
-            System.out.println("All " + stm.getBusinessEntity().size() + " businesses aved!");
-        }
-    }
-
-    private boolean TModelExists(String tModelKey, String token) {
-        GetTModelDetail r = new GetTModelDetail();
-        r.setAuthInfo(token);
-        r.getTModelKey().add(tModelKey);
-        try {
-            TModelDetail tModelDetail = inquiry.getTModelDetail(r);
-            if (tModelDetail != null && !tModelDetail.getTModel().isEmpty()) {
-                return true;
-            }
-        } catch (Exception ex) {
-        }
-        return false;
-    }
-
-    private boolean BusinessExists(String businessKey, String token) {
-        GetBusinessDetail r = new GetBusinessDetail();
-        r.setAuthInfo(token);
-        r.getBusinessKey().add(businessKey);
-        try {
-            BusinessDetail tModelDetail = inquiry.getBusinessDetail(r);
-            if (tModelDetail != null && !tModelDetail.getBusinessEntity().isEmpty()) {
-                return true;
-            }
-        } catch (Exception ex) {
-        }
-        return false;
-    }
-
-    private void ImportPublishers() throws Exception {
-
-        SavePublisher stm = JAXB.unmarshal(new File(publishersfile), SavePublisher.class);
-        if (safemode) {
-            for (int i = 0; i < stm.getPublisher().size(); i++) {
-                if (!PublisherExists(stm.getPublisher().get(i).getAuthorizedName(), token)) {
-                    SavePublisher stm2 = new SavePublisher();
-                    stm2.setAuthInfo(token);
-                    stm2.getPublisher().add(stm.getPublisher().get(i));
-                    try {
-                        juddi.savePublisher(stm2);
-                        System.out.println(stm.getPublisher().get(i).getAuthorizedName() + " saved");
-                    } catch (Exception ex) {
-                        System.out.println("Error saving " + stm.getPublisher().get(i).getAuthorizedName() + " " + ex.getMessage());
-                    }
+                return false;
+        }
+
+        private boolean BusinessExists(String businessKey, String token) {
+                GetBusinessDetail r = new GetBusinessDetail();
+                r.setAuthInfo(token);
+                r.getBusinessKey().add(businessKey);
+                try {
+                        BusinessDetail tModelDetail = inquiry.getBusinessDetail(r);
+                        if (tModelDetail != null && !tModelDetail.getBusinessEntity().isEmpty()) {
+                                return true;
+                        }
+                } catch (Exception ex) {
+                }
+                return false;
+        }
+
+        private void ImportPublishers() throws Exception {
+
+                SavePublisher stm = JAXB.unmarshal(new File(publishersfile), SavePublisher.class);
+                if (safemode) {
+                        for (int i = 0; i < stm.getPublisher().size(); i++) {
+                                if (!PublisherExists(stm.getPublisher().get(i).getAuthorizedName(), token)) {
+                                        SavePublisher stm2 = new SavePublisher();
+                                        stm2.setAuthInfo(token);
+                                        stm2.getPublisher().add(stm.getPublisher().get(i));
+                                        try {
+                                                juddi.savePublisher(stm2);
+                                                System.out.println(stm.getPublisher().get(i).getAuthorizedName() + " saved");
+                                        } catch (Exception ex) {
+                                                System.out.println("Error saving " + stm.getPublisher().get(i).getAuthorizedName() + " " + ex.getMessage());
+                                        }
+                                } else {
+                                        System.out.println(stm.getPublisher().get(i).getAuthorizedName() + " skipped, it exists already");
+                                }
+                        }
                 } else {
-                    System.out.println(stm.getPublisher().get(i).getAuthorizedName() + " skipped, it exists already");
+                        stm.setAuthInfo(token);
+                        juddi.savePublisher(stm);
+                        System.out.println("All " + stm.getPublisher().size() + " publishers saved!");
                 }
-            }
-        } else {
-            stm.setAuthInfo(token);
-            juddi.savePublisher(stm);
-            System.out.println("All " + stm.getPublisher().size() + " publishers saved!");
-        }
-    }
-
-    private boolean PublisherExists(String authorizedName, String token) {
-        GetPublisherDetail r = new GetPublisherDetail();
-        r.setAuthInfo(token);
-        r.getPublisherId().add(authorizedName);
-        try {
-            PublisherDetail publisherDetail = juddi.getPublisherDetail(r);
-            if (publisherDetail != null && !publisherDetail.getPublisher().isEmpty()) {
-                return true;
-            }
-        } catch (Exception ex) {
-        }
-        return false;
-    }
-
-    private void LoadProperties() {
-
-
-        try {
-            FileInputStream fos = new FileInputStream(mappingsfile);
-            mapping.load(fos);
-            fos.close();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-
-        //mapping.getProperty("usernames");
-
-        try {
-            FileInputStream fos = new FileInputStream(credFile);
-            userpwd.load(fos);
-            fos.close();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    private void EnsureCredentials() {
-        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-    }
+        }
+
+        private boolean PublisherExists(String authorizedName, String token) {
+                GetPublisherDetail r = new GetPublisherDetail();
+                r.setAuthInfo(token);
+                r.getPublisherId().add(authorizedName);
+                try {
+                        PublisherDetail publisherDetail = juddi.getPublisherDetail(r);
+                        if (publisherDetail != null && !publisherDetail.getPublisher().isEmpty()) {
+                                return true;
+                        }
+                } catch (Exception ex) {
+                }
+                return false;
+        }
+
+        private void LoadProperties() {
+
+
+                try {
+                        FileInputStream fos = new FileInputStream(mappingsfile);
+                        mapping.load(fos);
+                        fos.close();
+                } catch (Exception ex) {
+                        ex.printStackTrace();
+                }
+
+                //mapping.getProperty("usernames");
+
+                try {
+                        FileInputStream fos = new FileInputStream(credFile);
+                        userpwd.load(fos);
+                        fos.close();
+                } catch (Exception ex) {
+                        ex.printStackTrace();
+                }
+        }
+
+        private void EnsureCredentials() throws Exception {
+                Iterator<String> it = usernames.iterator();
+                while (it.hasNext()){
+                        String u = it.next();
+                        if (!userpwd.containsKey(u)){
+                                throw new Exception("The credential for user '"+u+"' is not in the credential file");
+                        }
+                }
+        }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org