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.

RepositoryContentConsumer.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package org.apache.archiva.consumers;
  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.repository.ManagedRepository;
  21. import java.util.Date;
  22. import java.util.List;
  23. /**
  24. * A consumer of content (files) in the repository.
  25. *
  26. * olamy: TODO/FIXME we must review this api, in the current situation we use prototype beans rather than singletons
  27. * this is a bit memory consuming the better will be to ConsumerContext bean to transport repository context etc...
  28. */
  29. public interface RepositoryContentConsumer
  30. extends Consumer
  31. {
  32. /**
  33. * Get the list of included file patterns for this consumer.
  34. *
  35. * @return the list of {@link String} patterns. (example: <code>&quot;**&#47;*.pom&quot;</code>)
  36. */
  37. List<String> getIncludes();
  38. /**
  39. * Get the list of excluded file patterns for this consumer.
  40. *
  41. * @return the list of {@link String} patterns. (example: <code>&quot;**&#47;*.pom&quot;</code>) - (can be null for no exclusions)
  42. */
  43. List<String> getExcludes();
  44. /**
  45. * <p>
  46. * Event that triggers at the beginning of a scan.
  47. * </p>
  48. * <p>
  49. * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
  50. * generally start tracking the scan as a whole.
  51. * </p>
  52. *
  53. * @param repository the repository that this consumer is being used for.
  54. * @param whenGathered the start of the repository scan
  55. * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
  56. */
  57. void beginScan( org.apache.archiva.repository.ManagedRepository repository, Date whenGathered )
  58. throws ConsumerException;
  59. /**
  60. * <p>
  61. * Event that triggers at the beginning of a scan, where you can also indicate whether the consumers will be
  62. * executed on an entire repository or on a specific resource.
  63. * </p>
  64. *
  65. * @param repository the repository that this consumer is being used for.
  66. * @param whenGathered the start of the repository scan
  67. * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
  68. * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
  69. * @see RepositoryContentConsumer#beginScan(ManagedRepository, java.util.Date)
  70. */
  71. void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
  72. throws ConsumerException;
  73. /**
  74. * <p>
  75. * Event indicating a file is to be processed by this consumer.
  76. * </p>
  77. * <p>
  78. * NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track
  79. * the files to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()}
  80. * event.
  81. * </p>
  82. *
  83. * @param path the relative file path (in the repository) to process.
  84. * @throws ConsumerException if there was a problem processing this file.
  85. */
  86. void processFile( String path )
  87. throws ConsumerException;
  88. /**
  89. * @param path the relative file path (in the repository) to process.
  90. * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
  91. * @throws Exception if there was a problem processing this file.
  92. */
  93. void processFile( String path, boolean executeOnEntireRepo )
  94. throws Exception;
  95. /**
  96. * <p>
  97. * Event that triggers on the completion of a scan.
  98. * </p>
  99. * <p>
  100. * NOTE: If the consumer opted to batch up processing requests in the {@link #processFile(String)} event
  101. * this would be the last opportunity to drain any processing queue's.
  102. * </p>
  103. */
  104. void completeScan();
  105. /**
  106. * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
  107. */
  108. void completeScan( boolean executeOnEntireRepo );
  109. /**
  110. * Whether the consumer should process files that have not been modified since the time passed in to the scan
  111. * method.
  112. *
  113. * @return whether to process the unmodified files
  114. */
  115. boolean isProcessUnmodified();
  116. }