private DeploymentRecord mapDeployment(final ServerInstance server, final DeploymentRecord parent,
final ModelNode node)
{
ModelNode deploymentNode = node.asProperty().getValue().asObject();
DeploymentRecord deployment = deploymentEntityAdapter.fromDMR(deploymentNode);
deployment.setName(node.asProperty().getName()); // for subdeployments
deployment.setType(parent == null ? DeploymentDataType.deployment : subdeployment);
try
{
ModelNode property = deploymentNode.get("content");
if (property.isDefined())
{
List<ModelNode> contentList = deploymentNode.get("content").asList();
if (!contentList.isEmpty())
{
// TODO: strange concept (list.size() always 1)
ModelNode content = contentList.get(0);
if (content.has("path")) { deployment.setPath(content.get("path").asString()); }
if (content.has("relative-to")) { deployment.setRelativeTo(content.get("relative-to").asString()); }
if (content.has("archive")) { deployment.setArchive(content.get("archive").asBoolean()); }
if (content.has("hash")) { deployment.setSha(content.get("hash").asString()); }
}
}
deployment.setParent(parent);
deployment.setSubdeployment(parent != null);
deployment.setHasSubdeployments(deploymentNode.get("subdeployment").isDefined());
deployment.setHasSubsystems(deploymentNode.get("subsystem").isDefined());
deployment.setServer(server);
ModelNode address;
// TODO Optimize address setup
if (server == null)
{
if (parent == null)
{
address = addressFor("deployment", deployment.getName());
}
else
{
address = addressFor("deployment", parent.getName(), "subdeployment", deployment.getName());
}
}
else
{
deployment.setServerGroup(server.getGroup());
if (parent == null)
{
address = addressFor("host", server.getHost(), "server", server.getName(), "deployment",
deployment.getName());
}
else
{
address = addressFor("host", server.getHost(), "server", server.getName(), "deployment", parent.getName(),
"subdeployment", deployment.getName());
}
}
deployment.setAddress(address);
}
catch (IllegalArgumentException e)
{
Log.error("Failed to parse data source representation", e);
}