URI sasUri = PathUtility.addToQuery(resourceUri, this.token); return PathUtility.addToQuery(sasUri, apiVersion);
/** * Appends a path to a URI correctly using "/" as separator. * * @param uri * The base Uri. * @param relativeOrAbsoluteUri * The relative or absloute URI. * @return The appended Uri. * @throws URISyntaxException */ public static URI appendPathToSingleUri(final URI uri, final String relativeOrAbsoluteUri) throws URISyntaxException { return appendPathToSingleUri(uri, relativeOrAbsoluteUri, "/"); }
/** * Appends a path to a list of URIs correctly using "/" as separator. * * @param uriList * The base Uri. * @param relativeOrAbslouteUri * The relative or absloute URI. * @return The appended Uri. * @throws URISyntaxException */ public static StorageUri appendPathToUri(final StorageUri uriList, final String relativeOrAbsoluteUri) throws URISyntaxException { return appendPathToUri(uriList, relativeOrAbsoluteUri, "/"); }
/** * Adds a queryString to an URI. * * @param resourceURI * the URI of the resource * @param queryString * the query string to add * @return an appended URI. * @throws URISyntaxException * if the resulting URI is invalid. * @throws StorageException */ public static URI addToQuery(final URI resourceURI, final String queryString) throws URISyntaxException, StorageException { return addToSingleUriQuery(resourceURI, parseQueryString(queryString)); }
/** * Gets the container URI from a blob address * * @param blobAddress * the blob address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the container URI from a blob address * @throws URISyntaxException */ public static StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris) throws URISyntaxException { final String containerName = getContainerNameFromUri(blobAddress.getPrimaryUri(), usePathStyleUris); final StorageUri containerUri = appendPathToUri(getServiceClientBaseAddress(blobAddress, usePathStyleUris), containerName); return containerUri; }
/** * Gets the share URI from a file address * * @param fileAddress * the file address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the share URI from a file address * @throws URISyntaxException */ public static StorageUri getShareURI(final StorageUri fileAddress, final boolean usePathStyleUris) throws URISyntaxException { final String shareName = getShareNameFromUri(fileAddress.getPrimaryUri(), usePathStyleUris); final StorageUri shareUri = appendPathToUri(getServiceClientBaseAddress(fileAddress, usePathStyleUris), shareName); return shareUri; }
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); this.blobServiceClient = new CloudBlobClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getContainerNameFromUri(this.storageUri.getPrimaryUri(), usePathStyleUris);
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); final HashMap<String, String[]> queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); this.blobServiceClient = new CloudBlobClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getBlobNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris);
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); this.fileServiceClient = new CloudFileClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getDirectoryNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris); final HashMap<String, String[]> queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); this.fileServiceClient = new CloudFileClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getFileNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris); final HashMap<String, String[]> queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
public void removeStorageBlob(URI blobURI, String resourceGroupName) throws Exception { // Obtain container, storage account, and blob name String storageAccountName = blobURI.getHost().split("\\.")[0]; String containerName = PathUtility.getContainerNameFromUri(blobURI, false); String blobName = PathUtility.getBlobNameFromURI(blobURI, false); LOGGER.log(Level.INFO, "removeStorageBlob: Removing blob {0}, in container {1} of storage account {2}", new Object[]{blobName, containerName, storageAccountName}); CloudBlobContainer container = getCloudBlobContainer(azureClient, resourceGroupName, storageAccountName, containerName); container.getBlockBlobReference(blobName).deleteIfExists(); if (containerName.startsWith("jnk")) { Iterable<ListBlobItem> blobs = container.listBlobs(); if (blobs.iterator().hasNext()) { // the container is not empty return; } // the container is empty and we should delete it LOGGER.log(Level.INFO, "removeStorageBlob: Removing empty container ", containerName); container.delete(); } }
URI tempURI; try { tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI()); containerAttributes.setName(PathUtility.getContainerNameFromUri(tempURI, usePathStyleUris));
/** * Gets the FileDirectoryAttributes from the given request. * * @param request * the request to get attributes from. * @param usePathStyleUris * a value indicating if the account is using pathSytleUris. * @return the FileDirectoryAttributes from the given request. * @throws StorageException */ public static FileDirectoryAttributes getFileDirectoryAttributes(final HttpURLConnection request, final boolean usePathStyleUris) throws StorageException { final FileDirectoryAttributes directoryAttributes = new FileDirectoryAttributes(); URI tempURI; try { tempURI = PathUtility.stripSingleURIQueryAndFragment(request.getURL().toURI()); } catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } directoryAttributes.setName(PathUtility.getDirectoryNameFromURI(tempURI, usePathStyleUris)); final FileDirectoryProperties directoryProperties = directoryAttributes.getProperties(); directoryProperties.setEtag(BaseResponse.getEtag(request)); directoryProperties.setLastModified(new Date(request.getLastModified())); directoryAttributes.setMetadata(getMetadata(request)); directoryProperties.setServerEncrypted( Constants.TRUE.equals(request.getHeaderField(Constants.HeaderConstants.SERVER_ENCRYPTED))); return directoryAttributes; }
/** * Gets the blob name from the URI. * * @param inURI * the resource address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the blobs name * @throws URISyntaxException */ public static String getBlobNameFromURI(final URI inURI, final boolean usePathStyleUris) throws URISyntaxException { return Utility.safeRelativize(new URI(getContainerURI(new StorageUri(inURI), usePathStyleUris).getPrimaryUri() .toString().concat("/")), inURI); }
/** * Returns the canonical name of the file in the format of * <i>/<service-name>/<account-name>/<share-name>/<file-name></i>. * <p> * This format is used for Shared Access operations. * * @return The canonical name in the format of <i>/<service-name>/<account-name> * /<share-name>/<file-name></i>. */ String getCanonicalName() { StringBuilder canonicalName = new StringBuilder("/"); canonicalName.append(SR.FILE); String rawPath = this.getUri().getRawPath(); if (this.fileServiceClient.isUsePathStyleUris()) { canonicalName.append(rawPath); } else { canonicalName.append(PathUtility.getCanonicalPathFromCredentials( this.getServiceClient().getCredentials(), rawPath)); } return canonicalName.toString(); }
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); this.queueServiceClient = new CloudQueueClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getContainerNameFromUri(storageUri.getPrimaryUri(), usePathStyleUris);
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); final HashMap<String, String[]> queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); this.blobServiceClient = new CloudBlobClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getBlobNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris);
/** * Gets the container URI from a blob address * * @param blobAddress * the blob address * @param usePathStyleUris * a value indicating if the address is a path style uri. * @return the container URI from a blob address * @throws URISyntaxException */ public static StorageUri getContainerURI(final StorageUri blobAddress, final boolean usePathStyleUris) throws URISyntaxException { final String containerName = getContainerNameFromUri(blobAddress.getPrimaryUri(), usePathStyleUris); final StorageUri containerUri = appendPathToUri(getServiceClientBaseAddress(blobAddress, usePathStyleUris), containerName); return containerUri; }
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); this.fileServiceClient = new CloudFileClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getDirectoryNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris); final HashMap<String, String[]> queryParameters = PathUtility.parseQueryString(completeUri.getQuery());
this.storageUri = PathUtility.stripURIQueryAndFragment(completeUri); this.fileServiceClient = new CloudFileClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getFileNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris); final HashMap<String, String[]> queryParameters = PathUtility.parseQueryString(completeUri.getQuery());