Substitute some !Optional.isPresent with Optional.isEmpty
This commit is contained in:
parent
28fe44aea4
commit
ceda459942
|
@ -55,7 +55,7 @@ public class OptionalAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
if (requestAccount.isPresent() && (!targetAccount.isPresent() || (targetAccount.isPresent() && !targetAccount.get().isEnabled()))) {
|
if (requestAccount.isPresent() && (targetAccount.isEmpty() || (targetAccount.isPresent() && !targetAccount.get().isEnabled()))) {
|
||||||
throw new WebApplicationException(Response.Status.NOT_FOUND);
|
throw new WebApplicationException(Response.Status.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,6 @@ public class ProfileController {
|
||||||
return getVersionedProfile(requestAccount, accessKey, uuid, version, Optional.of(credentialRequest));
|
return getVersionedProfile(requestAccount, accessKey, uuid, version, Optional.of(credentialRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("OptionalIsPresent")
|
|
||||||
private Optional<Profile> getVersionedProfile(Optional<Account> requestAccount,
|
private Optional<Profile> getVersionedProfile(Optional<Account> requestAccount,
|
||||||
Optional<Anonymous> accessKey,
|
Optional<Anonymous> accessKey,
|
||||||
UUID uuid,
|
UUID uuid,
|
||||||
|
@ -176,7 +175,7 @@ public class ProfileController {
|
||||||
if (!isZkEnabled) throw new WebApplicationException(Response.Status.NOT_FOUND);
|
if (!isZkEnabled) throw new WebApplicationException(Response.Status.NOT_FOUND);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!requestAccount.isPresent() && !accessKey.isPresent()) {
|
if (requestAccount.isEmpty() && accessKey.isEmpty()) {
|
||||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,13 +228,13 @@ public class ProfileController {
|
||||||
|
|
||||||
Optional<UUID> uuid = usernamesManager.get(username);
|
Optional<UUID> uuid = usernamesManager.get(username);
|
||||||
|
|
||||||
if (!uuid.isPresent()) {
|
if (uuid.isEmpty()) {
|
||||||
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
|
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Account> accountProfile = accountsManager.get(uuid.get());
|
Optional<Account> accountProfile = accountsManager.get(uuid.get());
|
||||||
|
|
||||||
if (!accountProfile.isPresent()) {
|
if (accountProfile.isEmpty()) {
|
||||||
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
|
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +257,8 @@ public class ProfileController {
|
||||||
UUID uuid)
|
UUID uuid)
|
||||||
throws InvalidInputException
|
throws InvalidInputException
|
||||||
{
|
{
|
||||||
if (!encodedProfileCredentialRequest.isPresent()) return Optional.empty();
|
if (encodedProfileCredentialRequest.isEmpty()) return Optional.empty();
|
||||||
if (!profile.isPresent()) return Optional.empty();
|
if (profile.isEmpty()) return Optional.empty();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProfileKeyCommitment commitment = new ProfileKeyCommitment(profile.get().getCommitment());
|
ProfileKeyCommitment commitment = new ProfileKeyCommitment(profile.get().getCommitment());
|
||||||
|
@ -296,7 +295,7 @@ public class ProfileController {
|
||||||
@QueryParam("ca") boolean useCaCertificate)
|
@QueryParam("ca") boolean useCaCertificate)
|
||||||
throws RateLimitExceededException
|
throws RateLimitExceededException
|
||||||
{
|
{
|
||||||
if (!requestAccount.isPresent() && !accessKey.isPresent()) {
|
if (requestAccount.isEmpty() && accessKey.isEmpty()) {
|
||||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue