| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ReOcket |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure1 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure11 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure13 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure15 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure17 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure19 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure21 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure3 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure5 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure7 |
|
| 1.0;1 | ||||
| ReOcket$AjcClosure9 |
|
| 1.0;1 |
| 1 | 0 | /** |
| 2 | * Copyright (c) 2012-2015, jcabi.com | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions | |
| 7 | * are met: 1) Redistributions of source code must retain the above | |
| 8 | * copyright notice, this list of conditions and the following | |
| 9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
| 10 | * copyright notice, this list of conditions and the following | |
| 11 | * disclaimer in the documentation and/or other materials provided | |
| 12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
| 13 | * the names of its contributors may be used to endorse or promote | |
| 14 | * products derived from this software without specific prior written | |
| 15 | * permission. | |
| 16 | * | |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
| 19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
| 21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
| 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | */ | |
| 30 | package com.jcabi.s3.retry; | |
| 31 | ||
| 32 | import com.amazonaws.services.s3.model.ObjectMetadata; | |
| 33 | import com.jcabi.aspects.Immutable; | |
| 34 | import com.jcabi.aspects.Loggable; | |
| 35 | import com.jcabi.aspects.RetryOnFailure; | |
| 36 | import com.jcabi.s3.Bucket; | |
| 37 | import com.jcabi.s3.Ocket; | |
| 38 | import java.io.IOException; | |
| 39 | import java.io.InputStream; | |
| 40 | import java.io.OutputStream; | |
| 41 | import lombok.EqualsAndHashCode; | |
| 42 | ||
| 43 | /** | |
| 44 | * Ocket that retries a few times before giving up. | |
| 45 | * | |
| 46 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
| 47 | * @version $Id: c148e9b63a89bb7ec0e2c5e562b0cab51afce915 $ | |
| 48 | * @since 0.5 | |
| 49 | */ | |
| 50 | 0 | @Immutable |
| 51 | 0 | @EqualsAndHashCode(of = "origin") |
| 52 | @Loggable(Loggable.DEBUG) | |
| 53 | public final class ReOcket implements Ocket { | |
| 54 | ||
| 55 | /** | |
| 56 | * Original ocket. | |
| 57 | */ | |
| 58 | private final transient Ocket origin; | |
| 59 | ||
| 60 | /** | |
| 61 | * Public ctor. | |
| 62 | * @param okt Ocket we're in | |
| 63 | */ | |
| 64 | 0 | public ReOcket(final Ocket okt) { |
| 65 | 0 | this.origin = okt; |
| 66 | 0 | } |
| 67 | ||
| 68 | @Override | |
| 69 | public Bucket bucket() { | |
| 70 | 0 | return new ReBucket(this.origin.bucket()); |
| 71 | } | |
| 72 | ||
| 73 | @Override | |
| 74 | public String key() { | |
| 75 | 0 | return this.origin.key(); |
| 76 | } | |
| 77 | ||
| 78 | @Override | |
| 79 | @RetryOnFailure(verbose = false) | |
| 80 | public ObjectMetadata meta() throws IOException { | |
| 81 | 0 | return this.origin.meta(); |
| 82 | } | |
| 83 | ||
| 84 | @Override | |
| 85 | @RetryOnFailure(verbose = false) | |
| 86 | public boolean exists() throws IOException { | |
| 87 | 0 | return this.origin.exists(); |
| 88 | } | |
| 89 | ||
| 90 | @Override | |
| 91 | @RetryOnFailure(verbose = false) | |
| 92 | public void read(final OutputStream output) throws IOException { | |
| 93 | 0 | this.origin.read(output); |
| 94 | 0 | } |
| 95 | ||
| 96 | @Override | |
| 97 | @RetryOnFailure(verbose = false) | |
| 98 | public void write(final InputStream input, final ObjectMetadata meta) | |
| 99 | throws IOException { | |
| 100 | 0 | this.origin.write(input, meta); |
| 101 | 0 | } |
| 102 | ||
| 103 | @Override | |
| 104 | public int compareTo(final Ocket okt) { | |
| 105 | 0 | return this.origin.key().compareTo(okt.key()); |
| 106 | } | |
| 107 | } |