Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,31 +273,17 @@ private static Optional<FilingAttachment> getAttachment(
CodesParser parser,
InfoCollector collector)
throws FilingError {
String documentTypeFormatName = getStringDefault(node, "document_type", "");
var documentTypeRes = parser.vetDocType(documentTypeFormatName, filingCode);
var documentBuilder = collector.varBuilder().name("document_type");
if (documentTypeRes.isErr()) {
var documentVar = collector.addCodeError(documentTypeRes.expectErr(""), documentBuilder);
throw FilingError.wrongValue(documentVar);
Optional<String> maybeFilename = getStringMember(node, "filename");
String fileName = maybeFilename.orElse("");
if (!fileName.endsWith(".pdf")) {
fileName += ".pdf";
}
var documentType = documentTypeRes.expect("");

String filingComponentCode = getStringDefault(node, "filing_component", "");
var componentRes = parser.vetFilingComponent(filingComponentCode, components);
var componentBuilder =
collector
.varBuilder()
.name("filing_component")
.description("Filing component: Lead or attachment");
if (componentRes.isErr()) {
var componentVar = collector.addCodeError(componentRes.expectErr(""), componentBuilder);
// I don't care, throw.
throw FilingError.wrongValue(componentVar);
// Check proxy_enabled asap
if (!node.has("proxy_enabled") || !node.get("proxy_enabled").asBoolean(false)) {
log.info("{} isn't proxy enabled", fileName);
return Optional.empty();
}
// TODO: use this default fallback?
// new FilingComponent("NO CODE", "NOT PRESENT", "", false, false, 0, "", "");
var filingComponent = componentRes.expect("");
Optional<String> maybeFilename = getStringMember(node, "filename");

var nameBuilder =
collector
.varBuilder()
Expand All @@ -307,10 +293,6 @@ private static Optional<FilingAttachment> getAttachment(
if (maybeFilename.isEmpty()) {
collector.addRequired(nameBuilder.build());
}
String fileName = maybeFilename.orElse("");
if (!fileName.endsWith(".pdf")) {
fileName += ".pdf";
}
var filenameRes = parser.vetFileName(fileName);
if (filenameRes.isErr()) {
switch (filenameRes.expectErr("")) {
Expand All @@ -326,10 +308,30 @@ private static Optional<FilingAttachment> getAttachment(
}

String documentDescription = getStringDefault(node, "document_description", fileName);
if (!node.has("proxy_enabled") || !node.get("proxy_enabled").asBoolean(false)) {
log.info("{} isn't proxy enabled", fileName);
return Optional.empty();
String documentTypeFormatName = getStringDefault(node, "document_type", "");
var documentTypeRes = parser.vetDocType(documentTypeFormatName, filingCode);
var documentBuilder = collector.varBuilder().name("document_type");
if (documentTypeRes.isErr()) {
var documentVar = collector.addCodeError(documentTypeRes.expectErr(""), documentBuilder);
throw FilingError.wrongValue(documentVar);
}
var documentType = documentTypeRes.expect("");

String filingComponentCode = getStringDefault(node, "filing_component", "");
var componentRes = parser.vetFilingComponent(filingComponentCode, components);
var componentBuilder =
collector
.varBuilder()
.name("filing_component")
.description("Filing component: Lead or attachment");
if (componentRes.isErr()) {
var componentVar = collector.addCodeError(componentRes.expectErr(""), componentBuilder);
// I don't care, throw.
throw FilingError.wrongValue(componentVar);
}
// TODO: use this default fallback?
// new FilingComponent("NO CODE", "NOT PRESENT", "", false, false, 0, "", "");
var filingComponent = componentRes.expect("");

if (!node.has("data_url")
|| !node.get("data_url").isTextual()
Expand Down
Loading