protected void addPermissions(/*not final*/ CnATreeElement element) {
   HashSet<Permission> newperms = new HashSet<Permission>();
   newperms.add(Permission.createPermission(element, authService.getUsername(), true, true));
   element.setPermissions(newperms);
   for (CnATreeElement child : element.getChildren()) {
     addPermissions(child);
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see sernet.gs.ui.rcp.main.service.commands.ICommand#execute()
   */
  @Override
  public void execute() {
    FinishedRiskAnalysis riskAnalysis =
        getDaoFactory().getDAO(FinishedRiskAnalysis.class).findById(riskAnalysisDbId);
    finishedRiskLists = getDaoFactory().getDAO(FinishedRiskAnalysisLists.class).findById(listDbId);

    gefaehrdungsUmsetzung = GefaehrdungsUmsetzungFactory.build(null, currentGefaehrdung, language);
    getDaoFactory().getDAO(GefaehrdungsUmsetzung.class).saveOrUpdate(gefaehrdungsUmsetzung);

    if (authService.isPermissionHandlingNeeded()) {
      gefaehrdungsUmsetzung.setPermissions(
          Permission.clonePermissionSet(gefaehrdungsUmsetzung, riskAnalysis.getPermissions()));
    }

    finishedRiskLists.getAssociatedGefaehrdungen().add(gefaehrdungsUmsetzung);
  }
 private void addPermissions(IBaseDao<CnATreeElement, Serializable> containerDAO) {
   // By default, inherit permissions from parent element but ITVerbund
   // instances cannot do this, as its parents (BSIModel) is not visible
   // and has no permissions. Therefore we use the name of the currently
   // logged in user as a role which has read and write permissions for
   // the new ITVerbund.
   if (child instanceof ITVerbund
       || child instanceof Organization
       || (child instanceof Audit && !isInheritAuditPermissions())) {
     addPermissions(child);
   } else {
     RetrieveInfo ri = new RetrieveInfo();
     ri.setPermissions(true);
     CnATreeElement elementPerm = containerDAO.retrieve(container.getDbId(), ri);
     child.setPermissions(Permission.clonePermissionSet(child, elementPerm.getPermissions()));
   }
 }