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.

InvalidScanConsumer.java 3.2KB

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.InvalidRepositoryContentConsumer;
  23. import org.apache.archiva.repository.ManagedRepository;
  24. import org.slf4j.Logger;
  25. import org.slf4j.LoggerFactory;
  26. import java.util.ArrayList;
  27. import java.util.Date;
  28. import java.util.List;
  29. /**
  30. * InvalidScanConsumer
  31. *
  32. *
  33. */
  34. public class InvalidScanConsumer
  35. extends AbstractMonitoredConsumer
  36. implements InvalidRepositoryContentConsumer
  37. {
  38. /**
  39. * default-value="unset-id"
  40. */
  41. private String id = "unset-id";
  42. private Logger logger = LoggerFactory.getLogger( getClass() );
  43. private int processCount = 0;
  44. private List<String> paths = new ArrayList<>( );
  45. @Override
  46. public void beginScan( ManagedRepository repository, Date whenGathered )
  47. throws ConsumerException
  48. {
  49. /* do nothing */
  50. }
  51. @Override
  52. public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
  53. throws ConsumerException
  54. {
  55. beginScan( repository, whenGathered );
  56. }
  57. @Override
  58. public void completeScan()
  59. {
  60. /* do nothing */
  61. }
  62. @Override
  63. public void completeScan( boolean executeOnEntireRepo )
  64. {
  65. completeScan();
  66. }
  67. @Override
  68. public List<String> getExcludes()
  69. {
  70. return null;
  71. }
  72. @Override
  73. public List<String> getIncludes()
  74. {
  75. return null;
  76. }
  77. @Override
  78. public void processFile( String path )
  79. throws ConsumerException
  80. {
  81. logger.info( "processFile: {}", path );
  82. paths.add( path );
  83. processCount++;
  84. }
  85. @Override
  86. public void processFile( String path, boolean executeOnEntireRepo )
  87. throws ConsumerException
  88. {
  89. processFile( path );
  90. }
  91. @Override
  92. public String getDescription()
  93. {
  94. return "Bad Content Scan Consumer (for testing)";
  95. }
  96. @Override
  97. public String getId()
  98. {
  99. return id;
  100. }
  101. public int getProcessCount()
  102. {
  103. return processCount;
  104. }
  105. public void setProcessCount( int processCount )
  106. {
  107. this.processCount = processCount;
  108. }
  109. public void setId( String id )
  110. {
  111. this.id = id;
  112. }
  113. public List<String> getPaths()
  114. {
  115. return paths;
  116. }
  117. }