public void addDeploymentOverlays(final List<ModelNode> updates) {
    if (domainModel.hasDefined(DEPLOYMENT_OVERLAY)) {

      HostFileRepository remoteRepository = null;
      if (!domainController.getLocalHostInfo().isMasterDomainController()) {
        remoteRepository = domainController.getRemoteFileRepository();
      }

      for (Property deploymentOverlay : domainModel.get(DEPLOYMENT_OVERLAY).asPropertyList()) {
        String name = deploymentOverlay.getName();
        ModelNode details = deploymentOverlay.getValue();

        PathAddress addr =
            PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY, name));
        ModelNode addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
        updates.add(addOp);

        if (details.hasDefined(CONTENT)) {

          for (Property content : details.get(CONTENT).asPropertyList()) {
            final String contentName = content.getName();
            final ModelNode contentDetails = content.getValue();
            byte[] hash = contentDetails.require(CONTENT).asBytes();
            File[] files = domainController.getLocalFileRepository().getDeploymentFiles(hash);
            if (files == null || files.length == 0) {
              if (remoteRepository != null) {
                remoteRepository.getDeploymentFiles(hash);
              }
            }
            addr =
                PathAddress.pathAddress(
                    PathElement.pathElement(DEPLOYMENT_OVERLAY, name),
                    PathElement.pathElement(CONTENT, contentName));
            addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
            addOp.get(CONTENT).get(HASH).set(contentDetails.get(CONTENT));
            updates.add(addOp);
          }
        }
        if (serverGroup.hasDefined(DEPLOYMENT_OVERLAY)) {
          final ModelNode groupOverlay = serverGroup.get(DEPLOYMENT_OVERLAY).asObject();
          if (groupOverlay.has(name)) {
            ModelNode deploymentsNode = groupOverlay.get(name);
            if (deploymentsNode.has(DEPLOYMENT)) {
              for (Property content : deploymentsNode.get(DEPLOYMENT).asPropertyList()) {
                final String deploymentName = content.getName();
                final ModelNode deploymentDetails = content.getValue();
                addr =
                    PathAddress.pathAddress(
                        PathElement.pathElement(DEPLOYMENT_OVERLAY, name),
                        PathElement.pathElement(DEPLOYMENT, deploymentName));
                addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
                updates.add(addOp);
              }
            }
          }
        }
      }
    }
  }
  private void addDeployments(List<ModelNode> updates) {
    if (serverGroup.hasDefined(DEPLOYMENT)) {

      HostFileRepository remoteRepository = null;
      if (!domainController.getLocalHostInfo().isMasterDomainController()) {
        remoteRepository = domainController.getRemoteFileRepository();
      }

      for (Property deployment : serverGroup.get(DEPLOYMENT).asPropertyList()) {
        String name = deployment.getName();
        ModelNode details = deployment.getValue();

        ModelNode domainDeployment = domainModel.require(DEPLOYMENT).require(name);
        ModelNode deploymentContent = domainDeployment.require(CONTENT).clone();

        if (remoteRepository != null) {
          // Make sure we have a copy of the deployment in the local repo
          for (ModelNode content : deploymentContent.asList()) {
            if ((content.hasDefined(HASH))) {
              byte[] hash = content.require(HASH).asBytes();
              File[] files = domainController.getLocalFileRepository().getDeploymentFiles(hash);
              if (files == null || files.length == 0) {
                remoteRepository.getDeploymentFiles(hash);
              }
            }
          }
        }

        PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT, name));
        ModelNode addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
        addOp.get(RUNTIME_NAME).set(details.get(RUNTIME_NAME));
        addOp.get(CONTENT).set(deploymentContent);
        addOp.get(ENABLED).set(!details.hasDefined(ENABLED) || details.get(ENABLED).asBoolean());

        updates.add(addOp);
      }
    }
  }