func getScanConfiguration(a httpRequestArgs) (*scanConfigImpl, errors.Error) { scan_consistency_field, err := a.getString(SCAN_CONSISTENCY, "NOT_BOUNDED") if err != nil { return nil, err } scan_level := newScanConsistency(scan_consistency_field) if scan_level == server.UNDEFINED_CONSISTENCY { return nil, errors.NewServiceErrorUnrecognizedValue(SCAN_CONSISTENCY, scan_consistency_field) } scan_wait, err := a.getDuration(SCAN_WAIT) if err != nil { return nil, err } scan_vector, err := a.getScanVector() if err != nil { return nil, err } scan_vectors, err := a.getScanVectors() if err != nil { return nil, err } var scan_vector_source timestamp.ScanVectorSource if scan_vector == nil { if scan_vectors == nil { if scan_level == server.AT_PLUS && scan_vector == nil && scan_vectors == nil { return nil, errors.NewServiceErrorMissingValue(SCAN_VECTOR) } scan_vector_source = &ZeroScanVectorSource{} } else { defaultNamespace, err := a.getString(NAMESPACE, "default") if err != nil { return nil, err } scan_vector_source = newMultipleScanVectorSource(defaultNamespace, scan_vectors) } } else { if scan_vectors == nil { scan_vector_source = &singleScanVectorSource{scan_vector: scan_vector} } else { // Not both scan_vector and scan_vectors. return nil, errors.NewServiceErrorMultipleValues("scan_vector and scan_vectors") } } return &scanConfigImpl{ scan_level: scan_level, scan_wait: scan_wait, scan_vector_source: scan_vector_source, }, nil }
func (this *urlArgs) formValue(field string) (string, errors.Error) { values := this.getField(field) switch len(values) { case 0: return "", nil case 1: return values[0], nil default: return "", errors.NewServiceErrorMultipleValues(field) } }