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;
}
};
}
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);
}
}
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();
}
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();
}
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;
}
Aggregations