@Test public void testGetBlobClient () throws Exception { Globals globals = new Globals (); JaqyInterpreter interpreter = new JaqyInterpreter (globals, null, null); AzureUtils.setAccount ("devstoreaccount1", interpreter); AzureUtils.setKey ("Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", interpreter); AzureUtils.setEndPoint ("http: CloudBlobClient client = AzureUtils.getBlobClient (interpreter, "devstoreaccount1"); CloudBlobContainer container = client.getContainerReference ("testcontainer"); if (!container.exists ()) { container.create (); } CloudBlobClient client2 = AzureUtils.getBlobClient (interpreter, "devstoreaccount1"); Assert.assertSame (client2, client); client2 = AzureUtils.getBlobClient (interpreter, null); Assert.assertSame (client2, client); client2 = AzureUtils.getBlobClient (interpreter, "abcdefg"); Assert.assertNotSame (client2, client); container.delete (); }
public static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account) throws IOException { VariableManager vm = interpreter.getVariableManager (); Object o = vm.get (WASB_CLIENT_VAR); if (o instanceof CloudBlobClient) { CloudBlobClient client = (CloudBlobClient)o; if (account == null) { return client; } StorageCredentials credential = client.getCredentials (); if (credential != null && account.equals (credential.getAccountName ())) { return client; } } try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(getAccountString (interpreter, account)); CloudBlobClient client = storageAccount.createCloudBlobClient(); vm.setVariable (WASB_CLIENT_VAR, client); return client; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } }
AzureUtils { public static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account) throws IOException { VariableManager vm = interpreter.getVariableManager (); Object o = vm.get (WASB_CLIENT_VAR); if (o instanceof CloudBlobClient) { CloudBlobClient client = (CloudBlobClient)o; if (account == null) { return client; } StorageCredentials credential = client.getCredentials (); if (credential != null && account.equals (credential.getAccountName ())) { return client; } } try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(getAccountString (interpreter, account)); CloudBlobClient client = storageAccount.createCloudBlobClient(); vm.setVariable (WASB_CLIENT_VAR, client); return client; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } } }
AzureUtils { public static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account) throws IOException { VariableManager vm = interpreter.getVariableManager (); Object o = vm.get (WASB_CLIENT_VAR); if (o instanceof CloudBlobClient) { CloudBlobClient client = (CloudBlobClient)o; if (account == null) { return client; } StorageCredentials credential = client.getCredentials (); if (credential != null && account.equals (credential.getAccountName ())) { return client; } } try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(getAccountString (interpreter, account)); CloudBlobClient client = storageAccount.createCloudBlobClient(); vm.setVariable (WASB_CLIENT_VAR, client); return client; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } }  }
AzureUtils { public static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account) throws IOException { VariableManager vm = interpreter.getVariableManager (); Object o = vm.get (WASB_CLIENT_VAR); if (o instanceof CloudBlobClient) { CloudBlobClient client = (CloudBlobClient)o; if (account == null) { return client; } StorageCredentials credential = client.getCredentials (); if (credential != null && account.equals (credential.getAccountName ())) { return client; } } try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(getAccountString (interpreter, account)); CloudBlobClient client = storageAccount.createCloudBlobClient(); vm.setVariable (WASB_CLIENT_VAR, client); return client; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } }  static void setAccount(String account, JaqyInterpreter interpreter); static void setContainer(String container, JaqyInterpreter interpreter); static void setKey(String key, JaqyInterpreter interpreter); static void setEndPoint(String endPoint, JaqyInterpreter interpreter); static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account); static AzurePathInfo getPathInfo(String path); static CloudBlobContainer getContainer(String account, String container, JaqyInterpreter interpreter); static void createContainer(String container, JaqyInterpreter interpreter); static void deleteContainer(String container, JaqyInterpreter interpreter); }
AzureUtils { public static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account) throws IOException { VariableManager vm = interpreter.getVariableManager (); Object o = vm.get (WASB_CLIENT_VAR); if (o instanceof CloudBlobClient) { CloudBlobClient client = (CloudBlobClient)o; if (account == null) { return client; } StorageCredentials credential = client.getCredentials (); if (credential != null && account.equals (credential.getAccountName ())) { return client; } } try { CloudStorageAccount storageAccount = CloudStorageAccount.parse(getAccountString (interpreter, account)); CloudBlobClient client = storageAccount.createCloudBlobClient(); vm.setVariable (WASB_CLIENT_VAR, client); return client; } catch (Exception ex) { throw new IOException (ex.getMessage (), ex); } }  static void setAccount(String account, JaqyInterpreter interpreter); static void setContainer(String container, JaqyInterpreter interpreter); static void setKey(String key, JaqyInterpreter interpreter); static void setEndPoint(String endPoint, JaqyInterpreter interpreter); static CloudBlobClient getBlobClient(JaqyInterpreter interpreter, String account); static AzurePathInfo getPathInfo(String path); static CloudBlobContainer getContainer(String account, String container, JaqyInterpreter interpreter); static void createContainer(String container, JaqyInterpreter interpreter); static void deleteContainer(String container, JaqyInterpreter interpreter); final static String WASB_CLIENT_VAR; final static String WASB_ACCOUNT_VAR; final static String WASB_CONTAINER_VAR; final static String WASB_KEY_VAR; final static String WASB_ENDPOINT_VAR; }