/** Write the Share module XML in the given conversion to the given stream. */
  public void writeShareConfig(
      OutputStream out, WorkflowDefinitionConversion conversion, boolean asModule)
      throws IOException {
    Module module = AlfrescoConversionUtil.getModule(conversion);
    try {
      Object toMarshall = module;

      // In case the configuration should NOT be exported as a module, wrap the configurations
      // in a "alfresco-configuration" element instead
      if (!asModule) {
        toMarshall = new AlfrescoConfiguration();
        ((AlfrescoConfiguration) toMarshall).setConfigurations(module.getConfigurations());
      }
      Marshaller marshaller = moduleJaxbContext.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(toMarshall, out);
    } catch (JAXBException jaxbe) {
      throw new IOException(jaxbe);
    }
  }