use of com.microsoft.azure.storage.StorageException in project zeppelin by apache.
the class AzureNotebookRepo method list.
@Override
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {
List<NoteInfo> infos = new LinkedList<>();
NoteInfo info = null;
for (ListFileItem item : rootDir.listFilesAndDirectories()) {
if (item.getClass() == CloudFileDirectory.class) {
CloudFileDirectory dir = (CloudFileDirectory) item;
try {
if (dir.getFileReference("note.json").exists()) {
info = new NoteInfo(getNote(dir.getName()));
if (info != null) {
infos.add(info);
}
}
} catch (StorageException | URISyntaxException e) {
String msg = "Error enumerating notebooks from Azure storage";
LOG.error(msg, e);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
return infos;
}
use of com.microsoft.azure.storage.StorageException in project zeppelin by apache.
the class AzureNotebookRepo method save.
@Override
public void save(Note note, AuthenticationInfo subject) throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setPrettyPrinting();
Gson gson = gsonBuilder.create();
String json = gson.toJson(note);
ByteArrayOutputStream output = new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(output);
writer.write(json);
writer.close();
output.close();
byte[] buffer = output.toByteArray();
try {
CloudFileDirectory dir = rootDir.getDirectoryReference(note.getId());
dir.createIfNotExists();
CloudFile cloudFile = dir.getFileReference("note.json");
cloudFile.uploadFromByteArray(buffer, 0, buffer.length);
} catch (URISyntaxException | StorageException e) {
String msg = String.format("Error saving notebook %s to Azure storage", note.getId());
LOG.error(msg, e);
throw new IOException(msg, e);
}
}
use of com.microsoft.azure.storage.StorageException in project azure-sdk-for-java by Azure.
the class ManageWebAppStorageAccountConnection method setUpStorageAccount.
private static CloudBlobContainer setUpStorageAccount(String connectionString, String containerName) {
try {
CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
// Create a blob service client
CloudBlobClient blobClient = account.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference(containerName);
container.createIfNotExists();
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Include public access in the permissions object
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
// Set the permissions on the container
container.uploadPermissions(containerPermissions);
return container;
} catch (StorageException | URISyntaxException | InvalidKeyException e) {
throw new RuntimeException(e);
}
}
use of com.microsoft.azure.storage.StorageException in project azure-sdk-for-java by Azure.
the class ManageLinuxWebAppStorageAccountConnection method setUpStorageAccount.
private static CloudBlobContainer setUpStorageAccount(String connectionString, String containerName) {
try {
CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
// Create a blob service client
CloudBlobClient blobClient = account.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference(containerName);
container.createIfNotExists();
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Include public access in the permissions object
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
// Set the permissions on the container
container.uploadPermissions(containerPermissions);
return container;
} catch (StorageException | URISyntaxException | InvalidKeyException e) {
throw new RuntimeException(e);
}
}
use of com.microsoft.azure.storage.StorageException in project camel by apache.
the class QueueServiceConsumer method poll.
@Override
protected int poll() throws Exception {
Exchange exchange = super.getEndpoint().createExchange();
try {
LOG.trace("Retrieving a message");
retrieveMessage(exchange);
super.getAsyncProcessor().process(exchange);
return 1;
} catch (StorageException ex) {
if (404 == ex.getHttpStatusCode()) {
return 0;
} else {
throw ex;
}
}
}
Aggregations