@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 Template getTemplate(TemplateRef ref) {
   return dao.getTemplate(ref);
 }