This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.consumers;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.archiva.repository.ManagedRepository;
023
024import java.util.Date;
025import java.util.List;
026
027/**
028 * A consumer of content (files) in the repository.
029 *
030 * olamy: TODO/FIXME we must review this api, in the current situation we use prototype beans rather than singletons
031 * this is a bit memory consuming the better will be to ConsumerContext bean to transport repository context etc...
032 */
033public interface RepositoryContentConsumer
034    extends Consumer
035{
036    /**
037     * Get the list of included file patterns for this consumer.
038     *
039     * @return the list of {@link String} patterns. (example: <code>&quot;**&#47;*.pom&quot;</code>)
040     */
041    List<String> getIncludes();
042
043    /**
044     * Get the list of excluded file patterns for this consumer.
045     *
046     * @return the list of {@link String} patterns. (example: <code>&quot;**&#47;*.pom&quot;</code>) - (can be null for no exclusions)
047     */
048    List<String> getExcludes();
049
050    /**
051     * <p>
052     * Event that triggers at the beginning of a scan.
053     * </p>
054     * <p>
055     * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to
056     * generally start tracking the scan as a whole.
057     * </p>
058     *
059     * @param repository   the repository that this consumer is being used for.
060     * @param whenGathered the start of the repository scan
061     * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
062     */
063    void beginScan( org.apache.archiva.repository.ManagedRepository repository, Date whenGathered )
064        throws ConsumerException;
065
066    /**
067     * <p>
068     * Event that triggers at the beginning of a scan, where you can also indicate whether the consumers will be
069     * executed on an entire repository or on a specific resource.
070     * </p>
071     *
072     * @param repository          the repository that this consumer is being used for.
073     * @param whenGathered        the start of the repository scan
074     * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource
075     * @throws ConsumerException if there was a problem with using the provided repository with the consumer.
076     * @see RepositoryContentConsumer#beginScan(ManagedRepository, java.util.Date)
077     */
078    void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo )
079        throws ConsumerException;
080
081    /**
082     * <p>
083     * Event indicating a file is to be processed by this consumer.
084     * </p>
085     * <p>
086     * NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track
087     * the files to be processed in batch.  Just be sure to complete the processing by the {@link #completeScan()}
088     * event.
089     * </p>
090     *
091     * @param path the relative file path (in the repository) to process.
092     * @throws ConsumerException if there was a problem processing this file.
093     */
094    void processFile( String path )
095        throws ConsumerException;
096
097    /**
098     * @param path the relative file path (in the repository) to process.
099     * @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}