Ejemplo n.º 1
0
 private CnATreeElement getFromCache(CnATreeElement element) {
   final Element cachedElement = getCache().get(element.getUuid());
   if (cachedElement != null) {
     element = (CnATreeElement) cachedElement.getValue();
     if (getLog().isDebugEnabled()) {
       getLog()
           .debug("Element from cache: " + element.getTitle() + ", UUID: " + element.getUuid());
     }
   } else {
     element = getDao().retrieve(element.getDbId(), RetrieveInfo.getPropertyInstance());
     if (element != null) {
       getCache().put(new Element(element.getUuid(), element));
     }
   }
   return element;
 }
Ejemplo n.º 2
0
 private List<UnifyMapping> createMapping(
     Map<String, CnATreeElement> sourceMap, Map<String, CnATreeElement> destinationMap) {
   List<UnifyMapping> mappings = new ArrayList<UnifyMapping>(sourceMap.size());
   for (String title : sourceMap.keySet()) {
     CnATreeElement source = sourceMap.get(title);
     UnifyMapping mapping =
         new UnifyMapping(new UnifyElement(source.getUuid(), source.getTitle()));
     CnATreeElement destination = destinationMap.get(title);
     if (destination != null) {
       mapping.setDestinationElement(
           new UnifyElement(destination.getUuid(), destination.getTitle()));
     }
     mappings.add(mapping);
   }
   return mappings;
 }
Ejemplo n.º 3
0
  public void execute() {
    IBaseDao<T, Serializable> dao;
    if (clazz == null) {
      clazz = CnATypeMapper.getClassFromTypeId(typeId);
    }

    dao = (IBaseDao<T, Serializable>) getDaoFactory().getDAO(clazz);

    IBaseDao<CnATreeElement, Serializable> containerDAO =
        getDaoFactory().getDAOforTypedElement(container);

    try {
      if (!skipReload && !containerDAO.contains(container)) {
        containerDAO.reload(container, container.getDbId());
      }

      // get constructor with parent-parameter and create new object:
      if (isOrganization()) {
        child =
            (T)
                Organization.class
                    .getConstructor(CnATreeElement.class, boolean.class)
                    .newInstance(container, createChildren);
      } else if (isAudit()) {
        child =
            (T)
                Audit.class
                    .getConstructor(CnATreeElement.class, boolean.class)
                    .newInstance(container, createChildren);
      } else {
        child = (T) clazz.getConstructor(CnATreeElement.class).newInstance(container);
      }
      if (title != null) {
        // override the default title
        child.setTitel(title);
      }

      if (authService.isPermissionHandlingNeeded()) {
        addPermissions(containerDAO);
      }

      child = dao.merge(child, false);
      container.addChild(child);
      child.setParentAndScope(container);

      if (isOrganization()) {
        setScope((Organization) child);
      }

      // initialize UUID, used to find container in display in views:
      container.getUuid();
    } catch (Exception e) {
      getLogger().error("Error while creating element", e);
      throw new RuntimeCommandException(e);
    }
  }
  /* (non-Javadoc)
   * @see sernet.verinice.interfaces.ICommand#execute()
   */
  @SuppressWarnings("restriction")
  @Override
  public void execute() {

    IBaseDao<Configuration, Serializable> confDao = getDaoFactory().getDAO(Configuration.class);
    List<Configuration> confs = confDao.findAll();

    for (Configuration c : confs) {

      try {
        CnATreeElement elmt = (CnATreeElement) c.getPerson();
        if (elmt.getUuid().equals(pIso.getUuid())) {
          configuration = c;
          break;
        }
      } catch (Exception e) {
        LOG.error("Error", e);
      }
    }
  }
Ejemplo n.º 5
0
 private Map<String, CnATreeElement> loadChildrenTitleMap(
     String uuidParent, Map<String, CnATreeElement> map) {
   RetrieveInfo ri = RetrieveInfo.getChildrenInstance().setChildrenProperties(true);
   ControlGroup source = getDao().findByUuid(uuidParent, ri);
   if (source != null) {
     for (CnATreeElement element : source.getChildren()) {
       if (element instanceof IISO27kGroup) {
         map = loadChildrenTitleMap(element.getUuid(), map);
       } else {
         map.put(getNumberOrTitle(element.getTitle()), element);
       }
     }
   }
   return map;
 }