1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.eclipse.aether.repository;
20
21 import org.eclipse.aether.RepositorySystemSession;
22 import org.eclipse.aether.artifact.Artifact;
23 import org.eclipse.aether.metadata.Metadata;
24
25 /**
26 * Manages access to a local repository.
27 *
28 * @see RepositorySystemSession#getLocalRepositoryManager()
29 * @see org.eclipse.aether.RepositorySystem#newLocalRepositoryManager(RepositorySystemSession, LocalRepository)
30 */
31 public interface LocalRepositoryManager {
32
33 /**
34 * Gets the description of the local repository being managed.
35 *
36 * @return The description of the local repository, never {@code null}.
37 */
38 LocalRepository getRepository();
39
40 /**
41 * Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at
42 * the returned location, the path merely indicates where the artifact would eventually be stored. The path uses the
43 * 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 * @return The path, relative to the local repository's base directory.
47 */
48 String getPathForLocalArtifact(Artifact artifact);
49
50 /**
51 * Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually
52 * exist yet at the returned location, the path merely indicates where the artifact would eventually be stored. The
53 * path uses the forward slash as directory separator regardless of the underlying file system.
54 *
55 * @param artifact The artifact for which to determine the path, must not be {@code null}.
56 * @param repository The source repository of the artifact, must not be {@code null}.
57 * @param context The resolution context in which the artifact is being requested, may be {@code null}.
58 * @return The path, relative to the local repository's base directory.
59 */
60 String getPathForRemoteArtifact(Artifact artifact, RemoteRepository repository, String context);
61
62 /**
63 * Gets the relative path for locally installed metadata. Note that the metadata need not actually exist yet at the
64 * returned location, the path merely indicates where the metadata would eventually be stored. The path uses the
65 * 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 * @return The path, relative to the local repository's base directory.
69 */
70 String getPathForLocalMetadata(Metadata metadata);
71
72 /**
73 * Gets the relative path for metadata cached from a remote repository. Note that the metadata need not actually
74 * exist yet at the returned location, the path merely indicates where the metadata would eventually be stored. The
75 * path uses the forward slash as directory separator regardless of the underlying file system.
76 *
77 * @param metadata The metadata for which to determine the path, must not be {@code null}.
78 * @param repository The source repository of the metadata, must not be {@code null}.
79 * @param context The resolution context in which the metadata is being requested, may be {@code null}.
80 * @return The path, relative to the local repository's base directory.
81 */
82 String getPathForRemoteMetadata(Metadata metadata, RemoteRepository repository, String context);
83
84 /**
85 * Queries for the existence of an artifact in the local repository. The request could be satisfied by a locally
86 * installed artifact or a previously downloaded artifact.
87 *
88 * @param session The repository system session during which the request is made, must not be {@code null}.
89 * @param request The artifact request, must not be {@code null}.
90 * @return The result of the request, never {@code null}.
91 */
92 LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request);
93
94 /**
95 * Registers an installed or resolved artifact with the local repository. Note that artifact registration is merely
96 * concerned about updating the local repository's internal state, not about actually installing the artifact or its
97 * accompanying metadata.
98 *
99 * @param session The repository system session during which the registration is made, must not be {@code null}.
100 * @param request The registration request, must not be {@code null}.
101 */
102 void add(RepositorySystemSession session, LocalArtifactRegistration request);
103
104 /**
105 * Queries for the existence of metadata in the local repository. The request could be satisfied by locally
106 * installed or previously downloaded metadata.
107 *
108 * @param session The repository system session during which the request is made, must not be {@code null}.
109 * @param request The metadata request, must not be {@code null}.
110 * @return The result of the request, never {@code null}.
111 */
112 LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request);
113
114 /**
115 * Registers installed or resolved metadata with the local repository. Note that metadata registration is merely
116 * concerned about updating the local repository's internal state, not about actually installing the metadata.
117 * However, this method MUST be called after the actual install to give the repository manager the opportunity to
118 * inspect the added metadata.
119 *
120 * @param session The repository system session during which the registration is made, must not be {@code null}.
121 * @param request The registration request, must not be {@code null}.
122 */
123 void add(RepositorySystemSession session, LocalMetadataRegistration request);
124 }