Skip to content

Commit f127394

Browse files
committed
Merge pull request #90 from rpmoore/master
General code cleanup
2 parents 8ed2c1d + c454085 commit f127394

File tree

7 files changed

+76
-90
lines changed

7 files changed

+76
-90
lines changed

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/command/GetTapeFailure.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@
1818

1919
import com.spectralogic.ds3cli.Arguments;
2020
import com.spectralogic.ds3cli.exceptions.CommandException;
21-
import com.spectralogic.ds3cli.models.GetBucketResult;
2221
import com.spectralogic.ds3cli.util.Ds3Provider;
2322
import com.spectralogic.ds3cli.util.FileUtils;
2423
import com.spectralogic.ds3client.commands.spectrads3.GetTapeFailuresSpectraS3Request;
2524
import com.spectralogic.ds3client.commands.spectrads3.GetTapeFailuresSpectraS3Response;
26-
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
27-
import com.spectralogic.ds3client.models.Contents;
2825
import com.spectralogic.ds3client.networking.FailedRequestException;
2926
import com.spectralogic.ds3cli.models.GetTapeFailureResult;
30-
import org.apache.commons.cli.MissingOptionException;
31-
32-
import java.util.Iterator;
33-
3427

3528
public class GetTapeFailure extends CliCommand<GetTapeFailureResult> {
3629

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/util/SyncUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import com.spectralogic.ds3client.serializer.XmlProcessingException;
2323
import org.joda.time.DateTime;
2424
import org.joda.time.DateTimeComparator;
25-
import org.joda.time.format.DateTimeFormat;
26-
import org.joda.time.format.DateTimeFormatter;
2725
import org.slf4j.Logger;
2826
import org.slf4j.LoggerFactory;
2927

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/util/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public static ImmutableList<Path> getPipedFilesFromStdin(final FileUtils fileUti
207207
LOG.warn(String.format("WARN: piped data must be a regular/symbolic link file and not a directory ==> %s will be skipped", line));
208208
continue;
209209
}
210-
LOG.info(line);
210+
LOG.info("File \"" + file.toString() + "\" from stdin");
211211
pipedFiles.add(file);
212212
}
213213
}

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/views/cli/GetServiceView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.bethecoder.ascii_table.ASCIITableHeader;
2020
import com.spectralogic.ds3cli.View;
2121
import com.spectralogic.ds3cli.models.GetServiceResult;
22-
import com.spectralogic.ds3client.models.Ds3Bucket;
22+
import com.spectralogic.ds3client.models.BucketDetails;
2323
import com.spectralogic.ds3client.models.ListAllMyBucketsResult;
2424

2525
import java.text.SimpleDateFormat;
@@ -41,10 +41,10 @@ public String render(final GetServiceResult obj) {
4141
}
4242

