@Override public void processItem(CopyToEnvironmentItem item) throws DeploymentException { String liveEnvironment = _contentRepository.getLiveEnvironmentName(item.getSite()); boolean isLive = false; if (StringUtils.isNotEmpty(liveEnvironment)) { if (liveEnvironment.equals(item.getEnvironment())) { isLive = true; } } else if (LIVE_ENVIRONMENT.equalsIgnoreCase(item.getEnvironment()) || PRODUCTION_ENVIRONMENT.equalsIgnoreCase(item.getEnvironment())) { isLive = true; } if (item.getAction() == CopyToEnvironmentItem.Action.DELETE) { if (item.getOldPath() != null && item.getOldPath().length() > 0) { _contentRepository.deleteContent(item.getSite(), item.getEnvironment(), item.getOldPath()); _contentRepository.clearRenamed(item.getSite(), item.getPath()); } _contentRepository.deleteContent(item.getSite(), item.getEnvironment(), item.getPath()); if (isLive) { _contentRepository.deleteContent(item); } } else { _contentRepository.setSystemProcessing(item.getSite(), item.getPath(), true); if (isLive) { if (!_importModeEnabled) { _contentRepository.createNewVersion( item.getSite(), item.getPath(), item.getSubmissionComment(), true); } else { LOGGER.debug( "Import mode is ON. Create new version is skipped for [{0}] site \"{1}\"", item.getPath(), item.getSite()); } } if (item.getAction() == CopyToEnvironmentItem.Action.MOVE) { if (item.getOldPath() != null && item.getOldPath().length() > 0) { _contentRepository.deleteContent( item.getSite(), item.getEnvironment(), item.getOldPath()); if (isLive) { _contentRepository.clearRenamed(item.getSite(), item.getPath()); } } } _contentRepository.copyToEnvironment(item.getSite(), item.getEnvironment(), item.getPath()); if (isLive) { _contentRepository.stateTransition( item.getSite(), item.getPath(), TransitionEvent.DEPLOYMENT); } _contentRepository.setSystemProcessing(item.getSite(), item.getPath(), false); } }
private CopyToEnvironmentItem createMissingItem( String site, String itemPath, CopyToEnvironmentItem item) { CopyToEnvironmentItem missingItem = new CopyToEnvironmentItem(); missingItem.setSite(site); missingItem.setEnvironment(item.getEnvironment()); missingItem.setPath(itemPath); missingItem.setScheduledDate(item.getScheduledDate()); missingItem.setState(item.getState()); if (_contentRepository.isNew(site, itemPath)) { missingItem.setAction(CopyToEnvironmentItem.Action.NEW); } if (_contentRepository.isRenamed(site, itemPath)) { String oldPath = _contentRepository.getOldPath(site, itemPath); missingItem.setOldPath(oldPath); missingItem.setAction(CopyToEnvironmentItem.Action.MOVE); } String contentTypeClass = _contentRepository.getContentTypeClass(site, itemPath); missingItem.setContentTypeClass(contentTypeClass); missingItem.setUser(item.getUser()); missingItem.setSubmissionComment(item.getSubmissionComment()); return missingItem; }