@Override
  public TemplateRef copyTemplate(TemplateRef ref) {
    // get complete template and change name
    Template template = dao.getTemplate(ref);
    template.setName(compileCopyOfName(ref.getName()));

    // export existing template to buffer
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    dao.exportTemplate(template, buffer);

    // import from buffer
    return dao.importTemplate(new ByteArrayInputStream(buffer.toByteArray()));
  }
  @Override
  public TemplateContainer copyContainer(TemplateContainer container) {
    // get complete container and change name (also for templates)
    TemplateContainerComplete origin = dao.getCompleteContainer(container);
    origin.setName(compileCopyOfName(origin.getName()));

    for (Template template : origin.getTemplates()) {
      template.setName(compileCopyOfName(template.getName()));
    }

    // export existing template to buffer
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    dao.exportContainer(origin, buffer);

    // import from buffer
    return dao.importContainer(new ByteArrayInputStream(buffer.toByteArray()));
  }