Search in sources :

Example 51 with NotNull

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

the class AzureCertificateHelper method getHttpsURLConnectionProvider.

@NotNull
private static HttpsURLConnectionProvider getHttpsURLConnectionProvider(@NotNull final SSLSocketFactory sslSocketFactory, @NotNull final RestServiceManager manager) {
    return new HttpsURLConnectionProvider() {

        @Override
        @NotNull
        public HttpsURLConnection getSSLConnection(@NotNull String managementUrl, @NotNull String path, @NotNull ContentType contentType) throws AzureCmdException {
            HttpsURLConnection sslConnection = manager.getSSLConnection(managementUrl, path, contentType);
            sslConnection.setSSLSocketFactory(sslSocketFactory);
            return sslConnection;
        }
    };
}
Also used : HttpsURLConnectionProvider(com.microsoft.tooling.msservices.helpers.azure.rest.RestServiceManager.HttpsURLConnectionProvider) ContentType(com.microsoft.tooling.msservices.helpers.azure.rest.RestServiceManager.ContentType) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 52 with NotNull

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

the class RestServiceManagerBaseImpl method getSSLConnection.

@NotNull
public HttpsURLConnection getSSLConnection(@NotNull String managementUrl, @NotNull String path, @NotNull ContentType contentType) throws AzureCmdException {
    try {
        URL myUrl = new URL(managementUrl + path);
        HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection();
        conn.addRequestProperty(USER_AGENT_HEADER, getPlatformUserAgent());
        conn.addRequestProperty(TELEMETRY_HEADER, getPlatformUserAgent());
        conn.addRequestProperty(X_MS_VERSION_HEADER, AZURE_API_VERSION);
        conn.addRequestProperty(ACCEPT_HEADER, "");
        conn.setReadTimeout(DEFAULT_READ_TIMEOUT);
        if (contentType != null) {
            conn.addRequestProperty(CONTENT_TYPE_HEADER, contentType.toString());
        }
        return conn;
    } catch (IOException e) {
        throw new AzureCmdException(e.getMessage(), e);
    }
}
Also used : AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) URL(java.net.URL) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 53 with NotNull

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

the class DockerUtil method createContainer.

/**
 * create container with specified ImageName:TagName.
 */
@NotNull
public static String createContainer(@NotNull DockerClient docker, @NotNull String imageNameWithTag, @NotNull String containerServerPort) throws DockerException, InterruptedException {
    final Map<String, List<PortBinding>> portBindings = new HashMap<>();
    List<PortBinding> randomPort = new ArrayList<>();
    PortBinding randomBinding = PortBinding.randomPort("0.0.0.0");
    randomPort.add(randomBinding);
    portBindings.put(containerServerPort, randomPort);
    final HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).build();
    final ContainerConfig config = ContainerConfig.builder().hostConfig(hostConfig).image(imageNameWithTag).exposedPorts(containerServerPort).build();
    final ContainerCreation container = docker.createContainer(config);
    return container.id();
}
Also used : ContainerConfig(com.spotify.docker.client.messages.ContainerConfig) ContainerCreation(com.spotify.docker.client.messages.ContainerCreation) PortBinding(com.spotify.docker.client.messages.PortBinding) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HostConfig(com.spotify.docker.client.messages.HostConfig) ArrayList(java.util.ArrayList) List(java.util.List) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 54 with NotNull

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

the class IDEHelperImpl method getArray.

@NotNull
private static byte[] getArray(@NotNull InputStream is) throws IOException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    int readCount;
    final byte[] data = new byte[16384];
    while ((readCount = is.read(data, 0, data.length)) != -1) {
        buffer.write(data, 0, readCount);
    }
    buffer.flush();
    return buffer.toByteArray();
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 55 with NotNull

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

the class IDEHelperImpl method getArtifacts.

@NotNull
@Override
public List<ArtifactDescriptor> getArtifacts(@NotNull ProjectDescriptor projectDescriptor) throws AzureCmdException {
    final Project project = findOpenProject(projectDescriptor);
    final List<ArtifactDescriptor> artifactDescriptors = new ArrayList<>();
    for (final Artifact artifact : ArtifactUtil.getArtifactWithOutputPaths(project)) {
        artifactDescriptors.add(new ArtifactDescriptor(artifact.getName(), artifact.getArtifactType().getId()));
    }
    return artifactDescriptors;
}
Also used : Project(com.intellij.openapi.project.Project) Artifact(com.intellij.packaging.artifacts.Artifact) 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