Skip to content

Commit 9e4cfa0

Browse files
committed
IRSA-257: add cookies to PTF ibe LC for loggedin user
1 parent f328fb6 commit 9e4cfa0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/persistence/IbeFileRetrieve.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ protected FileInfo loadData(ServerRequest request) throws IOException, DataAcces
4646
if (ofile == null || ofile.getSizeInBytes() == 0) {
4747
return null;
4848
} else {
49+
Map<String, String> cookies = ServerContext.getRequestOwner().getIdentityCookies();
50+
ofile.setCookies(cookies);
4951
return ofile;
5052
}
5153
} catch (Exception e) {

src/firefly/java/edu/caltech/ipac/firefly/server/query/ptf/PtfIbeResolver.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.ArrayList;
2121
import java.util.Iterator;
2222
import java.util.List;
23+
import java.util.Map;
2324

2425
/**
2526
* Utility class to get metadata from PTF pids using IBE API.
@@ -60,7 +61,7 @@ public String[] getListPfilenames(long[] pid) throws IOException, InterruptedExc
6061
public String[] getValuesFromColumn(long pid[], String colName) throws IOException {
6162
File tempFile = getTempFile();
6263
try {
63-
URLConnection aconn = URLDownload.makeConnection(createURL(pid));
64+
URLConnection aconn = URLDownload.makeConnection(createURL(pid), getCookies());
6465
aconn.setRequestProperty("Accept", "*/*");
6566
URLDownload.getDataToFile(aconn, tempFile);
6667
} catch (Exception e) {
@@ -106,4 +107,9 @@ protected File getTempFile() throws IOException {
106107
}
107108
return f;
108109
}
110+
111+
public Map<String,String> getCookies() {
112+
if(isTestMode) return null;//or overwrite in test unit
113+
return ServerContext.getRequestOwner().getIdentityCookies();
114+
}
109115
}

src/firefly/test/edu/caltech/ipac/firefly/server/query/PtfIbeTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.File;
1212
import java.io.IOException;
1313
import java.net.URL;
14+
import java.util.Map;
1415

1516
/**
1617
* Created by ejoliet on 7/20/17.
@@ -37,6 +38,11 @@ public void testPid2FilenameResolver() throws IOException, InterruptedException
3738
protected File getTempFile() throws IOException {
3839
return f;
3940
}
41+
42+
@Override
43+
public Map<String, String> getCookies() {
44+
return null;
45+
}
4046
};
4147
String[] fs = res.getValuesFromColumn(pids, "pfilename");
4248

0 commit comments

Comments
 (0)