gnodet commented on code in PR #884: URL: https://github.com/apache/maven/pull/884#discussion_r1033666376
########## api/maven-api-core/src/main/java/org/apache/maven/api/services/Transport.java: ########## @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.api.services; + +import java.io.Closeable; +import java.net.URI; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import org.apache.maven.api.RemoteRepository; +import org.apache.maven.api.annotations.Consumer; +import org.apache.maven.api.annotations.Experimental; +import org.apache.maven.api.annotations.Nonnull; +import org.apache.maven.api.annotations.Nullable; + +/** + * Transport for specified remote repository (using provided remote repository base URI as root). Must be treated as a + * resource, best in try-with-resource block. + * + * @since 4.0 + */ +@Experimental +@Consumer +public interface Transport extends Closeable { + /** + * GETs the source URI content into target (does not have to exist, or will be overwritten if exist). The + * source MUST BE relative from the {@link RemoteRepository#getUrl()} root. + * + * @return {@code true} if operation succeeded, {@code false} if source does not exist. + * @throws RuntimeException If failed (and not due source not exists). + */ + boolean get(@Nonnull URI relativeSource, @Nonnull Path target); + + /** + * GETs the source URI content as byte array. The source MUST BE relative from the {@link RemoteRepository#getUrl()} + * root. + * + * @return the byte array if operation succeeded, {@code null} if source does not exist. + * @throws RuntimeException If failed (and not due source not exists). + */ + @Nullable + byte[] getBytes(@Nonnull URI relativeSource); + + /** + * GETs the source URI content as string. The source MUST BE relative from the {@link RemoteRepository#getUrl()} + * root. + * + * @return the string if operation succeeded, {@code null} if source does not exist. + * @throws RuntimeException If failed (and not due source not exists). + */ + @Nullable + String getString(@Nonnull URI relativeSource, @Nonnull Charset charset); + + /** + * GETs the source URI content as string using UTF8 charset. The source MUST BE relative from the + * {@link RemoteRepository#getUrl()} root. + * + * @return the string if operation succeeded, {@code null} if source does not exist. + * @throws RuntimeException If failed (and not due source not exists). + */ + default String getString(@Nonnull URI relativeSource) { Review Comment: `@Nullable` ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org