/** * Reserved for internal use. Generates a <code>String</code> containing the entity associated with an operation in * Json format. * * @param operation * A {@link TableOperation} containing the entity to write to the returned <code>String</code>. * @param opContext * An {@link OperationContext} object for tracking the current operation. Specify <code>null</code> to * safely ignore operation context. * @return * A <code>String</code> containing the entity associated with the operation in Json format * @throws StorageException * if a Storage error occurs. * @throws IOException */ private static String writeStringForOperation(final TableOperation operation, TablePayloadFormat format, final OperationContext opContext) throws StorageException, IOException { Utility.assertNotNull("entity", operation.getEntity()); final StringWriter outWriter = new StringWriter(); TableEntitySerializer.writeSingleEntity(outWriter, operation.getEntity(), false, opContext); outWriter.write("\r\n"); return outWriter.toString(); }
/** * Reserved for internal use. Generates a <code>String</code> containing the entity associated with an operation in * Json format. * * @param operation * A {@link TableOperation} containing the entity to write to the returned <code>String</code>. * @param options * The {@link TableRequestOptions} to use for serializing. * @param opContext * An {@link OperationContext} object for tracking the current operation. Specify <code>null</code> to * safely ignore operation context. * @return * A <code>String</code> containing the entity associated with the operation in Json format * @throws StorageException * if a Storage error occurs. * @throws IOException */ private static String writeStringForOperation(final TableOperation operation, final TableRequestOptions options, final OperationContext opContext) throws StorageException, IOException { Utility.assertNotNull("entity", operation.getEntity()); final StringWriter outWriter = new StringWriter(); TableEntitySerializer.writeSingleEntityToString(outWriter, options, operation.getEntity(), false, opContext); outWriter.write("\r\n"); return outWriter.toString(); }
throws StorageException { final boolean isTableEntry = TableConstants.TABLES_SERVICE_TABLES_NAME.equals(tableName); final String tableIdentity = isTableEntry ? this.getEntity().writeEntity(opContext) .get(TableConstants.TABLE_NAME).getValueAsString() : null; Utility.assertNotNullOrEmpty(SR.ETAG_INVALID_FOR_DELETE, this.getEntity().getEtag()); Utility.assertNotNull(SR.PARTITIONKEY_MISSING_FOR_DELETE, this.getEntity().getPartitionKey()); Utility.assertNotNull(SR.ROWKEY_MISSING_FOR_DELETE, this.getEntity().getRowKey());
/** * Adds the collection of table operations to the batch operation <code>ArrayList</code>. * * @param c * A <code>java.util.Collection</code> of {@link TableOperation} objects to add to the batch operation. * @return * <code>true</code> if the operations were added successfully. */ @Override public boolean addAll(final java.util.Collection<? extends TableOperation> c) { int size = this.size(); for (final TableOperation operation : c) { Utility.assertNotNull("operation", operation); this.checkSingleQueryPerBatch(operation, size); if (operation.getEntity() == null) { // Query operation this.lockToPartitionKey(((QueryTableOperation) operation).getPartitionKey()); } else { this.lockToPartitionKey(operation.getEntity().getPartitionKey()); } size++; } return super.addAll(c); }
/** * Adds the collection of table operations to the batch operation <code>ArrayList</code>. * * @param c * A <code>java.util.Collection</code> of {@link TableOperation} objects to add to the batch operation. * @return * <code>true</code> if the operations were added successfully. */ @Override public boolean addAll(final java.util.Collection<? extends TableOperation> c) { int size = this.size(); for (final TableOperation operation : c) { Utility.assertNotNull("operation", operation); this.checkSingleQueryPerBatch(operation, size); if (operation.getEntity() == null) { // Query operation this.lockToPartitionKey(((QueryTableOperation) operation).getPartitionKey()); } else { this.lockToPartitionKey(operation.getEntity().getPartitionKey()); } size++; } return super.addAll(c); }
/** * Adds the collection of table operations to the batch operation <code>ArrayList</code> starting at the specified * index. * * @param index * An <code>int</code> which represents the index in the batch operation <code>ArrayList</code> to add * the table operation at. * @param c * A <code>java.util.Collection</code> of {@link TableOperation} objects to add to the batch operation. * @return * <code>true</code> if the operations were added successfully. */ @Override public boolean addAll(final int index, final java.util.Collection<? extends TableOperation> c) { int size = this.size(); for (final TableOperation operation : c) { Utility.assertNotNull("operation", operation); this.checkSingleQueryPerBatch(operation, size); if (operation.getEntity() == null) { // Query operation this.lockToPartitionKey(((QueryTableOperation) operation).getPartitionKey()); } else { this.lockToPartitionKey(operation.getEntity().getPartitionKey()); } size++; } return super.addAll(index, c); }
/** * Adds the collection of table operations to the batch operation <code>ArrayList</code> starting at the specified * index. * * @param index * An <code>int</code> which represents the index in the batch operation <code>ArrayList</code> to add * the table operation at. * @param c * A <code>java.util.Collection</code> of {@link TableOperation} objects to add to the batch operation. * @return * <code>true</code> if the operations were added successfully. */ @Override public boolean addAll(final int index, final java.util.Collection<? extends TableOperation> c) { int size = this.size(); for (final TableOperation operation : c) { Utility.assertNotNull("operation", operation); this.checkSingleQueryPerBatch(operation, size); if (operation.getEntity() == null) { // Query operation this.lockToPartitionKey(((QueryTableOperation) operation).getPartitionKey()); } else { this.lockToPartitionKey(operation.getEntity().getPartitionKey()); } size++; } return super.addAll(index, c); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { this.setSendStream(new ByteArrayInputStream(entityBytes)); this.setLength((long) entityBytes.length); return TableRequest.merge(client.getTransformedEndPoint(opContext) .getUri(this.getCurrentLocation()), options, null, opContext, tableName, generateRequestIdentity(false, null), operation.getEntity().getEtag()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { this.setSendStream(new ByteArrayInputStream(entityBytes)); this.setLength((long) entityBytes.length); return TableRequest.update( client.getTransformedEndPoint(context).getUri(this.getCurrentLocation()), options, null, context, tableName, generateRequestIdentity(false, null), operation.getEntity() .getEtag()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { this.setSendStream(new ByteArrayInputStream(entityBytes)); this.setLength((long) entityBytes.length); return TableRequest.merge(client.getTransformedEndPoint(opContext) .getUri(this.getCurrentLocation()), options, null, opContext, tableName, generateRequestIdentity(false, null), operation.getEntity().getEtag()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { return TableRequest.delete(client.getTransformedEndPoint(context).getUri(this.getCurrentLocation()), options, null, context, tableName, generateRequestIdentity(isTableEntry, tableIdentity), operation.getEntity().getEtag()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { this.setSendStream(new ByteArrayInputStream(entityBytes)); this.setLength((long) entityBytes.length); return TableRequest.update( client.getTransformedEndPoint(context).getUri(this.getCurrentLocation()), options, null, context, tableName, generateRequestIdentity(false, null), operation.getEntity() .getEtag()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { return TableRequest.delete(client.getTransformedEndPoint(context).getUri(this.getCurrentLocation()), options, null, context, tableName, generateRequestIdentity(isTableEntry, tableIdentity), operation.getEntity().getEtag()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { this.setSendStream(new ByteArrayInputStream(entityBytes)); this.setLength((long) entityBytes.length); return TableRequest.insert( client.getTransformedEndPoint(opContext).getUri(this.getCurrentLocation()), options, null, opContext, tableName, generateRequestIdentity(isTableEntry, tableIdentity), operation.opType != TableOperationType.INSERT ? operation.getEntity().getEtag() : null, operation.getEchoContent(), operation.opType.getUpdateType()); }
@Override public HttpURLConnection buildRequest(CloudTableClient client, TableOperation operation, OperationContext context) throws Exception { this.setSendStream(new ByteArrayInputStream(entityBytes)); this.setLength((long) entityBytes.length); return TableRequest.insert( client.getTransformedEndPoint(opContext).getUri(this.getCurrentLocation()), options, null, opContext, tableName, generateRequestIdentity(isTableEntry, tableIdentity), operation.opType != TableOperationType.INSERT ? operation.getEntity().getEtag() : null, operation.getEchoContent(), operation.opType.getUpdateType()); }
/** * Adds the table operation at the specified index in the batch operation <code>ArrayList</code>. * * @param index * An <code>int</code> which represents the index in the batch operation <code>ArrayList</code> to add * the table operation at. * @param element * The {@link TableOperation} to add to the batch operation. */ @Override public void add(final int index, final TableOperation element) { Utility.assertNotNull("element", element); this.checkSingleQueryPerBatch(element, this.size()); if (element.getOperationType() == TableOperationType.RETRIEVE) { this.lockToPartitionKey(((QueryTableOperation) element).getPartitionKey()); } else { this.lockToPartitionKey(element.getEntity().getPartitionKey()); } super.add(index, element); }
/** * Adds the table operation to the batch operation <code>ArrayList</code>. * * @param element * The {@link TableOperation} to add to the batch operation. * @return * <code>true</code> if the operation was added successfully. */ @Override public boolean add(final TableOperation element) { Utility.assertNotNull("element", element); this.checkSingleQueryPerBatch(element, this.size()); if (element.getOperationType() == TableOperationType.RETRIEVE) { // Query operation this.lockToPartitionKey(((QueryTableOperation) element).getPartitionKey()); } else { this.lockToPartitionKey(element.getEntity().getPartitionKey()); } return super.add(element); }
/** * Adds the table operation to the batch operation <code>ArrayList</code>. * * @param element * The {@link TableOperation} to add to the batch operation. * @return * <code>true</code> if the operation was added successfully. */ @Override public boolean add(final TableOperation element) { Utility.assertNotNull("element", element); this.checkSingleQueryPerBatch(element, this.size()); if (element.getOperationType() == TableOperationType.RETRIEVE) { // Query operation this.lockToPartitionKey(((QueryTableOperation) element).getPartitionKey()); } else { this.lockToPartitionKey(element.getEntity().getPartitionKey()); } return super.add(element); }
/** * Adds the table operation at the specified index in the batch operation <code>ArrayList</code>. * * @param index * An <code>int</code> which represents the index in the batch operation <code>ArrayList</code> to add * the table operation at. * @param element * The {@link TableOperation} to add to the batch operation. */ @Override public void add(final int index, final TableOperation element) { Utility.assertNotNull("element", element); this.checkSingleQueryPerBatch(element, this.size()); if (element.getOperationType() == TableOperationType.RETRIEVE) { this.lockToPartitionKey(((QueryTableOperation) element).getPartitionKey()); } else { this.lockToPartitionKey(element.getEntity().getPartitionKey()); } super.add(index, element); }