Skip to content

Commit

Permalink
Exit 1 when exception is caught
Browse files Browse the repository at this point in the history
- Also, use the more specific Lombok annotations, instead of @DaTa
  • Loading branch information
cfryanr committed Jun 1, 2020
1 parent 214dfe4 commit 198758f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/main/java/rr/hikvisiondownloadassistant/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void main(String[] commandLineArguments) {
run(commandLineArguments);
} catch (Exception e) {
System.err.println("ERROR: " + e.getMessage());
System.exit(1);
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/rr/hikvisiondownloadassistant/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;
Expand All @@ -15,9 +15,9 @@ public class Model {
public static final int VIDEOS_TRACK_ID = 101;
public static final int PHOTOS_TRACK_ID = 103;

@Data
@NoArgsConstructor
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class CMSearchDescription {
@Builder.Default
Expand All @@ -39,7 +39,7 @@ public static class CMSearchDescription {
private List<TimeSpan> timeSpan;
}

@Data
@Getter
@NoArgsConstructor
public static class CMSearchResult {
private String version; // e.g. 2.0
Expand All @@ -50,7 +50,7 @@ public static class CMSearchResult {
private List<SearchMatchItem> matchList;
}

@Data
@Getter
@NoArgsConstructor
public static class SearchMatchItem {
private String sourceID; // e.g. {0000000000-0000-0000-0000-000000000000}
Expand All @@ -60,16 +60,16 @@ public static class SearchMatchItem {
private Metadata metadataMatches;
}

@Data
@NoArgsConstructor
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class TimeSpan {
private String startTime; // e.g. 2020-05-29T04:57:49Z
private String endTime; // e.g. 2020-05-29T04:58:05Z
}

@Data
@Getter
@NoArgsConstructor
public static class MediaSegmentDescriptor {
private String contentType; // e.g. video or picture
Expand All @@ -81,9 +81,9 @@ public static class MediaSegmentDescriptor {
private String playbackURI;
}

@Data
@NoArgsConstructor
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class Metadata {
private String metadataDescriptor; // e.g. recordType.meta.hikvision.com/AllEvent
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/rr/hikvisiondownloadassistant/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.joestelmach.natty.DateGroup;
import com.joestelmach.natty.Parser;
import lombok.AccessLevel;
import lombok.Getter;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
Expand All @@ -13,6 +12,8 @@
import java.util.Date;
import java.util.List;

import static lombok.AccessLevel.PRIVATE;

@Getter
@Command(
name = "java -jar hikvision-download-assistant.jar",
Expand Down Expand Up @@ -45,15 +46,15 @@ public class Options {
defaultValue = "24 hours ago",
description = "Search starting from this time, entered using English natural language. Defaults to '${DEFAULT-VALUE}'."
)
@Getter(value = AccessLevel.PRIVATE)
@Getter(value = PRIVATE)
private String fromTime;

@Option(
names = {"-t", "--to-time"},
defaultValue = "now",
description = "Search up to this time, entered using English natural language. Defaults to '${DEFAULT-VALUE}'."
)
@Getter(value = AccessLevel.PRIVATE)
@Getter(value = PRIVATE)
private String toTime;

@Option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import rr.hikvisiondownloadassistant.Model.SearchMatchItem;
Expand All @@ -15,6 +13,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static lombok.AccessLevel.PRIVATE;
import static rr.hikvisiondownloadassistant.DateConverter.*;

@RequiredArgsConstructor
Expand Down Expand Up @@ -78,10 +77,11 @@ private List<OutputRow> convertToOutputRows(MediaType mediaType, List<SearchMatc
).collect(Collectors.toList());
}

@Data
@Getter
@RequiredArgsConstructor
private class OutputRow {

@Getter(value = AccessLevel.PRIVATE)
@Getter(value = PRIVATE)
private final SearchMatchItem item;

private final MediaType mediaType;
Expand Down

0 comments on commit 198758f

Please sign in to comment.