Search in sources :

Example 6 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class AddHDInsightAdditionalClusterImpl method getStorageAccountsFromResponseMessage.

//not using for now.
private static List<ClientStorageAccount> getStorageAccountsFromResponseMessage(String responseMessage) throws StorageAccountResolveException {
    responseMessage = responseMessage.replace(" ", "");
    Matcher matcher = PATTERN_DEFAULT_STORAGE.matcher(responseMessage);
    String defaultStorageName = "";
    try {
        if (matcher.find()) {
            String str = matcher.group();
            defaultStorageName = str.split("[@.]")[2];
        }
    } catch (Exception e) {
        throw new StorageAccountResolveException();
    }
    matcher = PATTER_STORAGE_KEY.matcher(responseMessage);
    HashMap<String, String> storageKeysMap = new HashMap<String, String>();
    while (matcher.find()) {
        String str = matcher.group();
        String[] strs = str.replace("\"", "").split(":");
        String storageName = strs[0].split("\\.")[4];
        storageKeysMap.put(storageName, strs[1]);
    }
    if (StringHelper.isNullOrWhiteSpace(defaultStorageName) || !storageKeysMap.containsKey(defaultStorageName)) {
        throw new StorageAccountResolveException();
    }
    List<ClientStorageAccount> storageAccounts = new ArrayList<ClientStorageAccount>();
    storageAccounts.add(new HDStorageAccount(null, defaultStorageName, storageKeysMap.get(defaultStorageName), false, null));
    for (String storageName : storageKeysMap.keySet()) {
        if (!storageName.equals(defaultStorageName)) {
            storageAccounts.add(new HDStorageAccount(null, storageName, storageKeysMap.get(storageName), false, null));
        }
    }
    return storageAccounts;
}
Also used : Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) HDStorageAccount(com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 7 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class ExternalStorageAccountForm method populateFullStorageAccount.

public void populateFullStorageAccount() {
    ClientStorageAccount clientStorageAccount = new ClientStorageAccount(accountNameTextField.getText());
    clientStorageAccount.setPrimaryKey(accountKeyTextField.getText());
    clientStorageAccount.setUseCustomEndpoints(specifyCustomEndpointsRadioButton.getSelection());
    if (specifyCustomEndpointsRadioButton.getSelection()) {
        clientStorageAccount.setBlobsUri(blobURLTextField.getText());
        clientStorageAccount.setQueuesUri(queueURLTextField.getText());
        clientStorageAccount.setTablesUri(tableURLTextField.getText());
    } else {
        clientStorageAccount.setProtocol(useHTTPRadioButton.getSelection() ? HTTP : HTTPS);
    }
    fullStorageAccount = clientStorageAccount;
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Example 8 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class BlobExplorerFileEditorProvider method accept.

@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    StorageAccount storageAccount = virtualFile.getUserData(UIHelperImpl.STORAGE_KEY);
    ClientStorageAccount clientStorageAccount = virtualFile.getUserData(UIHelperImpl.CLIENT_STORAGE_KEY);
    BlobContainer blobContainer = virtualFile.getUserData(CONTAINER_KEY);
    return ((storageAccount != null || clientStorageAccount != null) && blobContainer != null);
}
Also used : StorageAccount(com.microsoft.azure.management.storage.StorageAccount) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Example 9 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class AttachExternalStorageAccountAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm((Project) storageModule.getProject());
    form.setTitle("Attach External Storage Account");
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            ClientStorageAccount storageAccount = form.getStorageAccount();
            ClientStorageAccount fullStorageAccount = form.getFullStorageAccount();
            for (ClientStorageAccount clientStorageAccount : ExternalStorageHelper.getList(storageModule.getProject())) {
                String name = storageAccount.getName();
                if (clientStorageAccount.getName().equals(name)) {
                    JOptionPane.showMessageDialog(form.getContentPane(), "Storage account with name '" + name + "' already exists.", "Azure Explorer", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            ExternalStorageNode node = new ExternalStorageNode(storageModule, fullStorageAccount);
            storageModule.addChildNode(node);
            ExternalStorageHelper.add(storageAccount);
        }
    });
    form.show();
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageAccountForm(com.microsoft.intellij.forms.ExternalStorageAccountForm) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)

Example 10 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class ExternalStorageAccountForm method populateStorageAccount.

public void populateStorageAccount() {
    ClientStorageAccount clientStorageAccount = new ClientStorageAccount(accountNameTextField.getText());
    clientStorageAccount.setUseCustomEndpoints(specifyCustomEndpointsRadioButton.getSelection());
    if (rememberAccountKeyCheckBox.getSelection()) {
        clientStorageAccount.setPrimaryKey(accountKeyTextField.getText());
    }
    if (specifyCustomEndpointsRadioButton.getSelection()) {
        clientStorageAccount.setBlobsUri(blobURLTextField.getText());
        clientStorageAccount.setQueuesUri(queueURLTextField.getText());
        clientStorageAccount.setTablesUri(tableURLTextField.getText());
    } else {
        clientStorageAccount.setProtocol(useHTTPRadioButton.getSelection() ? HTTP : HTTPS);
    }
    storageAccount = clientStorageAccount;
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Aggregations

ClientStorageAccount (com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)13 ExternalStorageNode (com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)4 ExternalStorageAccountForm (com.microsoft.intellij.forms.ExternalStorageAccountForm)3 ArrayList (java.util.ArrayList)3 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)2 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)2 Gson (com.google.gson.Gson)1 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)1 HDStorageAccount (com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount)1 Azure (com.microsoft.azure.management.Azure)1 SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)1 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)1 ExternalStorageAccountForm (com.microsoft.azuretools.azureexplorer.forms.ExternalStorageAccountForm)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1 BlobContainer (com.microsoft.tooling.msservices.model.storage.BlobContainer)1 StorageModule (com.microsoft.tooling.msservices.serviceexplorer.azure.storage.StorageModule)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1