001package org.apache.archiva.repository; 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 java.util.Set; 023 024/** 025 * A repository content provider creates repository content instances for specific repository types. 026 */ 027public interface RepositoryContentProvider 028{ 029 /** 030 * Returns true, if this content object supports the given layout otherwise, false. 031 * @param layout the layout string 032 * @return true, if layout is supported, otherwise false. 033 */ 034 boolean supportsLayout(String layout); 035 036 /** 037 * Returns the repository types, this content object can be used for. 038 * 039 * @return all supported repository types. 040 */ 041 Set<RepositoryType> getSupportedRepositoryTypes(); 042 043 044 /** 045 * Returns true, if this content object supports the given repository type. 046 * 047 * @param type the type to check. 048 * @return true, if the type is supported, otherwise false. 049 */ 050 boolean supports(RepositoryType type); 051 052 /** 053 * Creates a new instance of RemoteRepositoryContent. The returned instance should be initialized 054 * from the given repository data. 055 * 056 * @param repository the repository 057 * @return a repository content instance 058 * @throws RepositoryException if the layout is not supported, or a error occured during initialization 059 */ 060 RemoteRepositoryContent createRemoteContent(RemoteRepository repository) throws RepositoryException; 061 062 /** 063 * Creates a new instance of ManagedRepositoryContent. 064 * 065 * @param repository the repository 066 * @return a new instance 067 * @throws RepositoryException if the layout is not supported, or a error occured during initialization 068 */ 069 ManagedRepositoryContent createManagedContent(ManagedRepository repository) throws RepositoryException; 070 071 /** 072 * Creates a generic content object. 073 * 074 * @param repository the repository 075 * @param clazz the content class 076 * @param <T> the generic type of the content 077 * @param <V> the generic type of the repository (must correspond to the content class) 078 * @return a new instance 079 * @throws RepositoryException if the clazz, or layout is not supported, or something went wrong during initialization 080 */ 081 <T extends RepositoryContent, V extends Repository> T createContent(Class<T> clazz, V repository) throws RepositoryException; 082}