You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KnownScanConsumer.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package org.apache.archiva.repository.scanner;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.consumers.AbstractMonitoredConsumer;
  21. import org.apache.archiva.consumers.ConsumerException;
  22. import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
  23. import org.apache.archiva.repository.ManagedRepository;
  24. import java.util.ArrayList;
  25. import java.util.Arrays;
  26. import java.util.Date;
  27. import java.util.List;
  28. /**
  29. * ScanConsumer
  30. *
  31. *
  32. */
  33. public class KnownScanConsumer
  34. extends AbstractMonitoredConsumer
  35. implements KnownRepositoryContentConsumer
  36. {
  37. private int processCount = 0;
  38. private List<String> includes = new ArrayList<>();
  39. private boolean processUnmodified = false;
  40. @Override
  41. public List<String> getExcludes()
  42. {
  43. return null;
  44. }
  45. public void setIncludes( String includesArray[] )
  46. {
  47. this.includes.clear();
  48. this.includes.addAll( Arrays.asList( includesArray ) );
  49. }
  50. @Override
  51. public List<String> getIncludes()
  52. {
  53. return includes;
  54. }
  55. @Override
  56. public String getId()
  57. {
  58. return "test-scan-consumer";
  59. }
  60. @Override
  61. public String getDescription()
  62. {
  63. return "Scan Consumer (for testing)";
  64. }
  65. @Override
  66. public void beginScan( ManagedRepository repository, Date whenGathered )
  67. throws ConsumerException
  68. {
  69. /* do nothing */
  70. }
  71. @Override
  72. public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
  73. throws ConsumerException
  74. {
  75. beginScan( repository, whenGathered );
  76. }
  77. @Override
  78. public void processFile( String path )
  79. throws ConsumerException
  80. {
  81. logger.info( "Processing {}", path);
  82. this.processCount++;
  83. }
  84. @Override
  85. public void processFile( String path, boolean executeOnEntireRepo )
  86. throws Exception
  87. {
  88. processFile( path );
  89. }
  90. @Override
  91. public void completeScan()
  92. {
  93. /* do nothing */
  94. }
  95. @Override
  96. public void completeScan( boolean executeOnEntireRepo )
  97. {
  98. completeScan();
  99. }
  100. public int getProcessCount()
  101. {
  102. return processCount;
  103. }
  104. public void setProcessCount( int processCount )
  105. {
  106. this.processCount = processCount;
  107. }
  108. @Override
  109. public boolean isProcessUnmodified()
  110. {
  111. return processUnmodified;
  112. }
  113. public void setProcessUnmodified( boolean processUnmodified )
  114. {
  115. this.processUnmodified = processUnmodified;
  116. }
  117. }