@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 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); } } }