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

3661 error on download of deleted file #4901

Merged
merged 4 commits into from
Jul 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 10 additions & 21 deletions src/main/java/edu/harvard/iq/dataverse/api/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -854,30 +854,19 @@ private boolean isAccessAuthorized(DataFile df, String apiToken) {

boolean published = false;

// TODO:
// this very likely creates a ton of queries; put some thought into
// optimizing this stuff? -- 4.2.1
//
// update: it appears that we can finally trust the dvObject.isReleased()
// method; so all this monstrous crawling through the filemetadatas,
// below, may not be necessary anymore! - need to verify... L.A. 10.21.2015
// update: NO! we still can't just trust .isReleased(), for these purposes!
// TODO: explain why. L.A. 10.29.2015


if (df.getOwner().getReleasedVersion() != null) {
//logger.fine("file belongs to a dataset with a released version.");
if (df.getOwner().getReleasedVersion().getFileMetadatas() != null) {
//logger.fine("going through the list of filemetadatas that belong to the released version.");
for (FileMetadata fm : df.getOwner().getReleasedVersion().getFileMetadatas()) {
if (df.equals(fm.getDataFile())) {
//logger.fine("found a match!");
published = true;
}
}

/*
SEK 7/26/2018 for 3661 relying on the version state of the dataset versions
to which this file is attached check to see if at least one is RELEASED
*/
for (FileMetadata fm : df.getFileMetadatas()){
if(fm.getDatasetVersion().isPublished()){
published = true;
break;
}
}


// TODO: (IMPORTANT!)
// Business logic like this should NOT be maintained in individual
// application fragments.
Expand Down