001package org.apache.maven.wagon;
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.io.InputStream;
023import java.io.OutputStream;
024
025import org.apache.maven.wagon.authorization.AuthorizationException;
026
027/**
028 * 
029 */
030public interface StreamingWagon
031    extends Wagon
032{
033    /**
034     * Downloads specified resource from the repository to given output stream.
035     * 
036     * @param resourceName
037     * @param stream
038     * @throws TransferFailedException
039     * @throws ResourceDoesNotExistException
040     * @throws AuthorizationException 
041     * @throws AuthorizationException
042     */
043    void getToStream( String resourceName, OutputStream stream )
044        throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException;
045
046    /**
047     * Downloads specified resource from the repository if it was modified since specified date. The date is measured in
048     * milliseconds, between the current time and midnight, January 1, 1970 UTC and aligned to GMT timezone.
049     * 
050     * @param resourceName
051     * @param stream
052     * @param timestamp
053     * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource in the
054     *         repository is older or has the same age.
055     * @throws TransferFailedException
056     * @throws ResourceDoesNotExistException
057     * @throws AuthorizationException 
058     * @throws AuthorizationException
059     */
060    boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
061        throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException;
062
063    /**
064     * @deprecated due to unknown contentLength various http(s) implementation will use a chuncked transfer encoding
065     *             mode you must take care you http target server supports that (ngnix don't !).
066     *             <b>So in case of http(s) transport layer avoid using this. Will be remove in 3.0</b>
067     * Copy from a local input stream to remote.
068     * 
069     * @param stream the local stream
070     * @param destination the remote destination
071     * @throws TransferFailedException
072     * @throws ResourceDoesNotExistException
073     * @throws AuthorizationException
074     */
075    void putFromStream( InputStream stream, String destination )
076        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
077
078    /**
079     * Copy from a local input stream to remote.
080     * 
081     * @param stream the local stream
082     * @param destination the remote destination
083     * @throws TransferFailedException
084     * @throws ResourceDoesNotExistException
085     * @throws AuthorizationException
086     */
087    void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
088        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
089}