Skip to content

Commit 8eb4f62

Browse files
committed
fix ifs
1 parent 4aa12ca commit 8eb4f62

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/main/java/edu/harvard/iq/dataverse/api/AbstractApiBean.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,14 @@ protected Dataset findDatasetOrDie(String id, boolean deep) throws WrappedRespon
415415
if (datasetId == null) {
416416
datasetId = dvObjSvc.findIdByAltGlobalId(globalId, DvObject.DType.Dataset);
417417
}
418-
if (datasetId == null && FeatureFlags.ENABLE_PID_FAILURE_LOG.enabled()) {
419-
FailedPIDResolutionLoggingServiceBean.FailedPIDResolutionEntry entry = new FailedPIDResolutionEntry(persistentId, httpRequest.getRequestURI(),httpRequest.getMethod(), new DataverseRequest(null, httpRequest).getSourceAddress());
420-
fprLogService.logEntry(entry);
418+
if (datasetId == null) {
419+
if (FeatureFlags.ENABLE_PID_FAILURE_LOG.enabled()) {
420+
421+
FailedPIDResolutionLoggingServiceBean.FailedPIDResolutionEntry entry = new FailedPIDResolutionEntry(persistentId, httpRequest.getRequestURI(), httpRequest.getMethod(), new DataverseRequest(null, httpRequest).getSourceAddress());
422+
fprLogService.logEntry(entry);
423+
}
421424
throw new WrappedResponse(
422-
notFound(BundleUtil.getStringFromBundle("find.dataset.error.dataset_id_is_null", Collections.singletonList(PERSISTENT_ID_KEY.substring(1)))));
425+
notFound(BundleUtil.getStringFromBundle("find.dataset.error.dataset_id_is_null", Collections.singletonList(PERSISTENT_ID_KEY.substring(1)))));
423426
}
424427
}
425428
if (deep) {
@@ -489,8 +492,11 @@ protected DataFile findDataFileOrDie(String id) throws WrappedResponse {
489492
}
490493
datafile = fileService.findByGlobalId(persistentId);
491494
if (datafile == null) {
492-
FailedPIDResolutionLoggingServiceBean.FailedPIDResolutionEntry entry = new FailedPIDResolutionEntry(persistentId, httpRequest.getRequestURI(),httpRequest.getMethod(), new DataverseRequest(null, httpRequest).getSourceAddress());
493-
fprLogService.logEntry(entry);
495+
if (FeatureFlags.ENABLE_PID_FAILURE_LOG.enabled()) {
496+
497+
FailedPIDResolutionLoggingServiceBean.FailedPIDResolutionEntry entry = new FailedPIDResolutionEntry(persistentId, httpRequest.getRequestURI(), httpRequest.getMethod(), new DataverseRequest(null, httpRequest).getSourceAddress());
498+
fprLogService.logEntry(entry);
499+
}
494500
throw new WrappedResponse(notFound(BundleUtil.getStringFromBundle("find.datafile.error.dataset.not.found.persistentId", Collections.singletonList(persistentId))));
495501
}
496502
return datafile;

0 commit comments

Comments
 (0)