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 2015/01/21 03:39:54 UTC
juddi git commit: JUDDI-734 new admin function added to rename a
node. updates the database and config files
Repository: juddi
Updated Branches:
refs/heads/master 8c5350d8f -> 2a243727f
JUDDI-734 new admin function added to rename a node. updates the database and config files
Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/2a243727
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/2a243727
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/2a243727
Branch: refs/heads/master
Commit: 2a243727f055bfdf97dc37e1e3dffc8a09a40199
Parents: 8c5350d
Author: Alex <al...@apache.org>
Authored: Tue Jan 20 21:39:49 2015 -0500
Committer: Alex <al...@apache.org>
Committed: Tue Jan 20 21:39:49 2015 -0500
----------------------------------------------------------------------
.../java/org/apache/juddi/config/AppConfig.java | 36 +++-
.../juddi/adminconsole/hub/UddiAdminHub.java | 187 ++++++++++++++-----
juddiv3-war/src/main/webapp/admin/admin.jsp | 14 +-
3 files changed, 182 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juddi/blob/2a243727/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
----------------------------------------------------------------------
diff --git a/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java b/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
index 9a9f5e0..131f067 100644
--- a/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
+++ b/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
@@ -19,7 +19,6 @@ package org.apache.juddi.config;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -39,10 +38,6 @@ import org.apache.juddi.ClassUtil;
import org.apache.juddi.Registry;
import org.apache.juddi.keygen.KeyGenerator;
import org.apache.juddi.model.UddiEntityPublisher;
-import org.apache.juddi.query.FindBusinessByCategoryQuery;
-import org.apache.juddi.query.util.FindQualifiers;
-import org.uddi.api_v3.CategoryBag;
-import org.uddi.api_v3.KeyedReference;
/**
* Handles the application level configuration for jUDDI. By default it first
@@ -64,6 +59,7 @@ public class AppConfig
private Configuration config;
private static AppConfig instance=null;
private static URL loadedFrom=null;
+ private static XMLConfiguration propConfig=null;
/**
* Enables an administrator to identify the physical location of the configuration file from which it was loaded.<br>
@@ -84,6 +80,20 @@ public class AppConfig
{
loadConfiguration();
}
+ public static void setJuddiProperty(String key, Object val) throws ConfigurationException{
+ if (instance==null) {
+ instance = new AppConfig();
+ }
+ propConfig.setProperty(key, val);
+ propConfig.save();
+ }
+
+ public static void saveConfiguration() throws ConfigurationException{
+ Configuration configuration = getConfiguration();
+ propConfig.save();
+ }
+
+
/**
* Does the actual work of reading the configuration from System
* Properties and/or juddiv3.xml file. When the juddiv3.xml
@@ -97,7 +107,7 @@ public class AppConfig
compositeConfig.addConfiguration(new SystemConfiguration());
//Properties from file
//changed 7-19-2013 AO for JUDDI-627
- XMLConfiguration propConfig = null;
+ propConfig = null;
final String filename = System.getProperty(JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY);
if (filename != null) {
propConfig = new XMLConfiguration (filename);
@@ -118,7 +128,7 @@ public class AppConfig
}
//Hey! this may break things
propConfig.setAutoSave(true);
-
+
log.info("Reading from jUDDI config file from: " + loadedFrom);
long refreshDelay = propConfig.getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY, 1000l);
log.debug("Setting refreshDelay to " + refreshDelay);
@@ -194,6 +204,10 @@ public class AppConfig
// The node Id is defined as the business key of the business entity categorized as a node. This entity is saved as part of the install.
// Only one business entity should be categorized as a node.
String nodeId = config.getString(Property.JUDDI_NODE_ID);
+ if (nodeId==null)
+ log.fatal("Error! " + Property.JUDDI_NODE_ID + " is not defined in the config!");
+ else
+ result.setProperty(Property.JUDDI_NODE_ID, nodeId);
/*
CategoryBag categoryBag = new CategoryBag();
KeyedReference keyedRef = new KeyedReference();
@@ -218,9 +232,13 @@ public class AppConfig
else
throw new ConfigurationException("A node business entity was not found. Please make sure that the application is properly installed.");
*/
- result.setProperty(Property.JUDDI_NODE_ROOT_BUSINESS, nodeId);
+ String rootbiz=config.getString(Property.JUDDI_NODE_ROOT_BUSINESS);
+ if (rootbiz==null)
+ log.fatal("Error! " + Property.JUDDI_NODE_ROOT_BUSINESS + " is not defined in the config");
+ else
+ result.setProperty(Property.JUDDI_NODE_ROOT_BUSINESS, rootbiz);
+
- //result.setProperty(Property.JUDDI_NODE_ROOT_BUSINESS, nodeId);
tx.commit();
return result;
http://git-wip-us.apache.org/repos/asf/juddi/blob/2a243727/juddiv3-war/src/main/java/org/apache/juddi/adminconsole/hub/UddiAdminHub.java
----------------------------------------------------------------------
diff --git a/juddiv3-war/src/main/java/org/apache/juddi/adminconsole/hub/UddiAdminHub.java b/juddiv3-war/src/main/java/org/apache/juddi/adminconsole/hub/UddiAdminHub.java
index 5cbd061..233c6ac 100644
--- a/juddiv3-war/src/main/java/org/apache/juddi/adminconsole/hub/UddiAdminHub.java
+++ b/juddiv3-war/src/main/java/org/apache/juddi/adminconsole/hub/UddiAdminHub.java
@@ -25,6 +25,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -37,6 +42,7 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
+import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
@@ -64,6 +70,10 @@ import org.apache.juddi.v3.client.transport.Transport;
import org.apache.juddi.v3_service.JUDDIApiPortType;
import org.apache.juddi.adminconsole.AES;
import org.apache.juddi.adminconsole.resources.ResourceLoader;
+import org.apache.juddi.api.impl.JUDDIApiImpl;
+import org.apache.juddi.api.impl.UDDIInquiryImpl;
+import org.apache.juddi.api.impl.UDDIPublicationImpl;
+import org.apache.juddi.api.impl.UDDIReplicationImpl;
import org.apache.juddi.api_v3.AdminSaveBusiness;
import org.apache.juddi.api_v3.AdminSaveSubscriptionRequest;
import org.apache.juddi.api_v3.AdminSaveSubscriptionResponse;
@@ -76,16 +86,25 @@ import org.apache.juddi.api_v3.GetEntityHistoryMessageRequest;
import org.apache.juddi.api_v3.GetEntityHistoryMessageResponse;
import org.apache.juddi.api_v3.NodeList;
import org.apache.juddi.api_v3.SubscriptionWrapper;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
+import org.apache.juddi.config.Property;
import org.apache.juddi.model.BindingTemplate;
import org.apache.juddi.subscription.notify.SMTPNotifier;
import org.uddi.api_v3.AuthToken;
+import org.uddi.api_v3.BusinessDetail;
+import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.BusinessService;
+import org.uddi.api_v3.DeleteBusiness;
import org.uddi.api_v3.DeleteTModel;
import org.uddi.api_v3.DiscardAuthToken;
import org.uddi.api_v3.DispositionReport;
import org.uddi.api_v3.FindBusiness;
import org.uddi.api_v3.FindQualifiers;
import org.uddi.api_v3.GetAuthToken;
+import org.uddi.api_v3.GetBusinessDetail;
import org.uddi.api_v3.Name;
+import org.uddi.api_v3.SaveBusiness;
import org.uddi.repl_v3.ReplicationConfiguration;
import org.uddi.sub_v3.Subscription;
import org.uddi.sub_v3.SubscriptionResultsList;
@@ -333,74 +352,54 @@ public class UddiAdminHub {
String action = parameters.getParameter("soapaction");
if (action.equalsIgnoreCase("adminDelete_tmodel")) {
return adminDelete_tmodel(parameters);
- }
- if (action.equalsIgnoreCase("delete_ClientSubscriptionInfo")) {
+ } else if (action.equalsIgnoreCase("delete_ClientSubscriptionInfo")) {
return delete_ClientSubscriptionInfo(parameters);
- }
- if (action.equalsIgnoreCase("delete_publisher")) {
+ } else if (action.equalsIgnoreCase("delete_publisher")) {
return delete_publisher(parameters);
- }
- if (action.equalsIgnoreCase("getAllPublisherDetail")) {
+ } else if (action.equalsIgnoreCase("getAllPublisherDetail")) {
return getAllPublisherDetail(parameters);
- }
- if (action.equalsIgnoreCase("get_publisherDetail")) {
+ } else if (action.equalsIgnoreCase("get_publisherDetail")) {
return get_publisherDetail(parameters);
- }
- if (action.equalsIgnoreCase("invoke_SyncSubscription")) {
+ } else if (action.equalsIgnoreCase("invoke_SyncSubscription")) {
return invoke_SyncSubscription(parameters);
- }
- if (action.equalsIgnoreCase("save_Clerk")) {
+ } else if (action.equalsIgnoreCase("save_Clerk")) {
return save_Clerk(parameters);
- }
- if (action.equalsIgnoreCase("save_ClientSubscriptionInfo")) {
+ } else if (action.equalsIgnoreCase("save_ClientSubscriptionInfo")) {
return save_ClientSubscriptionInfo(parameters);
- }
- if (action.equalsIgnoreCase("save_Node")) {
+ } else if (action.equalsIgnoreCase("save_Node")) {
return save_Node(parameters);
- }
- if (action.equalsIgnoreCase("save_publisher")) {
+ } else if (action.equalsIgnoreCase("save_publisher")) {
return save_publisher(parameters);
- }
-
- if (action.equalsIgnoreCase("send_EmailTest")) {
+ } else if (action.equalsIgnoreCase("send_EmailTest")) {
return sendTestEmail(parameters);
- }
- if (action.equalsIgnoreCase("get_AllNodes")) {
+ } else if (action.equalsIgnoreCase("get_AllNodes")) {
return getAllNodes(parameters);
- }
- if (action.equalsIgnoreCase("get_AllClerks")) {
+ } else if (action.equalsIgnoreCase("get_AllClerks")) {
return getAllClerks(parameters);
- }
- if (action.equalsIgnoreCase("delete_Node")) {
+ } else if (action.equalsIgnoreCase("delete_Node")) {
return deleteNode(parameters);
- }
- if (action.equalsIgnoreCase("delete_Clerk")) {
+ } else if (action.equalsIgnoreCase("delete_Clerk")) {
return deleteClerk(parameters);
- }
- if (action.equalsIgnoreCase("admin_DeleteSubscription")) {
+ } else if (action.equalsIgnoreCase("admin_DeleteSubscription")) {
return deleteSubscription(parameters);
- }
- if (action.equalsIgnoreCase("admin_SaveBusiness")) {
+ } else if (action.equalsIgnoreCase("admin_SaveBusiness")) {
return adminSaveBusiness(parameters);
- }
- if (action.equalsIgnoreCase("admin_SaveTModel")) {
+ } else if (action.equalsIgnoreCase("admin_SaveTModel")) {
return adminSaveTmodel(parameters);
- }
- if (action.equalsIgnoreCase("get_AllClientSubscriptionInfo")) {
+ } else if (action.equalsIgnoreCase("get_AllClientSubscriptionInfo")) {
return getAllClientSubscriptionInfo(parameters);
- }
- if (action.equalsIgnoreCase("set_ReplicationNodes")) {
+ } else if (action.equalsIgnoreCase("set_ReplicationNodes")) {
return setReplicationConfig(parameters);
- }
- if (action.equalsIgnoreCase("get_ReplicationNodes")) {
+ } else if (action.equalsIgnoreCase("get_ReplicationNodes")) {
return getReplicationNodes(parameters);
- }
- if (action.equalsIgnoreCase("admin_SaveSubscription")) {
+ } else if (action.equalsIgnoreCase("admin_SaveSubscription")) {
return adminSaveSubscription(parameters);
- }
- if (action.equalsIgnoreCase("get_EntityHistory")) {
+ } else if (action.equalsIgnoreCase("get_EntityHistory")) {
return getEntityHistory(parameters);
+ } else if (action.equalsIgnoreCase("change_NodeID")) {
+ return change_NodeID(parameters);
}
+
} catch (Exception ex) {
return "Error!" + HandleException(ex);
}
@@ -812,6 +811,104 @@ public class UddiAdminHub {
return StringEscapeUtils.escapeHtml(sw.toString());
}
+ private String change_NodeID(HttpServletRequest parameters) {
+ //check replication config
+
+ EntityManager em = PersistenceManager.getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+
+ try {
+
+ ReplicationConfiguration replicationNodes = new JUDDIApiImpl().getReplicationNodes(GetToken());
+ if (replicationNodes.getOperator().size() > 1) {
+ throw new Exception("Replication is configured with " + replicationNodes.getOperator() + " nodes. Node rename aborted");
+ }
+ Configuration configuration = AppConfig.getConfiguration();
+ //this is going to break a few design rules.
+ String currentnode = configuration.getString(Property.JUDDI_NODE_ID);
+ String newnode = parameters.getParameter("change_NodeIDKey");
+ if (newnode==null)
+ throw new Exception("The new node id was not specified");
+ newnode = newnode.trim();
+ newnode=newnode.toLowerCase();
+ log.warn("AUDIT - Renaming Node ID from " + currentnode + " to " + newnode);
+
+ UDDIPublicationImpl pub = new UDDIPublicationImpl();
+ UDDIInquiryImpl inquire = new UDDIInquiryImpl();
+
+ GetBusinessDetail gbd = new GetBusinessDetail();
+ gbd.setAuthInfo(GetToken());
+ gbd.getBusinessKey().add(newnode);
+ BusinessDetail businessDetail = null;
+ try {
+ businessDetail = inquire.getBusinessDetail(gbd);
+ } catch (Exception ex) {
+ //business doesn't exist
+ }
+ if (businessDetail == null || businessDetail.getBusinessEntity().isEmpty()) {
+ //copy the existing Root Node and rekey it with the new key
+ //incase the destination key generator is valid, we'll abort.
+ gbd.getBusinessKey().clear();
+ gbd.getBusinessKey().add(AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ROOT_BUSINESS));
+ businessDetail = inquire.getBusinessDetail(gbd);
+ BusinessEntity get = businessDetail.getBusinessEntity().get(0);
+ get.setBusinessKey(newnode);
+ get.getSignature().clear();
+ if (get.getBusinessServices() != null) {
+ for (BusinessService bs : get.getBusinessServices().getBusinessService()) {
+ bs.setBusinessKey(newnode);
+ bs.getSignature().clear();
+ //we also need to rekey all of the services and bindings wait do we?
+ //bs.setServiceKey(bs.getServiceKey());
+ }
+ }
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(GetToken());
+ sb.getBusinessEntity().add(get);
+ //if there's something wrong with the new key, this will throw
+ BusinessDetail saveBusiness = pub.saveBusiness(sb);
+ newnode = saveBusiness.getBusinessEntity().get(0).getBusinessKey();
+ }
+
+ tx.begin();
+ //rekey all entities with the new node id
+ Query createQuery = em.createQuery("Update UddiEntity ue set ue.nodeId=:node where ue.nodeId=:oldnode");
+ createQuery.setParameter("node", newnode);
+ createQuery.setParameter("oldnode", currentnode);
+ int records = createQuery.executeUpdate();
+ //rekey all the existing change records with the new node id
+ createQuery = em.createQuery("Update ChangeRecord ue set ue.nodeID=:node where ue.nodeID=:oldnode");
+ createQuery.setParameter("node", newnode);
+ createQuery.setParameter("oldnode", currentnode);
+ records += createQuery.executeUpdate();
+
+ //rekey is_replaced_by references? nah
+ tx.commit();
+ try{
+ DeleteBusiness db = new DeleteBusiness();
+ db.setAuthInfo(GetToken());
+ db.getBusinessKey().add(currentnode);
+ pub.deleteBusiness(db);
+ }
+ catch (Exception ex){
+ log.warn("Node id change error: ", ex);
+ }
+
+ //finally update the xml config and resave it
+ AppConfig.setJuddiProperty(Property.JUDDI_NODE_ID, newnode);
+ AppConfig.setJuddiProperty(Property.JUDDI_NODE_ROOT_BUSINESS, newnode);
+
+ return "Sucess, Records update: " + records + " current node id is now " + AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
+ } catch (Exception ex) {
+ return HandleException(ex);
+ } finally {
+ if (tx.isActive()) {
+ tx.rollback();
+ }
+ em.close();
+ }
+ }
+
public enum AuthStyle {
/**
http://git-wip-us.apache.org/repos/asf/juddi/blob/2a243727/juddiv3-war/src/main/webapp/admin/admin.jsp
----------------------------------------------------------------------
diff --git a/juddiv3-war/src/main/webapp/admin/admin.jsp b/juddiv3-war/src/main/webapp/admin/admin.jsp
index cddda77..d810025 100644
--- a/juddiv3-war/src/main/webapp/admin/admin.jsp
+++ b/juddiv3-war/src/main/webapp/admin/admin.jsp
@@ -21,6 +21,8 @@
--%>
+<%@page import="org.apache.juddi.config.Property"%>
+<%@page import="org.apache.juddi.config.AppConfig"%>
<%@page import="org.apache.juddi.api_v3.Publisher"%>
<%@page import="org.apache.juddi.api_v3.SavePublisher"%>
<%@page import="org.apache.juddi.api_v3.Clerk"%>
@@ -84,6 +86,7 @@
<option>set_ReplicationNodes</option>
<option>get_ReplicationNodes</option>
<option>get_EntityHistory</option>
+ <option>change_NodeID</option>
<option>------ Backup/Restore Management -----</option>
<option>admin_SaveBusiness</option>
@@ -223,12 +226,20 @@
<textarea rows="4" cols="80" id="admin_SaveSubscriptionXML" class="forminput" placeholder="Enter save subscription XML"></textarea>
</div>
- <div id="get_EntityHistory" style="display:none">
+ <div id="get_EntityHistory" style="display:none">
Entity Key <input type="text" id="get_EntityHistoryKey" class="forminput" placeholder="Entity Key"><br>
Records to fetch <input type="text" id="get_EntityHistoryMaxCount" class="forminput" value="25"><br>
Offset <input type="text" id="get_EntityHistoryOffset" class="forminput" value="0"><br>
</div>
+ <div id="change_NodeID" style="display:none">
+ This will change the current node's identifier. During the transaction, no one will be able to modify items stored in the database.
+ This option is not available if this node is configured for replication. It must be removed from the replication configuration on all nodes before renaming.
+ <br><br>
+ Note: Depending on how jUDDI was deployed, you may have to manually edit the juddiv3.xml config file, then restart jUDDI after this process is complete.<br><br>
+ New Node ID <input type="text" id="change_NodeIDKey" class="forminput" placeholder="Node ID" value="<%=StringEscapeUtils.escapeHtml( AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID))%>"><br>
+ </div>
+
@@ -263,6 +274,7 @@
$("#get_ReplicationNodes").hide();
$("#admin_SaveSubscription").hide();
$("#get_EntityHistory").hide();
+ $("#change_NodeID").hide();
$("#" + x).show();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org