Skip to content

Commit b2931f9

Browse files
authored
Applied APIView suggestion for KV Admin. (Azure#22381)
* Applied APIView suggestions. * Applied APIView suggestions. * Fixed SpotBugs issue. * Fixed another SpotBugs issue.
1 parent 913b669 commit b2931f9

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

sdk/keyvault/azure-security-keyvault-administration/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Release History
22

33
## 4.0.0 (2021-06-17)
4-
- Initial release of `KeyVaultAccessControlClient` and `KeyVaultAccessControlAsyncClient` to managed role assignments and definitions for Managed HSM.
4+
- Initial release of `KeyVaultAccessControlClient` and `KeyVaultAccessControlAsyncClient` to manage role assignments and definitions for Managed HSM.
55
- Initial release of `KeyVaultBackupClient` and `KeyVaultBackupAsyncClient` to backup and restore Managed HSM.
66

77
### Features Added

sdk/keyvault/azure-security-keyvault-administration/src/main/java/com/azure/security/keyvault/administration/models/KeyVaultRoleScope.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ public static KeyVaultRoleScope fromString(String name) {
3030
*
3131
* @param url A string representing a URL containing the name of the scope to look for.
3232
* @return The corresponding {@link KeyVaultRoleScope}.
33-
* @throws MalformedURLException If the given {@link String URL String} is malformed.
33+
* @throws IllegalArgumentException If the given {@link String URL String} is malformed.
3434
*/
35-
public static KeyVaultRoleScope fromUrl(String url) throws MalformedURLException {
36-
return fromString(new URL(url).getPath(), KeyVaultRoleScope.class);
35+
public static KeyVaultRoleScope fromUrl(String url) {
36+
try {
37+
return fromString(new URL(url).getPath(), KeyVaultRoleScope.class);
38+
} catch (MalformedURLException e) {
39+
throw new IllegalArgumentException(e);
40+
}
3741
}
3842

3943
/**

sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifier.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.azure.security.keyvault.certificates.models;
55

66
import com.azure.core.annotation.Immutable;
7+
import com.azure.core.util.logging.ClientLogger;
78
import com.azure.security.keyvault.certificates.CertificateAsyncClient;
89
import com.azure.security.keyvault.certificates.CertificateClient;
910

@@ -16,6 +17,7 @@
1617
*/
1718
@Immutable
1819
public final class KeyVaultCertificateIdentifier {
20+
private final ClientLogger logger = new ClientLogger(KeyVaultCertificateIdentifier.class);
1921
private final String sourceId, vaultUrl, name, version;
2022

2123
/**
@@ -37,7 +39,7 @@ public final class KeyVaultCertificateIdentifier {
3739
*/
3840
public KeyVaultCertificateIdentifier(String sourceId) {
3941
if (sourceId == null) {
40-
throw new NullPointerException("'sourceId' cannot be null");
42+
throw logger.logExceptionAsError(new NullPointerException("'sourceId' cannot be null"));
4143
}
4244

4345
try {
@@ -47,15 +49,17 @@ public KeyVaultCertificateIdentifier(String sourceId) {
4749

4850
// More or less segments in the URI than expected.
4951
if (pathSegments.length != 3 && pathSegments.length != 4) {
50-
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.");
52+
throw logger.logExceptionAsError(
53+
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier."));
5154
}
5255

5356
this.sourceId = sourceId;
5457
this.vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost());
5558
this.name = pathSegments[2];
5659
this.version = pathSegments.length == 4 ? pathSegments[3] : null;
5760
} catch (MalformedURLException e) {
58-
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e);
61+
throw logger.logExceptionAsError(
62+
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e));
5963
}
6064
}
6165

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/KeyVaultKeyIdentifier.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.azure.security.keyvault.keys.models;
55

66
import com.azure.core.annotation.Immutable;
7+
import com.azure.core.util.logging.ClientLogger;
78
import com.azure.security.keyvault.keys.KeyAsyncClient;
89
import com.azure.security.keyvault.keys.KeyClient;
910

@@ -16,6 +17,7 @@
1617
*/
1718
@Immutable
1819
public final class KeyVaultKeyIdentifier {
20+
private final ClientLogger logger = new ClientLogger(KeyVaultKeyIdentifier.class);
1921
private final String sourceId, vaultUrl, name, version;
2022

2123
/**
@@ -37,7 +39,7 @@ public final class KeyVaultKeyIdentifier {
3739
*/
3840
public KeyVaultKeyIdentifier(String sourceId) {
3941
if (sourceId == null) {
40-
throw new NullPointerException("'sourceId' cannot be null.");
42+
throw logger.logExceptionAsError(new NullPointerException("'sourceId' cannot be null."));
4143
}
4244

4345
try {
@@ -47,15 +49,17 @@ public KeyVaultKeyIdentifier(String sourceId) {
4749

4850
// More or less segments in the URI than expected.
4951
if (pathSegments.length != 3 && pathSegments.length != 4) {
50-
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.");
52+
throw logger.logExceptionAsError(
53+
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier."));
5154
}
5255

5356
this.sourceId = sourceId;
5457
this.vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost());
5558
this.name = pathSegments[2];
5659
this.version = pathSegments.length == 4 ? pathSegments[3] : null;
5760
} catch (MalformedURLException e) {
58-
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e);
61+
throw logger.logExceptionAsError(
62+
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e));
5963
}
6064
}
6165

sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/models/KeyVaultSecretIdentifier.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.azure.security.keyvault.secrets.models;
55

66
import com.azure.core.annotation.Immutable;
7+
import com.azure.core.util.logging.ClientLogger;
78
import com.azure.security.keyvault.secrets.SecretAsyncClient;
89
import com.azure.security.keyvault.secrets.SecretClient;
910

@@ -16,6 +17,7 @@
1617
*/
1718
@Immutable
1819
public final class KeyVaultSecretIdentifier {
20+
private final ClientLogger logger = new ClientLogger(KeyVaultSecretIdentifier.class);
1921
private final String sourceId, vaultUrl, name, version;
2022

2123
/**
@@ -37,7 +39,7 @@ public final class KeyVaultSecretIdentifier {
3739
*/
3840
public KeyVaultSecretIdentifier(String sourceId) {
3941
if (sourceId == null) {
40-
throw new NullPointerException("'sourceId' cannot be null.");
42+
throw logger.logExceptionAsError(new NullPointerException("'sourceId' cannot be null."));
4143
}
4244

4345
try {
@@ -47,15 +49,17 @@ public KeyVaultSecretIdentifier(String sourceId) {
4749

4850
// More or less segments in the URI than expected.
4951
if (pathSegments.length != 3 && pathSegments.length != 4) {
50-
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.");
52+
throw logger.logExceptionAsError(
53+
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier."));
5154
}
5255

5356
this.sourceId = sourceId;
5457
this.vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost());
5558
this.name = pathSegments[2];
5659
this.version = pathSegments.length == 4 ? pathSegments[3] : null;
5760
} catch (MalformedURLException e) {
58-
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e);
61+
throw logger.logExceptionAsError(
62+
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e));
5963
}
6064
}
6165

0 commit comments

Comments
 (0)