use of com.microsoft.tooling.msservices.model.storage.BlobFile in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method deleteSelectedFile.
private void deleteSelectedFile() {
final BlobFile blobItem = getFileSelection();
if (blobItem != null) {
if (JOptionPane.showConfirmDialog(mainPanel, "Are you sure you want to delete this blob?", "Delete Blob", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.OK_OPTION) {
setUIState(true);
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Deleting blob...", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
progressIndicator.setIndeterminate(true);
try {
StorageClientSDKManager.getManager().deleteBlobFile(connectionString, blobItem);
if (blobItems.size() <= 1) {
directoryQueue.clear();
directoryQueue.addLast(StorageClientSDKManager.getManager().getRootDirectory(connectionString, blobContainer));
queryTextField.setText("");
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
fillGrid();
}
});
} catch (AzureCmdException ex) {
String msg = "An error occurred while attempting to delete blob." + "\n" + String.format(message("webappExpMsg"), ex.getMessage());
PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, ex);
}
}
});
}
}
}
use of com.microsoft.tooling.msservices.model.storage.BlobFile in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method saveAsSelectedFile.
private void saveAsSelectedFile() {
BlobFile fileSelection = getFileSelection();
assert fileSelection != null;
JFileChooser jFileChooser = new JFileChooser(new File(fileSelection.getName()));
jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int saveDialog = jFileChooser.showSaveDialog(this.mainPanel);
if (saveDialog == JFileChooser.APPROVE_OPTION) {
downloadSelectedFile(jFileChooser.getSelectedFile(), false);
}
}
use of com.microsoft.tooling.msservices.model.storage.BlobFile in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method getBlobItems.
@NotNull
public List<BlobItem> getBlobItems(@NotNull String connectionString, @NotNull BlobDirectory blobDirectory) throws AzureCmdException {
List<BlobItem> biList = new ArrayList<BlobItem>();
try {
CloudBlobClient client = getCloudBlobClient(connectionString);
String containerName = blobDirectory.getContainerName();
String delimiter = client.getDirectoryDelimiter();
CloudBlobContainer container = client.getContainerReference(containerName);
CloudBlobDirectory directory = container.getDirectoryReference(blobDirectory.getPath());
for (ListBlobItem item : directory.listBlobs()) {
String uri = item.getUri() != null ? item.getUri().toString() : "";
if (item instanceof CloudBlobDirectory) {
CloudBlobDirectory subDirectory = (CloudBlobDirectory) item;
String name = extractBlobItemName(subDirectory.getPrefix(), delimiter);
String path = Strings.nullToEmpty(subDirectory.getPrefix());
biList.add(new BlobDirectory(name, uri, containerName, path));
} else if (item instanceof CloudBlob) {
CloudBlob blob = (CloudBlob) item;
String name = extractBlobItemName(blob.getName(), delimiter);
String path = Strings.nullToEmpty(blob.getName());
String type = "";
String cacheControlHeader = "";
String contentEncoding = "";
String contentLanguage = "";
String contentType = "";
String contentMD5Header = "";
String eTag = "";
Calendar lastModified = new GregorianCalendar();
long size = 0;
BlobProperties properties = blob.getProperties();
if (properties != null) {
if (properties.getBlobType() != null) {
type = properties.getBlobType().toString();
}
cacheControlHeader = Strings.nullToEmpty(properties.getCacheControl());
contentEncoding = Strings.nullToEmpty(properties.getContentEncoding());
contentLanguage = Strings.nullToEmpty(properties.getContentLanguage());
contentType = Strings.nullToEmpty(properties.getContentType());
contentMD5Header = Strings.nullToEmpty(properties.getContentMD5());
eTag = Strings.nullToEmpty(properties.getEtag());
if (properties.getLastModified() != null) {
lastModified.setTime(properties.getLastModified());
}
size = properties.getLength();
}
biList.add(new BlobFile(name, uri, containerName, path, type, cacheControlHeader, contentEncoding, contentLanguage, contentType, contentMD5Header, eTag, lastModified, size));
}
}
return biList;
} catch (Throwable t) {
throw new AzureCmdException("Error retrieving the Blob Item list", t);
}
}
use of com.microsoft.tooling.msservices.model.storage.BlobFile in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method deleteSelectedFile.
private void deleteSelectedFile() {
final BlobFile blobItem = getFileSelection();
if (blobItem != null) {
if (DefaultLoader.getUIHelper().showConfirmation("Are you sure you want to delete this blob?", "Delete Blob", new String[] { "Yes", "No" }, null)) {
setUIState(true);
DefaultLoader.getIdeHelper().runInBackground(null, "Deleting blob...", false, true, "Deleting blob...", new Runnable() {
@Override
public void run() {
try {
StorageClientSDKManager.getManager().deleteBlobFile(connectionString, blobItem);
if (blobItems.size() <= 1) {
directoryQueue.clear();
directoryQueue.addLast(StorageClientSDKManager.getManager().getRootDirectory(connectionString, blobContainer));
}
DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
@Override
public void run() {
if (blobItems.size() <= 1) {
queryTextField.setText("");
}
fillGrid();
}
});
} catch (AzureCmdException ex) {
DefaultLoader.getUIHelper().showException("Error deleting blob.", ex, "Error deleting blob", false, true);
}
}
});
}
}
}
Aggregations