1 package org.eclipse.aether.repository;
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.eclipse.aether.RepositorySystemSession;
23 import org.eclipse.aether.artifact.Artifact;
24 import org.eclipse.aether.metadata.Metadata;
25
26 /**
27 * Manages access to a local repository.
28 *
29 * @see RepositorySystemSession#getLocalRepositoryManager()
30 * @see org.eclipse.aether.RepositorySystem#newLocalRepositoryManager(RepositorySystemSession, LocalRepository)
31 */
32 public interface LocalRepositoryManager
33 {
34
35 /**
36 * Gets the description of the local repository being managed.
37 *
38 * @return The description of the local repository, never {@code null}.
39 */
40 LocalRepository getRepository();
41
42 /**
43 * Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at
44 * the returned location, the path merely indicates where the artifact would eventually be stored. The path uses the
45 * forward slash as directory separator regardless of the underlying file system.
46 *
47 * @param artifact The artifact for which to determine the path, must not be {@code null}.
48 * @return The path, relative to the local repository's base directory.
49 */
50 String getPathForLocalArtifact( Artifact artifact );
51
52 /**
53 * Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually
54 * exist yet at the returned location, the path merely indicates where the artifact would eventually be stored. The
55 * path uses the forward slash as directory separator regardless of the underlying file system.
56 *
57 * @param artifact The artifact for which to determine the path, must not be {@code null}.
58 * @param repository The source repository of the artifact, must not be {@code null}.
59 * @param context The resolution context in which the artifact is being requested, may be {@code null}.
60 * @return The path, relative to the local repository's base directory.
61 */
62 String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context );
63
64 /**
65 * Gets the relative path for locally installed metadata. Note that the metadata need not actually exist yet at the
66 * returned location, the path merely indicates where the metadata would eventually be stored. The path uses the
67 * forward slash as directory separator regardless of the underlying file system.
68 *
69 * @param metadata The metadata for which to determine the path, must not be {@code null}.
70 * @return The path, relative to the local repository's base directory.
71 */
72 String getPathForLocalMetadata( Metadata metadata );
73
74 /**
75 * Gets the relative path for metadata cached from a remote repository. Note that the metadata need not actually
76 * exist yet at the returned location, the path merely indicates where the metadata would eventually be stored. The
77 * path uses the forward slash as directory separator regardless of the underlying file system.
78 *
79 * @param metadata The metadata for which to determine the path, must not be {@code null}.
80 * @param repository The source repository of the metadata, must not be {@code null}.
81 * @param context The resolution context in which the metadata is being requested, may be {@code null}.
82 * @return The path, relative to the local repository's base directory.
83 */
84 String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context );
85
86 /**
87 * Queries for the existence of an artifact in the local repository. The request could be satisfied by a locally
88 * installed artifact or a previously downloaded artifact.
89 *
90 * @param session The repository system session during which the request is made, must not be {@code null}.
91 * @param request The artifact request, must not be {@code null}.
92 * @return The result of the request, never {@code null}.
93 */
94 LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request );
95
96 /**
97 * Registers an installed or resolved artifact with the local repository. Note that artifact registration is merely
98 * concerned about updating the local repository's internal state, not about actually installing the artifact or its
99 * accompanying metadata.
100 *
101 * @param session The repository system session during which the registration is made, must not be {@code null}.
102 * @param request The registration request, must not be {@code null}.
103 */
104 void add( RepositorySystemSession session, LocalArtifactRegistration request );
105
106 /**
107 * Queries for the existence of metadata in the local repository. The request could be satisfied by locally
108 * installed or previously downloaded metadata.
109 *
110 * @param session The repository system session during which the request is made, must not be {@code null}.
111 * @param request The metadata request, must not be {@code null}.
112 * @return The result of the request, never {@code null}.
113 */
114 LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request );
115
116 /**
117 * Registers installed or resolved metadata with the local repository. Note that metadata registration is merely
118 * concerned about updating the local repository's internal state, not about actually installing the metadata.
119 * However, this method MUST be called after the actual install to give the repository manager the opportunity to
120 * inspect the added metadata.
121 *
122 * @param session The repository system session during which the registration is made, must not be {@code null}.
123 * @param request The registration request, must not be {@code null}.
124 */
125 void add( RepositorySystemSession session, LocalMetadataRegistration request );
126
127 }