use of org.akaza.openclinica.bean.extract.ArchivedDatasetFileBean in project OpenClinica by OpenClinica.
the class AccessFileServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int fileId = fp.getInt("fileId");
ArchivedDatasetFileDAO asdfdao = new ArchivedDatasetFileDAO(sm.getDataSource());
DatasetDAO dsDao = new DatasetDAO(sm.getDataSource());
ArchivedDatasetFileBean asdfBean = (ArchivedDatasetFileBean) asdfdao.findByPK(fileId);
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
DatasetBean dsBean = (DatasetBean) dsDao.findByPK(asdfBean.getDatasetId());
int parentId = currentStudy.getParentStudyId();
if (//Logged in at study level
parentId == 0) {
StudyBean studyBean = (StudyBean) studyDao.findByPK(dsBean.getStudyId());
//parent id of dataset created
parentId = studyBean.getParentStudyId();
}
//logic: is parentId of the dataset created not equal to currentstudy? or is current study
if (parentId != currentStudy.getId())
if (dsBean.getStudyId() != currentStudy.getId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + respage.getString("change_study_contact_sysadmin"));
// TODO
throw new InsufficientPermissionException(Page.MENU_SERVLET, resexception.getString("not_allowed_access_extract_data_servlet"), "1");
}
// asdfBean.setWebPath(WEB_DIR+
// asdfBean.getDatasetId()+
// "/"+
// asdfBean.getName());
Page finalTarget = Page.EXPORT_DATA_CUSTOM;
/*
* if (asdfBean.getExportFormatId() ==
* ExportFormatBean.EXCELFILE.getId()) { //
* response.setContentType("application/octet-stream");
* response.setHeader("Content-Disposition", "attachment; filename=" +
* asdfBean.getName()); logger.info("found file name: "+
* finalTarget.getFileName()); //
* finalTarget.setFileName(asdfBean.getWebPath()); finalTarget =
* Page.GENERATE_EXCEL_DATASET; } else {
*/
logger.debug("found file reference: " + asdfBean.getFileReference() + " and file name: " + asdfBean.getName());
if (asdfBean.getFileReference().endsWith(".zip")) {
response.setHeader("Content-disposition", "attachment; filename=\"" + asdfBean.getName() + "\";");
response.setContentType("application/zip");
// response.setContentType("application/download");
} else if (asdfBean.getFileReference().endsWith(".pdf")) {
response.setHeader("Content-disposition", "attachment; filename=\"" + asdfBean.getName() + "\";");
response.setContentType("application/pdf");
// response.setContentType("application/download; application/pdf");
} else if (asdfBean.getFileReference().endsWith(".csv")) {
response.setHeader("Content-disposition", "attachment; filename=\"" + asdfBean.getName() + "\";");
response.setContentType("text/csv");
// response.setContentType("application/download; text/csv");
} else if (asdfBean.getFileReference().endsWith(".xml")) {
response.setHeader("Content-disposition", "attachment; filename=\"" + asdfBean.getName() + "\";");
response.setContentType("text/xml");
// response.setContentType("application/download; text/xml");
} else if (asdfBean.getFileReference().endsWith(".html")) {
response.setHeader("Content-disposition", "filename=\"" + asdfBean.getName() + "\";");
response.setContentType("text/html; charset=utf-8");
} else {
// response.setContentType("text/plain");
// to ensure backwards compatability to text files shown on server
// not needed anymore? tbh 10/2010
}
finalTarget.setFileName("/WEB-INF/jsp/extract/generatedFileDataset.jsp");
// }
// finalTarget.setFileName(asdfBean.getWebPath());
request.setAttribute("generate", asdfBean.getFileReference());
response.setHeader("Pragma", "public");
forwardPage(finalTarget);
}
use of org.akaza.openclinica.bean.extract.ArchivedDatasetFileBean in project OpenClinica by OpenClinica.
the class SecureController method decodeLINKURL.
private String decodeLINKURL(String successMsg, Integer datasetId) {
ArchivedDatasetFileDAO asdfDAO = new ArchivedDatasetFileDAO(sm.getDataSource());
ArrayList<ArchivedDatasetFileBean> fileBeans = asdfDAO.findByDatasetId(datasetId);
successMsg = successMsg.replace("$linkURL", "<a href=\"" + CoreResources.getField("sysURL.base") + "AccessFile?fileId=" + fileBeans.get(0).getId() + "\">here </a>");
return successMsg;
}
Aggregations