Author: chris.laprun(a)jboss.com
Date: 2008-11-07 18:01:47 -0500 (Fri, 07 Nov 2008)
New Revision: 12276
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
Log:
- JBPORTAL-2229: Check that portal dir exists in JBoss data dir, if not create it.
- JBPORTAL-2231: Updated schema version.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2008-11-07
22:41:08 UTC (rev 12275)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationServiceImpl.java 2008-11-07
23:01:47 UTC (rev 12276)
@@ -73,13 +73,16 @@
private static DefaultSchemaResolver RESOLVER;
+ private static final String PRODUCER_NAMESPACE =
"urn:jboss:portal:wsrp:producer:v2_7";
+ private static final String PRODUCER_XSD = "jboss-wsrp-producer_2_7.xsd";
+
static
{
RESOLVER = new DefaultSchemaResolver();
RESOLVER.setCacheResolvedSchemas(true);
RESOLVER.addSchemaLocation("http://www.w3.org/XML/1998/namespace",
"xsd/xml.xsd");
RESOLVER.addSchemaLocation("urn:jboss:portal:wsrp:producer:v2_6",
"xsd/jboss-wsrp-producer_2_6.xsd");
- RESOLVER.addSchemaLocation("urn:jboss:portal:wsrp:producer:v2_7",
"xsd/jboss-wsrp-producer_2_7.xsd");
+ RESOLVER.addSchemaLocation(PRODUCER_NAMESPACE, "xsd/" + PRODUCER_XSD);
}
public String getConfigLocation()
@@ -111,8 +114,27 @@
{
throw new RuntimeException("Couldn't locate server data dir!",
e);
}
- config = new File(dataDir, "portal/wsrp-producer-config.xml");
+ // if "portal" directory doesn't exist already in data, create it
(JBPORTAL-2229)
+ File portalDir = new File(dataDir, "portal");
+ if (!portalDir.exists())
+ {
+ if (!portalDir.mkdir())
+ {
+ throw new RuntimeException("Couldn't create 'portal'
directory in " + dataDir.getAbsolutePath());
+ }
+ }
+ else
+ {
+ if (!portalDir.isDirectory())
+ {
+ throw new RuntimeException("Was expecting a directory named
'portal' in " + dataDir.getAbsolutePath()
+ + ", not a simple file! Cannot continue.");
+ }
+ }
+
+ config = new File(portalDir, "wsrp-producer-config.xml");
+
reloadConfiguration();
}
@@ -129,7 +151,7 @@
if (config.exists())
{
log.debug("Configuration saved at " + config.getCanonicalPath()
- + " is not loading properly. Falling back to default
configuration.");
+ + " is not loading properly. Falling back to default
configuration.");
config.delete(); // delete improper config so that we retrieve the default
configuration
loadConfigurationAt(getConfigLocationURL());
}
@@ -229,7 +251,7 @@
StringWriter xmlOutput = new StringWriter();
// get the XML Schema source
- InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream("xsd/jboss-wsrp-producer_2_6.xsd");
+ InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream("xsd/" +
PRODUCER_XSD);
Reader xsReader = new InputStreamReader(is);
@@ -239,15 +261,15 @@
marshaller.setSchemaResolver(RESOLVER);
// we need to specify what elements are top most (roots) providing namespace URI,
prefix and local name
- marshaller.addRootElement("urn:jboss:portal:wsrp:producer:v2_6",
"", "producer-configuration");
+ marshaller.addRootElement(PRODUCER_NAMESPACE, "",
"producer-configuration");
// declare default namespace
- marshaller.declareNamespace("wpc",
"urn:jboss:portal:wsrp:producer:v2_6");
+ marshaller.declareNamespace("wpc", PRODUCER_NAMESPACE);
// add schema location by declaring xsi namespace and adding xsi:schemaLocation
attribute
marshaller.declareNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
marshaller.addAttribute("xsi", "schemaLocation",
"string",
- "urn:jboss:portal:wsrp:producer:v2_6
http://www.jboss.org/portal/xsd/jboss-wsrp-producer_2_6.xsd");
+ PRODUCER_NAMESPACE + "
http://www.jboss.org/portal/xsd/" +
PRODUCER_XSD);
// create an instance of Object Model Provider
ObjectModelProvider provider = new ProducerConfigurationProvider();