juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfa...@apache.org
Subject svn commit: r776476 - in /webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi: api/impl/ auth/ config/ query/ subscription/
Date Tue, 19 May 2009 21:34:07 GMT
Author: jfaath
Date: Tue May 19 21:34:07 2009
New Revision: 776476

URL: http://svn.apache.org/viewvc?rev=776476&view=rev
Log:
JUDDI-232: install process now checks "juddi_custom_install_data" on classpath for installation
files before checking the jar directory.  PersistenceManager moved to config directory.  Install
process cannot be externally triggered and can only be called from within the "config" package.

Added:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/PersistenceManager.java
  (contents, props changed)
      - copied, changed from r776353, webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/PersistenceManager.java
Removed:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/PersistenceManager.java
Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISecurityImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionListenerImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/auth/JUDDIAuthenticator.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Install.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDICustodyTransferImpl.java
Tue May 19 21:34:07 2009
@@ -33,6 +33,7 @@
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.config.Property;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.FatalErrorException;
@@ -42,7 +43,6 @@
 import org.apache.juddi.model.TransferTokenKey;
 import org.apache.juddi.model.UddiEntity;
 import org.apache.juddi.model.UddiEntityPublisher;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.query.util.DynamicQuery;
 import org.apache.juddi.validation.ValidateCustodyTransfer;
 import org.uddi.custody_v3.DiscardTransferToken;

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
Tue May 19 21:34:07 2009
@@ -24,9 +24,9 @@
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.juddi.mapping.MappingModelToApi;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.validation.ValidateInquiry;
 import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.config.Property;
 import org.apache.juddi.error.InvalidKeyPassedException;
 import org.apache.juddi.error.ErrorMessage;

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIPublicationImpl.java
Tue May 19 21:34:07 2009
@@ -59,12 +59,12 @@
 import org.apache.juddi.query.FindTModelByPublisherQuery;
 import org.apache.juddi.query.FindPublisherAssertionByBusinessQuery;
 import org.apache.juddi.query.DeletePublisherAssertionByBusinessQuery;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.model.UddiEntityPublisher;
 import org.apache.juddi.api.datatype.PublisherDetail;
 import org.apache.juddi.api.datatype.SavePublisher;
 import org.apache.juddi.api.datatype.DeletePublisher;
 import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.config.Property;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.FatalErrorException;

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISecurityImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISecurityImpl.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISecurityImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISecurityImpl.java
Tue May 19 21:34:07 2009
@@ -32,10 +32,10 @@
 
 import org.apache.juddi.auth.AuthenticatorFactory;
 import org.apache.juddi.auth.Authenticator;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.error.UnknownUserException;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.mapping.MappingModelToApi;
