1 package org.sonatype.aether.repository; 2 3 /******************************************************************************* 4 * Copyright (c) 2010-2011 Sonatype, Inc. 5 * All rights reserved. This program and the accompanying materials 6 * are made available under the terms of the Eclipse Public License v1.0 7 * which accompanies this distribution, and is available at 8 * http://www.eclipse.org/legal/epl-v10.html 9 *******************************************************************************/ 10 11 import org.sonatype.aether.RepositorySystemSession; 12 import org.sonatype.aether.artifact.Artifact; 13 import org.sonatype.aether.metadata.Metadata; 14 15 /** 16 * Manages access to the local repository. 17 * 18 * @author Benjamin Bentmann 19 */ 20 public interface LocalRepositoryManager 21 { 22 23 /** 24 * Gets the description of the local repository being managed. 25 * 26 * @return The description of the local repository, never {@code null}. 27 */ 28 LocalRepository getRepository(); 29 30 /** 31 * Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at 32 * the returned location, the path merely indicates where the artifact would eventually be stored. The path uses the 33 * forward slash as directory separator regardless of the underlying file system. 34 * 35 * @param artifact The artifact for which to determine the path, must not be {@code null}. 36 * @return The path, relative to the local repository's base directory. 37 */ 38 String getPathForLocalArtifact( Artifact artifact ); 39 40 /** 41 * Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually 42 * exist yet at the returned location, the path merely indicates where the artifact would eventually be stored. The 43 * path uses the forward slash as directory separator regardless of the underlying file system. 44 * 45 * @param artifact The artifact for which to determine the path, must not be {@code null}. 46 * @param repository The source repository of the artifact, must not be {@code null}. 47 * @param context The resolution context in which the artifact is being requested, may be {@code null}. 48 * @return The path, relative to the local repository's base directory. 49 */ 50 String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ); 51 52 /** 53 * Gets the relative path for locally installed metadata. Note that the metadata need not actually exist yet at the 54 * returned location, the path merely indicates where the metadata would eventually be stored. The path uses the 55 * forward slash as directory separator regardless of the underlying file system. 56 * 57 * @param metadata The metadata for which to determine the path, must not be {@code null}. 58 * @return The path, relative to the local repository's base directory. 59 */ 60 String getPathForLocalMetadata( Metadata metadata ); 61 62 /** 63 * Gets the relative path for metadata cached from a remote repository. Note that the metadata need not actually 64 * exist yet at the returned location, the path merely indicates where the metadata would eventually be stored. The 65 * path uses the forward slash as directory separator regardless of the underlying file system. 66 * 67 * @param metadata The metadata for which to determine the path, must not be {@code null}. 68 * @param repository The source repository of the metadata, must not be {@code null}. 69 * @param context The resolution context in which the metadata is being requested, may be {@code null}. 70 * @return The path, relative to the local repository's base directory. 71 */ 72 String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context ); 73 74 /** 75 * Queries for the existence of an artifact in the local repository. The request could be satisfied by a locally 76 * installed artifact or a previously downloaded artifact. 77 * 78 * @param session The repository system session during which the request is made, must not be {@code null}. 79 * @param request The artifact request, must not be {@code null}. 80 * @return The result of the request, never {@code null}. 81 */ 82 LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request ); 83 84 /** 85 * Registers an installed or resolved artifact with the local repository. Note that artifact registration is merely 86 * concerned about updating the local repository's internal state, not about actually installing the artifact or its 87 * accompanying metadata. 88 * 89 * @param session The repository system session during which the registration is made, must not be {@code null}. 90 * @param request The registration request, must not be {@code null}. 91 */ 92 void add( RepositorySystemSession session, LocalArtifactRegistration request ); 93 94 /** 95 * Queries for the existence of metadata in the local repository. The request could be satisfied by locally 96 * installed or previously downloaded metadata. 97 * 98 * @param session The repository system session during which the request is made, must not be {@code null}. 99 * @param request The metadata request, must not be {@code null}. 100 * @return The result of the request, never {@code null}. 101 */ 102 LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request ); 103 104 /** 105 * Registers installed or resolved metadata with the local repository. Note that metadata registration is merely 106 * concerned about updating the local repository's internal state, not about actually installing the metadata. 107 * However, this method MUST be called after the actual install to give the repository manager the opportunity to 108 * inspect the added metadata. 109 * 110 * @param session The repository system session during which the registration is made, must not be {@code null}. 111 * @param request The registration request, must not be {@code null}. 112 */ 113 void add( RepositorySystemSession session, LocalMetadataRegistration request ); 114 115 }