1 package org.apache.archiva.consumers;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.archiva.repository.ManagedRepository;
23
24 import java.util.Date;
25 import java.util.List;
26
27 /**
28 * A consumer of content (files) in the repository.
29 *
30 * olamy: TODO/FIXME we must review this api, in the current situation we use prototype beans rather than singletons
31 * this is a bit memory consuming the better will be to ConsumerContext bean to transport repository context etc...
32 */
33 public interface RepositoryContentConsumer
34 extends Consumer
35 {
36 /**
37 * Get the list of included file patterns for this consumer.
38 *
39 * @return the list of {@link String} patterns. (example: <code>"**/*.pom"</code>)
40 */
41 List<String> getIncludes();
42
43 /**
44 * Get the list of excluded file patterns for this consumer.
45 *
46 * @return the list of {@link String} patterns. (example: <code>"**/*.pom"</code>) - (can be null for no exclusions)
47 */
48 List<String> getExcludes();
49
50 /**
51 * <p>
52 * Event that triggers at the beginning of a scan.
53 * </p>
54 * <p>
55 * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
56 * generally start tracking the scan as a whole.
57 * </p>
58 *
59 * @param repository the repository that this consumer is being used for.
60 * @param whenGathered the start of the repository scan
61 * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
62 */
63 void beginScan( org.apache.archiva.repository.ManagedRepository repository, Date whenGathered )
64 throws ConsumerException;
65
66 /**
67 * <p>
68 * Event that triggers at the beginning of a scan, where you can also indicate whether the consumers will be
69 * executed on an entire repository or on a specific resource.
70 * </p>
71 *
72 * @param repository the repository that this consumer is being used for.
73 * @param whenGathered the start of the repository scan
74 * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
75 * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
76 * @see RepositoryContentConsumer#beginScan(ManagedRepository, java.util.Date)
77 */
78 void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
79 throws ConsumerException;
80
81 /**
82 * <p>
83 * Event indicating a file is to be processed by this consumer.
84 * </p>
85 * <p>
86 * NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track
87 * the files to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()}
88 * event.
89 * </p>
90 *
91 * @param path the relative file path (in the repository) to process.
92 * @throws ConsumerException if there was a problem processing this file.
93 */
94 void processFile( String path )
95 throws ConsumerException;
96
97 /**
98 * @param path the relative file path (in the repository) to process.
99 * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
100 * @throws Exception if there was a problem processing this file.
101 */
102 void processFile( String path, boolean executeOnEntireRepo )
103 throws Exception;
104
105 /**
106 * <p>
107 * Event that triggers on the completion of a scan.
108 * </p>
109 * <p>
110 * NOTE: If the consumer opted to batch up processing requests in the {@link #processFile(String)} event
111 * this would be the last opportunity to drain any processing queue's.
112 * </p>
113 */
114 void completeScan();
115
116 /**
117 * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
118 */
119 void completeScan( boolean executeOnEntireRepo );
120
121 /**
122 * Whether the consumer should process files that have not been modified since the time passed in to the scan
123 * method.
124 *
125 * @return whether to process the unmodified files
126 */
127 boolean isProcessUnmodified();
128 }