private VespaXMLFeedReader.Operation createUpdateOperation(HttpRequest request, String id, String condition, Optional<Boolean> create) { final VespaXMLFeedReader.Operation operationUpdate = singleDocumentParser.parseUpdate(request.getData(), id); if (condition != null && ! condition.isEmpty()) { operationUpdate.getDocumentUpdate().setCondition(new TestAndSetCondition(condition)); } create.ifPresent(c -> operationUpdate.getDocumentUpdate().setCreateIfNonExistent(c)); return operationUpdate; }
public static DocumentUpdate execute(Expression expression, AdapterFactory factory, DocumentUpdate update) { DocumentUpdate ret = null; for (UpdateAdapter adapter : factory.newUpdateAdapterList(update)) { DocumentUpdate output = adapter.getExpression(expression).execute(adapter); if (output == null) { // ignore } else if (ret != null) { ret.addAll(output); } else { ret = output; } } if (ret != null) { ret.setCreateIfNonExistent(update.getCreateIfNonExistent()); } return ret; }
} else if ("create-if-non-existent".equals(attributeName)) { if ("true".equals(attributeValue)) { update.setCreateIfNonExistent(true); } else if ("false".equals(attributeValue)) { update.setCreateIfNonExistent(false); } else { throw newDeserializeException("'create-if-non-existent' must be either 'true' or 'false', was '" + attributeValue +"'");
update.setCreateIfNonExistent(documentParseInfo.create.get());
public void read(DocumentUpdate update) { update.setId(new DocumentId(this)); update.setDocumentType(readDocumentType()); int size = getInt(null); for (int i = 0; i < size; i++) { update.addFieldUpdate(new FieldUpdate(this, update.getDocumentType(), 8)); } int sizeAndFlags = getInt(null); update.setCreateIfNonExistent(DocumentUpdateFlags.extractFlags(sizeAndFlags).getCreateIfNonExistent()); size = DocumentUpdateFlags.extractValue(sizeAndFlags); for (int i = 0; i < size; i++) { int type = getByte(null); update.addFieldPathUpdate(FieldPathUpdate.create(FieldPathUpdate.Type.valueOf(type), update.getDocumentType(), this)); } }