Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.greenpepper.server.rpc.xmlrpc.GreenPepperXmlRpcClient Maven / Gradle / Ivy
package com.greenpepper.server.rpc.xmlrpc;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.TreeTraverser;
import com.greenpepper.server.GreenPepperServerErrorKey;
import com.greenpepper.server.GreenPepperServerException;
import com.greenpepper.server.ServerPropertiesManager;
import com.greenpepper.repository.DocumentNode;
import com.greenpepper.server.domain.EnvironmentType;
import com.greenpepper.server.domain.Execution;
import com.greenpepper.server.domain.Project;
import com.greenpepper.server.domain.Reference;
import com.greenpepper.server.domain.Repository;
import com.greenpepper.server.domain.Requirement;
import com.greenpepper.server.domain.RequirementSummary;
import com.greenpepper.server.domain.Runner;
import com.greenpepper.server.domain.Specification;
import com.greenpepper.server.domain.SystemUnderTest;
import com.greenpepper.server.license.LicenseBean;
import com.greenpepper.server.rpc.RpcClientService;
import com.greenpepper.server.rpc.xmlrpc.client.XmlRpcClientExecutor;
import com.greenpepper.server.rpc.xmlrpc.client.XmlRpcClientExecutorFactory;
/**
* GreenPepperXmlRpcClient class.
*
* @author oaouattara
* @version $Id: $Id
*/
public class GreenPepperXmlRpcClient implements RpcClientService
{
private static Logger log = LoggerFactory.getLogger(GreenPepperXmlRpcClient.class);
/** Constant XML_RPC="rpc/xmlrpc"
*/
public static final String XML_RPC = "rpc/xmlrpc";
/** Constant HANDLER_SEPARTOR="."
*/
public static final String HANDLER_SEPARTOR = ".";
/** Constant PATH_SEPARTOR="/"
*/
public static final String PATH_SEPARTOR = "/";
/** Constant PORT_SEPARTOR=":"
*/
public static final String PORT_SEPARTOR = ":";
private ServerPropertiesManager propertiesManager;
/**
* Constructor for GreenPepperXmlRpcClient.
*
* @param propertiesManager a {@link com.greenpepper.server.ServerPropertiesManager} object.
*/
public GreenPepperXmlRpcClient(ServerPropertiesManager propertiesManager)
{
this.propertiesManager = propertiesManager;
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public LicenseBean license(String identifier) throws GreenPepperServerException
{
log.debug("Retrieving license info");
Vector licenseParams = (Vector)execute(XmlRpcMethodName.license, identifier);
return XmlRpcDataMarshaller.toLicense(licenseParams);
}
/** {@inheritDoc} */
public void uploadLicense(String newLicence, String identifier) throws GreenPepperServerException
{
log.debug("Uploading new license" + newLicence);
Vector vector = new Vector();
Collections.addAll(vector,newLicence);
execute(XmlRpcMethodName.uploadNewLicense, vector, identifier);
}
/** {@inheritDoc} */
public boolean testConnection(String hostName, String handler) throws GreenPepperServerException
{
try
{
log.debug("PINGING : HostName => " + hostName + " & Handler => " + handler);
XmlRpcClientExecutor xmlrpc = XmlRpcClientExecutorFactory.newExecutor(getXmlRpcUrl(hostName, XML_RPC));
String cmdLine = new StringBuffer(handler).append(HANDLER_SEPARTOR).append(XmlRpcMethodName.testConnection).toString();
XmlRpcDataMarshaller.checkForErrors(xmlrpc.execute(cmdLine, new Vector()));
return true;
}
// catch (FileNotFoundException e)
// {
// log.error(e.getMessage());
// throw new GreenPepperServerException(GreenPepperServerErrorKey.XML_RPC_URL_NOTFOUND, e.getMessage());
// }
catch (Exception e)
{
log.error(e.getMessage());
throw new GreenPepperServerException(GreenPepperServerErrorKey.XML_RPC_HANDLER_NOTFOUND, e.getMessage());
}
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public boolean ping(Repository repository, String identifier) throws GreenPepperServerException
{
String hostName = propertiesManager.getProperty(ServerPropertiesManager.URL, identifier);
log.debug("PINGING : HostName => " + hostName + " & Handler => " + getLocalHandler(identifier));
execute(XmlRpcMethodName.ping, CollectionUtil.toVector(repository.marshallize()), identifier);
return true;
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getAllEnvironmentTypes(String identifier) throws GreenPepperServerException
{
log.debug("Retreiving all Environment Types");
Vector envTypesParams = (Vector)execute(XmlRpcMethodName.getAllEnvironmentTypes, new Vector(), identifier);
return XmlRpcDataMarshaller.toEnvironmentTypeList(envTypesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Runner getRunner(String name, String identifier) throws GreenPepperServerException
{
log.debug("Retreiving all runners");
Vector runnerParams = (Vector)execute(XmlRpcMethodName.getRunner, CollectionUtil.toVector(name), identifier);
return XmlRpcDataMarshaller.toRunner(runnerParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getAllRunners(String identifier) throws GreenPepperServerException
{
log.debug("Retreiving all runners");
Vector runnersParams = (Vector)execute(XmlRpcMethodName.getAllRunners, new Vector(), identifier);
return XmlRpcDataMarshaller.toRunnerList(runnersParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void createRunner(Runner runner, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(runner.marshallize());
log.debug("Creating runner: " + runner.getName());
execute(XmlRpcMethodName.createRunner, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void updateRunner(String oldRunnerName, Runner runner, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(oldRunnerName, runner.marshallize());
log.debug("Updating runner: " + oldRunnerName);
execute(XmlRpcMethodName.updateRunner, params, identifier);
}
/** {@inheritDoc} */
public void removeRunner(String name, String identifier) throws GreenPepperServerException
{
log.debug("Removing runner: " + name);
execute(XmlRpcMethodName.removeRunner, CollectionUtil.toVector(name), identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Repository getRegisteredRepository(Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize());
log.debug("Retrieving Registered Repository: " + repository.getUid());
Vector repositoryParams = (Vector)execute(XmlRpcMethodName.getRegisteredRepository, params, identifier);
return XmlRpcDataMarshaller.toRepository(repositoryParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Repository registerRepository(Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize());
log.debug("Registering Repository: " + repository.getUid());
Vector repositoryParams = (Vector)execute(XmlRpcMethodName.registerRepository, params, identifier);
return XmlRpcDataMarshaller.toRepository(repositoryParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void updateRepositoryRegistration(Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize());
log.debug("Updating Repository registration: " + repository.getUid());
execute(XmlRpcMethodName.updateRepositoryRegistration, params, identifier);
}
/** {@inheritDoc} */
public void removeRepository(String repositoryUid, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repositoryUid);
log.debug("Removing Repository " + repositoryUid);
execute(XmlRpcMethodName.removeRepository, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getAllProjects(String identifier) throws GreenPepperServerException
{
log.debug("Retrieving All Projects");
Vector projectsParams = (Vector)execute(XmlRpcMethodName.getAllProjects, identifier);
return XmlRpcDataMarshaller.toProjectList(projectsParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getAllSpecificationRepositories(String identifier) throws GreenPepperServerException
{
log.debug("Retrieving all specification repositories.");
Vector repositoriesParams = (Vector)execute(XmlRpcMethodName.getAllSpecificationRepositories, identifier);
return XmlRpcDataMarshaller.toRepositoryList(repositoriesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getAllRepositoriesForSystemUnderTest(SystemUnderTest systemUnderTest, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize());
log.debug("Retrieving repositories for Associated project. (SystemUnderTest : " + systemUnderTest.getName() + ")");
Vector repositoriesParams = (Vector)execute(XmlRpcMethodName.getAllRepositoriesForSystemUnderTest, params, identifier);
return XmlRpcDataMarshaller.toRepositoryList(repositoriesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getSpecificationRepositoriesOfAssociatedProject(Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize());
log.debug("Retrieving Specification repositories for Associated project. (Repo UID: " + repository.getUid() + ")");
Vector repositoriesParams = (Vector)execute(XmlRpcMethodName.getSpecificationRepositoriesOfAssociatedProject, params, identifier);
return XmlRpcDataMarshaller.toRepositoryList(repositoriesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getSpecificationRepositoriesOfAssociatedProject(SystemUnderTest systemUnderTest, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize());
log.debug("Retrieving Specification repositories for Associated project. (SystemUnderTest : " + systemUnderTest.getName() + ")");
Vector repositoriesParams = (Vector)execute(XmlRpcMethodName.getSpecificationRepositoriesForSystemUnderTest, params, identifier);
return XmlRpcDataMarshaller.toRepositoryList(repositoriesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getRequirementRepositoriesOfAssociatedProject(Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize());
log.debug("Retrieving Requirement repositories for Associated project. (Repo UID: " + repository.getUid() + ")");
Vector repositoriesParams = (Vector)execute(XmlRpcMethodName.getRequirementRepositoriesOfAssociatedProject, params, identifier);
return XmlRpcDataMarshaller.toRepositoryList(repositoriesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getSystemUnderTestsOfAssociatedProject(Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize());
log.debug("Retrieving SUT list for Associated repository: " + repository.getName());
Vector sutsParams = (Vector)execute(XmlRpcMethodName.getSystemUnderTestsOfAssociatedProject, params, identifier);
return XmlRpcDataMarshaller.toSystemUnderTestList(sutsParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getSystemUnderTestsOfProject(String projectName, String identifier) throws GreenPepperServerException
{
log.debug("Retrieving SUT list for Project: " + projectName);
Vector sutsParams = (Vector)execute(XmlRpcMethodName.getSystemUnderTestsOfProject, CollectionUtil.toVector(projectName), identifier);
return XmlRpcDataMarshaller.toSystemUnderTestList(sutsParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void addSystemUnderTest(SystemUnderTest systemUnderTest, Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), specification.marshallize());
log.debug("Adding SUT " + systemUnderTest.getName() + " to SUT list of specification: " + specification.getName());
execute(XmlRpcMethodName.addSpecificationSystemUnderTest, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void removeSystemUnderTest(SystemUnderTest systemUnderTest, Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), specification.marshallize());
log.debug("Adding SUT " + systemUnderTest.getName() + " to SUT list of specification: " + specification.getName());
execute(XmlRpcMethodName.removeSpecificationSystemUnderTest, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public boolean hasReferences(Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(specification.marshallize());
log.debug("Does specification " + specification.getName() + " Has References");
String hasReferences = (String)execute(XmlRpcMethodName.doesSpecificationHasReferences, params, identifier);
return Boolean.valueOf(hasReferences);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getReferences(Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(specification.marshallize());
log.debug("Retrieving Specification " + specification.getName() + " References");
Vector referencesParams = (Vector)execute(XmlRpcMethodName.getSpecificationReferences, params, identifier);
return XmlRpcDataMarshaller.toReferencesList(referencesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public boolean hasReferences(Requirement requirement, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(requirement.marshallize());
log.debug("Does Requirement " + requirement.getName() + " Has References");
String hasReferences = (String)execute(XmlRpcMethodName.doesRequirementHasReferences, params, identifier);
return Boolean.valueOf(hasReferences);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Set getReferences(Requirement requirement, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(requirement.marshallize());
log.debug("Retrieving Requirement " + requirement.getName() + " References");
Vector referencesParams = (Vector)execute(XmlRpcMethodName.getRequirementReferences, params, identifier);
return XmlRpcDataMarshaller.toReferencesList(referencesParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Reference getReference(Reference reference, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(reference.marshallize());
log.debug("Retrieving Reference: " + reference.getRequirement().getName() + "," + reference.getSpecification().getName());
Vector referenceParams = (Vector)execute(XmlRpcMethodName.getReference, params, identifier);
return XmlRpcDataMarshaller.toReference(referenceParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public SystemUnderTest getSystemUnderTest(SystemUnderTest systemUnderTest, Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), repository.marshallize());
log.debug("Retrieving SystemUnderTest: " + systemUnderTest.getName());
Vector sutParams = (Vector)execute(XmlRpcMethodName.getSystemUnderTest, params, identifier);
return XmlRpcDataMarshaller.toSystemUnderTest(sutParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void createSystemUnderTest(SystemUnderTest systemUnderTest, Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), repository.marshallize());
log.debug("Creating SystemUnderTest: " + systemUnderTest.getName());
execute(XmlRpcMethodName.createSystemUnderTest, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void updateSystemUnderTest(String oldSystemUnderTestName, SystemUnderTest newSystemUnderTest, Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(oldSystemUnderTestName, newSystemUnderTest.marshallize(), repository.marshallize());
log.debug("Updating SystemUnderTest: " + oldSystemUnderTestName);
execute(XmlRpcMethodName.updateSystemUnderTest, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void removeSystemUnderTest(SystemUnderTest systemUnderTest, Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), repository.marshallize());
log.debug("Removing SystemUnderTest: " + systemUnderTest.getName());
execute(XmlRpcMethodName.removeSystemUnderTest, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void setSystemUnderTestAsDefault(SystemUnderTest systemUnderTest, Repository repository, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), repository.marshallize());
log.debug("Setting as default the SystemUnderTest: " + systemUnderTest.getName());
execute(XmlRpcMethodName.setSystemUnderTestAsDefault, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void removeRequirement(Requirement requirement, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(requirement.marshallize());
log.debug("Removing Requirement: " + requirement.getName());
execute(XmlRpcMethodName.removeRequirement, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Specification getSpecification(Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(specification.marshallize());
log.debug("Retrieving Specification: " + specification.getName());
Vector specificationParams = (Vector)execute(XmlRpcMethodName.getSpecification, params, identifier);
return XmlRpcDataMarshaller.toSpecification(specificationParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Specification createSpecification(Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(specification.marshallize());
log.debug("Creating Specification: " + specification.getName());
Vector specificationParams = (Vector)execute(XmlRpcMethodName.createSpecification, params, identifier);
return XmlRpcDataMarshaller.toSpecification(specificationParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void updateSpecification(Specification oldSpecification, Specification newSpecification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(oldSpecification.marshallize(), newSpecification.marshallize());
log.debug("Updating Specification: " + oldSpecification.getName());
execute(XmlRpcMethodName.updateSpecification, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void removeSpecification(Specification specification, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(specification.marshallize());
log.debug("Removing Specification: " + specification.getName());
execute(XmlRpcMethodName.removeSpecification, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void createReference(Reference reference, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(reference.marshallize());
log.debug("Creating Test Case: " + reference.getRequirement().getName() + "," + reference.getSpecification().getName());
execute(XmlRpcMethodName.createReference, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Reference updateReference(Reference oldReference, Reference newReference, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(oldReference.marshallize(), newReference.marshallize());
log.debug("Updating Reference: " + newReference.getRequirement().getName() + "," + newReference.getSpecification().getName());
Vector referenceParams = (Vector)execute(XmlRpcMethodName.updateReference, params, identifier);
return XmlRpcDataMarshaller.toReference(referenceParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public void removeReference(Reference reference, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(reference.marshallize());
log.debug("Removing Reference: " + reference.getRequirement().getName() + "," + reference.getSpecification().getName());
execute(XmlRpcMethodName.removeReference, params, identifier);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Execution runSpecification(SystemUnderTest systemUnderTest, Specification specification, boolean implementedVersion, String locale, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(systemUnderTest.marshallize(), specification.marshallize(), implementedVersion, locale);
log.debug("Running Specification: " + specification.getName() + " ON System:" + systemUnderTest.getName());
Vector executionParams = (Vector)execute(XmlRpcMethodName.runSpecification, params, identifier);
return XmlRpcDataMarshaller.toExecution(executionParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public Reference runReference(Reference reference, String locale, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(reference.marshallize(), locale);
log.debug("Running Reference: " + reference.getRequirement().getName() + "," + reference.getSpecification().getName());
Vector referenceParams = (Vector)execute(XmlRpcMethodName.runReference, params, identifier);
return XmlRpcDataMarshaller.toReference(referenceParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public RequirementSummary getSummary(Requirement requirement, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(requirement.marshallize());
Vector compilParams = (Vector)execute(XmlRpcMethodName.getRequirementSummary, params, identifier);
log.debug("Getting Requirement " + requirement.getName() + " summary");
return XmlRpcDataMarshaller.toRequirementSummary(compilParams);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
public DocumentNode getSpecificationHierarchy(Repository repository, SystemUnderTest systemUnderTest, String identifier) throws GreenPepperServerException
{
Vector params = CollectionUtil.toVector(repository.marshallize(), systemUnderTest.marshallize());
log.debug("Get Specification Hierarchy: " + repository.getName() + " & " + systemUnderTest.getName());
Vector vector = (Vector)execute(XmlRpcMethodName.getSpecificationHierarchy, params, identifier);
DocumentNode documentNode = DocumentNode.toDocumentNode(vector);
if (log.isDebugEnabled()) {
TreeTraverser traverser = new TreeTraverser() {
@Override
public Iterable children(DepthAwareDocumentNode root) {
List depthAwareDocumentNodes = new ArrayList();
Iterable children = root.getChildren();
for (DocumentNode child : children) {
DepthAwareDocumentNode node = new DepthAwareDocumentNode(child, root.depth+1);
depthAwareDocumentNodes.add(node);
}
return depthAwareDocumentNodes;
}
};
for (DepthAwareDocumentNode node : traverser.preOrderTraversal(new DepthAwareDocumentNode(documentNode, 0))) {
String state = node.documentNode.canBeImplemented() ? "workingcopy" : "implemented";
log.debug("[{}] [{}] {} {}", new String[]{node.documentNode.isExecutable() ? "X" : " ", state, String.format("%"+(node.depth+1)+"s", "") , node.documentNode.getTitle()});
}
}
return documentNode;
}
private class DepthAwareDocumentNode {
DocumentNode documentNode;
int depth;
DepthAwareDocumentNode(DocumentNode documentNode, int depth) {
this.documentNode = documentNode;
this.depth = depth;
}
Iterable getChildren() {
return documentNode.getChildren();
}
}
/**
* getServerPropertiesManager.
*
* @return a {@link com.greenpepper.server.ServerPropertiesManager} object.
*/
public ServerPropertiesManager getServerPropertiesManager()
{
return propertiesManager;
}
/*************************** PRIVATE SECTION ******************************/
private Object execute(XmlRpcMethodName methodName, String identifier) throws GreenPepperServerException
{
return execute(methodName, new Vector(), identifier);
}
private Object execute(XmlRpcMethodName methodName, Vector params, String identifier) throws GreenPepperServerException
{
String handler = getLocalHandler(identifier);
XmlRpcClientExecutor xmlrpc = XmlRpcClientExecutorFactory.newExecutor(getLocalXmlRpcUrl(identifier));
String cmdLine = new StringBuffer(handler).append(HANDLER_SEPARTOR).append(methodName).toString();
Object response = xmlrpc.execute(cmdLine, params);
XmlRpcDataMarshaller.checkForErrors(response);
return response;
}
private String getLocalXmlRpcUrl(String identifier) throws GreenPepperServerException
{
String hostName = propertiesManager.getProperty(ServerPropertiesManager.URL, identifier);
return getXmlRpcUrl(hostName, XML_RPC);
}
private String getXmlRpcUrl(String hostName, String rpcContext) throws GreenPepperServerException
{
if (StringUtils.isEmpty(hostName) || StringUtils.isEmpty(rpcContext))
{
throw new GreenPepperServerException(GreenPepperServerErrorKey.NO_CONFIGURATION, "No config");
}
StringBuffer buffer = new StringBuffer(hostName);
if (!hostName.endsWith(PATH_SEPARTOR) && !rpcContext.startsWith(PATH_SEPARTOR))
{
buffer.append(PATH_SEPARTOR);
}
buffer.append(rpcContext);
return buffer.toString();
}
private String getLocalHandler(String identifier) throws GreenPepperServerException
{
String handlerName = propertiesManager.getProperty(ServerPropertiesManager.HANDLER, identifier);
if (StringUtils.isEmpty(handlerName))
{
throw new GreenPepperServerException(GreenPepperServerErrorKey.NO_CONFIGURATION, "No config");
}
return handlerName;
}
}