4343
private String[][] formatBucketList(final ListAllMyBucketsResult result) {
44-
final List<Ds3Bucket> buckets = result.getBuckets();
44+
final List<BucketDetails> buckets = result.getBuckets();
4545
final String [][] formatArray = new String[buckets.size()][];
4646
for(int i = 0; i < buckets.size(); i ++) {
47-
final Ds3Bucket bucket = buckets.get(i);
47+
final BucketDetails bucket = buckets.get(i);
4848
final String [] bucketArray = new String[2];
4949
bucketArray[0] = nullGuard(bucket.getName());
5050

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,70 @@
1-
/*
2-
* ******************************************************************************
3-
* Copyright 2014 Spectra Logic Corporation. All Rights Reserved.
4-
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5-
* this file except in compliance with the License. A copy of the License is located at
6-
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* or in the "license" file accompanying this file.
10-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11-
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12-
* specific language governing permissions and limitations under the License.
13-
* ****************************************************************************
14-
*/
15-
16-
package com.spectralogic.ds3cli.views.cli;
17-
18-
import com.bethecoder.ascii_table.ASCIITable;
19-
import com.bethecoder.ascii_table.ASCIITableHeader;
20-
import com.spectralogic.ds3cli.View;
21-
import com.spectralogic.ds3cli.models.GetTapeFailureResult;
22-
import com.spectralogic.ds3client.models.DetailedTapeFailure;
23-
import com.spectralogic.ds3client.models.DetailedTapeFailureList;
24-
import com.spectralogic.ds3client.models.Ds3Bucket;
25-
import com.spectralogic.ds3client.models.ListAllMyBucketsResult;
26-
27-
import java.text.SimpleDateFormat;
28-
import java.util.List;
29-
import java.util.TimeZone;
30-
31-
import static com.spectralogic.ds3cli.util.Utils.nullGuard;
32-
33-
public class GetTapeFailureView implements View<GetTapeFailureResult> {
34-
@Override
35-
public String render(final GetTapeFailureResult obj) {
36-
final DetailedTapeFailureList result = obj.getResult();
37-
if( (result == null)
38-
|| (null == result.getDetailedTapeFailures())
39-
|| (result.getDetailedTapeFailures().size() == 0) ) {
40-
return "No tape failures on remote appliance";
41-
}
42-
43-
return "" + result.getDetailedTapeFailures().size() + " Tape Failures:\n" +
44-
ASCIITable.getInstance().getTable(getHeaders(), formatBucketList(result));
45-
}
46-
47-
private String[][] formatBucketList(final DetailedTapeFailureList result) {
48-
final List<DetailedTapeFailure> failures = result.getDetailedTapeFailures();
49-
final String [][] formatArray = new String[failures.size()][];
50-
int i = 0;
51-
for(final DetailedTapeFailure failure : failures) {
52-
final String [] bucketArray = new String[4];
53-
bucketArray[0] = nullGuard(failure.getType().toString());
54-
bucketArray[1] = nullGuard(failure.getErrorMessage().toString());
55-
bucketArray[2] = nullGuard(failure.getId().toString());
56-
final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
57-
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
58-
bucketArray[3] = DATE_FORMAT.format(failure.getDate());
59-
formatArray[i++] = bucketArray;
60-
}
61-
return formatArray;
62-
}
63-
64-
private ASCIITableHeader[] getHeaders() {
65-
return new ASCIITableHeader[]{
66-
new ASCIITableHeader("Failure Type", ASCIITable.ALIGN_LEFT),
67-
new ASCIITableHeader("Failure Message", ASCIITable.ALIGN_CENTER),
68-
new ASCIITableHeader("Id", ASCIITable.ALIGN_CENTER),
69-
new ASCIITableHeader("Failure Date", ASCIITable.ALIGN_RIGHT)
70-
};
71-
}
72-
}
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3cli.views.cli;
17+
18+
import com.bethecoder.ascii_table.ASCIITable;
19+
import com.bethecoder.ascii_table.ASCIITableHeader;
20+
import com.spectralogic.ds3cli.View;
21+
import com.spectralogic.ds3cli.models.GetTapeFailureResult;
22+
import com.spectralogic.ds3client.models.DetailedTapeFailure;
23+
import com.spectralogic.ds3client.models.DetailedTapeFailureList;
24+
25+
import java.text.SimpleDateFormat;
26+
import java.util.List;
27+
import java.util.TimeZone;
28+
29+
import static com.spectralogic.ds3cli.util.Utils.nullGuard;
30+
31+
public class GetTapeFailureView implements View<GetTapeFailureResult> {
32+
@Override
33+
public String render(final GetTapeFailureResult obj) {
34+
final DetailedTapeFailureList result = obj.getResult();
35+
if( (result == null)
36+
|| (null == result.getDetailedTapeFailures())
37+
|| (result.getDetailedTapeFailures().size() == 0) ) {
38+
return "No tape failures on remote appliance";
39+
}
40+
41+
return "" + result.getDetailedTapeFailures().size() + " Tape Failures:\n" +
42+
ASCIITable.getInstance().getTable(getHeaders(), formatBucketList(result));
43+
}
44+
45+
private String[][] formatBucketList(final DetailedTapeFailureList result) {
46+
final List<DetailedTapeFailure> failures = result.getDetailedTapeFailures();
47+
final String [][] formatArray = new String[failures.size()][];
48+
int i = 0;
49+
for(final DetailedTapeFailure failure : failures) {
50+
final String [] bucketArray = new String[4];
51+
bucketArray[0] = nullGuard(failure.getType().toString());
52+
bucketArray[1] = nullGuard(failure.getErrorMessage());
53+
bucketArray[2] = nullGuard(failure.getId().toString());
54+
final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
55+
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
56+
bucketArray[3] = DATE_FORMAT.format(failure.getDate());
57+
formatArray[i++] = bucketArray;
58+
}
59+
return formatArray;
60+
}
61+
62+
private ASCIITableHeader[] getHeaders() {
63+
return new ASCIITableHeader[]{
64+
new ASCIITableHeader("Failure Type", ASCIITable.ALIGN_LEFT),
65+
new ASCIITableHeader("Failure Message", ASCIITable.ALIGN_CENTER),
66+
new ASCIITableHeader("Id", ASCIITable.ALIGN_CENTER),
67+
new ASCIITableHeader("Failure Date", ASCIITable.ALIGN_RIGHT)
68+
};
69+
}
70+
}

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/views/cli/GetTapesWithFullDetailsView.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
import com.spectralogic.ds3client.models.NamedDetailedTapeList;
2525
import com.spectralogic.ds3client.utils.Guard;
2626

27-
import java.text.SimpleDateFormat;
28-
import java.util.TimeZone;
29-
3027
import static com.spectralogic.ds3cli.util.Utils.nullGuard;
3128
import static com.spectralogic.ds3cli.util.Utils.nullGuardToString;
3229

ds3_java_cli/src/test/java/com/spectralogic/ds3cli/Ds3Cli_Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.spectralogic.ds3client.networking.WebResponse;
3535
import com.spectralogic.ds3client.serializer.XmlOutput;
3636
import org.apache.commons.io.IOUtils;
37+
import org.hamcrest.core.StringEndsWith;
3738
import org.junit.Test;
3839
import org.junit.runner.RunWith;
3940
import org.mockito.invocation.InvocationOnMock;
@@ -794,7 +795,6 @@ public void getCompletedJobJson() throws Exception {
794795
+ " \"status\" : \"COMPLETED\",\n"
795796
+ " \"userId\" : \"c2581493-058c-40d7-a3a1-9a50b20d6d3b\",\n"
796797
+ " \"userName\" : \"spectra\",\n"
797-
+ " \"writeOptimization\" : \"CAPACITY\",\n"
798798
+ " \"Nodes\" : [ ],\n"
799799
+ " \"Objects\" : [ ]\n"
800800
+ " }\n"
@@ -815,7 +815,7 @@ public void getCompletedJobJson() throws Exception {
815815
final Ds3Cli cli = new Ds3Cli(new Ds3ProviderImpl(client, null), args, null);
816816

817817
final CommandResponse result = cli.call();
818-
assertTrue(result.getMessage().endsWith(expected));
818+
assertThat(result.getMessage(), StringEndsWith.endsWith(expected));
819819
assertThat(result.getReturnCode(), is(0));
820820
}
821821

0 commit comments

Comments
 (0)