Skip to content
Merged
Show file tree
Hide file tree
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 @@ -175,14 +175,17 @@ public FilingInformation fromNode(JsonNode node, InfoCollector collector) throws
userEmail = users.get(0).getContactInfo().getEmail();
}
if (userEmail.isEmpty() || userEmail.orElse("").isBlank()) {
InterviewVariable var =
new InterviewVariable(
"users[0].email",
"Email is required for at least one user",
"text",
List.of(),
Optional.empty());
collector.addRequired(var);
var allowAnon = node.get("allow_anon_user");
if (allowAnon == null || !allowAnon.asBoolean()) {
InterviewVariable var =
new InterviewVariable(
"users[0].email",
"Email is required for at least one user",
"text",
List.of(),
Optional.empty());
collector.addRequired(var);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public record FileExtensionNotAllowed(String given, List<NameAndCode> allowed) i
public record FileNameTextError(TextVarError err) implements FileNameError {}

public sealed interface FilingDocError {}
public record DocTooBig(int idx) implements FilingDocError {}
public record CumulativeDocsTooBig(long cumulativeBytes) implements FilingDocError {}
public record DocTooBig(String docName, long docSize, long maxAllowed) implements FilingDocError {}
public record CumulativeDocsTooBig(long cumulativeBytes, long maxTotal) implements FilingDocError {}
// spotless:on

// Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ecf4.latest.gov.niem.niem.niem_core._2.DateType;
import ecf4.latest.gov.niem.niem.niem_core._2.EntityType;
import ecf4.latest.gov.niem.niem.niem_core._2.IdentificationType;
import ecf4.latest.gov.niem.niem.niem_core._2.MeasureType;
import ecf4.latest.gov.niem.niem.niem_core._2.TextType;
import ecf4.latest.gov.niem.niem.proxy.xsd._2.Date;
import ecf4.latest.oasis.names.tc.legalxml_courtfiling.schema.xsd.casequerymessage_4.CaseQueryMessageType;
Expand Down Expand Up @@ -46,6 +45,8 @@
import edu.suffolk.litlab.efsp.Jurisdiction;
import edu.suffolk.litlab.efsp.ecf4.QueryType;
import edu.suffolk.litlab.efsp.ecfcodes.CodesParser;
import edu.suffolk.litlab.efsp.ecfcodes.CodesParser.CumulativeDocsTooBig;
import edu.suffolk.litlab.efsp.ecfcodes.CodesParser.DocTooBig;
import edu.suffolk.litlab.efsp.ecfcodes.NameAndCode;
import edu.suffolk.litlab.efsp.model.CaseServiceContact;
import edu.suffolk.litlab.efsp.model.FilingDoc;
Expand Down Expand Up @@ -227,9 +228,6 @@ private CoreMessageAndNames prepareFiling(
maybeLocationInfo.orElse(new CourtLocationInfo(info.getCourtLocation(), false, false));
String courtName = locationInfo.name();

CourtPolicyResponseMessageType policy =
policyCacher.getPolicyFor(filingPort, info.getCourtLocation());

if (!locationInfo.allowfilingintononindexedcase()
&& info.getCaseDocketNumber().isPresent()
&& info.getPreviousCaseId().isEmpty()) {
Expand Down Expand Up @@ -417,31 +415,32 @@ private CoreMessageAndNames prepareFiling(
cfm.setSendingMDEProfileCode(Ecf4Helper.MDE_PROFILE_CODE);
cfm.setCase(assembledCase);

MeasureType maxIndivDocSize =
policy.getDevelopmentPolicyParameters().getValue().getMaximumAllowedAttachmentSize();
long maxSize = Ecf4Helper.sizeMeasureAsBytes(maxIndivDocSize);
long cumulativeBytes = 0;

Map<String, Object> filingIdToObj = new HashMap<>();
int seqNum = 0;
for (FilingDoc filingDoc : info.getFilings()) {
long bytes = filingDoc.allAttachmentsLength();
if (bytes > maxSize) {
var docSizeRes = parser.vetFilingDocSize(info.getFilings());
if (docSizeRes.isErr()) {
if (docSizeRes.expectErr("") instanceof DocTooBig tooBig) {
FilingError err =
FilingError.malformedInterview(
"Document "
+ filingDoc
.getDescription()
.map(d -> d.get())
.orElse(filingDoc.getFilingComments().orElse(""))
+ tooBig.docName()
+ " is too big! Must be max "
+ maxSize
+ tooBig.maxAllowed()
+ ", is "
+ bytes);
+ tooBig.docSize());
collector.error(err);
} else if (docSizeRes.expectErr("") instanceof CumulativeDocsTooBig tooBig) {
FilingError err =
FilingError.malformedInterview(
"All Documents combined are too big! Must be max"
+ tooBig.maxTotal()
+ ", are "
+ tooBig.cumulativeBytes());
collector.error(err);
}
cumulativeBytes += bytes;
}

Map<String, Object> filingIdToObj = new HashMap<>();
int seqNum = 0;
for (FilingDoc filingDoc : info.getFilings()) {
FilingCode fc = allCodes.filings().get(seqNum);

collector.pushAttributeStack("al_court_bundle[" + seqNum + "]");
Expand All @@ -458,18 +457,6 @@ private CoreMessageAndNames prepareFiling(
seqNum += 1;
log.info("Added a document to the XML");
}
MeasureType maxTotalDocSize =
policy.getDevelopmentPolicyParameters().getValue().getMaximumAllowedMessageSize();
long maxTotal = Ecf4Helper.sizeMeasureAsBytes(maxTotalDocSize);
if (cumulativeBytes > maxTotal) {
FilingError err =
FilingError.malformedInterview(
"All Documents combined are too big! Must be max"
+ maxSize
+ ", are "
+ cumulativeBytes);
collector.error(err);
}
EcfCaseTypeFactory.getCaseAugmentation(assembledCase.getValue())
.ifPresent(
aug -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public Response retrieveCategories(@PathParam("retrieve_name") String retrieveNa
* contain at least one case type that is matched by the term. Can be used to confirm that all of
* the expected courts you want to file in contain a case type that you can use.
*
* <p>Used primarly for exploration and gaining a better understanding of jurisdiction naming
* <p>Used primarily for exploration and gaining a better understanding of jurisdiction naming
* conventions. Likely shouldn't be used while a user is filing.
*/
@GET
Expand Down Expand Up @@ -373,14 +373,7 @@ public Response getCategoryByCode(String courtId, String catCode) throws SQLExce
@Override
public Response getCaseTypes(String courtId, String categoryId, String timing)
throws SQLException {
if (categoryId == null || categoryId.isBlank()) {
return cors(
Response.status(400)
.entity(
"\"You need to limit the number of case types by providing a category_id: see"
+ " /categories\""));
}

// It's okay if we don't filter by category id actually.
try (TFCodeDatabase cd = cdSupplier.get()) {
if (!cd.getAllLocations().contains(courtId)) {
return cors(Response.status(404).entity("\"Court " + courtId + " does not exist\""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import edu.suffolk.litlab.efsp.utils.FilingError;
import edu.suffolk.litlab.efsp.utils.InfoCollector;
import gov.niem.niem.niem_core._2.IdentificationType;
import gov.niem.niem.niem_core._2.MeasureType;
import gov.niem.niem.niem_core._2.TextType;
import imagesoft.ecf.wsdl.webservicesprofile_implementation_4_0.CourtRecordMDEService;
import imagesoft.ecf.wsdl.webservicesprofile_implementation_4_0.FilingReviewMDEService;
Expand Down Expand Up @@ -152,7 +151,6 @@ private CoreMessageAndNames prepareFiling(
try (TFCodeDatabase cd = cdSupplier.get()) {
String courtName = info.getCourtLocation();
EcfCaseTypeFactory ecfCaseFactory = new EcfCaseTypeFactory(cd, this.jurisdiction);
var policy = policyCacher.getPolicyFor(filingPort, info.getCourtLocation());
var maybeParser = getParser(info.getCourtLocation(), creds);
if (maybeParser.isEmpty()) {
collector.error(
Expand Down Expand Up @@ -202,33 +200,34 @@ private CoreMessageAndNames prepareFiling(
var leadContact = repairLeadContact(info.getLeadContact(), info);
cfm.setDocumentSubmitter(serializer.serializeNiemEntity(leadContact));

// filing lead documents
MeasureType maxIndivDocSize =
policy.getDevelopmentPolicyParameters().getMaximumAllowedAttachmentSize();
long maxSize = Ecf4Helper.sizeMeasureAsBytes(maxIndivDocSize);
long cumulativeBytes = 0;
/*
var docSizeRes = parser.vetFilingDocSize(info.getFilings());
if (docSizeRes.isErr()) {
if (docSizeRes.expectErr("") instanceof DocTooBig tooBig) {
FilingError err =
FilingError.malformedInterview(
"Document "
+ tooBig.docName()
+ " is too big! Must be max "
+ tooBig.maxAllowed()
+ ", is "
+ tooBig.docSize());
collector.error(err);
} else if (docSizeRes.expectErr("") instanceof CumulativeDocsTooBig tooBig) {
FilingError err =
FilingError.malformedInterview(
"All Documents combined are too big! Must be max"
+ tooBig.maxTotal()
+ ", are "
+ tooBig.cumulativeBytes());
collector.error(err);
}
}
*/

Map<String, Object> filingIdToObj = new HashMap<>();
int seqNum = 0;
for (FilingDoc filingDoc : info.getFilings()) {

long bytes = filingDoc.allAttachmentsLength();
if (bytes > maxSize) {
FilingError err =
FilingError.malformedInterview(
"Document "
+ filingDoc
.getDescription()
.map(d -> d.get())
.orElse(filingDoc.getFilingComments().orElse(""))
+ " is too big! Must be max "
+ maxSize
+ ", is "
+ bytes);
collector.error(err);
}
cumulativeBytes += bytes;

NameAndCode fc = allCodes.filings().get(seqNum);
collector.pushAttributeStack("al_court_bundle[" + seqNum + "]");
DocumentType result = serializer.filingDocToXml(filingDoc, fc);
Expand All @@ -239,18 +238,6 @@ private CoreMessageAndNames prepareFiling(
seqNum += 1;
log.info("Added a document to the XML");
}
MeasureType maxTotalDocSize =
policy.getDevelopmentPolicyParameters().getMaximumAllowedMessageSize();
long maxTotal = Ecf4Helper.sizeMeasureAsBytes(maxTotalDocSize);
if (cumulativeBytes > maxTotal) {
FilingError err =
FilingError.malformedInterview(
"All Documents combined are too big! Must be max"
+ maxSize
+ ", are "
+ cumulativeBytes);
collector.error(err);
}
log.info(
"Full cfm: {}",
Ecf4Helper.objectToXmlStrOrError(cfm, CoreFilingMessageType.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ INSERT INTO truefiling_casetype (
DELETE FROM truefiling_casetype WHERE jurisdiction=?
""";

public static PreparedStatement prepQuery(
Connection conn, String jurisdiction, String courtLocationId) throws SQLException {
String query =
"""
SELECT id, code, description, casecategory
FROM truefiling_casetype
WHERE jurisdiction=? AND location=?
""";
PreparedStatement st = conn.prepareStatement(query);
st.setString(1, jurisdiction);
st.setString(2, courtLocationId);
return st;
}

public static PreparedStatement prepQuery(
Connection conn, String jurisdiction, String courtLocationId, String caseCategoryCode)
throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,12 @@ public List<NameAndCode> getCaseTypeNamesFor(
return safetyWrap(
() -> {
// initial is ignored
PreparedStatement st =
CaseType.prepQuery(conn, jurisStr(), courtLocationId, caseCategoryCode);
PreparedStatement st;
if (caseCategoryCode == null || caseCategoryCode.isBlank()) {
st = CaseType.prepQuery(conn, jurisStr(), courtLocationId);
} else {
st = CaseType.prepQuery(conn, jurisStr(), courtLocationId, caseCategoryCode);
}
ResultSet rs = st.executeQuery();
List<NameAndCode> nacs = new ArrayList<>();
// TODO(bryce): can be more efficient, just grabbing the name and code and not all of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,16 @@ public Result<NullValue, FilingDocError> vetFilingDocSize(List<FilingDoc> docs)
var doc = docs.get(i);
long docSize = doc.allAttachmentsLength();
if (docSize > maxEach) {
return Result.err(new DocTooBig(i));
var docName =
doc.getDescription().map(d -> d.get()).orElse(doc.getFilingComments().orElse(""));
return Result.err(new DocTooBig(docName, docSize, maxEach));
}
cumulativeBytes += docSize;
}
MeasureType maxTotalDocSize = policy.getMaximumAllowedMessageSize();
long maxTotal = Ecf4Helper.sizeMeasureAsBytes(maxTotalDocSize);
if (cumulativeBytes > maxTotal) {
return Result.err(new CumulativeDocsTooBig(cumulativeBytes));
return Result.err(new CumulativeDocsTooBig(cumulativeBytes, maxTotal));
}
return Result.nullOk();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,16 @@ public Result<NullValue, FilingDocError> vetFilingDocSize(List<FilingDoc> docs)
var doc = docs.get(i);
long docSize = doc.allAttachmentsLength();
if (docSize > maxEach) {
return Result.err(new DocTooBig(i));
var docName =
doc.getDescription().map(d -> d.get()).orElse(doc.getFilingComments().orElse(""));
return Result.err(new DocTooBig(docName, docSize, maxEach));
}
cumulativeBytes += docSize;
}
MeasureType maxTotalDocSize = policy.getMaximumAllowedMessageSize();
long maxTotal = Ecf4Helper.sizeMeasureAsBytes(maxTotalDocSize);
if (cumulativeBytes > maxTotal) {
return Result.err(new CumulativeDocsTooBig(cumulativeBytes));
return Result.err(new CumulativeDocsTooBig(cumulativeBytes, maxTotal));
}
return Result.nullOk();
}
Expand Down
Loading