Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
How to tell Development vs. Testing vs. Production
Bowker
I'm building a component that needs to get data from a remote service. I'll be using xsl:variable name="remoteData" select="document(...)" type of access to obtain the data.
The URL I need to pass into document() varies depending upon which environment presenting the page. We have multiple "testing" environments (development, system, user-acceptance and production).
Is there a way to define parameters or something within LiveSite that can be picked up by components (either directly or through an External)?
Find more posts tagged with
Comments
Rick Poulin
Best I can suggest is using (in an external) java.net.InetAddress.getLocalHost().getHostName() and then having a configuration of some type map those host names to the environment-specific values.
Bowker
Once again - good idea.
[PHP]
package com.xxxx.livesite.external;
import org.apache.commons.logging.Log;//Uncomment to enable logging
import org.apache.commons.logging.LogFactory;//Uncomment to enable logging
import org.dom4j.Document;
import org.dom4j.Element;
import com.interwoven.livesite.dom4j.Dom4jUtils;
import java.util.*;
import com.interwoven.livesite.runtime.RequestContext;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
public class Environment {
public Document getEnvironment(com.interwoven.livesite.runtime.RequestContext context) {
org.dom4j.Document doc = Dom4jUtils.newDocument();
Element server = doc.addElement("server");
server.addElement("mode").setText(context.getMode().toString());
try {
server.addElement("host").setText(java.net.InetAddress.getLocalHost().getHostName());
} catch (java.net.UnknownHostException e) {
server.addElement("host").setText("Error obtaining host name - " + e.getMessage());
}
return doc;
}
}
[/PHP]
and in the Content XML portion of the template
[PHP]
[/PHP]
results in:
[PHP]
PREVIEW
MYSERVERNAME
[/PHP]
tec_iwov
take a look at RequestContext interface.
There's two functions isPreview and isRuntime.
you still might have to check host name or something since i would expect testing in a runtime system as well.
and of cource would have to do this within the external
Bowker
You may use the isXxxxx() or if you would like a string representation you can use the getMode() method.
context.getMode().toString()
Will return a String representation of:
RUNTIME
EDIT
PREVIEW
GENERATE_HTML
EMBEDDED