@Override public boolean storeArtifactStore( final ArtifactStore key, final ChangeSummary summary, final boolean skipIfExists, final EventMetadata eventMetadata) throws IndyDataException { return delegate.storeArtifactStore(key, summary, skipIfExists, new EventMetadata()); }
private ArtifactStore getRequestStore(PromoteRequest promoteRequest, String baseUrl) throws PromotionValidationException { final ArtifactStore store; final Logger logger = LoggerFactory.getLogger(getClass()); if (needTempRepo(promoteRequest)) { logger.info( "Promotion temporary repo is needed for {}, points to {} ", promoteRequest.getSource(), baseUrl); final PathsPromoteRequest pathsReq = (PathsPromoteRequest) promoteRequest; String tempName = PROMOTE_REPO_PREFIX + "tmp_" + pathsReq.getSource().getName() + new SimpleDateFormat("yyyyMMdd.hhmmss.SSSZ").format(new Date()); final RemoteRepository tempRemote = new RemoteRepository(tempName, baseUrl); tempRemote.setPathMaskPatterns(pathsReq.getPaths()); store = tempRemote; try { storeDataMgr.storeArtifactStore( tempRemote, new ChangeSummary(ChangeSummary.SYSTEM_USER, "create temp remote repository")); } catch (IndyDataException e) { throw new PromotionValidationException( "Can not store the temp remote repository correctly", e); } } else { logger.info("Promotion temporary repo is not needed for {} ", promoteRequest.getSource()); try { store = storeDataMgr.getArtifactStore(promoteRequest.getSource()); } catch (IndyDataException e) { throw new PromotionValidationException( "Failed to retrieve source ArtifactStore: {}. Reason: {}", e, promoteRequest.getSource(), e.getMessage()); } } return store; }
@Override public Set<Group> getGroupsContaining(final StoreKey repo) throws IndyDataException { return delegate.getGroupsContaining(repo); }
@Override public List<ArtifactStore> getOrderedStoresInGroup( final String groupName, final boolean enabledOnly) throws IndyDataException { return delegate.getOrderedStoresInGroup(groupName, enabledOnly); }
@Override public List<ArtifactStore> getAllConcreteArtifactStores() throws IndyDataException { return delegate.getAllConcreteArtifactStores(); }
@Override public List<HostedRepository> getAllHostedRepositories() throws IndyDataException { return delegate.getAllHostedRepositories(); }
@Override public List<Group> getAllGroups() throws IndyDataException { return delegate.getAllGroups(); }
@Override public List<? extends ArtifactStore> getAllArtifactStores(final StoreType type) throws IndyDataException { return delegate.getAllArtifactStores(type); }
public void validate(PromoteRequest request, ValidationResult result, String baseUrl) throws PromotionValidationException { ValidationRuleSet set = validationsManager.getRuleSetMatching(request.getTargetKey()); Logger logger = LoggerFactory.getLogger(getClass()); if (set != null) { logger.debug("Running validation rule-set for promotion: {}", set.getName()); result.setRuleSet(set.getName()); List<String> ruleNames = set.getRuleNames(); if (ruleNames != null && !ruleNames.isEmpty()) { final ArtifactStore store = getRequestStore(request, baseUrl); try { final ValidationRequest req = new ValidationRequest(request, set, validationTools, store); for (String ruleRef : ruleNames) { String ruleName = new File(ruleRef).getName(); // flatten in case some path fragment leaks in... ValidationRuleMapping rule = validationsManager.getRuleMappingNamed(ruleName); if (rule != null) { try { logger.debug("Running promotion validation rule: {}", rule.getName()); String error = rule.getRule().validate(req); if (StringUtils.isNotEmpty(error)) { logger.debug("{} failed", rule.getName()); result.addValidatorError(rule.getName(), error); } else { logger.debug("{} succeeded", rule.getName()); } } catch (Exception e) { if (e instanceof PromotionValidationException) { throw (PromotionValidationException) e; } throw new PromotionValidationException( "Failed to run validation rule: {} for request: {}. Reason: {}", e, rule.getName(), request, e); } } } } finally { if (needTempRepo(request)) { try { storeDataMgr.deleteArtifactStore( store.getKey(), new ChangeSummary(ChangeSummary.SYSTEM_USER, "remove the temp remote repo")); logger.info( "Promotion temporary repo {} has been deleted for {}", store.getKey(), request.getSource()); } catch (IndyDataException e) { logger.warn("StoreDataManager can not remove artifact stores correctly.", e); } } } } } else { logger.info("No validation rule-sets are defined for: {}", request.getTargetKey()); } }
@Override public RemoteRepository findRemoteRepository(final String url) { return delegate.findRemoteRepository(url); }
@Override public boolean hasArtifactStore(final StoreKey key) { return delegate.hasArtifactStore(key); }
@Override public boolean hasHostedRepository(final String name) { return delegate.hasHostedRepository(name); }
@Override public boolean hasGroup(final String name) { return delegate.hasGroup(name); }
@Override public void clear(final ChangeSummary summary) throws IndyDataException { delegate.clear(summary); }
@Override public void deleteArtifactStore( final StoreKey key, final ChangeSummary summary, final EventMetadata eventMetadata) throws IndyDataException { delegate.deleteArtifactStore(key, summary, new EventMetadata()); }
@Override public void install() throws IndyDataException { delegate.install(); }
@Override public void reload() throws IndyDataException { delegate.reload(); }
@Override public boolean isStarted() { return delegate.isStarted(); }