@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); } } }
@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); }
@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); }
@Override public Set<PublishingTargetItem> getAllTargetsForSite(String site) { PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); SiteService siteService = _servicesManager.getService(SiteService.class); Map<String, PublishingChannelGroupConfigTO> groupConfigTOs = siteService.getPublishingChannelGroupConfigs(site); Set<PublishingTargetItem> targets = new HashSet<PublishingTargetItem>(); Map<String, PublishingTargetItem> targetMap = new HashMap<String, PublishingTargetItem>(); if (groupConfigTOs != null && groupConfigTOs.size() > 0) { for (PublishingChannelGroupConfigTO groupConfigTO : groupConfigTOs.values()) { List<PublishingChannelConfigTO> channelConfigTOs = groupConfigTO.getChannels(); if (channelConfigTOs != null && channelConfigTOs.size() > 0) { for (PublishingChannelConfigTO channelConfigTO : channelConfigTOs) { DeploymentEndpointConfigTO endpoint = siteService.getDeploymentEndpoint(site, channelConfigTO.getName()); if (endpoint != null) { PublishingTargetItem targetItem = targetMap.get(endpoint.getName()); if (targetItem == null) { targetItem = new PublishingTargetItem(); targetItem.setId(endpoint.getName()); targetItem.setName(endpoint.getName()); targetItem.setTarget(endpoint.getTarget()); targetItem.setType(endpoint.getType()); targetItem.setServerUrl(endpoint.getServerUrl()); targetItem.setStatusUrl(endpoint.getStatusUrl()); targetItem.setVersionUrl(endpoint.getVersionUrl()); targetItem.setPassword(endpoint.getPassword()); targetItem.setExcludePattern(endpoint.getExcludePattern()); targetItem.setIncludePattern(endpoint.getIncludePattern()); targetItem.setBucketSize(endpoint.getBucketSize()); targetItem.setSiteId(endpoint.getSiteId()); targets.add(targetItem); targetMap.put(endpoint.getName(), targetItem); } targetItem.addEnvironment(groupConfigTO.getName()); } } } } } return targets; }
@Override public void deleteContent(String site, String environment, String path) { PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); String fullPath = SITE_ENVIRONMENT_ROOT_PATTERN.replaceAll(SITE_REPLACEMENT_PATTERN, site); fullPath = fullPath.replaceAll(ENVIRONMENT_REPLACEMENT_PATTERN, environment); fullPath = fullPath + path; NodeRef nodeRef = persistenceManagerService.getNodeRef(fullPath); if (nodeRef != null) { NodeRef parentNode = persistenceManagerService.getPrimaryParent(nodeRef).getParentRef(); persistenceManagerService.deleteNode(nodeRef); 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); } } }
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; }