001 package 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 022 import org.apache.archiva.admin.model.beans.ManagedRepository; 023 024 import java.util.Date; 025 import 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 */ 033 public 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>"**<span />/*.pom"</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>"**<span />/*.pom"</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 * <p> 056 * NOTE: This would be a good place to initialize the consumer, to lock any resources, and to 057 * generally start tracking the scan as a whole. 058 * </p> 059 * 060 * @param repository the repository that this consumer is being used for. 061 * @param whenGathered the start of the repository scan 062 * @throws ConsumerException if there was a problem with using the provided repository with the consumer. 063 */ 064 void beginScan( ManagedRepository repository, Date whenGathered ) 065 throws ConsumerException; 066 067 /** 068 * <p> 069 * Event that triggers at the beginning of a scan, where you can also indicate whether the consumers will be 070 * executed on an entire repository or on a specific resource. 071 * </p> 072 * 073 * @param repository the repository that this consumer is being used for. 074 * @param whenGathered the start of the repository scan 075 * @param executeOnEntireRepo flags whether the consumer will be executed on an entire repository or just on a specific resource 076 * @throws ConsumerException if there was a problem with using the provided repository with the consumer. 077 * @see RepositoryContentConsumer#beginScan(ManagedRepository, java.util.Date) 078 */ 079 void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo ) 080 throws ConsumerException; 081 082 /** 083 * <p> 084 * Event indicating a file is to be processed by this consumer. 085 * </p> 086 * <p/> 087 * <p> 088 * NOTE: The consumer does not need to process the file immediately, can can opt to queue and/or track 089 * the files to be processed in batch. Just be sure to complete the processing by the {@link #completeScan()} 090 * event. 091 * </p> 092 * 093 * @param path the relative file path (in the repository) to process. 094 * @throws ConsumerException if there was a problem processing this file. 095 */ 096 void processFile( String path ) 097 throws ConsumerException; 098 099 /** 100 * @param path 101 * @param executeOnEntireRepo 102 * @throws Exception 103 */ 104 void processFile( String path, boolean executeOnEntireRepo ) 105 throws Exception; 106 107 /** 108 * <p> 109 * Event that triggers on the completion of a scan. 110 * </p> 111 * <p/> 112 * <p> 113 * NOTE: If the consumer opted to batch up processing requests in the {@link #processFile(String)} event 114 * this would be the last opportunity to drain any processing queue's. 115 * </p> 116 */ 117 void completeScan(); 118 119 /** 120 * @param executeOnEntireRepo 121 * @throws Exception 122 */ 123 void completeScan( boolean executeOnEntireRepo ); 124 125 /** 126 * Whether the consumer should process files that have not been modified since the time passed in to the scan 127 * method. 128 * 129 * @return whether to process the unmodified files 130 */ 131 boolean isProcessUnmodified(); 132 }