/** * Sets this {@link EntityProperty} using the serialized <code>java.util.Date</code> value. * * @param value * The <code>java.util.Date</code> value to set as the {@link EntityProperty} value. This value may be * <code>null</code>. */ public synchronized final void setValue(final Date value) { this.edmType = EdmType.DATE_TIME; this.type = Date.class; this.value = value == null ? null : Utility.getJavaISO8601Time(value); }
private void getProperties(String currentNode, String value) throws ParseException { if (currentNode.equals(Constants.LAST_MODIFIED_ELEMENT)) { this.attributes.getProperties().setLastModified(Utility.parseRFC1123DateFromStringInGMT(value)); } else if (currentNode.equals(Constants.ETAG_ELEMENT)) { this.attributes.getProperties().setEtag(Utility.formatETag(value)); } else if (currentNode.equals(FileConstants.SHARE_QUOTA_ELEMENT)) { this.attributes.getProperties().setShareQuota(Utility.isNullOrEmpty(value) ? null : Integer.parseInt(value)); } } }
/** * Tries to determine the storage credentials from a connection string. * <p> * The format for the connection string is in the pattern "<i>keyname=value</i>". Multiple key/value pairs can be * separated by a semi-colon, for example, "<i>keyname1=value1;keyname2=value2</i>". Either include an account name * with an account key or a shared access signature. If you use an account name and account key, do not include a * shared access signature, and vice versa. * <p> * The same connection string can be used as for {@link CloudStorageAccount#parse(String)} but here only the account * name, account key, and sas key/value pairs will be examined. * * @param connectionString * A <code>String</code> that contains the key/value pairs that represent the storage credentials. * * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection * string. * * @throws InvalidKeyException * If the account key specified in <code>connectionString</code> is not valid. * @throws StorageException */ public static StorageCredentials tryParseCredentials(final String connectionString) throws InvalidKeyException, StorageException { return tryParseCredentials(Utility.parseAccountString(connectionString)); }
/** * Reserved for internal use. Sets the class type of the entity returned by the query. * * @param clazzType * The <code>java.lang.Class</code> implementing {@link TableEntity} that represents the entity type for * the query. */ protected void setClazzType(final Class<? extends TableEntity> clazzType) { Utility.assertNotNull("clazzType", clazzType); Utility.checkNullaryCtor(clazzType); this.clazzType = clazzType; }
/** * Adds the Range Header for Blob Service Operations. * * @param request * The request to add the range header to. * @param offset * Starting byte of the range. * @param count * Number of bytes in the range. */ private static void addRangeImpl(String header, HttpURLConnection request, Long offset, Long count) { if (count != null) { Utility.assertNotNull("offset", offset); Utility.assertInBounds("count", count, 1, Long.MAX_VALUE); } if (offset != null) { long rangeStart = offset; long rangeEnd; if (count != null) { rangeEnd = offset + count - 1; request.setRequestProperty(header, String.format( Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, rangeStart, rangeEnd)); } else { request.setRequestProperty(header, String.format( Utility.LOCALE_US, Constants.HeaderConstants.BEGIN_RANGE_HEADER_FORMAT, rangeStart)); } } }
/** * A static factory method returning a {@link TableOperation} instance to merge the specified table entity into * Microsoft Azure storage. To execute this {@link TableOperation} on a given table, call the * {@link CloudTable#execute(TableOperation)} method on a {@link CloudTableClient} instance with the * * @param entity * The object instance implementing {@link TableEntity} to associate with the operation. * @return * A new {@link TableOperation} instance for merging the table entity. */ public static TableOperation merge(final TableEntity entity) { Utility.assertNotNull("entity", entity); Utility.assertNotNullOrEmpty("entity etag", entity.getEtag()); return new TableOperation(entity, TableOperationType.MERGE); }
if (Utility.isNullOrEmpty(blockId) || !Base64.validateIsBase64String(blockId)) { throw new IllegalArgumentException(SR.INVALID_BLOCK_ID); descriptor = Utility.writeToOutputStream(sourceStream, byteStream, length, false /* rewindSourceStream */, options.getUseTransactionalContentMD5(), opContext, options); descriptor = Utility.analyzeStream(sourceStream, length, -1L, true /* rewindSourceStream */, options.getUseTransactionalContentMD5());
/** * RESERVED FOR INTERNAL USE. Applies the lease access condition to the request. * * @param request * A <code>java.net.HttpURLConnection</code> object that represents the request * to which the condition is being applied. */ public void applyLeaseConditionToRequest(final HttpURLConnection request) { if (!Utility.isNullOrEmpty(this.leaseID)) { request.setRequestProperty(Constants.HeaderConstants.LEASE_ID_HEADER, this.leaseID); } }
private static Date parseETagForTimestamp(String etag) throws UnsupportedEncodingException { // must handle both weak and strong ETags if (etag.startsWith("W/")) { etag = etag.substring(2); } // remove etag prefix and '" suffix etag = etag.substring(TableConstants.ETAG_PREFIX.length(), etag.length() - 2); etag = URLDecoder.decode(etag, Constants.UTF8_CHARSET); return Utility.parseDate(etag); } }
final EnumSet<MessageUpdateFields> messageUpdateFields, QueueRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertNotNull("message", message); Utility.assertNotNullOrEmpty("messageId", message.getId()); Utility.assertNotNullOrEmpty("popReceipt", message.getPopReceipt()); Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS);
Utility.assertNotNull(TableConstants.PARTITION_KEY, entity.getPartitionKey()); Utility.assertNotNull(TableConstants.ROW_KEY, entity.getRowKey()); Utility.assertNotNull(TableConstants.TIMESTAMP, entity.getTimestamp()); generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp()));
final BlobRequestOptions options, final SegmentedStorageRequest segmentedRequest) { Utility.assertContinuationType(segmentedRequest.getToken(), ResultContinuationType.CONTAINER);
@Test public void testDateStringFormatting() { String fullDateString = "2014-12-07T09:15:12.123Z"; String outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString)); assertEquals(fullDateString, outDateString); fullDateString = "2015-01-14T14:53:32.800Z"; outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString)); assertEquals(fullDateString, outDateString); // Ensure that trimming of trailing zeroes by the service does not affect this fullDateString = "2015-01-14T14:53:32.8Z"; outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString)); fullDateString = fullDateString.replace("Z", "00Z"); assertEquals(fullDateString, outDateString); // Ensure that trimming of trailing zeroes by the service does not affect this // even with dateBackwardCompatibility fullDateString = "2015-01-14T14:53:32.0000800Z"; outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString, true)); fullDateString = "2015-01-14T14:53:32.800Z"; assertEquals(fullDateString, outDateString); }
/** * Sets the {@link FileRequestOptions} that is used for any requests associated with this * <code>CloudFileClient</code> object. * * @param defaultRequestOptions * A {@link FileRequestOptions} object which specifies the options to use. */ public void setDefaultRequestOptions(FileRequestOptions defaultRequestOptions) { Utility.assertNotNull("defaultRequestOptions", defaultRequestOptions); this.defaultRequestOptions = defaultRequestOptions; }
/** * Sets the limit on the size of files (in GB) stored on the share. * * @param shareQuota * A <code>java.lang.Integer</code> object which represents the limit on * the size of files stored on the share. */ public void setShareQuota(Integer shareQuota) { if (shareQuota != null) { Utility.assertInBounds("Share Quota", shareQuota, 1, FileConstants.MAX_SHARE_QUOTA); } this.shareQuota = shareQuota; } }
/** * @param maxResults * the maxResults to set, must be at least 1 */ protected final void setMaxResults(final Integer maxResults) { if (null != maxResults) { Utility.assertGreaterThanOrEqual("maxResults", maxResults, 1); } this.maxResults = maxResults; }
/** * Sets the name of the source table for the table query. A table query must have a source table to be executed. * * @param sourceTableName * A <code>String</code> which specifies the name of the source table to use in the query. */ protected void setSourceTableName(final String sourceTableName) { Utility.assertNotNullOrEmpty("tableName", sourceTableName); this.sourceTableName = sourceTableName; }
descriptor = Utility.writeToOutputStream(sourceStream, byteStream, length, false /* rewindSourceStream */, options.getUseTransactionalContentMD5(), opContext, options); descriptor = Utility.analyzeStream(sourceStream, length, -1L, true /* rewindSourceStream */, options.getUseTransactionalContentMD5());
final StreamMd5AndLength descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true /* rewindSourceStream */, options.getUseTransactionalContentMD5() /* calculateMD5 */);
long byteCount = Utility.encryptStreamIfUnderThreshold(inputDataStream, targetStream, cipher, descriptor.getLength(), options.getSingleBlobPutThresholdInBytes() + 1 /*abandon if the operation hits this limit*/); descriptor = Utility.analyzeStream(inputDataStream, descriptor.getLength(), options.getSingleBlobPutThresholdInBytes() + 1 /*abandon if the operation hits this limit*/, true /* rewindSourceStream */, options.getStoreBlobContentMD5());