Author: alexoree
Date: Sat Nov 30 00:12:02 2013
New Revision: 1546666
URL: http://svn.apache.org/r1546666
Log:
JUDDI-729 first cut, complete
Modified:
juddi/trunk/juddi-migration-tool/pom.xml
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java
juddi/trunk/uddi-client-dist/src/main/assembly/assembly.xml
Modified: juddi/trunk/juddi-migration-tool/pom.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-migration-tool/pom.xml?rev=1546666&r1=1546665&r2=1546666&view=diff
==============================================================================
--- juddi/trunk/juddi-migration-tool/pom.xml (original)
+++ juddi/trunk/juddi-migration-tool/pom.xml Sat Nov 30 00:12:02 2013
@@ -7,11 +7,14 @@
<artifactId>juddi-parent</artifactId>
<version>3.2.0-SNAPSHOT</version>
</parent>
+
<groupId>org.apache.juddi</groupId>
<artifactId>juddi-migration-tool</artifactId>
- <version>3.2-SNAPSHOT</version>
+
<name>UDDI Migration tool</name>
- <url>http://maven.apache.org</url>
+ <packaging>bundle</packaging>
+
+
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Modified:
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java?rev=1546666&r1=1546665&r2=1546666&view=diff
==============================================================================
---
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java
(original)
+++
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/App.java
Sat Nov 30 00:12:02 2013
@@ -15,6 +15,7 @@
*/
package org.apache.juddi.v3.migration.tool;
+import java.util.Random;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -33,6 +34,8 @@ public class App {
public static void main(String[] args) throws ParseException, Exception {
System.out.println("This tool is used to export and import UDDI data
from a UDDI v3 registry");
+ System.out.println("Random TIP: " + RandomTip());
+ System.out.println();
Options options = new Options();
options.addOption("import", false, "Imports data into a UDDIv3
registry");
@@ -42,14 +45,14 @@ public class App {
//options.addOption("safeMode", false, "Prevents overriding existing
entities, saves items one at a time");
options.addOption("config", true, "Use an alternate config file
default is 'uddi.xml'");
options.addOption("node", true, "The node 'name' in the config,
default is 'default'");
- options.addOption("isJuddi", false, "Is this a jUDDI registry? Is so
we can in/export more stuff");
- options.addOption("tmodel", true, "Im/Export for tmodels, default is
'tmodel-export.xml'");
- options.addOption("business", true, "Im/Export option, default is
'business-export.xml'");
- options.addOption("mappings", true, "Im/Export option, default is
'entityusermappings.properties'");
- options.addOption("publishers", true, "jUDDI only - In/Export option,
default is 'publishers-export.xml'");
+ options.addOption("isJuddi", false, "Is this a jUDDI registry? If so
we can in/export more stuff");
+ options.addOption("tmodel", true, "Im/Export for tmodels, file to
store tmodel data, default is 'tmodel-export.xml'");
+ options.addOption("business", true, "Im/Export option, file to store
the business data, default is 'business-export.xml'");
+ options.addOption("mappings", true, "Im/Export option, file that maps
keys to owners, default is 'entityusermappings.properties'");
+ options.addOption("publishers", true, "jUDDI only - In/Export option,
file to store publishers, default is 'publishers-export.xml'");
options.addOption("myItemsOnly", false, "Export option, Only export
items owned by yourself");
- // options.addOption("preserveOwnership", false, "Im/Export option,
Only export items owned by yourself");
- // options.addOption("credFile", true, "Used with -preserveOwnership,
this is a properties file mapping with user=pass");
+ 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");
// create the parser
@@ -76,7 +79,9 @@ public class App {
String tmodel = line.getOptionValue("tmodel", "tmodel-export.xml");
String business = line.getOptionValue("business",
"business-export.xml");
String publishers = line.getOptionValue("publishers",
"publishers-export.xml");
-
+ //username to password
+ String credFile = line.getOptionValue("credFile",
"credentials.properties");
+ //key to username
String mappings = line.getOptionValue("mappings",
"entityusermappings.properties");
boolean preserveOwnership =
false;//line.hasOption("preserveOwnership");
boolean juddi = line.hasOption("isJuddi");
@@ -85,12 +90,18 @@ 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);
+ new Export().Execute(config, node, user, pass, tmodel,
business, juddi, safe, publishers, myItemsOnly, mappings, preserveOwnership,
credFile);
+ System.out.println();
+ if (preserveOwnership) {
+ System.out.println("Next step(s), Edit the " + credFile +
" and make any adjustments that are necessary.");
+ System.out.println("TIP: if you're using juddi, you
temporarily switch to the 'JuddiAuthenticator' which doesn't validate
passwords.");
+ }
+ System.out.println("Next step(s), Edit " + config + " to point
to the next registry. Then try -import. You can also specify a different
node.");
}
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);
+ new Import().Execute(config, node, user, pass, tmodel,
business, juddi, safe, publishers, preserveOwnership, mappings, credFile);
}
@@ -108,4 +119,18 @@ public class App {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("java -jar
juddi-migration-tool-(VERSION)-jar-with-dependencies.jar", options);
}
+
+ private static String RandomTip() {
+ String[] tips = new String[]{
+ "You can use setup custom SSL trust/key stores using
-Djavax.net.ssl.keyStore=file -javax.net.ssl.keyStorePassword=pwd
-Djavax.net.ssl.trustStore=file "
+ + "-Djavax.net.ssl.trustStorePassword=pwd",
+ "You can easily script the UDDI migration tool and use it as a
backup mechanism.",
+ "You can protect credentials by storing them in uddi client config
file.",
+ "This tool can only work with UDDI v3 registries.",
+ "With the preserveOwnership flag, you can maintain entity
ownership.",
+ "Without the preserveOwnership flag, all imported data will be
owned by the username that imported it."
+ };
+ Random r = new Random();
+ return tips[r.nextInt(tips.length)];
+ }
}
Modified:
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java?rev=1546666&r1=1546665&r2=1546666&view=diff
==============================================================================
---
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java
(original)
+++
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Export.java
Sat Nov 30 00:12:02 2013
@@ -17,6 +17,7 @@ package org.apache.juddi.v3.migration.to
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.security.AuthProvider;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties;
@@ -70,6 +71,8 @@ public class Export {
String mappingsfile = null;
boolean safemode = false;
boolean myitemsonly = false;
+ boolean preserveOwnership;
+ String credFile;
Set<String> usernames = new HashSet<String>();
Properties mapping = new Properties();
@@ -77,7 +80,8 @@ public class Export {
String tmodelout, String businessOut,
boolean isJuddi, boolean safe, String publishersFile,
boolean myItemsOnly,
- String mappingsfile) throws Exception {
+ 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;
@@ -85,6 +89,9 @@ public class Export {
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);
@@ -126,7 +133,10 @@ public class Export {
ExportClerks();
ExportPublishers();
}
- SaveProperties();
+ if (preserveOwnership) {
+ SaveProperties();
+ SaveCredFileTemplate();
+ }
clerkManager.stop();
}
@@ -140,12 +150,10 @@ public class Export {
int offset = 0;
int maxrows = 20;
- //TODO param
req.setMaxRows(maxrows);
req.setListHead(offset);
BusinessList findTModel = null;
SaveBusiness sb = new SaveBusiness();
- //TODO exclusion list
do {
findTModel = inquiry.findBusiness(req);
if (findTModel.getBusinessInfos() != null) {
@@ -238,9 +246,11 @@ public class Export {
}
private void ExportNodes() {
+ //TODO wait for JUDDI-706
}
private void ExportClerks() {
+ //TODO wait for JUDDI-706
}
private void ExportPublishers() throws Exception {
@@ -269,7 +279,23 @@ public class Export {
mapping.put("usernames", sb.toString());
try {
FileOutputStream fos = new FileOutputStream(mappingsfile);
- mapping.store(fos, token);
+ 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/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java?rev=1546666&r1=1546665&r2=1546666&view=diff
==============================================================================
---
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java
(original)
+++
juddi/trunk/juddi-migration-tool/src/main/java/org/apache/juddi/v3/migration/tool/Import.java
Sat Nov 30 00:12:02 2013
@@ -63,14 +63,23 @@ public class Import {
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) throws Exception {
+ String mappingsfile, String credFile) throws Exception {
+ this.credFile = credFile;
this.publishersfile = publishersFile;
this.tmodelfile = tmodelIn;
this.businessfile = businessIn;
@@ -128,8 +137,8 @@ public class Import {
return mapping.getProperty(key);
}
- public String GetPwd(String key) {
- return null;
+ public String GetPwd(String username) {
+ return userpwd.getProperty(username);
}
private void ImportTmodels() throws Exception {
@@ -139,7 +148,9 @@ public class Import {
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));
+ stm2.setAuthInfo(Common.GetAuthToken(
+
GetOwner(stm.getTModel().get(i).getTModelKey()),
+
GetPwd(GetOwner(stm.getTModel().get(i).getTModelKey())), security));
} else {
stm2.setAuthInfo(token);
}
@@ -261,15 +272,7 @@ public class Import {
private void LoadProperties() {
- 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 {
FileInputStream fos = new FileInputStream(mappingsfile);
mapping.load(fos);
@@ -278,7 +281,15 @@ public class Import {
ex.printStackTrace();
}
- mapping.getProperty("usernames");
+ //mapping.getProperty("usernames");
+
+ try {
+ FileInputStream fos = new FileInputStream(credFile);
+ userpwd.load(fos);
+ fos.close();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
}
private void EnsureCredentials() {
Modified: juddi/trunk/uddi-client-dist/src/main/assembly/assembly.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/uddi-client-dist/src/main/assembly/assembly.xml?rev=1546666&r1=1546665&r2=1546666&view=diff
==============================================================================
--- juddi/trunk/uddi-client-dist/src/main/assembly/assembly.xml (original)
+++ juddi/trunk/uddi-client-dist/src/main/assembly/assembly.xml Sat Nov 30
00:12:02 2013
@@ -30,6 +30,7 @@
<include>org.apache.juddi:uddi-tck:test-jar</include>
<include>org.apache.juddi:uddi-tck-base:jar</include>
<include>org.apache.juddi:uddi-ws:jar</include>
+
<include>org.apache.juddi:juddi-migration-tool:jar</include>
</includes>
<excludes>
<exclude>org.apache.juddi:juddi-client:jar:sources</exclude>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]