fix parsing of batch scripts from REST
@@ -36,21 +36,10 @@ import java.util.stream.Collectors;
/**
* Executes a batch of operations in a single call. This is useful to reduce network latency issuing multiple commands as multiple
- * requests. Batch command supports transactions as well.<br>
- * <br>
- * Format: { "transaction" : &lt;true|false&gt;, "operations" : [ { "type" : "&lt;type&gt;" }* ] }<br>
- * Where:
- * <ul>
- * <li><b>type</b> can be:
- * <ul>
- * <li>'c' for create</li>
- * <li>'u' for update</li>
- * <li>'d' for delete. The '@rid' field only is needed.</li>
- * </ul>
- * </li>
- * </ul>
- * Example:<br>
- *
+ * requests. Batch command supports transactions as well.<br> <br> Format: { "transaction" : &lt;true|false&gt;, "operations" : [ {
+ * "type" : "&lt;type&gt;" }* ] }<br> Where: <ul> <li><b>type</b> can be: <ul> <li>'c' for create</li> <li>'u' for update</li>
+ * <li>'d' for delete. The '@rid' field only is needed.</li> </ul> </li> </ul> Example:<br>
+ * <p>
* <pre>
* { "transaction" : true,
* "operations" : [
@@ -75,7 +64,6 @@ import java.util.stream.Collectors;
* </pre>
*
* @author Luca Garulli (l.garulli--(at)--orientdb.com)
- *
*/
public class OServerCommandPostBatch extends OServerCommandDocumentAbstract {
private static final String[] NAMES = { "POST|batch/*" };
@@ -97,8 +85,8 @@ public class OServerCommandPostBatch extends OServerCommandDocumentAbstract {
if (db.getTransaction().isActive()) {
// TEMPORARY PATCH TO UNDERSTAND WHY UNDER HIGH LOAD TX IS NOT COMMITTED AFTER BATCH. MAYBE A PENDING TRANSACTION?
- OLogManager.instance().warn(this,
- "Found database instance from the pool with a pending transaction. Forcing rollback before using it");
+ OLogManager.instance()
+ .warn(this, "Found database instance from the pool with a pending transaction. Forcing rollback before using it");
db.rollback(true);
}
@@ -184,8 +172,12 @@ public class OServerCommandPostBatch extends OServerCommandDocumentAbstract {
int i = 0;
for (Object o : OMultiValue.getMultiValueIterable(script)) {
if (o != null) {
- if (i++ > 0)
+ if (i++ > 0) {
+ if (!text.toString().trim().endsWith(";")) {
+ text.append(";");
+ }
text.append("\n");
+ }
text.append(o.toString());
}
}
