Search in sources :

Example 1 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull in project azure-tools-for-java by Microsoft.

the class IDEHelperImpl method runInBackground.

@NotNull
@Override
public CancellableTask.CancellableTaskHandle runInBackground(@NotNull ProjectDescriptor projectDescriptor, @NotNull final String name, @Nullable final String indicatorText, @NotNull final CancellableTask cancellableTask) throws AzureCmdException {
    final CancellableTaskHandleImpl handle = new CancellableTaskHandleImpl();
    final Project project = findOpenProject(projectDescriptor);
    // background tasks via ProgressManager can be scheduled only on the
    // dispatch thread
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            ProgressManager.getInstance().run(getCancellableBackgroundTask(project, name, indicatorText, handle, cancellableTask));
        }
    }, ModalityState.any());
    return handle;
}
Also used : Project(com.intellij.openapi.project.Project) CancellableTaskHandleImpl(com.microsoft.intellij.helpers.tasks.CancellableTaskHandleImpl) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 2 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method getBlobContainers.

@NotNull
public List<BlobContainer> getBlobContainers(@NotNull String connectionString) throws AzureCmdException {
    List<BlobContainer> bcList = new ArrayList<BlobContainer>();
    try {
        CloudBlobClient client = getCloudBlobClient(connectionString);
        for (CloudBlobContainer container : client.listContainers(null, ContainerListingDetails.ALL, null, null)) {
            String uri = container.getUri() != null ? container.getUri().toString() : "";
            String eTag = "";
            Calendar lastModified = new GregorianCalendar();
            BlobContainerProperties properties = container.getProperties();
            if (properties != null) {
                eTag = Strings.nullToEmpty(properties.getEtag());
                if (properties.getLastModified() != null) {
                    lastModified.setTime(properties.getLastModified());
                }
            }
            String publicReadAccessType = "";
            BlobContainerPermissions blobContainerPermissions = container.downloadPermissions();
            if (blobContainerPermissions != null && blobContainerPermissions.getPublicAccess() != null) {
                publicReadAccessType = blobContainerPermissions.getPublicAccess().toString();
            }
            bcList.add(new BlobContainer(Strings.nullToEmpty(container.getName()), uri, eTag, lastModified, publicReadAccessType));
        }
        return bcList;
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the Blob Container list", t);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 3 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull in project azure-tools-for-java by Microsoft.

the class HDInsightHelperImpl method createAddNewHDInsightReaderClusterAction.

@NotNull
public NodeActionListener createAddNewHDInsightReaderClusterAction(@NotNull HDInsightRootModule module, @NotNull ClusterDetail clusterDetail) {
    return new NodeActionListener() {

        @Override
        protected void actionPerformed(NodeActionEvent nodeActionEvent) throws AzureCmdException {
            AddNewHDInsightReaderClusterForm linkClusterForm = new AddNewHDInsightReaderClusterForm(PluginUtil.getParentShell(), module, clusterDetail);
            linkClusterForm.open();
        }
    };
}
Also used : NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AddNewHDInsightReaderClusterForm(com.microsoft.azuretools.azureexplorer.forms.AddNewHDInsightReaderClusterForm) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 4 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull in project azure-tools-for-java by Microsoft.

the class TelemetryUtils method getMachieId.

@NotNull
public static String getMachieId(String dataFile, String prefVal, String instId) {
    String ret = "";
    if (new File(dataFile).exists()) {
        String prefValue = DataOperations.getProperty(dataFile, prefVal);
        if (prefValue != null && prefValue.equalsIgnoreCase("false")) {
            return ret;
        }
        ret = DataOperations.getProperty(dataFile, instId);
        if (ret == null || ret.isEmpty() || !InstallationIdUtils.isValidHashMac(ret)) {
            ret = InstallationIdUtils.getHashMac();
        }
    } else {
        ret = InstallationIdUtils.getHashMac();
    }
    return ret;
}
Also used : File(java.io.File) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 5 with NotNull

use of com.microsoft.azuretools.azurecommons.helpers.NotNull in project azure-tools-for-java by Microsoft.

the class CreateProjectUtil method convert.

@NotNull
private static IFile convert(@NotNull File file) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IPath location = Path.fromOSString(file.getAbsolutePath());
    IFile ifile = workspace.getRoot().getFileForLocation(location);
    return ifile;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IWorkspace(org.eclipse.core.resources.IWorkspace) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Aggregations

NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)65 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)21 Nullable (com.microsoft.azuretools.azurecommons.helpers.Nullable)8 File (java.io.File)8 IOException (java.io.IOException)8 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)7 java.util (java.util)7 Observable (rx.Observable)7 URI (java.net.URI)6 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)5 ObjectConvertUtils (com.microsoft.azure.hdinsight.sdk.rest.ObjectConvertUtils)5 List (java.util.List)5 StringUtils (org.apache.commons.lang3.StringUtils)5 Project (com.intellij.openapi.project.Project)4 CloudQueue (com.microsoft.azure.storage.queue.CloudQueue)4 CloudQueueClient (com.microsoft.azure.storage.queue.CloudQueueClient)4 ExecutionException (java.util.concurrent.ExecutionException)4 Collectors (java.util.stream.Collectors)4 ExecutionException (com.intellij.execution.ExecutionException)3 Artifact (com.intellij.packaging.artifacts.Artifact)3