-import org.apache.juddi.query.PersistenceManager;
 
 /**
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
Tue May 19 21:34:07 2009
@@ -61,6 +61,7 @@
 import org.uddi.v3_service.UDDISubscriptionPortType;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.config.Property;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.FatalErrorException;
@@ -71,7 +72,6 @@
 import org.apache.juddi.model.SubscriptionMatch;
 import org.apache.juddi.model.UddiEntityPublisher;
 import org.apache.juddi.query.FindSubscriptionByPublisherQuery;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.util.JAXBMarshaller;
 import org.apache.juddi.validation.ValidateSubscription;
 import org.apache.log4j.Logger;

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionListenerImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionListenerImpl.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionListenerImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionListenerImpl.java
Tue May 19 21:34:07 2009
@@ -27,10 +27,10 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.FatalErrorException;
 import org.apache.juddi.model.UddiEntityPublisher;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.validation.ValidateSubscriptionListener;
 import org.apache.log4j.Logger;
 import org.uddi.api_v3.DispositionReport;

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/auth/JUDDIAuthenticator.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/auth/JUDDIAuthenticator.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/auth/JUDDIAuthenticator.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/auth/JUDDIAuthenticator.java
Tue May 19 21:34:07 2009
@@ -21,11 +21,11 @@
 import javax.persistence.EntityTransaction;
 
 import org.apache.juddi.model.Publisher;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.error.AuthenticationException;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.UnknownUserException;
 import org.apache.juddi.model.UddiEntityPublisher;
-import org.apache.juddi.query.PersistenceManager;
 
 /**
  * This is the default implementation of jUDDI's Authenticator interface, which

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/AppConfig.java
Tue May 19 21:34:07 2009
@@ -34,7 +34,6 @@
 import org.apache.juddi.keygen.KeyGenerator;
 import org.apache.juddi.model.UddiEntityPublisher;
 import org.apache.juddi.query.FindBusinessByCategoryQuery;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.query.util.FindQualifiers;
 import org.apache.log4j.Logger;
 import org.uddi.api_v3.CategoryBag;

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Install.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Install.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Install.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Install.java
Tue May 19 21:34:07 2009
@@ -17,8 +17,6 @@
 
 package org.apache.juddi.config;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -34,7 +32,6 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.juddi.api.impl.UDDIInquiryImpl;
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.FatalErrorException;
@@ -44,7 +41,6 @@
 import org.apache.juddi.keygen.KeyGenerator;
 import org.apache.juddi.mapping.MappingApiToModel;
 import org.apache.juddi.model.UddiEntityPublisher;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.validation.ValidatePublish;
 import org.apache.juddi.validation.ValidateUDDIKey;
 import org.apache.log4j.Logger;
@@ -67,22 +63,10 @@
 	
 	public static final String FILE_PERSISTENCE = "persistence.xml";
 	public static final String JUDDI_INSTALL_DATA_DIR = "juddi_install_data/";
+	public static final String JUDDI_CUSTOM_INSTALL_DATA_DIR = "juddi_custom_install_data/";
 	public static Logger log = Logger.getLogger(Install.class);
 
-	public static void install() throws JAXBException, DispositionReportFaultMessage, IOException
{
-		install(JUDDI_INSTALL_DATA_DIR, null, false);
-	}
-	
-	public static void install(String srcDir, String userPartition, boolean reloadConfig) throws
JAXBException, DispositionReportFaultMessage, IOException {
-		if (srcDir != null) {
-			if (srcDir.endsWith("/") || srcDir.endsWith("\\")) {
-				// Do nothing
-			}
-			else 
-				srcDir = srcDir + java.io.File.separator;
-		}
-		else
-			srcDir = "";
+	protected static void install() throws JAXBException, DispositionReportFaultMessage, IOException
{
 				
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
@@ -93,27 +77,27 @@
 			tx.begin();
 	
 			if (alreadyInstalled(em))
-				throw new FatalErrorException(new ErrorMessage("errors.install.AlreadyInstalled"));
+				new FatalErrorException(new ErrorMessage("errors.install.AlreadyInstalled"));
 			
-			TModel rootTModelKeyGen = (TModel)buildEntityFromDoc(JUDDI_INSTALL_DATA_DIR + FILE_ROOT_TMODELKEYGEN,
"org.uddi.api_v3");
-			org.uddi.api_v3.BusinessEntity rootBusinessEntity = (org.uddi.api_v3.BusinessEntity)buildEntityFromDoc(srcDir
+ FILE_ROOT_BUSINESSENTITY, "org.uddi.api_v3");
+			TModel rootTModelKeyGen = (TModel)buildInstallEntity(FILE_ROOT_TMODELKEYGEN, "org.uddi.api_v3");
+			org.uddi.api_v3.BusinessEntity rootBusinessEntity = (org.uddi.api_v3.BusinessEntity)buildInstallEntity(FILE_ROOT_BUSINESSENTITY,
"org.uddi.api_v3");
 			
-			String rootPartition = getRootPartition(rootTModelKeyGen, userPartition);
+			String rootPartition = getRootPartition(rootTModelKeyGen);
 			String nodeId = getNodeId(rootBusinessEntity.getBusinessKey(), rootPartition);
 			
-			rootPublisher = installPublisher(em, JUDDI_INSTALL_DATA_DIR + FILE_ROOT_PUBLISHER);
-			uddiPublisher = installPublisher(em, JUDDI_INSTALL_DATA_DIR + FILE_UDDI_PUBLISHER);
-			// TODO:  These do not belong here
+			rootPublisher = installPublisher(em, FILE_ROOT_PUBLISHER);
+			uddiPublisher = installPublisher(em, FILE_UDDI_PUBLISHER);
+			// TODO:  These do not belong here?
 			// Inserting 2 test publishers
-			installPublisher(em, JUDDI_INSTALL_DATA_DIR + FILE_JOE_PUBLISHER);
-			installPublisher(em, JUDDI_INSTALL_DATA_DIR + FILE_SSYNDICATOR);
+			installPublisher(em, FILE_JOE_PUBLISHER);
+			installPublisher(em, FILE_SSYNDICATOR);
 
 			installRootPublisherKeyGen(em, rootTModelKeyGen, rootPartition, rootPublisher, nodeId);
 
 			rootBusinessEntity.setBusinessKey(nodeId);
 			installRootBusinessEntity(em, rootBusinessEntity, rootPublisher, rootPartition);
 
-			installUDDITModels(em, JUDDI_INSTALL_DATA_DIR + FILE_UDDI_TMODELS, uddiPublisher, nodeId);
+			installSaveTModel(em, FILE_UDDI_TMODELS, uddiPublisher, nodeId);
 			
 			tx.commit();
 		}
@@ -137,15 +121,9 @@
 			}
 			em.close();
 		}
-
-		// Now that all necessary persistent entities are loaded, the configuration must be reloaded
to be sure all properties are set.
-		if (reloadConfig) {
-			try { AppConfig.reloadConfig(); } catch (ConfigurationException ce) { log.error(ce.getMessage(),
ce); }
-		}
-		
 	}
 
-	public static void uninstall() {
+	protected static void uninstall() {
 		// Close the open emf, open a new one with Persistence.create...(String, Map) and overwrite
the property that handles the table 
 		// generation. The persistence.xml file will have to be read in to determine which property
 		// to overwrite.  The property will be specific to the provider.  
@@ -156,7 +134,7 @@
 		
 	}
 	
-	public static boolean alreadyInstalled() {
+	protected static boolean alreadyInstalled() {
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
@@ -174,7 +152,7 @@
 		}
 	}
 
-	public static boolean alreadyInstalled(EntityManager em) {
+	protected static boolean alreadyInstalled(EntityManager em) {
 		
 		org.apache.juddi.model.Publisher publisher = em.find(org.apache.juddi.model.Publisher.class,
Constants.ROOT_PUBLISHER);
 		if (publisher != null)
@@ -187,36 +165,36 @@
 		return false;
 	}
 	
-	public static String getRootPartition(TModel rootTModelKeyGen, String userPartition) throws
JAXBException, IOException, DispositionReportFaultMessage {
+	protected static String getRootPartition(TModel rootTModelKeyGen) throws JAXBException,
IOException, DispositionReportFaultMessage {
 		String result = rootTModelKeyGen.getTModelKey().substring(0, rootTModelKeyGen.getTModelKey().lastIndexOf(KeyGenerator.PARTITION_SEPARATOR));
 		
-		if (userPartition != null && userPartition.length() > 0) {
-			// A root partition was provided by the user.  Must validate it.  The first component
should be a domain key and the any following
-			// tokens should be a valid KSS.
-			userPartition = userPartition.trim();
-			if (userPartition.endsWith(KeyGenerator.PARTITION_SEPARATOR) || userPartition.startsWith(KeyGenerator.PARTITION_SEPARATOR))
-				throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
userPartition));
-			
-			StringTokenizer tokenizer = new StringTokenizer(userPartition.toLowerCase(), KeyGenerator.PARTITION_SEPARATOR);
-			for(int count = 0; tokenizer.hasMoreTokens(); count++) {
-				String nextToken = tokenizer.nextToken();
-
-				if (count == 0) {
-					if(!ValidateUDDIKey.isValidDomainKey(nextToken))
-						throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
userPartition));
-				}
-				else {
-					if (!ValidateUDDIKey.isValidKSS(nextToken))
-						throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
userPartition));
-				}
+		if (result == null || result.length() == 0)
+			throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
result));
+		
+		// Must validate the root partition.  The first component should be a domain key and the
any following
+		// tokens should be a valid KSS.
+		result = result.trim();
+		if (result.endsWith(KeyGenerator.PARTITION_SEPARATOR) || result.startsWith(KeyGenerator.PARTITION_SEPARATOR))
+			throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
result));
+		
+		StringTokenizer tokenizer = new StringTokenizer(result.toLowerCase(), KeyGenerator.PARTITION_SEPARATOR);
+		for(int count = 0; tokenizer.hasMoreTokens(); count++) {
+			String nextToken = tokenizer.nextToken();
+
+			if (count == 0) {
+				if(!ValidateUDDIKey.isValidDomainKey(nextToken))
+					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
result));
+			}
+			else {
+				if (!ValidateUDDIKey.isValidKSS(nextToken))
+					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey",
result));
 			}
-			// If the user-supplied root partition checks out, we can use that.
-			result = KeyGenerator.UDDI_SCHEME + KeyGenerator.PARTITION_SEPARATOR + userPartition;
 		}
+
 		return result;
 	}
 	
-	public static String getNodeId(String userNodeId, String rootPartition) throws DispositionReportFaultMessage
{
+	protected static String getNodeId(String userNodeId, String rootPartition) throws DispositionReportFaultMessage
{
 
 		String result = userNodeId;
 		if (result == null || result.length() == 0) {
@@ -231,21 +209,6 @@
 		return result;
 	}
 	
-	public static org.uddi.api_v3.BusinessEntity getNodeBusinessEntity(String businessKey) throws
DispositionReportFaultMessage {
-		UDDIInquiryImpl inquiry = new UDDIInquiryImpl();
-		
-		org.uddi.api_v3.GetBusinessDetail gbd = new org.uddi.api_v3.GetBusinessDetail();
-		gbd.getBusinessKey().add(businessKey);
-		
-		org.uddi.api_v3.BusinessDetail bd = inquiry.getBusinessDetail(gbd);
-		if (bd != null) {
-			List<org.uddi.api_v3.BusinessEntity> beList = bd.getBusinessEntity();
-			if (beList != null && beList.size() > 0)
-				return beList.get(0);
-		}
-
-		return new org.uddi.api_v3.BusinessEntity();
-	}
 	
 	
 	private static String installRootBusinessEntity(EntityManager em, org.uddi.api_v3.BusinessEntity
rootBusinessEntity, UddiEntityPublisher rootPublisher, String rootPartition) 
@@ -417,21 +380,6 @@
 	
 	
 	
-	public static void installUDDITModels(EntityManager em, String resource, UddiEntityPublisher
publisher, String nodeId) 
-		throws JAXBException, DispositionReportFaultMessage, IOException {
-		SaveTModel apiSaveTModel = (SaveTModel)buildEntityFromDoc(resource, "org.uddi.api_v3");
-		installTModels(em, apiSaveTModel.getTModel(), publisher, nodeId);
-		
-	}
-	
-	public static UddiEntityPublisher installPublisher(EntityManager em, String resource) 
-		throws JAXBException, DispositionReportFaultMessage, IOException {
-		org.apache.juddi.api.datatype.Publisher apiPub = (org.apache.juddi.api.datatype.Publisher)buildEntityFromDoc(resource,
"org.apache.juddi.api.datatype");
-		org.apache.juddi.model.Publisher modelPub = new org.apache.juddi.model.Publisher();
-		MappingApiToModel.mapPublisher(apiPub, modelPub);
-		em.persist(modelPub);
-		return modelPub;
-	}
 	
 	private static void installTModels(EntityManager em, List<org.uddi.api_v3.TModel>
apiTModelList, UddiEntityPublisher publisher, String nodeId) throws DispositionReportFaultMessage
{
 		if (apiTModelList != null) {
@@ -486,21 +434,87 @@
 		
 	}
 	
-	private static Object buildEntityFromDoc(String resource, String thePackage) throws JAXBException,
IOException {
+	private static Object buildInstallEntity(String fileName, String packageName) throws JAXBException,
IOException {
 		InputStream resourceStream = null;
 		
-		URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
+		// First try the custom install directory
+		URL url = Thread.currentThread().getContextClassLoader().getResource(JUDDI_CUSTOM_INSTALL_DATA_DIR
+ fileName);
 		if (url != null)
 			resourceStream = url.openStream();
 		
+		// If the custom install directory doesn't exist, then use the standard install directory
where the resource is guaranteed to exist.
 		if (resourceStream == null) {
-			resourceStream = new FileInputStream(new File(resource));
+			url = Thread.currentThread().getContextClassLoader().getResource(JUDDI_INSTALL_DATA_DIR
+ fileName);
+			resourceStream = url.openStream();
 		}
 		
-		JAXBContext jc = JAXBContext.newInstance(thePackage);
+		JAXBContext jc = JAXBContext.newInstance(packageName);
 		Unmarshaller unmarshaller = jc.createUnmarshaller();
 		Object obj = ((JAXBElement<?>)unmarshaller.unmarshal(resourceStream)).getValue();
 		return obj;
 	}
 
+	/**
+	 * Public convenience method that allows one to retrieve the node business entity (perhaps
to display during an install process, or even to
+	 * initiate the install process).
+	 * 
+	 * @param businessKey
+	 * @return
+	 * @throws DispositionReportFaultMessage
+	 */
+	public static org.uddi.api_v3.BusinessEntity getNodeBusinessEntity(String businessKey) throws
DispositionReportFaultMessage {
+		UDDIInquiryImpl inquiry = new UDDIInquiryImpl();
+		
+		org.uddi.api_v3.GetBusinessDetail gbd = new org.uddi.api_v3.GetBusinessDetail();
+		gbd.getBusinessKey().add(businessKey);
+		
+		org.uddi.api_v3.BusinessDetail bd = inquiry.getBusinessDetail(gbd);
+		if (bd != null) {
+			List<org.uddi.api_v3.BusinessEntity> beList = bd.getBusinessEntity();
+			if (beList != null && beList.size() > 0)
+				return beList.get(0);
+		}
+
+		return new org.uddi.api_v3.BusinessEntity();
+	}
+	
+	/**
+	 * Public convenience method that allows one to install additional TModels via a SaveTModel
structure.
+	 * 
+	 * @param em - the entity manager to a juddi model
+	 * @param fileName - name of SaveTModel xml file
+	 * @param publisher - the publisher structure that owns the tModels
+	 * @param nodeId - the node id of the custodial node
+	 * @throws JAXBException
+	 * @throws DispositionReportFaultMessage
+	 * @throws IOException
+	 */
+	public static void installSaveTModel(EntityManager em, String fileName, UddiEntityPublisher
publisher, String nodeId) 
+		throws JAXBException, DispositionReportFaultMessage, IOException {
+
+		SaveTModel apiSaveTModel = (SaveTModel)buildInstallEntity(fileName, "org.uddi.api_v3");
+		installTModels(em, apiSaveTModel.getTModel(), publisher, nodeId);
+	}
+
+	/**
+	 * Public convenience method that allows one to install additional Publishers via a Publisher
structure.
+	 * 
+	 * @param em - the entity manager to the juddi model
+	 * @param fileName - name of Publisher xml file
+	 * @return
+	 * @throws JAXBException
+	 * @throws DispositionReportFaultMessage
+	 * @throws IOException
+	 */
+	public static UddiEntityPublisher installPublisher(EntityManager em, String fileName) 
+		throws JAXBException, DispositionReportFaultMessage, IOException {
+
+		org.apache.juddi.api.datatype.Publisher apiPub = (org.apache.juddi.api.datatype.Publisher)buildInstallEntity(fileName,
"org.apache.juddi.api.datatype");
+		org.apache.juddi.model.Publisher modelPub = new org.apache.juddi.model.Publisher();
+		MappingApiToModel.mapPublisher(apiPub, modelPub);
+		em.persist(modelPub);
+		return modelPub;
+	}
+	
+	
 }

