From 44e1b02633380e7262ab8985de5c455ee615073c Mon Sep 17 00:00:00 2001 From: Michael Bolz Date: Mon, 25 Jan 2016 14:43:24 +0100 Subject: [PATCH] [OLINGO-832] Minor change for PoC demo --- .../processor/TechnicalEntityProcessor.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java index f4c81c182..dc7f0b794 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java @@ -567,12 +567,11 @@ public class TechnicalEntityProcessor extends TechnicalProcessor @Override public Entity next() { Entity next = entityIterator.next(); - replacePrimitiveProperty(next, "PropertyString", generateData(28192)); -// next.getProperties().remove(1); +// replacePrimitiveProperty(next, "PropertyString", generateData(28192)); + replacePrimitiveProperty(next, "PropertyString", generateData(request)); // next.addProperty(new Property(null, "PropertyString", ValueType.PRIMITIVE, generateData(28192))); - try { - TimeUnit.MILLISECONDS.sleep(2500); - } catch (InterruptedException e) { } + + sleep(request, 2500); return next; } @@ -594,6 +593,29 @@ public class TechnicalEntityProcessor extends TechnicalProcessor } } + private void sleep(ODataRequest request, int defaultTimeMs) { + String sleepTimeMs = request.getHeader("StreamSleep"); + if(sleepTimeMs != null) { + try { + defaultTimeMs = Integer.parseInt(sleepTimeMs); + } catch (NumberFormatException e) { } + } + try { + TimeUnit.MILLISECONDS.sleep(defaultTimeMs); + } catch (InterruptedException e) { } + + } + + private String generateData(ODataRequest request) { + String streamHeader = request.getHeader("StreamData"); + if(streamHeader != null) { + try { + return generateData(Integer.parseInt(streamHeader)); + } catch (NumberFormatException e) { } + } + return generateData(28192); + } + private String generateData(final int len) { Random random = new Random(); StringBuilder b = new StringBuilder(len);