[OLINGO-832] Minor change for PoC demo

This commit is contained in:
Michael Bolz 2016-01-25 14:43:24 +01:00
parent c02215e2ef
commit 44e1b02633
1 changed files with 27 additions and 5 deletions

View File

@ -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);