コード例 #1
0
 @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());
 }
コード例 #2
0
  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;
  }
コード例 #3
0
 @Override
 public Set<Group> getGroupsContaining(final StoreKey repo) throws IndyDataException {
   return delegate.getGroupsContaining(repo);
 }
コード例 #4
0
 @Override
 public List<ArtifactStore> getOrderedStoresInGroup(
     final String groupName, final boolean enabledOnly) throws IndyDataException {
   return delegate.getOrderedStoresInGroup(groupName, enabledOnly);
 }
コード例 #5
0
 @Override
 public List<ArtifactStore> getAllConcreteArtifactStores() throws IndyDataException {
   return delegate.getAllConcreteArtifactStores();
 }
コード例 #6
0
 @Override
 public List<HostedRepository> getAllHostedRepositories() throws IndyDataException {
   return delegate.getAllHostedRepositories();
 }
コード例 #7
0
 @Override
 public List<Group> getAllGroups() throws IndyDataException {
   return delegate.getAllGroups();
 }
コード例 #8
0
 @Override
 public List<? extends ArtifactStore> getAllArtifactStores(final StoreType type)
     throws IndyDataException {
   return delegate.getAllArtifactStores(type);
 }
コード例 #9
0
  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());
    }
  }
コード例 #10
0
 @Override
 public RemoteRepository findRemoteRepository(final String url) {
   return delegate.findRemoteRepository(url);
 }
コード例 #11
0
 @Override
 public boolean hasArtifactStore(final StoreKey key) {
   return delegate.hasArtifactStore(key);
 }
コード例 #12
0
 @Override
 public boolean hasHostedRepository(final String name) {
   return delegate.hasHostedRepository(name);
 }
コード例 #13
0
 @Override
 public boolean hasGroup(final String name) {
   return delegate.hasGroup(name);
 }
コード例 #14
0
 @Override
 public void clear(final ChangeSummary summary) throws IndyDataException {
   delegate.clear(summary);
 }
コード例 #15
0
 @Override
 public void deleteArtifactStore(
     final StoreKey key, final ChangeSummary summary, final EventMetadata eventMetadata)
     throws IndyDataException {
   delegate.deleteArtifactStore(key, summary, new EventMetadata());
 }
コード例 #16
0
 @Override
 public void install() throws IndyDataException {
   delegate.install();
 }
コード例 #17
0
 @Override
 public void reload() throws IndyDataException {
   delegate.reload();
 }
コード例 #18
0
 @Override
 public boolean isStarted() {
   return delegate.isStarted();
 }