_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q167600 | IndyKafkaProducer.send | validation | public void send( String topic, String message, LogbackFormatter formatter ) throws IOException
{
doKafkaSend( topic, message, formatter );
} | java | {
"resource": ""
} |
q167601 | IndyKafkaProducer.send | validation | public void send( String topic, String message, long timeoutMillis )
throws IOException, InterruptedException, ExecutionException, TimeoutException
{
send( topic, message, null, timeoutMillis );
} | java | {
"resource": ""
} |
q167602 | IndyKafkaProducer.send | validation | public void send( String topic, String message, LogbackFormatter formatter, long timeoutMillis )
throws IOException, InterruptedException, ExecutionException, TimeoutException
{
Future future = doKafkaSend( topic, message, formatter );
if ( future != null )
{
future.get( timeoutMillis, TimeUnit.MILLISECONDS );
}
} | java | {
"resource": ""
} |
q167603 | IndyKojiContentProvider.getCacheNames | validation | public Set<String> getCacheNames()
{
Set<String> ret = new HashSet<>();
if ( kojiConfig.isEnabled() && kojiConfig.isQueryCacheEnabled() )
{
ret.add( KOJI_TAGS );
ret.add( KOJI_BUILD_INFO );
ret.add( KOJI_BUILD_INFO_CONTAINING_ARTIFACT );
ret.add( KOJI_ARCHIVES_FOR_BUILD );
ret.add( KOJI_ARCHIVES_MATCHING_GA );
}
return ret;
} | java | {
"resource": ""
} |
q167604 | FoloUtils.zipTrackedContent | validation | public static void zipTrackedContent( File out, Set<TrackedContent> sealed ) throws IOException
{
logger.info( "Writing sealed zip to: '{}'", out.getAbsolutePath() );
try (ZipOutputStream zip = new ZipOutputStream( new FileOutputStream( out ) ))
{
for ( TrackedContent f : sealed )
{
String name = SEALED.getValue() + "/" + f.getKey().getId();
logger.trace( "Adding {} to zip", name );
zip.putNextEntry( new ZipEntry( name ) );
copy( toInputStream( f ), zip );
}
}
} | java | {
"resource": ""
} |
q167605 | FoloUtils.readZipInputStreamAnd | validation | public static int readZipInputStreamAnd( InputStream inputStream, Consumer<TrackedContent> consumer )
throws IOException, ClassNotFoundException
{
int count = 0;
try ( ZipInputStream stream = new ZipInputStream( inputStream ) )
{
ZipEntry entry;
while((entry = stream.getNextEntry())!=null)
{
logger.trace( "Read entry: %s, len: %d", entry.getName(), entry.getSize() );
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
byte[] buffer = new byte[1024];
while ((len = stream.read( buffer)) > 0)
{
bos.write(buffer, 0, len);
}
bos.close();
ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream( bos.toByteArray() ));
TrackedContent record = (TrackedContent) ois.readObject();
consumer.accept( record );
count++;
}
}
return count;
} | java | {
"resource": ""
} |
q167606 | PromotionManager.getTargetKey | validation | private StoreKey getTargetKey( final String targetName )
{
return targetGroupKeyMap.computeIfAbsent( targetName,
k -> new StoreKey( MavenPackageTypeDescriptor.MAVEN_PKG_KEY,
StoreType.group, targetName ) );
} | java | {
"resource": ""
} |
q167607 | PathMaskChecker.checkListingMask | validation | public static boolean checkListingMask( final ArtifactStore store, final String path )
{
Set<String> maskPatterns = store.getPathMaskPatterns();
logger.trace( "Checking mask in: {}", store.getKey() );
logger.trace( "Mask patterns in {}: {}", store.getName(), maskPatterns );
if (maskPatterns == null || maskPatterns.isEmpty())
{
logger.trace( "Checking mask in: {}, - NO PATTERNS", store.getName() );
return true;
}
for ( String pattern : maskPatterns )
{
if ( isRegexPattern( pattern ) )
{
// if there is a regexp pattern we cannot check presence of directory listing, because we would have to
// check only the beginning of the regexp and that's impossible, so we have to assume that the path is
// present
return true;
}
}
for ( String pattern : maskPatterns )
{
if ( path.startsWith( pattern ) || pattern.startsWith( path ) )
{
logger.trace( "Checking mask in: {}, pattern: {} - MATCH", store.getName(), pattern );
return true;
}
}
logger.debug( "Listing for path {} not enabled by path mask {} of repo {}", path, maskPatterns, store.getKey() );
return false;
} | java | {
"resource": ""
} |
q167608 | MavenMetadataGenerator.clearObsoleteFiles | validation | private void clearObsoleteFiles( Transfer item )
{
Transfer httpMeta = item.getSiblingMeta( HTTP_METADATA_EXT );
try
{
httpMeta.delete();
}
catch ( IOException e )
{
logger.warn( "Failed to delete {}", httpMeta.getResource() );
}
} | java | {
"resource": ""
} |
q167609 | DefaultKojiRepoNameParser.parse | validation | public String parse( String repoName )
{
String prefix = null;
if ( repoName.startsWith( KOJI_BINARY_ ) )
{
prefix = KOJI_BINARY_;
}
else if ( repoName.startsWith( KOJI_ ) )
{
prefix = KOJI_;
}
if ( prefix != null )
{
return repoName.substring( prefix.length() );
}
return null;
} | java | {
"resource": ""
} |
q167610 | StoreAdminHandler.exists | validation | @ApiOperation( "Check if a given store exists" )
@ApiResponses( { @ApiResponse( code = 200, message = "The store exists" ),
@ApiResponse( code = 404, message = "The store doesn't exist" ) } )
@Path( "/{name}" )
@HEAD
public Response exists( final @PathParam( "packageType" ) String packageType,
final @ApiParam( allowableValues = "hosted,group,remote", required = true )
@PathParam( "type" ) String type,
@ApiParam( required = true ) @PathParam( "name" ) final String name )
{
Response response;
final StoreType st = StoreType.get( type );
logger.info( "Checking for existence of: {}:{}:{}", packageType, st, name );
if ( adminController.exists( new StoreKey( packageType, st, name ) ) )
{
logger.info( "returning OK" );
response = Response.ok().build();
}
else
{
logger.info( "Returning NOT FOUND" );
response = Response.status( Status.NOT_FOUND ).build();
}
return response;
} | java | {
"resource": ""
} |
q167611 | DataFileStoreUtils.loadFromDiskAnd | validation | public static void loadFromDiskAnd( DataFileManager manager, IndyObjectMapper serializer,
final ChangeSummary summary, Consumer<ArtifactStore> consumer )
{
loadFromDiskAnd( manager, serializer, null, summary, consumer );
} | java | {
"resource": ""
} |
q167612 | DataFileStoreUtils.loadFromDiskAnd | validation | public static void loadFromDiskAnd( DataFileManager manager, IndyObjectMapper serializer, StoreKey key,
final ChangeSummary summary, Consumer<ArtifactStore> consumer )
{
if ( key != null ) // Load a single file
{
DataFile f = manager.getDataFile( INDY_STORE, key.getPackageType(), key.getType().singularEndpointName(),
key.getName() + ".json" );
if ( f.exists() )
{
ArtifactStore store;
try
{
String json = f.readString();
store = serializer.readValue( json, key.getType().getStoreClass() );
}
catch ( IOException e )
{
logger.error( "Failed to read file", e );
return;
}
consumer.accept( store );
}
return;
}
// Load all
DataFile[] packageDirs = manager.getDataFile( INDY_STORE ).listFiles( ( f ) -> true );
for ( DataFile pkgDir : packageDirs )
{
for ( StoreType type : StoreType.values() )
{
DataFile[] files = pkgDir.getChild( type.singularEndpointName() ).listFiles( f -> true );
if ( files != null )
{
for ( final DataFile f : files )
{
try
{
final String json = f.readString();
final ArtifactStore store = serializer.readValue( json, type.getStoreClass() );
if ( store == null )
{
f.delete( summary );
}
else
{
consumer.accept( store );
}
}
catch ( final IOException e )
{
logger.error( String.format( "Failed to load %s store: %s. Reason: %s", type, f,
e.getMessage() ), e );
try
{
f.delete( summary );
}
catch ( IOException e1 )
{
logger.error( "Failed to delete invalid store definition file: " + f, e );
}
}
}
}
}
}
} | java | {
"resource": ""
} |
q167613 | HostedByArchiveManager.createStoreByArc | validation | public HostedRepository createStoreByArc( final InputStream fileInput, final String repoName, final String user,
final String ignoredPrefix )
throws IndyWorkflowException
{
final HostedRepository repo = createHostedByName( repoName, user, "Create hosted by zip." );
storeZipContentInHosted( fileInput, ignoredPrefix, repo );
return repo;
} | java | {
"resource": ""
} |
q167614 | IndyHttpProvider.createContext | validation | public HttpClientContext createContext( final String siteId ) throws IndyHttpException
{
try
{
return httpFactory.createContext( siteConfigLookup.lookup( siteId ) );
}
catch ( JHttpCException e )
{
throw new IndyHttpException( "Failed to create http client context: %s", e, e.getMessage() );
}
} | java | {
"resource": ""
} |
q167615 | IndyHttpProvider.createClient | validation | public CloseableHttpClient createClient( final String siteId ) throws IndyHttpException
{
try
{
return httpFactory.createClient( siteConfigLookup.lookup( siteId ) );
}
catch ( JHttpCException e )
{
throw new IndyHttpException( "Failed to create http client: %s", e, e.getMessage() );
}
} | java | {
"resource": ""
} |
q167616 | KojiRepairManager.doRepair | validation | private KojiRepairResult.RepairResult doRepair( String packageType, RemoteRepository repository,
KojiBuildInfo buildInfo, String user, boolean isDryRun )
throws KojiRepairException
{
StoreKey storeKey;
if ( repository != null )
{
storeKey = repository.getKey();
}
else
{
String name = kojiUtils.getRepositoryName( buildInfo );
storeKey = new StoreKey( packageType, StoreType.remote, name );
try
{
repository = (RemoteRepository) storeManager.getArtifactStore( storeKey );
}
catch ( IndyDataException e )
{
throw new KojiRepairException( "Cannot get store: %s. Reason: %s", e, storeKey,
e.getMessage() );
}
}
KojiRepairResult.RepairResult repairResult = new KojiRepairResult.RepairResult( storeKey );
String url = repository.getUrl();
String newUrl;
try
{
newUrl = kojiUtils.formatStorageUrl( config.getStorageRootUrl(), buildInfo ); // volume is involved
}
catch ( MalformedURLException e )
{
throw new KojiRepairException( "Failed to format storage Url: %s. Reason: %s", e, storeKey,
e.getMessage() );
}
boolean changed = !url.equals( newUrl );
if ( changed )
{
repairResult.withPropertyChange( "url", url, newUrl );
if ( !isDryRun )
{
ChangeSummary changeSummary = new ChangeSummary( user,
"Repair " + storeKey + " url with volume: " + buildInfo
.getVolumeName() );
repository.setUrl( newUrl );
repository.setMetadata( METADATA_KOJI_BUILD_ID, Integer.toString( buildInfo.getId() ) );
boolean fireEvents = false;
boolean skipIfExists = false;
try
{
storeManager.storeArtifactStore( repository, changeSummary, skipIfExists, fireEvents, new EventMetadata() );
}
catch ( IndyDataException e )
{
throw new KojiRepairException( "Failed to repair store: %s. Reason: %s", e, storeKey, e.getMessage() );
}
}
}
return repairResult;
} | java | {
"resource": ""
} |
q167617 | MetadataStoreListener.handleGroupMembersChanged | validation | private void handleGroupMembersChanged(final ArtifactStore store,
final Map<ArtifactStore, ArtifactStore> changeMap)
{
final StoreKey key = store.getKey();
if ( StoreType.group == key.getType() )
{
final List<StoreKey> newMembers = ( (Group) store ).getConstituents();
logger.trace( "New members of: {} are: {}", store.getKey(), newMembers );
final Group group = (Group) changeMap.get( store );
final List<StoreKey> oldMembers = group.getConstituents();
logger.trace( "Old members of: {} are: {}", group.getName(), oldMembers );
boolean membersChanged = false;
if ( newMembers.size() != oldMembers.size() )
{
membersChanged = true;
}
else
{
for ( StoreKey storeKey : newMembers )
{
if ( !oldMembers.contains( storeKey ) )
{
membersChanged = true;
}
}
}
if ( membersChanged )
{
logger.trace( "Membership change confirmed. Clearing caches for group: {} and groups affected by it.", group.getKey() );
clearGroupMetaCache( group, group );
try
{
storeManager.query().getGroupsAffectedBy( group.getKey() ).forEach( g -> clearGroupMetaCache( g, group ) );
}
catch ( IndyDataException e )
{
logger.error( String.format( "Can not get affected groups of %s", group.getKey() ), e );
}
}
else
{
logger.trace( "No members changed, no need to expunge merged metadata" );
}
}
} | java | {
"resource": ""
} |
q167618 | KeycloakConfig.setSystemProperties | validation | public KeycloakConfig setSystemProperties()
{
if ( !isEnabled() )
{
return this;
}
final Properties properties = System.getProperties();
properties.setProperty( KEYCLOAK_REALM, getRealm() );
properties.setProperty( KEYCLOAK_URL, getUrl() );
if ( getServerResource() != null )
{
properties.setProperty( KEYCLOAK_SERVER_RESOURCE, getServerResource() );
}
if ( getServerCredentialSecret() != null )
{
properties.setProperty( KEYCLOAK_SERVER_CREDENTIAL_SECRET, getServerCredentialSecret() );
}
if ( getRealmPublicKey() != null )
{
properties.setProperty( KEYCLOAK_REALM_PUBLIC_KEY, getRealmPublicKey() );
}
System.setProperties( properties );
return this;
} | java | {
"resource": ""
} |
q167619 | FileRangeHandler.getFileRanges | validation | protected static ArrayList<FileRange> getFileRanges(InputStream streamRef) throws ParserConfigurationException,
SAXException, IOException {
SAXParser saxParser = Utility.getSAXParser();
FileRangeHandler handler = new FileRangeHandler();
saxParser.parse(streamRef, handler);
return handler.fileRanges;
} | java | {
"resource": ""
} |
q167620 | QueueMessageHandler.readMessages | validation | public static ArrayList<CloudQueueMessage> readMessages(final InputStream stream, final boolean shouldEncodeMessage)
throws SAXException, IOException, ParserConfigurationException {
SAXParser saxParser = Utility.getSAXParser();
QueueMessageHandler handler = new QueueMessageHandler(shouldEncodeMessage);
saxParser.parse(stream, handler);
return handler.messages;
} | java | {
"resource": ""
} |
q167621 | CloudTable.createIfNotExists | validation | @DoesServiceRequest
public boolean createIfNotExists(TableRequestOptions options, OperationContext opContext) throws StorageException {
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
boolean exists = this.exists(true, options, opContext);
if (exists) {
return false;
}
else {
try {
this.create(options, opContext);
return true;
}
catch (StorageException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT
&& StorageErrorCodeStrings.TABLE_ALREADY_EXISTS.equals(e.getErrorCode())) {
return false;
}
else {
throw e;
}
}
}
} | java | {
"resource": ""
} |
q167622 | CloudTable.delete | validation | @DoesServiceRequest
public void delete(TableRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
Utility.assertNotNullOrEmpty("tableName", this.name);
final DynamicTableEntity tableEntry = new DynamicTableEntity();
tableEntry.getProperties().put(TableConstants.TABLE_NAME, new EntityProperty(this.name));
TableOperation deleteOp = new TableOperation(tableEntry, TableOperationType.DELETE);
deleteOp.execute(this.tableServiceClient, TableConstants.TABLES_SERVICE_TABLES_NAME, options, opContext);
} | java | {
"resource": ""
} |
q167623 | CloudTable.deleteIfExists | validation | @DoesServiceRequest
public boolean deleteIfExists(TableRequestOptions options, OperationContext opContext) throws StorageException {
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
if (this.exists(true, options, opContext)) {
try {
this.delete(options, opContext);
}
catch (StorageException ex) {
if (ex.getHttpStatusCode() == HttpURLConnection.HTTP_NOT_FOUND
&& StorageErrorCodeStrings.RESOURCE_NOT_FOUND.equals(ex.getErrorCode())) {
return false;
}
else {
throw ex;
}
}
return true;
}
else {
return false;
}
} | java | {
"resource": ""
} |
q167624 | CloudTable.uploadPermissions | validation | @DoesServiceRequest
public void uploadPermissions(final TablePermissions permissions, TableRequestOptions options,
OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
ExecutionEngine.executeWithRetry(this.tableServiceClient, this,
this.uploadPermissionsImpl(permissions, options), options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167625 | CloudTable.downloadPermissions | validation | @DoesServiceRequest
public TablePermissions downloadPermissions(TableRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
return ExecutionEngine.executeWithRetry(this.tableServiceClient, this, this.downloadPermissionsImpl(options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167626 | RequestOptions.applyBaseDefaultsInternal | validation | protected static void applyBaseDefaultsInternal(final RequestOptions modifiedOptions) {
Utility.assertNotNull("modifiedOptions", modifiedOptions);
if (modifiedOptions.getRetryPolicyFactory() == null) {
modifiedOptions.setRetryPolicyFactory(new RetryExponentialRetry());
}
if (modifiedOptions.getLocationMode() == null) {
modifiedOptions.setLocationMode(LocationMode.PRIMARY_ONLY);
}
} | java | {
"resource": ""
} |
q167627 | StorageErrorHandler.getExtendedErrorInformation | validation | public static StorageExtendedErrorInformation getExtendedErrorInformation(final InputStream stream)
throws SAXException, IOException, ParserConfigurationException {
SAXParser saxParser = Utility.getSAXParser();
StorageErrorHandler handler = new StorageErrorHandler();
saxParser.parse(stream, handler);
return handler.errorInfo;
} | java | {
"resource": ""
} |
q167628 | AccessCondition.generateIfSequenceNumberLessThanOrEqualCondition | validation | public static AccessCondition generateIfSequenceNumberLessThanOrEqualCondition(long sequenceNumber) {
AccessCondition retCondition = new AccessCondition();
retCondition.ifSequenceNumberLessThanOrEqual = sequenceNumber;
return retCondition;
} | java | {
"resource": ""
} |
q167629 | AccessCondition.generateIfSequenceNumberLessThanCondition | validation | public static AccessCondition generateIfSequenceNumberLessThanCondition(long sequenceNumber) {
AccessCondition retCondition = new AccessCondition();
retCondition.ifSequenceNumberLessThan = sequenceNumber;
return retCondition;
} | java | {
"resource": ""
} |
q167630 | AccessCondition.generateIfSequenceNumberEqualCondition | validation | public static AccessCondition generateIfSequenceNumberEqualCondition(long sequenceNumber) {
AccessCondition retCondition = new AccessCondition();
retCondition.ifSequenceNumberEqual = sequenceNumber;
return retCondition;
} | java | {
"resource": ""
} |
q167631 | AccessCondition.applyConditionToRequest | validation | public void applyConditionToRequest(final HttpURLConnection request) {
applyLeaseConditionToRequest(request);
if (this.ifModifiedSinceDate != null) {
request.setRequestProperty(Constants.HeaderConstants.IF_MODIFIED_SINCE,
Utility.getGMTTime(this.ifModifiedSinceDate));
}
if (this.ifUnmodifiedSinceDate != null) {
request.setRequestProperty(Constants.HeaderConstants.IF_UNMODIFIED_SINCE,
Utility.getGMTTime(this.ifUnmodifiedSinceDate));
}
if (!Utility.isNullOrEmpty(this.ifMatchETag)) {
request.setRequestProperty(Constants.HeaderConstants.IF_MATCH, this.ifMatchETag);
}
if (!Utility.isNullOrEmpty(this.ifNoneMatchETag)) {
request.setRequestProperty(Constants.HeaderConstants.IF_NONE_MATCH, this.ifNoneMatchETag);
}
} | java | {
"resource": ""
} |
q167632 | AccessCondition.applySourceConditionToRequest | validation | public void applySourceConditionToRequest(final HttpURLConnection request) {
if (!Utility.isNullOrEmpty(this.leaseID)) {
// Unsupported
throw new IllegalArgumentException(SR.LEASE_CONDITION_ON_SOURCE);
}
if (this.ifModifiedSinceDate != null) {
request.setRequestProperty(
Constants.HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER,
Utility.getGMTTime(this.ifModifiedSinceDate));
}
if (this.ifUnmodifiedSinceDate != null) {
request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER,
Utility.getGMTTime(this.ifUnmodifiedSinceDate));
}
if (!Utility.isNullOrEmpty(this.ifMatchETag)) {
request.setRequestProperty(
Constants.HeaderConstants.SOURCE_IF_MATCH_HEADER,
this.ifMatchETag);
}
if (!Utility.isNullOrEmpty(this.ifNoneMatchETag)) {
request.setRequestProperty(
Constants.HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER,
this.ifNoneMatchETag);
}
} | java | {
"resource": ""
} |
q167633 | AccessCondition.applyAppendConditionToRequest | validation | public void applyAppendConditionToRequest(final HttpURLConnection request) {
if (this.ifMaxSizeLessThanOrEqual != null) {
request.setRequestProperty(Constants.HeaderConstants.IF_MAX_SIZE_LESS_THAN_OR_EQUAL,
this.ifMaxSizeLessThanOrEqual.toString());
}
if (this.ifAppendPositionEqual != null) {
request.setRequestProperty(Constants.HeaderConstants.IF_APPEND_POSITION_EQUAL_HEADER,
this.ifAppendPositionEqual.toString());
}
} | java | {
"resource": ""
} |
q167634 | AccessCondition.applyLeaseConditionToRequest | validation | public void applyLeaseConditionToRequest(final HttpURLConnection request) {
if (!Utility.isNullOrEmpty(this.leaseID)) {
request.setRequestProperty(Constants.HeaderConstants.LEASE_ID_HEADER, this.leaseID);
}
} | java | {
"resource": ""
} |
q167635 | AccessCondition.applySequenceConditionToRequest | validation | public void applySequenceConditionToRequest(final HttpURLConnection request) {
if (this.ifSequenceNumberLessThanOrEqual != null) {
request.setRequestProperty(
Constants.HeaderConstants.IF_SEQUENCE_NUMBER_LESS_THAN_OR_EQUAL,
this.ifSequenceNumberLessThanOrEqual.toString());
}
if (this.ifSequenceNumberLessThan != null) {
request.setRequestProperty(
Constants.HeaderConstants.IF_SEQUENCE_NUMBER_LESS_THAN,
this.ifSequenceNumberLessThan.toString());
}
if (this.ifSequenceNumberEqual != null) {
request.setRequestProperty(
Constants.HeaderConstants.IF_SEQUENCE_NUMBER_EQUAL,
this.ifSequenceNumberEqual.toString());
}
} | java | {
"resource": ""
} |
q167636 | AccessCondition.verifyConditional | validation | public boolean verifyConditional(final String etag, final Date lastModified) {
if (this.ifModifiedSinceDate != null) {
// The IfModifiedSince has a special helper in HttpURLConnection, use it instead of manually setting the
// header.
if (!lastModified.after(this.ifModifiedSinceDate)) {
return false;
}
}
if (this.ifUnmodifiedSinceDate != null) {
if (lastModified.after(this.ifUnmodifiedSinceDate)) {
return false;
}
}
if (!Utility.isNullOrEmpty(this.ifMatchETag)) {
if (!this.ifMatchETag.equals(etag) && !this.ifMatchETag.equals("*")) {
return false;
}
}
if (!Utility.isNullOrEmpty(this.ifNoneMatchETag)) {
if (this.ifNoneMatchETag.equals(etag)) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q167637 | TableQuery.combineFilters | validation | public static String combineFilters(String filterA, String operator, String filterB) {
return String.format("(%s) %s (%s)", filterA, operator, filterB);
} | java | {
"resource": ""
} |
q167638 | ServiceClient.setStorageUri | validation | protected final void setStorageUri(final StorageUri storageUri) {
this.usePathStyleUris = Utility.determinePathStyleFromUri(storageUri.getPrimaryUri());
this.storageUri = storageUri;
} | java | {
"resource": ""
} |
q167639 | SharedAccessPolicySerializer.writeSharedAccessIdentifiersToStream | validation | public static <T extends SharedAccessPolicy> void writeSharedAccessIdentifiersToStream(
final HashMap<String, T> sharedAccessPolicies, final StringWriter outWriter)
throws IllegalArgumentException, IllegalStateException, IOException {
Utility.assertNotNull("sharedAccessPolicies", sharedAccessPolicies);
Utility.assertNotNull("outWriter", outWriter);
final XmlSerializer xmlw = Utility.getXmlSerializer(outWriter);
if (sharedAccessPolicies.keySet().size() > Constants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS) {
final String errorMessage = String.format(SR.TOO_MANY_SHARED_ACCESS_POLICY_IDENTIFIERS,
sharedAccessPolicies.keySet().size(), Constants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS);
throw new IllegalArgumentException(errorMessage);
}
// default is UTF8
xmlw.startDocument(Constants.UTF8_CHARSET, true);
xmlw.startTag(Constants.EMPTY_STRING, Constants.SIGNED_IDENTIFIERS_ELEMENT);
for (final Entry<String, T> entry : sharedAccessPolicies.entrySet()) {
final SharedAccessPolicy policy = entry.getValue();
xmlw.startTag(Constants.EMPTY_STRING, Constants.SIGNED_IDENTIFIER_ELEMENT);
// Set the identifier
Utility.serializeElement(xmlw, Constants.ID, entry.getKey());
xmlw.startTag(Constants.EMPTY_STRING, Constants.ACCESS_POLICY);
// Set the Start Time
Utility.serializeElement(xmlw, Constants.START, Utility
.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()).toString());
// Set the Expiry Time
Utility.serializeElement(xmlw, Constants.EXPIRY,
Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()).toString());
// Set the Permissions
Utility.serializeElement(xmlw, Constants.PERMISSION, policy.permissionsToString());
// end AccessPolicy
xmlw.endTag(Constants.EMPTY_STRING, Constants.ACCESS_POLICY);
// end SignedIdentifier
xmlw.endTag(Constants.EMPTY_STRING, Constants.SIGNED_IDENTIFIER_ELEMENT);
}
// end SignedIdentifiers
xmlw.endTag(Constants.EMPTY_STRING, Constants.SIGNED_IDENTIFIERS_ELEMENT);
// end doc
xmlw.endDocument();
} | java | {
"resource": ""
} |
q167640 | QueueMessageSerializer.generateMessageRequestBody | validation | public static byte[] generateMessageRequestBody(final String message) throws IllegalArgumentException,
IllegalStateException, IOException {
final StringWriter outWriter = new StringWriter();
final XmlSerializer xmlw = Utility.getXmlSerializer(outWriter);
// default is UTF8
xmlw.startDocument(Constants.UTF8_CHARSET, true);
xmlw.startTag(Constants.EMPTY_STRING, QueueConstants.QUEUE_MESSAGE_ELEMENT);
Utility.serializeElement(xmlw, QueueConstants.MESSAGE_TEXT_ELEMENT, message);
// end QueueMessage_ELEMENT
xmlw.endTag(Constants.EMPTY_STRING, QueueConstants.QUEUE_MESSAGE_ELEMENT);
// end doc
xmlw.endDocument();
return outWriter.toString().getBytes(Constants.UTF8_CHARSET);
} | java | {
"resource": ""
} |
q167641 | Canonicalizer.addCanonicalizedHeaders | validation | private static void addCanonicalizedHeaders(final HttpURLConnection conn, final StringBuilder canonicalizedString) {
// Look for header names that start with
// HeaderNames.PrefixForStorageHeader
// Then sort them in case-insensitive manner.
final Map<String, List<String>> headers = conn.getRequestProperties();
final ArrayList<String> httpStorageHeaderNameArray = new ArrayList<String>();
for (final String key : headers.keySet()) {
if (key.toLowerCase(Utility.LOCALE_US).startsWith(Constants.PREFIX_FOR_STORAGE_HEADER)) {
httpStorageHeaderNameArray.add(key.toLowerCase(Utility.LOCALE_US));
}
}
Collections.sort(httpStorageHeaderNameArray);
// Now go through each header's values in the sorted order and append
// them to the canonicalized string.
for (final String key : httpStorageHeaderNameArray) {
final StringBuilder canonicalizedElement = new StringBuilder(key);
String delimiter = ":";
final ArrayList<String> values = getHeaderValues(headers, key);
boolean appendCanonicalizedElement = false;
// Go through values, unfold them, and then append them to the
// canonicalized element string.
for (final String value : values) {
if (value != null) {
appendCanonicalizedElement = true;
}
// Unfolding is simply removal of CRLF.
final String unfoldedValue = CRLF.matcher(value)
.replaceAll(Matcher.quoteReplacement(Constants.EMPTY_STRING));
// Append it to the canonicalized element string.
canonicalizedElement.append(delimiter);
canonicalizedElement.append(unfoldedValue);
delimiter = ",";
}
// Now, add this canonicalized element to the canonicalized header
// string.
if (appendCanonicalizedElement) {
appendCanonicalizedElement(canonicalizedString, canonicalizedElement.toString());
}
}
} | java | {
"resource": ""
} |
q167642 | Canonicalizer.appendCanonicalizedElement | validation | protected static void appendCanonicalizedElement(final StringBuilder builder, final String element) {
builder.append("\n");
builder.append(element);
} | java | {
"resource": ""
} |
q167643 | Canonicalizer.canonicalizeHttpRequest | validation | protected static String canonicalizeHttpRequest(final java.net.URL address, final String accountName,
final String method, final String contentType, final long contentLength, final String date,
final HttpURLConnection conn) throws StorageException {
// The first element should be the Method of the request.
// I.e. GET, POST, PUT, or HEAD.
final StringBuilder canonicalizedString = new StringBuilder(ExpectedBlobQueueCanonicalizedStringLength);
canonicalizedString.append(conn.getRequestMethod());
// The next elements are
// If any element is missing it may be empty.
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_ENCODING));
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_LANGUAGE));
appendCanonicalizedElement(canonicalizedString,
contentLength <= 0 ? Constants.EMPTY_STRING : String.valueOf(contentLength));
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5));
appendCanonicalizedElement(canonicalizedString, contentType != null ? contentType : Constants.EMPTY_STRING);
final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE);
// If x-ms-date header exists, Date should be empty string
appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date
: Constants.EMPTY_STRING);
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_MODIFIED_SINCE));
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_MATCH));
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_NONE_MATCH));
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_UNMODIFIED_SINCE));
appendCanonicalizedElement(canonicalizedString,
Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.RANGE));
addCanonicalizedHeaders(conn, canonicalizedString);
appendCanonicalizedElement(canonicalizedString, getCanonicalizedResource(address, accountName));
return canonicalizedString.toString();
} | java | {
"resource": ""
} |
q167644 | Canonicalizer.canonicalizeTableHttpRequest | validation | protected static String canonicalizeTableHttpRequest(final java.net.URL address, final String accountName,
final String method, final String contentType, final long contentLength, final String date,
final HttpURLConnection conn) throws StorageException {
// The first element should be the Method of the request.
// I.e. GET, POST, PUT, or HEAD.
final StringBuilder canonicalizedString = new StringBuilder(ExpectedTableCanonicalizedStringLength);
canonicalizedString.append(conn.getRequestMethod());
// The second element should be the MD5 value.
// This is optional and may be empty.
final String httpContentMD5Value = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5);
appendCanonicalizedElement(canonicalizedString, httpContentMD5Value);
// The third element should be the content type.
appendCanonicalizedElement(canonicalizedString, contentType);
// The fourth element should be the request date.
// See if there's an storage date header.
// If there's one, then don't use the date header.
final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE);
// If x-ms-date header exists, Date should be that value.
appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date : dateString);
appendCanonicalizedElement(canonicalizedString, getCanonicalizedResourceLite(address, accountName));
return canonicalizedString.toString();
} | java | {
"resource": ""
} |
q167645 | StorageCredentialsHelper.computeHmac256 | validation | public static synchronized String computeHmac256(final StorageCredentials creds, final String value) throws InvalidKeyException {
if (creds.getClass().equals(StorageCredentialsAccountAndKey.class)) {
byte[] utf8Bytes = null;
try {
utf8Bytes = value.getBytes(Constants.UTF8_CHARSET);
}
catch (final UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
return Base64.encode(((StorageCredentialsAccountAndKey) creds).getHmac256().doFinal(utf8Bytes));
}
else {
return null;
}
} | java | {
"resource": ""
} |
q167646 | StorageCredentialsHelper.signTableRequest | validation | public static void signTableRequest(final StorageCredentials creds, final java.net.HttpURLConnection request,
final long contentLength, OperationContext opContext) throws InvalidKeyException, StorageException {
if (creds.getClass().equals(StorageCredentialsAccountAndKey.class)) {
opContext = opContext == null ? new OperationContext() : opContext;
request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime());
final Canonicalizer canonicalizer = CanonicalizerFactory.getTableCanonicalizer(request);
final String stringToSign = canonicalizer.canonicalize(request, creds.getAccountName(), contentLength);
final String computedBase64Signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign);
Logger.debug(opContext, LogConstants.SIGNING, stringToSign);
request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION,
String.format("%s %s:%s", "SharedKey", creds.getAccountName(), computedBase64Signature));
}
} | java | {
"resource": ""
} |
q167647 | CloudQueue.getFirstOrNull | validation | private static CloudQueueMessage getFirstOrNull(final Iterable<CloudQueueMessage> messages) {
for (final CloudQueueMessage m : messages) {
return m;
}
return null;
} | java | {
"resource": ""
} |
q167648 | CloudQueue.addMessage | validation | @DoesServiceRequest
public void addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds,
final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext)
throws StorageException {
Utility.assertNotNull("message", message);
Utility.assertNotNull("messageContent", message.getMessageContentAsByte());
Utility.assertInBounds("timeToLiveInSeconds", timeToLiveInSeconds, 0,
QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS);
final int realTimeToLiveInSeconds = timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS
: timeToLiveInSeconds;
Utility.assertInBounds("initialVisibilityDelayInSeconds", initialVisibilityDelayInSeconds, 0,
realTimeToLiveInSeconds - 1);
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this,
this.addMessageImpl(message, realTimeToLiveInSeconds, initialVisibilityDelayInSeconds, options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167649 | CloudQueue.clear | validation | @DoesServiceRequest
public void clear(QueueRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.clearImpl(options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167650 | CloudQueue.create | validation | @DoesServiceRequest
public void create(QueueRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.createImpl(options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167651 | CloudQueue.createIfNotExists | validation | @DoesServiceRequest
public boolean createIfNotExists(QueueRequestOptions options, OperationContext opContext) throws StorageException {
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
boolean exists = this.exists(true, options, opContext);
if (exists) {
return false;
}
else {
try {
this.create(options, opContext);
return true;
}
catch (StorageException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT
&& StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS.equals(e.getErrorCode())) {
return false;
}
else {
throw e;
}
}
}
} | java | {
"resource": ""
} |
q167652 | CloudQueue.delete | validation | @DoesServiceRequest
public void delete(QueueRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.deleteImpl(options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167653 | CloudQueue.deleteIfExists | validation | @DoesServiceRequest
public boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException {
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
boolean exists = this.exists(true, options, opContext);
if (exists) {
try {
this.delete(options, opContext);
return true;
}
catch (StorageException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_NOT_FOUND
&& StorageErrorCodeStrings.QUEUE_NOT_FOUND.equals(e.getErrorCode())) {
return false;
}
else {
throw e;
}
}
}
else {
return false;
}
} | java | {
"resource": ""
} |
q167654 | CloudQueue.deleteMessage | validation | @DoesServiceRequest
public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext)
throws StorageException {
Utility.assertNotNull("message", message);
Utility.assertNotNullOrEmpty("messageId", message.getId());
Utility.assertNotNullOrEmpty("popReceipt", message.getPopReceipt());
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.deleteMessageImpl(message, options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167655 | CloudQueue.downloadAttributes | validation | @DoesServiceRequest
public void downloadAttributes(QueueRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.downloadAttributesImpl(options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167656 | CloudQueue.exists | validation | @DoesServiceRequest
public boolean exists(QueueRequestOptions options, OperationContext opContext) throws StorageException {
return this.exists(false, options, opContext);
} | java | {
"resource": ""
} |
q167657 | CloudQueue.peekMessage | validation | @DoesServiceRequest
public CloudQueueMessage peekMessage(final QueueRequestOptions options, final OperationContext opContext)
throws StorageException {
return getFirstOrNull(this.peekMessages(1, null /* options */, null /* opContext */));
} | java | {
"resource": ""
} |
q167658 | CloudQueue.peekMessages | validation | @DoesServiceRequest
public Iterable<CloudQueueMessage> peekMessages(final int numberOfMessages) throws StorageException {
return this.peekMessages(numberOfMessages, null /* options */, null /* opContext */);
} | java | {
"resource": ""
} |
q167659 | CloudQueue.peekMessages | validation | @DoesServiceRequest
public Iterable<CloudQueueMessage> peekMessages(final int numberOfMessages, QueueRequestOptions options,
OperationContext opContext) throws StorageException {
Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK);
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
return ExecutionEngine.executeWithRetry(this.queueServiceClient, this,
this.peekMessagesImpl(numberOfMessages, options), options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167660 | CloudQueue.retrieveMessage | validation | @DoesServiceRequest
public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options,
final OperationContext opContext) throws StorageException {
return getFirstOrNull(this.retrieveMessages(1, visibilityTimeoutInSeconds, options, opContext));
} | java | {
"resource": ""
} |
q167661 | CloudQueue.retrieveMessages | validation | @DoesServiceRequest
public Iterable<CloudQueueMessage> retrieveMessages(final int numberOfMessages) throws StorageException {
return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS,
null /* options */, null /* opContext */);
} | java | {
"resource": ""
} |
q167662 | CloudQueue.retrieveMessages | validation | @DoesServiceRequest
public Iterable<CloudQueueMessage> retrieveMessages(final int numberOfMessages,
final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext)
throws StorageException {
Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK);
Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0,
QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS);
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
return ExecutionEngine.executeWithRetry(this.queueServiceClient, this,
this.retrieveMessagesImpl(numberOfMessages, visibilityTimeoutInSeconds, options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167663 | CloudQueue.updateMessage | validation | public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds)
throws StorageException {
this.updateMessage(message, visibilityTimeoutInSeconds, EnumSet.of(MessageUpdateFields.VISIBILITY),
null /* options */, null /* opContext */);
} | java | {
"resource": ""
} |
q167664 | CloudQueue.updateMessage | validation | @DoesServiceRequest
public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds,
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);
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this,
this.updateMessageImpl(message, visibilityTimeoutInSeconds, messageUpdateFields, options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167665 | CloudQueue.uploadPermissions | validation | @DoesServiceRequest
public void uploadPermissions(final QueuePermissions permissions, QueueRequestOptions options,
OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
ExecutionEngine.executeWithRetry(this.queueServiceClient, this,
this.uploadPermissionsImpl(permissions, options), options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167666 | CloudQueue.downloadPermissions | validation | @DoesServiceRequest
public QueuePermissions downloadPermissions(QueueRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.downloadPermissionsImpl(options),
options.getRetryPolicyFactory(), opContext);
} | java | {
"resource": ""
} |
q167667 | CloudQueue.getTransformedAddress | validation | private final StorageUri getTransformedAddress(final OperationContext opContext) throws URISyntaxException,
StorageException {
return this.queueServiceClient.getCredentials().transformUri(this.getStorageUri(), opContext);
} | java | {
"resource": ""
} |
q167668 | CloudAnalyticsClient.getHourMetricsTable | validation | public CloudTable getHourMetricsTable(StorageService service, StorageLocation location) throws URISyntaxException,
StorageException {
Utility.assertNotNull("service", service);
if (location == null) {
location = StorageLocation.PRIMARY;
}
switch (service) {
case BLOB:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_PRIMARY_TRANSACTIONS_BLOB);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_SECONDARY_TRANSACTIONS_BLOB);
}
case FILE:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_PRIMARY_TRANSACTIONS_FILE);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_SECONDARY_TRANSACTIONS_FILE);
}
case QUEUE:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_PRIMARY_TRANSACTIONS_QUEUE);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_SECONDARY_TRANSACTIONS_QUEUE);
}
case TABLE:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_PRIMARY_TRANSACTIONS_TABLE);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_HOUR_SECONDARY_TRANSACTIONS_TABLE);
}
default:
throw new IllegalArgumentException(SR.INVALID_STORAGE_SERVICE);
}
} | java | {
"resource": ""
} |
q167669 | CloudAnalyticsClient.getMinuteMetricsTable | validation | public CloudTable getMinuteMetricsTable(StorageService service, StorageLocation location)
throws URISyntaxException, StorageException {
Utility.assertNotNull("service", service);
if (location == null) {
location = StorageLocation.PRIMARY;
}
switch (service) {
case BLOB:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_PRIMARY_TRANSACTIONS_BLOB);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_SECONDARY_TRANSACTIONS_BLOB);
}
case FILE:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_PRIMARY_TRANSACTIONS_FILE);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_SECONDARY_TRANSACTIONS_FILE);
}
case QUEUE:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_PRIMARY_TRANSACTIONS_QUEUE);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_SECONDARY_TRANSACTIONS_QUEUE);
}
case TABLE:
if (location == StorageLocation.PRIMARY) {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_PRIMARY_TRANSACTIONS_TABLE);
}
else {
return this.tableClient.getTableReference(
Constants.AnalyticsConstants.METRICS_MINUTE_SECONDARY_TRANSACTIONS_TABLE);
}
default:
throw new IllegalArgumentException(SR.INVALID_STORAGE_SERVICE);
}
} | java | {
"resource": ""
} |
q167670 | CloudQueueMessage.getMessageContentAsByte | validation | public final byte[] getMessageContentAsByte() throws StorageException {
if (Utility.isNullOrEmpty(this.messageContent)) {
return new byte[0];
}
if (this.messageType == QueueMessageType.RAW_STRING) {
try {
return this.messageContent.getBytes(Constants.UTF8_CHARSET);
}
catch (final UnsupportedEncodingException e) {
throw Utility.generateNewUnexpectedStorageException(e);
}
}
else {
return Base64.decode(this.messageContent);
}
} | java | {
"resource": ""
} |
q167671 | CloudQueueMessage.getMessageContentAsString | validation | public final String getMessageContentAsString() throws StorageException {
if (this.messageType == QueueMessageType.RAW_STRING) {
return this.messageContent;
}
else {
if (Utility.isNullOrEmpty(this.messageContent)) {
return null;
}
try {
return new String(Base64.decode(this.messageContent), Constants.UTF8_CHARSET);
}
catch (final UnsupportedEncodingException e) {
throw Utility.generateNewUnexpectedStorageException(e);
}
}
} | java | {
"resource": ""
} |
q167672 | FileListHandler.getFileAndDirectoryList | validation | public static ListResponse<ListFileItem> getFileAndDirectoryList(final InputStream stream,
final CloudFileDirectory directory) throws ParserConfigurationException, SAXException, IOException {
SAXParser saxParser = Utility.getSAXParser();
FileListHandler handler = new FileListHandler(directory);
saxParser.parse(stream, handler);
return handler.response;
} | java | {
"resource": ""
} |
q167673 | TableRequest.applyContinuationToQueryBuilder | validation | private static void applyContinuationToQueryBuilder(final UriQueryBuilder builder,
final ResultContinuation continuationToken) throws StorageException {
if (continuationToken != null) {
if (continuationToken.getNextPartitionKey() != null) {
builder.add(TableConstants.TABLE_SERVICE_NEXT_PARTITION_KEY, continuationToken.getNextPartitionKey());
}
if (continuationToken.getNextRowKey() != null) {
builder.add(TableConstants.TABLE_SERVICE_NEXT_ROW_KEY, continuationToken.getNextRowKey());
}
if (continuationToken.getNextTableName() != null) {
builder.add(TableConstants.TABLE_SERVICE_NEXT_TABLE_NAME, continuationToken.getNextTableName());
}
}
} | java | {
"resource": ""
} |
q167674 | TableRequest.merge | validation | public static HttpURLConnection merge(final URI rootUri, final TableRequestOptions tableOptions,
final UriQueryBuilder queryBuilder, final OperationContext opContext, final String tableName,
final String identity, final String eTag) throws IOException, URISyntaxException, StorageException {
final HttpURLConnection retConnection = coreCreate(rootUri, tableOptions, queryBuilder, opContext, tableName,
eTag, identity, "POST");
retConnection.setRequestProperty(TableConstants.HeaderConstants.X_HTTP_METHOD, "MERGE");
retConnection.setDoOutput(true);
return retConnection;
} | java | {
"resource": ""
} |
q167675 | TableRequest.query | validation | public static HttpURLConnection query(final URI rootUri, final TableRequestOptions tableOptions,
UriQueryBuilder queryBuilder, final OperationContext opContext, final String tableName,
final String identity, final ResultContinuation continuationToken) throws IOException, URISyntaxException,
StorageException {
if (queryBuilder == null) {
queryBuilder = new UriQueryBuilder();
}
applyContinuationToQueryBuilder(queryBuilder, continuationToken);
final HttpURLConnection retConnection = coreCreate(rootUri, tableOptions, queryBuilder, opContext, tableName,
null, identity, "GET");
return retConnection;
} | java | {
"resource": ""
} |
q167676 | TableRequest.update | validation | public static HttpURLConnection update(final URI rootUri, final TableRequestOptions tableOptions,
final UriQueryBuilder queryBuilder, final OperationContext opContext, final String tableName,
final String identity, final String eTag) throws IOException, URISyntaxException, StorageException {
final HttpURLConnection retConnection = coreCreate(rootUri, tableOptions, queryBuilder, opContext, tableName,
eTag, identity, "PUT");
retConnection.setDoOutput(true);
return retConnection;
} | java | {
"resource": ""
} |
q167677 | TableRequest.setAcl | validation | public static HttpURLConnection setAcl(final URI rootUri, final TableRequestOptions options,
final OperationContext opContext) throws IOException, URISyntaxException, StorageException {
UriQueryBuilder queryBuilder = new UriQueryBuilder();
queryBuilder.add(Constants.QueryConstants.COMPONENT, "acl");
final HttpURLConnection retConnection = BaseRequest.createURLConnection(rootUri, options, queryBuilder,
opContext);
retConnection.setRequestMethod("PUT");
retConnection.setDoOutput(true);
return retConnection;
} | java | {
"resource": ""
} |
q167678 | ServicePropertiesSerializer.serializeToByteArray | validation | public static byte[] serializeToByteArray(final ServiceProperties properties) throws IllegalArgumentException,
IllegalStateException, IOException {
final StringWriter outWriter = new StringWriter();
final XmlSerializer xmlw = Utility.getXmlSerializer(outWriter);
// default is UTF8
xmlw.startDocument(Constants.UTF8_CHARSET, true);
xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT);
if (properties.getLogging() != null) {
// Logging Properties
writeLoggingProperties(xmlw, properties.getLogging());
}
if (properties.getHourMetrics() != null) {
// Hour Metrics
writeMetricsProperties(xmlw, properties.getHourMetrics(), Constants.AnalyticsConstants.HOUR_METRICS_ELEMENT);
}
if (properties.getMinuteMetrics() != null) {
// Minute Metrics
writeMetricsProperties(xmlw, properties.getMinuteMetrics(),
Constants.AnalyticsConstants.MINUTE_METRICS_ELEMENT);
}
if (properties.getCors() != null) {
// CORS Properties
writeCorsProperties(xmlw, properties.getCors());
}
// Default Service Version
if (properties.getDefaultServiceVersion() != null) {
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION,
properties.getDefaultServiceVersion());
}
// end StorageServiceProperties
xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT);
// end doc
xmlw.endDocument();
return outWriter.toString().getBytes(Constants.UTF8_CHARSET);
} | java | {
"resource": ""
} |
q167679 | ServicePropertiesSerializer.writeRetentionPolicy | validation | private static void writeRetentionPolicy(final XmlSerializer xmlw, final Integer val)
throws IllegalArgumentException, IllegalStateException, IOException {
xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT);
// Enabled
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ENABLED_ELEMENT, val != null ? Constants.TRUE
: Constants.FALSE);
if (val != null) {
// Days
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.DAYS_ELEMENT, val.toString());
}
// End Retention Policy
xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT);
} | java | {
"resource": ""
} |
q167680 | ServicePropertiesSerializer.writeCorsProperties | validation | private static void writeCorsProperties(final XmlSerializer xmlw, final CorsProperties cors)
throws IllegalArgumentException, IllegalStateException, IOException {
Utility.assertNotNull("CorsRules", cors.getCorsRules());
// CORS
xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_ELEMENT);
for (CorsRule rule : cors.getCorsRules()) {
if (rule.getAllowedOrigins().isEmpty() || rule.getAllowedMethods().isEmpty()
|| rule.getMaxAgeInSeconds() < 0) {
throw new IllegalArgumentException(SR.INVALID_CORS_RULE);
}
xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_RULE_ELEMENT);
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_ORIGINS_ELEMENT,
joinToString(rule.getAllowedOrigins(), ","));
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_METHODS_ELEMENT,
joinToString(rule.getAllowedMethods(), ","));
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.EXPOSED_HEADERS_ELEMENT,
joinToString(rule.getExposedHeaders(), ","));
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ALLOWED_HEADERS_ELEMENT,
joinToString(rule.getAllowedHeaders(), ","));
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.MAX_AGE_IN_SECONDS_ELEMENT,
Integer.toString(rule.getMaxAgeInSeconds()));
xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_RULE_ELEMENT);
}
// end CORS
xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.CORS_ELEMENT);
} | java | {
"resource": ""
} |
q167681 | ServicePropertiesSerializer.writeMetricsProperties | validation | private static void writeMetricsProperties(final XmlSerializer xmlw, final MetricsProperties metrics,
final String metricsName) throws IllegalArgumentException, IllegalStateException, IOException {
Utility.assertNotNull("metrics.Configuration", metrics.getMetricsLevel());
// Metrics
xmlw.startTag(Constants.EMPTY_STRING, metricsName);
// Version
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.VERSION_ELEMENT, metrics.getVersion());
// Enabled
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.ENABLED_ELEMENT,
metrics.getMetricsLevel() != MetricsLevel.DISABLED ? Constants.TRUE : Constants.FALSE);
if (metrics.getMetricsLevel() != MetricsLevel.DISABLED) {
// Include APIs
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT,
metrics.getMetricsLevel() == MetricsLevel.SERVICE_AND_API ? Constants.TRUE : Constants.FALSE);
}
// Retention Policy
writeRetentionPolicy(xmlw, metrics.getRetentionIntervalInDays());
// end Metrics
xmlw.endTag(Constants.EMPTY_STRING, metricsName);
} | java | {
"resource": ""
} |
q167682 | ServicePropertiesSerializer.writeLoggingProperties | validation | private static void writeLoggingProperties(final XmlSerializer xmlw, final LoggingProperties logging)
throws IllegalArgumentException, IllegalStateException, IOException {
Utility.assertNotNull("logging.LogOperationTypes", logging.getLogOperationTypes());
// Logging
xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.LOGGING_ELEMENT);
// Version
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.VERSION_ELEMENT, logging.getVersion());
// Delete
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.DELETE_ELEMENT, logging.getLogOperationTypes()
.contains(LoggingOperations.DELETE) ? Constants.TRUE : Constants.FALSE);
// Read
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.READ_ELEMENT, logging.getLogOperationTypes()
.contains(LoggingOperations.READ) ? Constants.TRUE : Constants.FALSE);
// Write
Utility.serializeElement(xmlw, Constants.AnalyticsConstants.WRITE_ELEMENT, logging.getLogOperationTypes()
.contains(LoggingOperations.WRITE) ? Constants.TRUE : Constants.FALSE);
// Retention Policy
writeRetentionPolicy(xmlw, logging.getRetentionIntervalInDays());
// end Logging
xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.LOGGING_ELEMENT);
} | java | {
"resource": ""
} |
q167683 | FileRequest.abortCopy | validation | public static HttpURLConnection abortCopy(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String copyId)
throws StorageException, IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.COPY);
builder.add(Constants.QueryConstants.COPY_ID, copyId);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setFixedLengthStreamingMode(0);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
request.setRequestProperty(Constants.HeaderConstants.COPY_ACTION_HEADER,
Constants.HeaderConstants.COPY_ACTION_ABORT);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
} | java | {
"resource": ""
} |
q167684 | FileRequest.addShareSnapshot | validation | public static void addShareSnapshot(final UriQueryBuilder builder, final String snapshotVersion)
throws StorageException {
if (snapshotVersion != null) {
builder.add(Constants.QueryConstants.SHARE_SNAPSHOT, snapshotVersion);
}
} | java | {
"resource": ""
} |
q167685 | FileRequest.copyFrom | validation | public static HttpURLConnection copyFrom(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition sourceAccessCondition,
final AccessCondition destinationAccessCondition, String source)
throws StorageException, IOException, URISyntaxException {
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, null, opContext);
request.setFixedLengthStreamingMode(0);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
request.setRequestProperty(Constants.HeaderConstants.COPY_SOURCE_HEADER, source);
if (sourceAccessCondition != null) {
sourceAccessCondition.applyConditionToRequest(request);
}
if (destinationAccessCondition != null) {
destinationAccessCondition.applyConditionToRequest(request);
}
return request;
} | java | {
"resource": ""
} |
q167686 | FileRequest.createShare | validation | public static HttpURLConnection createShare(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final FileShareProperties properties)
throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
final HttpURLConnection request = BaseRequest.create(uri, fileOptions, shareBuilder, opContext);
addProperties(request, properties);
return request;
} | java | {
"resource": ""
} |
q167687 | FileRequest.deleteShare | validation | public static HttpURLConnection deleteShare(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, String snapshotVersion, DeleteShareSnapshotsOption deleteSnapshotsOption)
throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
FileRequest.addShareSnapshot(shareBuilder, snapshotVersion);
HttpURLConnection request = BaseRequest.delete(uri, fileOptions, shareBuilder, opContext);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
switch (deleteSnapshotsOption) {
case NONE:
// nop
break;
case INCLUDE_SNAPSHOTS:
request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
Constants.HeaderConstants.INCLUDE_SNAPSHOTS_VALUE);
break;
default:
break;
}
return request;
} | java | {
"resource": ""
} |
q167688 | FileRequest.getAcl | validation | public static HttpURLConnection getAcl(final URI uri, final FileRequestOptions fileOptions,
final AccessCondition accessCondition, final OperationContext opContext) throws IOException,
URISyntaxException, StorageException {
final UriQueryBuilder builder = getShareUriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.ACL);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
if (accessCondition != null && !Utility.isNullOrEmpty(accessCondition.getLeaseID())) {
accessCondition.applyLeaseConditionToRequest(request);
}
return request;
} | java | {
"resource": ""
} |
q167689 | FileRequest.getFile | validation | public static HttpURLConnection getFile(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion, final Long offset,
final Long count, boolean requestRangeContentMD5) throws IOException, URISyntaxException, StorageException {
if (offset != null && requestRangeContentMD5) {
Utility.assertNotNull("count", count);
Utility.assertInBounds("count", count, 1, Constants.MAX_BLOCK_SIZE);
}
final UriQueryBuilder builder = new UriQueryBuilder();
FileRequest.addShareSnapshot(builder, snapshotVersion);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
if (offset != null) {
long rangeStart = offset;
long rangeEnd;
if (count != null) {
rangeEnd = offset + count - 1;
request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, String.format(
Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, rangeStart, rangeEnd));
}
else {
request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, String.format(
Utility.LOCALE_US, Constants.HeaderConstants.BEGIN_RANGE_HEADER_FORMAT, rangeStart));
}
}
if (offset != null && requestRangeContentMD5) {
request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, Constants.TRUE);
}
return request;
} | java | {
"resource": ""
} |
q167690 | FileRequest.getFileProperties | validation | public static HttpURLConnection getFileProperties(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion) throws StorageException,
IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
return getProperties(uri, fileOptions, opContext, accessCondition, builder, snapshotVersion);
} | java | {
"resource": ""
} |
q167691 | FileRequest.getFileRanges | validation | public static HttpURLConnection getFileRanges(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion) throws StorageException,
IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
addShareSnapshot(builder, snapshotVersion);
builder.add(Constants.QueryConstants.COMPONENT, RANGE_LIST_QUERY_ELEMENT_NAME);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
} | java | {
"resource": ""
} |
q167692 | FileRequest.getShareProperties | validation | public static HttpURLConnection getShareProperties(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, AccessCondition accessCondition, final String snapshotVersion) throws IOException, URISyntaxException,
StorageException {
final UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
return getProperties(uri, fileOptions, opContext, accessCondition, shareBuilder, snapshotVersion);
} | java | {
"resource": ""
} |
q167693 | FileRequest.getShareStats | validation | public static HttpURLConnection getShareStats(final URI uri, final FileRequestOptions options,
final OperationContext opContext)
throws IOException, URISyntaxException, StorageException {
UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
shareBuilder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.STATS);
final HttpURLConnection retConnection = BaseRequest.createURLConnection(uri, options, shareBuilder, opContext);
retConnection.setRequestMethod(Constants.HTTP_GET);
return retConnection;
} | java | {
"resource": ""
} |
q167694 | FileRequest.getShareUriQueryBuilder | validation | private static UriQueryBuilder getShareUriQueryBuilder() throws StorageException {
final UriQueryBuilder uriBuilder = new UriQueryBuilder();
try {
uriBuilder.add(Constants.QueryConstants.RESOURCETYPE, "share");
}
catch (final IllegalArgumentException e) {
throw Utility.generateNewUnexpectedStorageException(e);
}
return uriBuilder;
} | java | {
"resource": ""
} |
q167695 | FileRequest.getProperties | validation | private static HttpURLConnection getProperties(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, AccessCondition accessCondition, final UriQueryBuilder builder,
String snapshotVersion)
throws IOException, URISyntaxException, StorageException {
addShareSnapshot(builder, snapshotVersion);
HttpURLConnection request = BaseRequest.getProperties(uri, fileOptions, builder, opContext);
if (accessCondition != null) {
accessCondition.applyLeaseConditionToRequest(request);
}
return request;
} | java | {
"resource": ""
} |
q167696 | FileRequest.listShares | validation | public static HttpURLConnection listShares(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final ListingContext listingContext,
final EnumSet<ShareListingDetails> detailsIncluded) throws URISyntaxException, IOException, StorageException {
final UriQueryBuilder builder = BaseRequest.getListUriQueryBuilder(listingContext);
if (detailsIncluded != null && detailsIncluded.size() > 0) {
final StringBuilder sb = new StringBuilder();
boolean started = false;
if (detailsIncluded.contains(ShareListingDetails.SNAPSHOTS)) {
started = true;
sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME);
}
if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
if (started)
{
sb.append(",");
}
sb.append(Constants.QueryConstants.METADATA);
}
builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
}
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
return request;
} | java | {
"resource": ""
} |
q167697 | FileRequest.setShareMetadata | validation | public static HttpURLConnection setShareMetadata(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
URISyntaxException, StorageException {
final UriQueryBuilder shareBuilder = getShareUriQueryBuilder();
return setMetadata(uri, fileOptions, opContext, accessCondition, shareBuilder);
} | java | {
"resource": ""
} |
q167698 | FileRequest.setDirectoryMetadata | validation | public static HttpURLConnection setDirectoryMetadata(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
URISyntaxException, StorageException {
final UriQueryBuilder directoryBuilder = getDirectoryUriQueryBuilder();
return setMetadata(uri, fileOptions, opContext, accessCondition, directoryBuilder);
} | java | {
"resource": ""
} |
q167699 | FileRequest.createDirectory | validation | public static HttpURLConnection createDirectory(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext) throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder directoryBuilder = getDirectoryUriQueryBuilder();
return BaseRequest.create(uri, fileOptions, directoryBuilder, opContext);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.