Skip to content

IRSA-257: add cookies to PTF ibe LC for loggedin user #430

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

Merged
merged 1 commit into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
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 @@ -46,6 +46,8 @@ protected FileInfo loadData(ServerRequest request) throws IOException, DataAcces
if (ofile == null || ofile.getSizeInBytes() == 0) {
return null;
} else {
Map<String, String> cookies = ServerContext.getRequestOwner().getIdentityCookies();
ofile.setCookies(cookies);
return ofile;
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
* Utility class to get metadata from PTF pids using IBE API.
Expand Down Expand Up @@ -60,7 +61,7 @@ public String[] getListPfilenames(long[] pid) throws IOException, InterruptedExc
public String[] getValuesFromColumn(long pid[], String colName) throws IOException {
File tempFile = getTempFile();
try {
URLConnection aconn = URLDownload.makeConnection(createURL(pid));
URLConnection aconn = URLDownload.makeConnection(createURL(pid), getCookies());
aconn.setRequestProperty("Accept", "*/*");
URLDownload.getDataToFile(aconn, tempFile);
} catch (Exception e) {
Expand Down Expand Up @@ -106,4 +107,9 @@ protected File getTempFile() throws IOException {
}
return f;
}

public Map<String,String> getCookies() {
if(isTestMode) return null;//or overwrite in test unit
return ServerContext.getRequestOwner().getIdentityCookies();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Map;

/**
* Created by ejoliet on 7/20/17.
Expand All @@ -37,6 +38,11 @@ public void testPid2FilenameResolver() throws IOException, InterruptedException
protected File getTempFile() throws IOException {
return f;
}

@Override
public Map<String, String> getCookies() {
return null;
}
};
String[] fs = res.getValuesFromColumn(pids, "pfilename");

Expand Down