final long fsFid = fid;
final String fsPath = fs.getPath().toString();
FSAnalyzer fsa = fe.getAnalyzer();
FileSummaryData fsd = fsa.getFileSummaryData(fid);
DataDescriptor dd = fsd.getDataDescriptor();
List<TypeGuessSummary> tgses = fs.getTypeGuesses();
add(new Label("filetitle", fs.getFname()));
add(new ExternalLink("filesubtitlelink", urlFor(FilesPage.class, new PageParameters("targetdir=" + fs.getPath().getParent().toString())).toString(), fs.getPath().getParent().toString()));
// Set up the download file link
IResourceStream hadoopfsStream = new AbstractResourceStreamWriter() {
public void write(Response output) {
WebResponse weboutput = (WebResponse) output;
try {
BufferedInputStream in = new BufferedInputStream(new FileSummary(FishEye.getInstance().getAnalyzer(), fid).getRawBytes());
try {
byte buf[] = new byte[4096];
int contentLen = -1;
while ((contentLen = in.read(buf)) >= 0) {
weboutput.write(buf, 0, contentLen);
}
} finally {
try {
in.close();
} catch (IOException iex) {
}
}
} catch (IOException iex) {
iex.printStackTrace();
}
}
public Bytes length() {
return Bytes.bytes(new FileSummary(FishEye.getInstance().getAnalyzer(), fid).getSize());
}
};
ResourceStreamResource resourceStream = new ResourceStreamResource(hadoopfsStream);
resourceStream.setContentDisposition(ContentDisposition.ATTACHMENT);
resourceStream.setFileName(fs.getFname());
add(new ResourceLink<File>("downloadlink", resourceStream));
// querySupported container holds queryform
// queryUnsupported container holds an error message
final boolean querySupported = dd.isHiveSupported() && fe.isQueryServerAvailable(false);
final boolean hasJoins = joinPairs.size() > 0;
add(new WebMarkupContainer("querySupported") {
{
setOutputMarkupPlaceholderTag(true);
setVisibilityAllowed(querySupported);