result = false; } else if (parkingRequestFactory.getSecondCarPlateNumber().length() > 10) { actionMessages.add("secondCarPlateNumberPT", new ActionMessage( "error.maxLengthExceeded", "10"));
    private boolean checkRequestFields(ParkingRequestFactory parkingRequestFactory,            HttpServletRequest request, DynaActionForm parkingForm) {        final boolean isStudent = isStudent(SessionUtils.getUserView(request));        ActionMessages actionMessages = new ActionMessages();        boolean result = true;        if (parkingRequestFactory.getFirstCarMake() == null                || parkingRequestFactory.getFirstCarMake().trim().length() == 0) {            actionMessages.add("firstCarMakePT", new ActionMessage("error.requiredField"));            result = false;        }        if (parkingRequestFactory.getFirstCarPlateNumber() == null                || parkingRequestFactory.getFirstCarPlateNumber().trim().length() == 0) {            actionMessages.add("firstCarPlateNumberPT", new ActionMessage("error.requiredField"));            result = false;        }        if (hasNotDeliveryValue(parkingForm, "driverLicense")) {            actionMessages.add("driverLicenseDeliveryMessage", new ActionMessage(                    "error.requiredDocumentDelivery"));            result = false;        } else if ((isStudent || isElectronicDelivery(parkingForm, "driverLicense"))                && (parkingRequestFactory.getDriverLicenseFileName() == null || parkingRequestFactory                        .getDriverLicenseFileName().length() == 0)) {            actionMessages.add("driverLicenseMessage", new ActionMessage("error.requiredStudentField"));            parkingForm.set("driverLicense", ParkingDocumentState.ELECTRONIC_DELIVERY.name());            result = false;        }        // FirstCar        if (hasNotDeliveryValue(parkingForm, "registry1")) {            actionMessages.add("firstCarPropertyRegistryDeliveryMessage", new ActionMessage(                    "error.requiredDocumentDelivery"));            result = false;        } else if ((isStudent || isElectronicDelivery(parkingForm, "registry1"))                && (parkingRequestFactory.getFirstCarPropertyRegistryFileName() == null || parkingRequestFactory                        .getFirstCarPropertyRegistryFileName().length() == 0)) {            actionMessages.add("firstCarPropertyRegistryMessage", new ActionMessage(                    "error.requiredStudentField"));            parkingForm.set("registry1", ParkingDocumentState.ELECTRONIC_DELIVERY.name());            result = false;        }        if (hasNotDeliveryValue(parkingForm, "insurance1")) {            actionMessages.add("firstInsuranceDeliveryMessage", new ActionMessage(                    "error.requiredDocumentDelivery"));            result = false;        } else if ((isStudent || isElectronicDelivery(parkingForm, "insurance1"))                && (parkingRequestFactory.getFirstInsuranceFileName() == null || parkingRequestFactory                        .getFirstInsuranceFileName().length() == 0)) {            actionMessages.add("firstInsuranceMessage", new ActionMessage("error.requiredStudentField"));            parkingForm.set("insurance1", ParkingDocumentState.ELECTRONIC_DELIVERY.name());            result = false;        }        if (!isOwner(parkingForm, "ownVehicle1")) {            parkingForm.set("ownVehicle1", false);            if (hasNotDeliveryValue(parkingForm, "Id1")) {                actionMessages.add("firstCarOwnerIdDeliveryMessage", new ActionMessage(                        "error.requiredDocumentDelivery"));                result = false;            } else if ((isStudent || isElectronicDelivery(parkingForm, "Id1"))                    && (parkingRequestFactory.getFirstCarOwnerIdFileName() == null || parkingRequestFactory                            .getFirstCarOwnerIdFileName().length() == 0)) {                actionMessages.add("firstCarOwnerIdMessage", new ActionMessage(                        "error.requiredStudentField"));                parkingForm.set("Id1", ParkingDocumentState.ELECTRONIC_DELIVERY.name());                result = false;            }            if (hasNotDeliveryValue(parkingForm, "declaration1")) {                actionMessages.add("firstDeclarationAuthorizationDeliveryMessage", new ActionMessage(                        "error.requiredDocumentDelivery"));                result = false;            } else if ((isStudent || isElectronicDelivery(parkingForm, "declaration1"))                    && (parkingRequestFactory.getFirstDeclarationAuthorizationFileName() == null || parkingRequestFactory                            .getFirstDeclarationAuthorizationFileName().length() == 0)) {                actionMessages.add("firstDeclarationAuthorizationMessage", new ActionMessage(                        "error.requiredStudentField"));                parkingForm.set("declaration1", ParkingDocumentState.ELECTRONIC_DELIVERY.name());                result = false;            }        }        // SecondCar        if (isOwner(parkingForm, "vehicle2")) {            if ((parkingRequestFactory.getSecondCarMake() != null && parkingRequestFactory                    .getSecondCarMake().trim().length() != 0)                    || (parkingRequestFactory.getSecondCarPlateNumber() != null && parkingRequestFactory                            .getSecondCarPlateNumber().trim().length() != 0)) {                if (parkingRequestFactory.getSecondCarMake() == null                        || parkingRequestFactory.getSecondCarMake().trim().length() == 0) {                    actionMessages.add("secondCarMakePT", new ActionMessage("error.requiredField"));                    result = false;                }                if (parkingRequestFactory.getSecondCarPlateNumber() == null                        || parkingRequestFactory.getSecondCarPlateNumber().trim().length() == 0) {                    actionMessages.add("secondCarPlateNumberPT",                            new ActionMessage("error.requiredField"));                    result = false;                }                if (hasNotDeliveryValue(parkingForm, "registry2")) {                    actionMessages.add("secondCarPropertyRegistryDeliveryMessage", new ActionMessage(                            "error.requiredDocumentDelivery"));                    result = false;                } else if ((isStudent || isElectronicDelivery(parkingForm, "registry2"))                        && (parkingRequestFactory.getSecondCarPropertyRegistryFileName() == null || parkingRequestFactory                                .getSecondCarPropertyRegistryFileName().length() == 0)) {                    actionMessages.add("secondCarPropertyRegistryMessage", new ActionMessage(                            "error.requiredStudentField"));                    parkingForm.set("registry2", ParkingDocumentState.ELECTRONIC_DELIVERY.name());                    result = false;                }                if (hasNotDeliveryValue(parkingForm, "insurance2")) {                    actionMessages.add("secondInsuranceDeliveryMessage", new ActionMessage(                            "error.requiredDocumentDelivery"));                    result = false;                } else if ((isStudent || isElectronicDelivery(parkingForm, "insurance2"))                        && (parkingRequestFactory.getSecondInsuranceFileName() == null || parkingRequestFactory                                .getSecondInsuranceFileName().length() == 0)) {                    actionMessages.add("secondInsuranceMessage", new ActionMessage(                            "error.requiredStudentField"));                    parkingForm.set("insurance2", ParkingDocumentState.ELECTRONIC_DELIVERY.name());                    result = false;                }                if (!isOwner(parkingForm, "ownVehicle2")) {                    parkingForm.set("ownVehicle2", false);                    if (hasNotDeliveryValue(parkingForm, "Id2")) {                        actionMessages.add("secondCarOwnerIdDeliveryMessage", new ActionMessage(                                "error.requiredDocumentDelivery"));                        result = false;                    } else if ((isStudent || isElectronicDelivery(parkingForm, "Id2"))                            && (parkingRequestFactory.getSecondCarOwnerIdFileName() == null || parkingRequestFactory                                    .getSecondCarOwnerIdFileName().length() == 0)) {                        actionMessages.add("secondCarOwnerIdMessage", new ActionMessage(                                "error.requiredStudentField"));                        parkingForm.set("Id2", ParkingDocumentState.ELECTRONIC_DELIVERY.name());                        result = false;                    }                    if (hasNotDeliveryValue(parkingForm, "declaration2")) {                        actionMessages.add("secondDeclarationAuthorizationDeliveryMessage",                                new ActionMessage("error.requiredDocumentDelivery"));                        result = false;                    } else if ((isStudent || isElectronicDelivery(parkingForm, "declaration2"))                            && (parkingRequestFactory.getSecondDeclarationAuthorizationFileName() == null || parkingRequestFactory                                    .getSecondDeclarationAuthorizationFileName().length() == 0)) {                        actionMessages.add("secondDeclarationAuthorizationMessage", new ActionMessage(                                "error.requiredStudentField"));                        parkingForm.set("declaration2", ParkingDocumentState.ELECTRONIC_DELIVERY.name());                        result = false;                    }                }            }        }        saveMessages(request, actionMessages);        return result;    }