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);
   }
 }
 private void getStrukturElements(CnATreeElement parent) {
   for (CnATreeElement child : parent.getChildren()) {
     if (!(child instanceof IDatenschutzElement)) {
       items.add(child);
       if (!categories.contains(child.getParent())) {
         categories.add(child.getParent());
       }
     }
     getStrukturElements(child);
   }
 }
Exemple #3
0
  private void exportChildren(final ExportTransaction transaction) throws CommandException {
    final int timeOutFactor = 40;
    final CnATreeElement element = transaction.getElement();
    final Set<CnATreeElement> children = element.getChildren();
    if (FinishedRiskAnalysis.TYPE_ID.equals(element.getTypeId())) {
      children.addAll(getRiskAnalysisOrphanElements(element));
    }

    final List<ExportTransaction> transactionList = new ArrayList<ExportTransaction>();

    taskExecutor = Executors.newFixedThreadPool(getMaxNumberOfThreads());
    if (!children.isEmpty()) {
      for (final CnATreeElement child : children) {
        final ExportTransaction childTransaction = new ExportTransaction(child);
        transactionList.add(childTransaction);
        final ExportThread thread = new ExportThread(childTransaction);
        configureThread(thread);

        // Multi thread:
        thread.addListener(
            new IThreadCompleteListener() {
              @Override
              public void notifyOfThreadComplete(final Thread thread) {
                final ExportThread exportThread = (ExportThread) thread;
                synchronized (LOCK) {
                  if (exportThread.getSyncObject() != null) {
                    transaction.getTarget().getChildren().add(exportThread.getSyncObject());
                  }
                  getValuesFromThread(exportThread);
                }
              }
            });
        taskExecutor.execute(thread);
      }
    }

    awaitTermination(transactionList.size() * timeOutFactor);

    if (getLog().isDebugEnabled() && transactionList.size() > 0) {
      getLog().debug(transactionList.size() + " export threads finished.");
    }

    for (final ExportTransaction childTransaction : transactionList) {
      if (checkElement(childTransaction.getElement())) {
        exportChildren(childTransaction);
      }
    }
  }