Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handled NotFoundException to fix IPT fails #609

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.gbif.registry.domain.ws.LegacyDataset;
import org.gbif.registry.domain.ws.LegacyEndpoint;
import org.gbif.registry.domain.ws.LegacyInstallation;
import org.gbif.ws.NotFoundException;
import org.gbif.ws.security.LegacyRequestAuthorization;

import java.util.UUID;
Expand Down Expand Up @@ -68,11 +69,12 @@ public static boolean isValidOnUpdate(
LegacyInstallation installation,
InstallationService installationService,
OrganizationService organizationService) {
Installation existing = installationService.get(installation.getKey());
if (existing == null) {
try {
installationService.get(installation.getKey());
} catch (NotFoundException e) {
LOG.error(
"Installation update uses an installation that does not exist, key={}",
installation.getKey());
"Installation update uses an installation that does not exist, key={}",
installation.getKey());
return false;
}
return isValid(installation, organizationService);
Expand All @@ -97,7 +99,9 @@ public static boolean isValid(
installation.getKey());
return false;
}
if (organizationService.get(installation.getOrganizationKey()) == null) {
try {
organizationService.get(installation.getOrganizationKey());
} catch (NotFoundException e){
LOG.error(
"Installation uses a hosting org that does not exist, key={}",
installation.getOrganizationKey());
Expand Down Expand Up @@ -130,25 +134,29 @@ public static boolean isValid(
LOG.error("Dataset is missing mandatory field type, key={}", dataset.getKey());
return false;
}
if (dataset.getPublishingOrganizationKey() == null) {
LOG.error(
try {
if (dataset.getPublishingOrganizationKey() == null) {
LOG.error(
"Publishing org key not included in HTTP parameters for dataset, key={}",
dataset.getKey());
return false;
}
if (organizationService.get(dataset.getPublishingOrganizationKey()) == null) {
return false;
}
organizationService.get(dataset.getPublishingOrganizationKey());
} catch (NotFoundException e) {
LOG.error(
"Dataset uses an publishing org that does not exist, key={}",
dataset.getPublishingOrganizationKey());
"Dataset uses an publishing org that does not exist, key={}",
dataset.getPublishingOrganizationKey());
return false;
}
if (dataset.getInstallationKey() == null) {
LOG.error(
try {
if (dataset.getInstallationKey() == null) {
LOG.error(
"Installation key not included in HTTP parameters for dataset, or could not be inferred, key={}",
dataset.getKey());
return false;
}
if (installationService.get(dataset.getInstallationKey()) == null) {
return false;
}
installationService.get(dataset.getInstallationKey());
} catch (NotFoundException e) {
LOG.error("Dataset uses an IPT that does not exist, key={}", dataset.getInstallationKey());
return false;
}
Expand Down