Copied: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/PersistenceManager.java
(from r776353, webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/PersistenceManager.java)
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/PersistenceManager.java?p2=webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/PersistenceManager.java&p1=webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/PersistenceManager.java&r1=776353&r2=776476&rev=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/PersistenceManager.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/PersistenceManager.java
Tue May 19 21:34:07 2009
@@ -15,14 +15,13 @@
  *
  */
 
-package org.apache.juddi.query;
+package org.apache.juddi.config;
 
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;
 import javax.persistence.EntityManager;
 
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.juddi.config.AppConfig;
 import org.apache.log4j.Logger;
 
 public class PersistenceManager {
@@ -35,7 +34,8 @@
 	// Now, the factory will be initialized in the config. This will force the config to initialize,
thereby initializing emf.
 	static {
 		try {
-			AppConfig.getInstance();
+			if (emf == null)
+				AppConfig.getInstance();
 		} 
 		catch (ConfigurationException e) {
 			log.error("Error initializing config in PersistenceManager", e);
@@ -52,7 +52,7 @@
 			emf.close();
 	}
 	
-	public static void initializeEntityManagerFactory(String persistenceUnitName) {
+	protected static void initializeEntityManagerFactory(String persistenceUnitName) {
 		try {
 			if (emf == null)
 				emf = Persistence.createEntityManagerFactory(persistenceUnitName);

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/PersistenceManager.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java?rev=776476&r1=776475&r2=776476&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/subscription/SubscriptionNotifier.java
Tue May 19 21:34:07 2009
@@ -38,10 +38,10 @@
 import org.apache.juddi.api.AccessPointType;
 import org.apache.juddi.api.impl.UDDISubscriptionImpl;
 import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
 import org.apache.juddi.config.Property;
 import org.apache.juddi.model.Subscription;
 import org.apache.juddi.model.UddiEntityPublisher;
-import org.apache.juddi.query.PersistenceManager;
 import org.apache.log4j.Logger;
 import org.uddi.sub_v3.CoveragePeriod;
 import org.uddi.sub_v3.GetSubscriptionResults;



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


Mime
View raw message