You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by jf...@apache.org on 2008/11/25 23:51:14 UTC
svn commit: r720637 - in /webservices/juddi/branches/v3_trunk/juddi-core/src:
main/java/org/apache/juddi/config/ main/java/org/apache/juddi/keygen/
main/java/org/apache/juddi/validation/ main/resources/
test/java/org/apache/juddi/test/
Author: jfaath
Date: Tue Nov 25 14:51:14 2008
New Revision: 720637
URL: http://svn.apache.org/viewvc?rev=720637&view=rev
Log:
JUDDI-156: Loading the root domain into the configuration
Modified:
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/Property.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/DefaultKeyGenerator.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/KeyGenerator.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateUDDIKey.java
webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java
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=720637&r1=720636&r2=720637&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 Nov 25 14:51:14 2008
@@ -16,18 +16,30 @@
*/
package org.apache.juddi.config;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.MapConfiguration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
+import org.apache.juddi.keygen.KeyGenerator;
+import org.apache.juddi.model.KeyGeneratorKey;
+import org.apache.juddi.model.UddiEntityPublisher;
+import org.apache.juddi.query.PersistenceManager;
import org.apache.log4j.Logger;
/**
* Handles the application level configuration for jUDDI. By default it first
* looks at system properties
* @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
*/
public class AppConfig
{
@@ -57,15 +69,53 @@
compositeConfig.addConfiguration(new SystemConfiguration());
//Properties from file
PropertiesConfiguration propConfig = new PropertiesConfiguration(JUDDI_PROPERTIES);
+ // Properties from the persistence layer
+ MapConfiguration persistentConfig = new MapConfiguration(getPersistentConfiguration());
+
long refreshDelay = propConfig.getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY, 1000l);
log.debug("Setting refreshDelay to " + refreshDelay);
FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
propConfig.setReloadingStrategy(fileChangedReloadingStrategy);
compositeConfig.addConfiguration(propConfig);
+ compositeConfig.addConfiguration(persistentConfig);
//Making the new configuration globally accessible.
config = compositeConfig;
}
+
+ /*
+ * This method will build any "persisted" properties. Persisted properties are those that are stored in the database. These values
+ * should be stored when the application is installed. If they don't exist, then an error should occur.
+ */
+ private Properties getPersistentConfiguration() throws ConfigurationException {
+ Properties result = new Properties();
+
+ EntityManager em = PersistenceManager.getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+ tx.begin();
+
+ UddiEntityPublisher rootPublisher = em.find(UddiEntityPublisher.class, "root");
+ if (rootPublisher == null)
+ throw new ConfigurationException("The 'root' publisher was not found. Please make sure that the application is properly installed.");
+
+ Set<KeyGeneratorKey> rootKeyGenList = rootPublisher.getKeyGeneratorKeys();
+ if (rootKeyGenList == null || rootKeyGenList.size() == 0)
+ throw new ConfigurationException("The 'root' publisher key generator was not found. Please make sure that the application is properly installed.");
+
+ String rootKeyGen = rootKeyGenList.iterator().next().getKeygenTModelKey();
+ rootKeyGen = rootKeyGen.substring((KeyGenerator.UDDI_SCHEME + KeyGenerator.PARTITION_SEPARATOR).length());
+ rootKeyGen = rootKeyGen.substring(0, rootKeyGen.length() - (KeyGenerator.PARTITION_SEPARATOR + KeyGenerator.KEYGENERATOR_SUFFIX).length());
+ log.debug("root domain: " + rootKeyGen);
+
+ result.setProperty(Property.JUDDI_ROOT_DOMAIN, rootKeyGen);
+
+ tx.commit();
+ em.close();
+
+ return result;
+ }
+
+
/**
* Obtains the reference to the Singleton instance.
*
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java?rev=720637&r1=720636&r2=720637&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/config/Property.java Tue Nov 25 14:51:14 2008
@@ -20,4 +20,5 @@
public final static String JUDDI_USERSFILE ="juddi.usersfile";
public final static String JUDDI_MAX_ROWS ="juddi.maxRows";
public final static String JUDDI_MAX_IN_CLAUSE ="juddi.maxInClause";
+ public final static String JUDDI_ROOT_DOMAIN ="juddi.rootDomain";
}
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/DefaultKeyGenerator.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/DefaultKeyGenerator.java?rev=720637&r1=720636&r2=720637&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/DefaultKeyGenerator.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/DefaultKeyGenerator.java Tue Nov 25 14:51:14 2008
@@ -17,8 +17,14 @@
package org.apache.juddi.keygen;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.Property;
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
import org.apache.juddi.uuidgen.UUIDGenFactory;
import org.apache.juddi.uuidgen.UUIDGen;
+import org.uddi.v3_service.DispositionReportFaultMessage;
/**
* The default jUDDI key generator. Generates a key like this:
@@ -29,8 +35,14 @@
*/
public class DefaultKeyGenerator implements KeyGenerator {
- public String generate() {
+ public String generate() throws DispositionReportFaultMessage {
+ String rootDomain = "";
+ try
+ { rootDomain = AppConfig.getConfiguration().getString(Property.JUDDI_ROOT_DOMAIN); }
+ catch(ConfigurationException ce)
+ { throw new FatalErrorException(new ErrorMessage("errors.configuration.Retrieval", Property.JUDDI_ROOT_DOMAIN));}
+
UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
- return UDDI_SCHEME + PARTITION_SEPARATOR + ROOT_DOMAIN + PARTITION_SEPARATOR + uuidgen.uuidgen();
+ return UDDI_SCHEME + PARTITION_SEPARATOR + rootDomain + PARTITION_SEPARATOR + uuidgen.uuidgen();
}
}
\ No newline at end of file
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/KeyGenerator.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/KeyGenerator.java?rev=720637&r1=720636&r2=720637&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/KeyGenerator.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/keygen/KeyGenerator.java Tue Nov 25 14:51:14 2008
@@ -17,21 +17,18 @@
package org.apache.juddi.keygen;
+import org.uddi.v3_service.DispositionReportFaultMessage;
/**
* @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
*/
public interface KeyGenerator {
- // TODO: This is temporary until JUDDI-155 is worked out.
- public static String ROOT_DOMAIN = "juddi.apache.org";
-
-
- public static String UDDI_SCHEME = "uddi";
- public static String PARTITION_SEPARATOR = ":";
- public static String KEYGENERATOR_SUFFIX = "keygenerator";
+ public static final String UDDI_SCHEME = "uddi";
+ public static final String PARTITION_SEPARATOR = ":";
+ public static final String KEYGENERATOR_SUFFIX = "keygenerator";
/*
* Generates a key that is used to save a UDDI entity.
*/
- public String generate();
+ public String generate() throws DispositionReportFaultMessage;
}
\ No newline at end of file
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateUDDIKey.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateUDDIKey.java?rev=720637&r1=720636&r2=720637&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateUDDIKey.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateUDDIKey.java Tue Nov 25 14:51:14 2008
@@ -23,8 +23,12 @@
import javax.xml.bind.JAXBElement;
import org.uddi.v3_service.DispositionReportFaultMessage;
+import org.apache.commons.configuration.ConfigurationException;
import org.apache.juddi.keygen.KeyGenerator;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.Property;
import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
import org.apache.juddi.error.InvalidKeyPassedException;
import org.apache.juddi.error.ValueNotAllowedException;
@@ -57,8 +61,13 @@
if(!ValidateUDDIKey.isValidDomainKey(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
- // TODO: This is temporary until JUDDI-155 is worked out.
- if (!org.apache.juddi.keygen.KeyGenerator.ROOT_DOMAIN.equalsIgnoreCase(nextToken))
+ String rootDomain = "";
+ try
+ { rootDomain = AppConfig.getConfiguration().getString(Property.JUDDI_ROOT_DOMAIN); }
+ catch(ConfigurationException ce)
+ { throw new FatalErrorException(new ErrorMessage("errors.configuration.Retrieval", Property.JUDDI_ROOT_DOMAIN));}
+
+ if (!rootDomain.equalsIgnoreCase(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
}
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties?rev=720637&r1=720636&r2=720637&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/messages_en.properties Tue Nov 25 14:51:14 2008
@@ -55,6 +55,7 @@
#-- General error messages
errors.Unspecified=An unspecified error occurred
+errors.configuration.Retrieval=An error occurred attempting to retrieve configuration information
errors.NullInput=No input was provided for this API call
errors.keyunavailable.BadPartition=The proposed key is not within the partition defined by owning publisher
errors.keyunavailable.KeyExists=The key used for the save operation already exists. Another key must be chosen
Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java?rev=720637&r1=720636&r2=720637&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java (original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java Tue Nov 25 14:51:14 2008
@@ -19,6 +19,9 @@
import org.apache.juddi.api.impl.UDDISecurityImpl;
import org.apache.juddi.query.PersistenceManager;
import org.apache.juddi.mapping.MappingApiToModel;
+import org.apache.juddi.model.KeyGeneratorKey;
+import org.apache.juddi.model.KeyGeneratorKeyId;
+import org.apache.juddi.model.UddiEntityPublisher;
import org.uddi.api_v3.*;
import org.uddi.v3_service.DispositionReportFaultMessage;
@@ -75,6 +78,13 @@
em.persist(modelTModel);
+ UddiEntityPublisher rootPublisher = em.find(UddiEntityPublisher.class, ROOT_PUBLISHER);
+ KeyGeneratorKey keyGenKey = new KeyGeneratorKey();
+ keyGenKey.setId(new KeyGeneratorKeyId(rootPublisher.getPublisherId(), 0));
+ keyGenKey.setPublisher(rootPublisher);
+ keyGenKey.setKeygenTModelKey(modelTModel.getTmodelKey());
+ rootPublisher.getKeyGeneratorKeys().add(keyGenKey);
+
tx.commit();
em.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org