コード例 #1
0
 @Override
 public void deleteContent(CopyToEnvironmentItem item) {
   PersistenceManagerService persistenceManagerService =
       _servicesManager.getService(PersistenceManagerService.class);
   String fullPath =
       SITE_ENVIRONMENT_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, item.getSite());
   fullPath = fullPath.replaceAll(ENVIRONMENT_REPLACEMENT_PATTERN, WORK_AREA_REPOSITORY);
   fullPath = fullPath + item.getPath();
   NodeRef nodeRef = persistenceManagerService.getNodeRef(fullPath);
   if (nodeRef != null) {
     // _dmContentService.deleteContent(site, path, true, true, null);
     // return;
     List<String> paths = new ArrayList<String>();
     paths.add(item.getPath());
     _dmContentService.generateDeleteActivity(item.getSite(), paths, item.getUser());
     NodeRef parentNode = persistenceManagerService.getPrimaryParent(nodeRef).getParentRef();
     persistenceManagerService.deleteNode(nodeRef);
     persistenceManagerService.deleteObjectState(nodeRef.getId());
     List<FileInfo> children = persistenceManagerService.list(parentNode);
     while (children == null || children.size() < 1) {
       NodeRef helpNode = parentNode;
       parentNode = persistenceManagerService.getPrimaryParent(helpNode).getParentRef();
       persistenceManagerService.deleteNode(helpNode);
       children = persistenceManagerService.list(parentNode);
     }
   }
 }
コード例 #2
0
 @Override
 public void setSystemProcessing(String site, List<String> paths, boolean isSystemProcessing) {
   PersistenceManagerService persistenceManagerService =
       _servicesManager.getService(PersistenceManagerService.class);
   List<String> objectIds = new ArrayList<String>();
   String rootPath = SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);
   for (String relativePath : paths) {
     NodeRef nodeRef = persistenceManagerService.getNodeRef(rootPath, relativePath);
     if (nodeRef != null) {
       objectIds.add(nodeRef.getId());
     }
   }
   persistenceManagerService.setSystemProcessingBulk(objectIds, isSystemProcessing);
 }
コード例 #3
0
 @Override
 public void stateTransition(String site, List<String> paths, TransitionEvent event) {
   PersistenceManagerService persistenceManagerService =
       _servicesManager.getService(PersistenceManagerService.class);
   List<String> objectIds = new ArrayList<String>();
   String rootPath = SITE_REPO_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site);
   for (String relativePath : paths) {
     NodeRef nodeRef = persistenceManagerService.getNodeRef(rootPath, relativePath);
     if (nodeRef != null) {
       objectIds.add(nodeRef.getId());
     }
   }
   ObjectStateService.TransitionEvent convertedEvent = eventConversionMap.get(event);
   ObjectStateService.State defaultState = defaultStateForEvent.get(event);
   persistenceManagerService.transitionBulk(objectIds, convertedEvent, defaultState);
 }
コード例 #4
0
    private Object toJsonCompatible(Object value) {
      if (value instanceof Node) {
        final Node node = (Node) value;
        final Map<String, Object> result = SubGraph.toMap((PropertyContainer) node);
        result.put("_id", node.getId());

        final List<String> labelNames = SubGraph.getLabelNames(node);
        if (!labelNames.isEmpty()) result.put("_labels", labelNames);
        return result;
      }
      if (value instanceof Relationship) {
        final Relationship relationship = (Relationship) value;
        final Map<String, Object> result = SubGraph.toMap((PropertyContainer) relationship);
        result.put("_id", relationship.getId());
        result.put("_start", relationship.getStartNode().getId());
        result.put("_end", relationship.getEndNode().getId());
        result.put("_type", relationship.getType().name());
        return result;
      }
      if (value instanceof Map) {
        @SuppressWarnings("unchecked")
        Map<String, Object> map = (Map<String, Object>) value;
        final Map<String, Object> result = new LinkedHashMap<>(map.size());
        for (Map.Entry<String, Object> entry : map.entrySet()) {
          result.put(entry.getKey(), toJsonCompatible(entry.getValue()));
        }
        return result;
      }
      if (value instanceof Iterable) {
        final List<Object> result = new ArrayList<>();
        for (Object inner : (Iterable) value) {
          result.add(toJsonCompatible(inner));
        }
        return result;
      }
      return value;
    }