List of usage examples for javax.servlet.http HttpSession getServletContext
public ServletContext getServletContext();
From source file:edu.ucsd.library.xdre.web.CollectionOperationController.java
public static String handleProcesses(Map<String, String[]> paramsMap, HttpSession session) throws Exception { String message = ""; String returnMessage = ""; DAMSClient damsClient = null;//w w w. j a va2 s .com String collectionId = getParameter(paramsMap, "category"); boolean[] operations = new boolean[20]; operations[0] = getParameter(paramsMap, "validateFileCount") != null; operations[1] = getParameter(paramsMap, "validateChecksums") != null; operations[2] = getParameter(paramsMap, "rdfImport") != null; operations[3] = getParameter(paramsMap, "createDerivatives") != null; operations[4] = getParameter(paramsMap, "collectionRelease") != null; operations[5] = getParameter(paramsMap, "externalImport") != null; operations[6] = getParameter(paramsMap, "marcModsImport") != null || getParameter(paramsMap, "excelImport") != null; operations[7] = getParameter(paramsMap, "luceneIndex") != null || getParameter(paramsMap, "solrDump") != null || getParameter(paramsMap, "solrRecordsDump") != null; operations[8] = getParameter(paramsMap, "sendToCDL") != null; operations[9] = getParameter(paramsMap, "dataConvert") != null; operations[10] = getParameter(paramsMap, "ingest") != null; operations[11] = getParameter(paramsMap, "serialize") != null; operations[12] = getParameter(paramsMap, "tsSyn") != null; operations[13] = getParameter(paramsMap, "createJson") != null; operations[14] = getParameter(paramsMap, "cacheJson") != null; operations[15] = getParameter(paramsMap, "fileUpload") != null; operations[16] = getParameter(paramsMap, "jsonDiffUpdate") != null; operations[17] = getParameter(paramsMap, "validateManifest") != null; operations[18] = getParameter(paramsMap, "metadataExport") != null; operations[19] = getParameter(paramsMap, "jhoveReport") != null; int submissionId = (int) System.currentTimeMillis(); String logLink = "https://" + (Constants.CLUSTER_HOST_NAME.indexOf("localhost") >= 0 ? "localhost:8443" : Constants.CLUSTER_HOST_NAME.indexOf("lib-ingest") >= 0 ? Constants.CLUSTER_HOST_NAME + ".ucsd.edu:8443" : Constants.CLUSTER_HOST_NAME + ".ucsd.edu") + "/damsmanager/downloadLog.do?submissionId=" + submissionId; String dataLink = ""; String ds = getParameter(paramsMap, "ts"); String dsDest = null; if ((ds == null || (ds = ds.trim()).length() == 0) && !(operations[15] || operations[16])) ds = Constants.DEFAULT_TRIPLESTORE; else if (operations[12]) { dsDest = getParameter(paramsMap, "dsDest"); if (dsDest == null) throw new ServletException("No destination triplestore data source provided..."); else if (ds.equals(dsDest) || !dsDest.startsWith("ts/")) throw new ServletException("Can't sync triplestore from " + ds + " to destination " + dsDest + "."); } String fileStore = getParameter(paramsMap, "fs"); damsClient = new DAMSClient(Constants.DAMS_STORAGE_URL); damsClient.setTripleStore(ds); damsClient.setFileStore(fileStore); damsClient.setUser((String) session.getAttribute("user")); String clientVersion = session.getServletContext().getInitParameter("src-version"); String clientTool = "Custom"; if (message.length() == 0) { int userId = -1; String userIdAttr = (String) session.getAttribute("employeeId"); if (userIdAttr != null && userIdAttr.length() > 0) { try { userId = Integer.parseInt(userIdAttr); } catch (NumberFormatException e) { userId = -1; } } CollectionHandler handler = null; OutputStream fileOut = null; try { boolean successful = true; for (int i = 0; i < operations.length; i++) { handler = null; String exeInfo = ""; if (operations[i]) { String opMessage = "Preparing procedure "; RequestOrganizer.setProgressPercentage(session, 0); message = ""; if (i == 0) { session.setAttribute("status", opMessage + "File Count Validation for FileStore " + fileStore + " ..."); boolean ingestFile = getParameter(paramsMap, "ingestFile") != null; boolean dams4FileRename = getParameter(paramsMap, "dams4FileRename") != null; handler = new FileCountValidaionHandler(damsClient, collectionId); ((FileCountValidaionHandler) handler).setDams4FileRename(dams4FileRename); if (ingestFile) { String[] filesPaths = getParameter(paramsMap, "filesLocation").split(";"); List<String> ingestFiles = new ArrayList<String>(); for (int j = 0; j < filesPaths.length; j++) ingestFiles.add(new File(Constants.DAMS_STAGING + "/" + filesPaths[j]) .getAbsolutePath()); ((FileCountValidaionHandler) handler).setIngestFile(ingestFile); ((FileCountValidaionHandler) handler) .setFilesPaths(ingestFiles.toArray(new String[ingestFiles.size()])); } } else if (i == 1) { session.setAttribute("status", opMessage + "Checksum Validation for FileStore " + fileStore + " ..."); handler = new ChecksumsHandler(damsClient, collectionId, null); } else if (i == 2) { session.setAttribute("status", opMessage + "Importing metadata ..."); String dataFormat = getParameter(paramsMap, "dataFormat"); String importMode = getParameter(paramsMap, "importMode"); handler = new MetadataImportHandler(damsClient, collectionId, getParameter(paramsMap, "data"), dataFormat, importMode); } else if (i == 3) { session.setAttribute("status", opMessage + "Derivatives Creation ..."); boolean derReplace = getParameter(paramsMap, "derReplace") == null ? false : true; String reqSize = getParameter(paramsMap, "size"); String[] sizes = null; if (reqSize != null && reqSize.length() > 0) sizes = reqSize.split(","); handler = new DerivativeHandler(damsClient, collectionId, sizes, derReplace); } else if (i == 4) { session.setAttribute("status", opMessage + " release collection " + collectionId + " ..."); String releaseState = getParameter(paramsMap, "releaseState"); String releaseOption = getParameter(paramsMap, "releaseOption"); String collectionToMerge = getParameter(paramsMap, "collectionToMerge"); log.info("Collection release: category =>" + collectionId + ", releaseState => " + releaseState + ", releaseOption => " + releaseOption + ", collectionToMerge => " + collectionToMerge); handler = new CollectionReleaseHandler(damsClient, collectionId, releaseState, releaseOption); ((CollectionReleaseHandler) handler).setCollectionToMerge(collectionToMerge); } else if (i == 5) { session.setAttribute("status", opMessage + "Importing objects ..."); String[] dataPaths = getParameter(paramsMap, "dataPath").split(";"); String[] filesPaths = getParameter(paramsMap, "filesPath").split(";"); String importOption = getParameter(paramsMap, "importOption"); boolean replace = getParameter(paramsMap, "externalImportReplace") != null; List<File> dFiles = new ArrayList<File>(); for (int j = 0; j < dataPaths.length; j++) { String dataPath = dataPaths[j]; if (dataPath != null && (dataPath = dataPath.trim()).length() > 0) { File file = new File(Constants.DAMS_STAGING + "/" + dataPath); CollectionHandler.listFiles(dFiles, file); } } List<String> ingestFiles = new ArrayList<String>(); for (int j = 0; j < filesPaths.length; j++) { if ((filesPaths[j] = filesPaths[j].trim()).length() > 0) ingestFiles.add(new File(Constants.DAMS_STAGING + "/" + filesPaths[j]) .getAbsolutePath()); } String[] excelExts = { "xls", "xlsx" }; List<File> excelFiles = FileUtils.filterFiles(dFiles, excelExts); if (excelFiles.size() > 0) { // Remove the Excel source that need conversion from the file list dFiles.removeAll(excelFiles); // Pre-processing boolean preprocessing = importOption.equalsIgnoreCase("pre-processing"); Element rdfPreview = null; StringBuilder errorMessage = new StringBuilder(); StringBuilder duplicatRecords = new StringBuilder(); List<String> ids = new ArrayList<String>(); if (preprocessing) { Document doc = new DocumentFactory().createDocument(); rdfPreview = TabularRecord.createRdfRoot(doc); } handler = new MetadataImportHandler(damsClient, null); handler.setSubmissionId(submissionId); handler.setSession(session); handler.setUserId(userId); // Directory to hold the converted rdf/xml File tmpDir = new File(Constants.TMP_FILE_DIR + File.separatorChar + "converted"); if (!tmpDir.exists()) tmpDir.mkdir(); // Convert Excel source files to DAMS4 rdf/xml int filesCount = 0; for (File f : excelFiles) { filesCount++; RecordSource src = new ExcelSource(f); for (Record rec = null; (rec = src.nextRecord()) != null;) { String id = rec.recordID(); handler.logMessage("Pre-processing record with ID " + id + " ... "); if (ids.indexOf(id) < 0) { ids.add(id); } else { duplicatRecords.append(id + ", "); handler.logError("Found duplicated record with ID " + id + "."); } try { Document doc = rec.toRDFXML(); if (duplicatRecords.length() == 0 && errorMessage.length() == 0) { if (preprocessing) { // preview when there are no error reported rdfPreview.add(rec.toRDFXML().selectSingleNode("//dams:Object") .detach()); } else { File convertedFile = new File(tmpDir.getAbsolutePath(), id.replaceAll("[\\//:.*]+", "") + ".rdf.xml"); try { writeXml(convertedFile, doc.asXML()); } finally { convertedFile.deleteOnExit(); if (dFiles.indexOf(convertedFile) < 0) { dFiles.add(convertedFile); handler.logMessage("Added converted RDF/XML file " + convertedFile.getAbsolutePath()); } } } } } catch (Exception e) { log.warn("Excel Input Stream error", e); errorMessage.append("-" + e.getMessage() + "\n"); handler.logMessage(e.getMessage() + "\n"); } } handler.setProgressPercentage(filesCount * 100 / excelFiles.size()); } if (errorMessage.length() == 0 && duplicatRecords.length() == 0) { if (preprocessing) { File destFile = new File(Constants.TMP_FILE_DIR, "preview-" + submissionId + "-rdf.xml"); writeXml(destFile, rdfPreview.getDocument().asXML()); successful = true; message = "\nPre-processing passed. "; message += "\nThe converted RDF/XML is ready for <a href=\"" + logLink + "&file=" + destFile.getName() + "\">download</a>."; //handler.logMessage(message); handler.release(); handler = null; } else { handler.release(); // Initiate the ingest task for Excel AND/OR RDF/XML files handler = new RDFDAMS4ImportTsHandler(damsClient, dFiles.toArray(new File[dFiles.size()]), importOption); ((RDFDAMS4ImportTsHandler) handler) .setFilesPaths(ingestFiles.toArray(new String[ingestFiles.size()])); ((RDFDAMS4ImportTsHandler) handler).setReplace(replace); } } else { successful = false; message = "\nPre-processing issues found:"; if (duplicatRecords.length() > 0) message += "\nDuplicated records: " + duplicatRecords .substring(0, duplicatRecords.length() - 2).toString(); if (errorMessage.length() > 0) message += "\nOther Errors: \n" + errorMessage.toString(); //handler.logMessage(message); handler.release(); handler = null; } } else { // Ingest for RDF/XML files handler = new RDFDAMS4ImportTsHandler(damsClient, dFiles.toArray(new File[dFiles.size()]), importOption); ((RDFDAMS4ImportTsHandler) handler) .setFilesPaths(ingestFiles.toArray(new String[ingestFiles.size()])); ((RDFDAMS4ImportTsHandler) handler).setReplace(replace); } } else if (i == 6) { session.setAttribute("status", opMessage + "Importing from Standard Input Stream source ..."); log.info(opMessage + "Importing from Standard Input Stream source ..."); String unit = getParameter(paramsMap, "unit"); String source = getParameter(paramsMap, "source"); String bibNumber = getParameter(paramsMap, "bibInput"); String modsXml = getParameter(paramsMap, "modsInput"); String copyrightStatus = getParameter(paramsMap, "copyrightStatus"); String copyrightJurisdiction = getParameter(paramsMap, "countryCode"); String copyrightOwner = getParameter(paramsMap, "copyrightOwner"); String program = getParameter(paramsMap, "program"); String access = getParameter(paramsMap, "accessOverride"); String beginDate = getParameter(paramsMap, "licenseBeginDate"); String endDate = getParameter(paramsMap, "licenseEndDate"); String[] dataPaths = getParameter(paramsMap, "dataPath").split(";"); String[] filesPaths = getParameter(paramsMap, "filesPath").split(";"); String importOption = getParameter(paramsMap, "importOption"); List<String> ingestFiles = new ArrayList<String>(); for (int j = 0; j < filesPaths.length; j++) { if ((filesPaths[j] = filesPaths[j].trim()).length() > 0) ingestFiles.add(new File(Constants.DAMS_STAGING + "/" + filesPaths[j]) .getAbsolutePath()); } List<File> dataFiles = new ArrayList<File>(); for (int j = 0; j < dataPaths.length; j++) { String dataPath = dataPaths[j]; if (dataPath != null && (dataPath = dataPath.trim()).length() > 0) { File file = new File(Constants.DAMS_STAGING + "/" + dataPath); CollectionHandler.listFiles(dataFiles, file); } } // initiate the source metadata List<Object> sources = new ArrayList<Object>(); if (source != null && source.equalsIgnoreCase("bib")) { String[] bibs = bibNumber.split(","); for (int j = 0; j < bibs.length; j++) { if (bibs[j] != null && (bibs[j] = bibs[j].trim()).length() > 0) sources.add(bibs[j]); } } else { List<String> filters = new ArrayList<>(); if (getParameter(paramsMap, "excelImport") != null) { // Excel Input Stream source = "excel"; filters.add("xls"); filters.add("xlsx"); } else { // MARC/MODS source filters.add("xml"); } dataFiles = FileUtils.filterFiles(dataFiles, filters.toArray(new String[filters.size()])); sources.addAll(dataFiles); dataFiles.clear(); } // Handling pre-processing request Element rdfPreview = null; StringBuilder duplicatRecords = new StringBuilder(); List<String> ids = new ArrayList<String>(); boolean preprocessing = importOption.equalsIgnoreCase("pre-processing"); boolean ingestWithFiles = importOption.equalsIgnoreCase("metadataAndFiles"); if (preprocessing) { Document doc = new DocumentFactory().createDocument(); rdfPreview = TabularRecord.createRdfRoot(doc); } boolean preSuccessful = true; StringBuilder proMessage = new StringBuilder(); if (source != null && (source.equalsIgnoreCase("bib") || source.equalsIgnoreCase("mods") || source.equalsIgnoreCase("excel"))) { // Initiate the logging handler handler = new MetadataImportHandler(damsClient, null); handler.setSubmissionId(submissionId); handler.setSession(session); handler.setUserId(userId); Map<String, String> collections = new HashMap<String, String>(); if (StringUtils.isNotBlank(collectionId)) { String collType = damsClient.getCollectionType(collectionId); collections.put(collectionId, collType); } for (int j = 0; j < sources.size(); j++) { InputStream in = null; String sourceID = null; Object srcRecord = sources.get(j); sourceID = (srcRecord instanceof File ? ((File) srcRecord).getName() : srcRecord.toString()); if (preprocessing) handler.setStatus("Pre-processing record " + sourceID + " ... "); else handler.setStatus("Processing record " + sourceID + " ... "); RecordSource recordSource = null; InputStreamRecord record = null; try { if (source.equalsIgnoreCase("excel")) { clientTool = "Excel"; // Handling Excel Input Stream records recordSource = new ExcelSource((File) srcRecord); // Report for Excel column name validation List<String> invalidColumns = ((ExcelSource) recordSource) .getInvalidColumns(); if (invalidColumns != null && invalidColumns.size() > 0) { successful = false; preSuccessful = false; proMessage.append("Excel source " + sourceID + " - failed - " + CollectionHandler.damsDateFormat.format(new Date()) + ": \n"); if (invalidColumns != null && invalidColumns.size() > 0) { // Report invalid columns proMessage.append("* Found the following invalid column name" + (invalidColumns.size() > 1 ? "s" : "") + ": "); for (int k = 0; k < invalidColumns.size(); k++) { proMessage.append(invalidColumns.get(k)); if (k == invalidColumns.size() - 1) proMessage.append("\n"); else proMessage.append("; "); } } } } else { // Handling AT/Roger records try { if (source.equalsIgnoreCase("bib")) { clientTool = "MARC"; String url = Constants.DAMS_STORAGE_URL.substring(0, Constants.DAMS_STORAGE_URL.indexOf("/dams/")) + "/jollyroger/get?type=bib&mods=true&ns=true&value=" + sourceID; log.info("Getting MARC XML for Roger record " + sourceID + " from URL: " + url); HttpGet req = new HttpGet(url); Document doc = damsClient.getXMLResult(req); modsXml = doc.asXML(); in = new ByteArrayInputStream(modsXml.getBytes("UTF-8")); } else { // METS/MODS XML from staging area clientTool = "AT"; File srcFile = (File) sources.get(j); in = new FileInputStream(srcFile); } File xsl = new File(session.getServletContext() .getRealPath("files/mets2dams.xsl")); recordSource = new XsltSource(xsl, sourceID.replaceAll("\\..*", ""), in); } finally { CollectionHandler.close(in); in = null; } } } catch (Exception e) { e.printStackTrace(); successful = false; preSuccessful = false; String error = e.getMessage() != null ? e.getMessage() : e.getCause() != null ? e.getCause().getMessage() : e.getClass().getName(); handler.setStatus(error); log.error("Error metadata source " + sourceID + ": " + error); proMessage.append(sourceID + " - failed - " + CollectionHandler.damsDateFormat.format(new Date()) + " - " + error); } String id = ""; String info = ""; if (recordSource != null && preSuccessful) { for (Record rec = null; (rec = recordSource.nextRecord()) != null;) { String objTitle = ""; id = rec.recordID(); StringBuilder errorMessage = new StringBuilder(); try { record = new InputStreamRecord(rec, collections, unit, copyrightStatus, copyrightJurisdiction, copyrightOwner, program, access, beginDate, endDate); objTitle = getTitle(record.toRDFXML()); info = "Pre-processing record with ID " + id + " ... "; handler.setStatus(info); log.info(info); if (ids.indexOf(id) < 0) { ids.add(id); } else { duplicatRecords.append(rec + ", "); String error = "Duplicated record with ID " + id; handler.setStatus(error); log.error(info); errorMessage.append("\n* " + error); } // Add master file(s) for the bib/Roger record: a PDF or a TIFF, or a PDF + ZIP List<File> filesToIngest = null; if (source.equalsIgnoreCase("bib") && ingestWithFiles) { filesToIngest = getRogerFiles((String) srcRecord, ingestFiles); // Processing the master file(s) with error report. if (filesToIngest.size() == 0) { errorMessage.append("\n* Roger record " + srcRecord + " has no master file(s) for \"Ingest metadata and files\" option."); } else if (filesToIngest.size() > 2 || (filesToIngest.size() == 2 && !filesToIngest.get(1) .getName().endsWith(".zip"))) { errorMessage .append("\n* Unexpected file(s) for Roger record " + srcRecord + ": "); for (File file : filesToIngest) { errorMessage.append( (filesToIngest.indexOf(file) > 0 ? ", " : "") + file.getName()); } } else { // Handle the use property for the file(s) Map<String, String> fileUseMap = getFileUse(filesToIngest); record.addFiles(0, filesToIngest, fileUseMap); } } else if (source.equalsIgnoreCase("excel")) { // Report for invalid Excel control values validation List<Map<String, String>> invalidValues = ((ExcelSource) recordSource) .getInvalidValues(); if (invalidValues != null && invalidValues.size() > 0) { // process to retrieve control values errors for the record since it will parse the row for the next record StringBuilder cvErrors = new StringBuilder(); for (int k = 0; k < invalidValues.size(); k++) { Map<String, String> m = invalidValues.get(k); if (m.containsKey(TabularRecord.OBJECT_ID) && m.get(TabularRecord.OBJECT_ID) .equals(String.valueOf(id))) { cvErrors.append( "* Row index " + m.get("row") + " ["); // don't count for the row number and the record id m.remove("row"); m.remove(TabularRecord.OBJECT_ID); int l = 0; for (String key : m.keySet()) { if (l++ > 0) cvErrors.append(" | "); cvErrors.append(key + " => " + m.get(key)); } cvErrors.append("]\n"); } } if (cvErrors.length() > 0) { errorMessage.append("Invalid control value(s)" + " - \n" + cvErrors.toString()); } } } } catch (Exception e) { e.printStackTrace(); info = "Error: " + e.getMessage(); handler.setStatus(info); log.warn(info); errorMessage.append("\n* " + e.getMessage()); } objTitle = StringUtils.isEmpty(objTitle) ? "[Object]" : objTitle; if (errorMessage.length() == 0) { info = objTitle + " - " + id + " - " + " successful - " + CollectionHandler.damsDateFormat.format(new Date()); proMessage.append("\n\n" + info); log.info(info); if (preprocessing) { // Pre-processing with rdf preview rdfPreview.add(record.toRDFXML() .selectSingleNode("//dams:Object").detach()); } else { // Write the converted rdf/xml to file system File tmpDir = new File(Constants.TMP_FILE_DIR + File.separatorChar + "converted"); if (!tmpDir.exists()) tmpDir.mkdir(); File convertedFile = new File(tmpDir.getAbsolutePath(), id.replaceAll("[\\//:.*]+", "") + ".rdf.xml"); try { writeXml(convertedFile, record.toRDFXML().asXML()); } finally { convertedFile.deleteOnExit(); dataFiles.add(convertedFile); } } } else { preSuccessful = false; info = objTitle + " - " + id + " - " + " failed - " + CollectionHandler.damsDateFormat.format(new Date()) + " - " + errorMessage.toString(); proMessage.append("\n\n" + info); log.error(info); } handler.setProgressPercentage(j * 100 / sources.size()); } } } // Logging the result for pre-processing if (preprocessing || !preSuccessful) { message = "\nPre-processing " + (preSuccessful ? "successful" : "failed") + ": \n" + (proMessage.length() == 0 ? "" : "\n " + proMessage.toString()); handler.logMessage(message); } handler.release(); handler = null; if (preSuccessful) { // Write the converted RDF/xml for preview if (preprocessing) { File destFile = new File(Constants.TMP_FILE_DIR, "preview-" + submissionId + "-rdf.xml"); writeXml(destFile, rdfPreview.getDocument().asXML()); dataLink = "\nThe converted RDF/XML is ready for <a href=\"" + logLink + "&file=" + destFile.getName() + "\">download</a>.\n"; } else { // Ingest the converted RDF/XML files handler = new RDFDAMS4ImportTsHandler(damsClient, dataFiles.toArray(new File[dataFiles.size()]), importOption); ((RDFDAMS4ImportTsHandler) handler) .setFilesPaths(ingestFiles.toArray(new String[ingestFiles.size()])); ((RDFDAMS4ImportTsHandler) handler).setReplace(true); } } else { successful = false; } } else { successful = false; message += "\nUnknown source type: " + source; } } else if (i == 7) { session.setAttribute("status", opMessage + "SOLR Index ..."); boolean update = getParameter(paramsMap, "indexReplace") != null; if (getParameter(paramsMap, "solrRecordsDump") != null) { // Handle single records submission List<String> items = new ArrayList<String>(); String txtInput = getParameter(paramsMap, "textInput"); String fileInputValue = getParameter(paramsMap, "data"); if (txtInput != null && (txtInput = txtInput.trim()).length() > 0) { String[] subjects = txtInput.split(","); for (String subject : subjects) { subject = subject.trim(); if (subject.length() > 0) { items.add(subject); } } } // Handle records submitted in file with csv format, in lines or mixed together if (fileInputValue != null && (fileInputValue = fileInputValue.trim()).length() > 0) { // Handle record with line input String[] lines = fileInputValue.split("\n"); for (String line : lines) { // Handle CSV encoding records and records delimited by comma, whitespace etc. if (line != null && (line = line.trim().replace("\"", "")).length() > 0) { String[] tokens = line.split(","); for (String token : tokens) { String[] records = token.split(" "); for (String record : records) { record = record.trim(); if (record.length() > 0) { items.add(record); } } } } } } // Initiate SOLRIndexHandler to index the records handler = new SOLRIndexHandler(damsClient, null, update); handler.setItems(items); handler.setCollectionTitle("SOLR Records"); } else { // Handle solr update for collections if (collectionId.indexOf(",") > 0) { String collIDs = collectionId; String[] collArr = collectionId.split(","); List<String> items = new ArrayList<String>(); String collNames = ""; for (int j = 0; j < collArr.length; j++) { if (collArr[j] != null && (collArr[j] = collArr[j].trim()).length() > 0) { collectionId = collArr[j]; if (collectionId.equalsIgnoreCase("all")) { items.addAll(damsClient.listAllRecords()); collNames += "All Records (" + items.size() + "), "; } else { try { handler = new SOLRIndexHandler(damsClient, collectionId); items.addAll(handler.getItems()); collNames += handler.getCollectionTitle() + "(" + handler.getFilesCount() + "), "; if (j > 0 && j % 5 == 0) collNames += "\n"; } finally { if (handler != null) { handler.release(); handler = null; } } } } } handler = new SOLRIndexHandler(damsClient, null, update); handler.setItems(items); handler.setCollectionTitle(collNames.substring(0, collNames.lastIndexOf(","))); handler.setCollectionId(collIDs); } else { if (collectionId.equalsIgnoreCase("all")) { handler = new SOLRIndexHandler(damsClient, null, update); handler.setItems(damsClient.listAllRecords()); } else handler = new SOLRIndexHandler(damsClient, collectionId, update); } } } /*else if (i == 8){ //session.setAttribute("status", opMessage + "CDL Sending ..."); int operationType = 0; boolean resend = getParameter(paramsMap, "cdlResend") != null; if(resend){ operationType = 1; }else{ resend = getParameter(paramsMap, "cdlResendMets") != null; if(resend) operationType = 2; } //handler = new CdlIngestHandler(tsUtils, collectionId, userId, operationType); String feeder = getParameter(paramsMap, "feeder"); session.setAttribute("status", opMessage + "CDL " + feeder.toUpperCase() + " METS feeding ..."); boolean includeEmbargoed = (getParameter(paramsMap, "includeEmbargoed")!=null); if(feeder.equals("merritt")){ String account = getParameter(paramsMap, "account"); String password = getParameter(paramsMap, "password"); //String accessGroupId = getParameter(paramsMap, "accessGroup"); handler = new CdlIngestHandler(damsClient, collectionId, userId, operationType, feeder, account, password); }else handler = new CdlIngestHandler(damsClient, collectionId, userId, operationType); if(!includeEmbargoed) handler.excludeEmbargoedObjects(); }else if (i == 9){ session.setAttribute("status", opMessage + "Metadata Converting and populating ..."); String tsOperation = getParameter(paramsMap, "sipOption"); if(tsOperation == null || tsOperation.length() == 0) tsOperation = "tsNew"; int operationType = MetadataImportController.getOperationId(tsOperation); String srcFile = (String) session.getAttribute("source"); String srcFormat = (String) session.getAttribute("format"); String pathMap = (String) session.getAttribute("pathMap"); int sheetNo = 0; if(session.getAttribute("sheetNo") != null) sheetNo = ((Integer)session.getAttribute("sheetNo")).intValue(); String rdfFileToWrite = Constants.TMP_FILE_DIR + "tmpRdf_" + session.getId() + ".xml"; if("excel".equalsIgnoreCase(srcFormat)){ handler = new ExcelConverter(damsClient, collectionId, srcFile, sheetNo, pathMap, operationType); ExcelConverter converter = (ExcelConverter)handler; converter.setUseArk(true); converter.setRdfFileToWrite(rdfFileToWrite); }else throw new ServletException("Unsupported data format: " + srcFormat); }*/else if (i == 10) { session.setAttribute("status", opMessage + "Stage Ingesting ..."); String unit = getParameter(paramsMap, "unit"); String arkSetting = getParameter(paramsMap, "arkSetting").trim(); String filePath = getParameter(paramsMap, "filePath").trim(); String fileFilter = getParameter(paramsMap, "fileFilter").trim(); String preferedOrder = getParameter(paramsMap, "preferedOrder"); String fileSuffixes = getParameter(paramsMap, "fileSuffixes"); String fileUse = getParameter(paramsMap, "fileUse"); if (fileSuffixes != null && fileSuffixes.length() > 0) fileSuffixes = fileSuffixes.trim(); String coDelimiter = "p"; if (arkSetting.equals("1")) { if (preferedOrder == null || preferedOrder.equalsIgnoreCase("cofDelimiter")) { coDelimiter = getParameter(paramsMap, "cofDelimiter").trim(); } else if (preferedOrder.equals("suffix")) coDelimiter = getParameter(paramsMap, "coDelimiter").trim(); else coDelimiter = null; } else { if (arkSetting.equals("5")) { coDelimiter = getParameter(paramsMap, "coDelimiter").trim(); } } String[] fileOrderSuffixes = null; if (fileSuffixes != null && fileSuffixes.length() > 0) fileOrderSuffixes = fileSuffixes.split(","); String[] fileUses = null; if (fileUse != null && (fileUse = fileUse.trim()).length() > 0) { fileUses = fileUse.split(","); for (int j = 0; j < fileUses.length; j++) { if (fileUses[j] != null) fileUses[j] = fileUses[j].trim(); } } session.setAttribute("category", collectionId); session.setAttribute("unit", unit); session.setAttribute("arkSetting", arkSetting); session.setAttribute("filePath", filePath); session.setAttribute("fileFilter", fileFilter); session.setAttribute("preferedOrder", preferedOrder); session.setAttribute("fileSuffixes", fileSuffixes); session.setAttribute("fileUse", fileUse); String[] dirArr = filePath.split(";"); List<String> fileList = new ArrayList<String>(); String dir = null; for (int j = 0; j < dirArr.length; j++) { dir = dirArr[j]; if (dir != null && (dir = dir.trim()).length() > 0) { if ((dir.startsWith("/") || dir.startsWith("\\")) && (Constants.DAMS_STAGING.endsWith("/") || Constants.DAMS_STAGING.endsWith("\\"))) dir = dir.substring(1); fileList.add(Constants.DAMS_STAGING + dir); } } handler = new FileIngestionHandler(damsClient, fileList, Integer.parseInt(arkSetting), collectionId, fileFilter, coDelimiter); ((FileIngestionHandler) handler).setFileOrderSuffixes(fileOrderSuffixes); ((FileIngestionHandler) handler).setPreferedOrder(preferedOrder); ((FileIngestionHandler) handler).setUnit(unit); ((FileIngestionHandler) handler).setFileUses(fileUses); } else if (i == 11) { session.setAttribute("status", opMessage + "Serialize records as RDF/XML to filestore ..."); if (collectionId.indexOf(",") > 0) { String collIDs = collectionId; String[] collArr = collectionId.split(","); List<String> items = new ArrayList<String>(); String collNames = ""; for (int j = 0; j < collArr.length; j++) { if (collArr[j] != null && (collArr[j] = collArr[j].trim()).length() > 0) { collectionId = collArr[j]; if (collectionId.equalsIgnoreCase("all")) { items.addAll(damsClient.listAllRecords()); collNames += "All Records (" + items.size() + "), "; } else { try { handler = new SOLRIndexHandler(damsClient, collectionId); items.addAll(handler.getItems()); collNames += handler.getCollectionTitle() + "(" + handler.getFilesCount() + "), "; if (j > 0 && j % 5 == 0) collNames += "\n"; } finally { if (handler != null) { handler.release(); handler = null; } } } } } handler = new FilestoreSerializationHandler(damsClient, null); handler.setItems(items); handler.setCollectionTitle(collNames.substring(0, collNames.lastIndexOf(","))); handler.setCollectionId(collIDs); } else { if (collectionId.equalsIgnoreCase("all")) { handler = new FilestoreSerializationHandler(damsClient, null); handler.setItems(damsClient.listAllRecords()); } else handler = new FilestoreSerializationHandler(damsClient, collectionId); } } else if (i == 15) { session.setAttribute("status", opMessage + "Uploading files from dams-staging to " + damsClient.getFileStore() + " ..."); Map<String, String> filesMap = new TreeMap<String, String>(); for (Iterator<String> it = paramsMap.keySet().iterator(); it.hasNext();) { String key = it.next(); if (key.startsWith("f-")) { String file = paramsMap.get(key)[0]; String fileURI = paramsMap.get(key.replaceFirst("f-", "fid-"))[0]; if (fileURI != null && fileURI.startsWith(Constants.DAMS_ARK_URL_BASE)) filesMap.put(file, fileURI.trim()); else message += "Invalid fileURL for file " + file + " (" + fileURI + "). \n"; } } handler = new FileUploadHandler(damsClient, filesMap); handler.setItems(Arrays.asList(filesMap.keySet().toArray(new String[filesMap.size()]))); } else if (i == 18) { boolean components = getParameter(paramsMap, "exComponents") == null; String exFormat = getParameter(paramsMap, "exportFormat"); String xslSource = getParameter(paramsMap, "xsl"); if (xslSource == null || (xslSource = xslSource.trim()).length() == 0) { xslSource = "/pub/data1/import/apps/glossary/xsl/dams/convertToCSV.xsl"; if (!new File(xslSource).exists()) xslSource = Constants.CLUSTER_HOST_NAME + "glossary/xsl/dams/convertToCSV.xsl"; } session.setAttribute("status", opMessage + (exFormat.equalsIgnoreCase("csv") ? "CSV" : exFormat.equalsIgnoreCase("N-TRIPLE") ? "N-TRIPLE" : "RDF XML ") + " Metadata Export ..."); File outputFile = new File(Constants.TMP_FILE_DIR, "export-" + DAMSClient.stripID(collectionId) + "-" + System.currentTimeMillis() + "-rdf.xml"); String nsInput = getParameter(paramsMap, "nsInput"); List<String> nsInputs = new ArrayList<String>(); boolean componentsIncluded = true; if (nsInput != null && (nsInput = nsInput.trim()).length() > 0) { String[] nsInputArr = nsInput.split(","); for (int j = 0; j < nsInputArr.length; j++) { if (nsInputArr[j] != null && (nsInputArr[j] = nsInputArr[j].trim()).length() > 0) nsInputs.add(nsInputArr[j]); } } fileOut = new FileOutputStream(outputFile); handler = new MetadataExportHandler(damsClient, collectionId, nsInputs, componentsIncluded, exFormat, fileOut); ((MetadataExportHandler) handler).setFileUri(logLink + "&file=" + outputFile.getName()); ((MetadataExportHandler) handler).setComponents(components); } else if (i == 19) { session.setAttribute("status", opMessage + "Jhove report ..."); boolean bytestreamFilesOnly = getParameter(paramsMap, "bsJhoveReport") != null; boolean update = getParameter(paramsMap, "bsJhoveUpdate") != null; handler = new JhoveReportHandler(damsClient, collectionId, bytestreamFilesOnly); if (update) ((JhoveReportHandler) handler) .setJhoveUpdate(getParameter(paramsMap, "jhoveUpdate")); } else throw new ServletException("Unhandle operation index: " + i); if (handler != null) { try { damsClient.setClientInfo(clientTool + (StringUtils.isNotBlank(clientVersion) ? " " + clientVersion : "")); handler.setSubmissionId(submissionId); handler.setDamsClient(damsClient); handler.setSession(session); handler.setUserId(userId); if (handler.getCollectionId() == null && (collectionId != null && collectionId.length() > 0)) handler.setCollectionId(collectionId); successful = handler.execute(); } catch (InterruptedException e) { successful = false; exeInfo += e.getMessage(); e.printStackTrace(); } catch (Exception e) { successful = false; exeInfo += "\n" + e.getMessage(); e.printStackTrace(); } finally { String collectionName = handler.getCollectionId(); if (collectionName != null && collectionName.length() > 0 && logLink.indexOf("&category=") < 0) logLink += "&category=" + collectionName.replace(" ", ""); handler.setExeResult(successful); exeInfo += handler.getExeInfo(); handler.release(); if (fileOut != null) { CollectionHandler.close(fileOut); fileOut = null; } } } } else continue; message += exeInfo; if (!successful) { String errors = "Execution failed:\n" + message + "\n"; returnMessage += errors; break; } else { returnMessage += "\n" + message; } } } catch (Exception e) { e.printStackTrace(); returnMessage += e.getMessage(); } finally { if (damsClient != null) damsClient.close(); if (fileOut != null) { CollectionHandler.close(fileOut); fileOut = null; } } } else returnMessage = message; String logMessage = "For details, please download " + "<a href=\"" + logLink + "\">log</a>" + "."; if (returnMessage.length() > 1000) { returnMessage = returnMessage.substring(0, 1000); int idx = returnMessage.lastIndexOf("\n"); if (idx > 0) returnMessage = returnMessage.substring(0, idx); else { idx = returnMessage.lastIndexOf("</a>"); if (idx < returnMessage.lastIndexOf("<a ")) returnMessage = returnMessage.substring(0, idx); } returnMessage = "\n" + returnMessage + "\n ... "; } returnMessage += "\n" + dataLink + "\n" + logMessage; RequestOrganizer.addResultMessage(session, returnMessage.replace("\n", "<br />") + "<br />"); return returnMessage; }
From source file:org.apache.jsp.fileUploader_jsp.java
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;/*from w w w.j av a 2 s .c o m*/ HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=utf-8"); pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("<!--\n"); out.write("Copyright 2012 The Infinit.e Open Source Project\n"); out.write("\n"); out.write("Licensed under the Apache License, Version 2.0 (the \"License\");\n"); out.write("you may not use this file except in compliance with the License.\n"); out.write("You may obtain a copy of the License at\n"); out.write("\n"); out.write(" http://www.apache.org/licenses/LICENSE-2.0\n"); out.write("\n"); out.write("Unless required by applicable law or agreed to in writing, software\n"); out.write("distributed under the License is distributed on an \"AS IS\" BASIS,\n"); out.write("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"); out.write("See the License for the specific language governing permissions and\n"); out.write("limitations under the License.\n"); out.write("-->\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"); out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"); out.write("<head>\n"); out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"); out.write("<title>Infinit.e File Upload Tool</title>\n"); out.write("<style media=\"screen\" type=\"text/css\">\n"); out.write("\n"); out.write("body \n"); out.write("{\n"); out.write("\tfont: 14px Arial,sans-serif;\n"); out.write("}\n"); out.write("h2\n"); out.write("{\n"); out.write("\tfont-family: \"Times New Roman\";\n"); out.write("\tfont-style: italic;\n"); out.write("\tfont-variant: normal;\n"); out.write("\tfont-weight: normal;\n"); out.write("\tfont-size: 24px;\n"); out.write("\tline-height: 29px;\n"); out.write("\tfont-size-adjust: none;\n"); out.write("\tfont-stretch: normal;\n"); out.write("\t-x-system-font: none;\n"); out.write("\tcolor: #d2331f;\n"); out.write("\tmargin-bottom: 25px;\n"); out.write("}\n"); out.write(".show {\n"); out.write("display: ;\n"); out.write("visibility: visible;\n"); out.write("}\n"); out.write(".hide {\n"); out.write("display: none;\n"); out.write("visibility: hidden;\n"); out.write("}\n"); out.write("</style>\n"); out.write("<script language=\"javascript\" src=\"AppConstants.js\"> </script>\n"); out.write("</head>\n"); out.write("\n"); out.write("<body onload=\"populate()\">\n"); if (API_ROOT == null) { ServletContext context = session.getServletContext(); String realContextPath = context.getRealPath("/"); ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("javascript"); try { // EC2 Machines FileReader reader = new FileReader(realContextPath + "/AppConstants.js"); engine.eval(reader); reader.close(); engine.eval("output = getEndPointUrl();"); API_ROOT = (String) engine.get("output"); SHARE_ROOT = API_ROOT + "share/get/"; } catch (Exception je) { try { ////////////Windows + Tomcat FileReader reader = new FileReader(realContextPath + "\\..\\AppConstants.js"); engine.eval(reader); reader.close(); engine.eval("output = getEndPointUrl();"); API_ROOT = (String) engine.get("output"); SHARE_ROOT = API_ROOT + "share/get/"; } catch (Exception e) { System.err.println(e.toString()); } } if (null == API_ROOT) { // Default to localhost API_ROOT = "http://localhost:8080/api/"; SHARE_ROOT = "$infinite/share/get/"; } if (API_ROOT.contains("localhost")) localCookie = true; else localCookie = false; } Boolean isLoggedIn = isLoggedIn(request, response); if (isLoggedIn == null) { out.println("The Infinit.e API cannot be reached."); out.println(API_ROOT); } else if (isLoggedIn == true) { showAll = (request.getParameter("sudo") != null); DEBUG_MODE = (request.getParameter("debug") != null); communityList = generateCommunityList(request, response); if (request.getParameter("logout") != null) { logOut(request, response); out.println("<div style=\" text-align: center;\">"); out.println("<meta http-equiv=\"refresh\" content=\"0\">"); out.println("</div>"); } else { out.println("<div style=\" text-align: center;\">"); String contentType = request.getContentType(); if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) { // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); // Parse the request FileItemIterator iter = upload.getItemIterator(request); byte[] fileBytes = null; String fileDS = null; byte[] iconBytes = null; String iconDS = null; Set<String> communities = new HashSet<String>(); boolean isFileSet = false; while (iter.hasNext()) { FileItemStream item = iter.next(); String name = item.getFieldName(); InputStream stream = item.openStream(); if (item.isFormField()) { if (name.equalsIgnoreCase("communities")) { communities.add(Streams.asString(stream)); } else request.setAttribute(name, Streams.asString(stream)); //out.println("<b>" + name + ":</b>" + request.getAttribute(name).toString()+"</br>"); } else { if (name.equalsIgnoreCase("file")) { if (!item.getName().equals("")) isFileSet = true; fileDS = item.getContentType(); fileBytes = IOUtils.toByteArray(stream); // Check if this should be a java-archive (rather than just an octet stream) if (fileDS.equals("application/octet-stream")) { ZipInputStream zis = new ZipInputStream( new ByteArrayInputStream(fileBytes)); ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { if (entry.getName().endsWith(".class")) { fileDS = "application/java-archive"; break; } } } // Reset stream, and read } } } ////////////////////////////////////Delete Share //////////////////////////////// if (request.getAttribute("deleteId") != null) { String fileId = request.getAttribute("deleteId").toString(); if (fileId != null && fileId != "") removeFromShare(fileId, request, response).toString(); } ////////////////////////////////////Update Community Info//////////////////////////////// else if (null == fileBytes) { String shareId = request.getAttribute("DBId").toString(); if (shareId != null && shareId != "") addRemoveCommunities(shareId, communities, request, response); } else { ////////////////////////////////////////////////////////////////////////////////// Boolean newUpload = (request.getAttribute("DBId").toString().length() == 0); ///////////////////////////////// SWF Manip ///////////////////////////////// String shareId = request.getAttribute("DBId").toString(); String fileUrl = ""; String fileId = ""; String bin = request.getAttribute("binary").toString(); if (request.getAttribute("title") != null && request.getAttribute("description") != null && fileBytes != null) { if (!isFileSet) //if not a binary file or file was not changed { fileId = shareId; if (shareId != null && shareId != "") addRemoveCommunities(shareId, communities, request, response); out.println("File was not set, just updated communities."); } else if (bin.equals("null")) //is a json file, make sure its okay and upload it { fileId = UpdateToShare(fileBytes, fileDS, request.getAttribute("title").toString(), request.getAttribute("description").toString(), shareId, communities, true, request.getAttribute("type").toString(), newUpload, request, response); } else //is a binary, do normal { fileId = UpdateToShare(fileBytes, fileDS, request.getAttribute("title").toString(), request.getAttribute("description").toString(), shareId, communities, false, request.getAttribute("type").toString(), newUpload, request, response); } if (fileId.contains("Failed")) { out.println(fileId); } else { fileUrl = SHARE_ROOT + fileId; if (newUpload) out.println( "You have successfully added a file to the share, its location is: " + fileUrl); else out.println( "You have successfully updated a file on the share, its location is: " + fileUrl); } } else { fileUrl = null; out.println("Error: Not enough information provided for file Upload"); } ///////////////////////////////// End File Manip ///////////////////////////////// out.println("</div>"); } } else { } out.write("\n"); out.write("\t\n"); out.write("\t<script>\n"); out.write("\tfunction clearCommList()\n"); out.write("\t\t{\n"); out.write("\t\t\tmult_comms = document.getElementById('communities');\n"); out.write("\t\t\tfor ( var i = 0, l = mult_comms.options.length, o; i < l; i++ )\n"); out.write("\t\t\t{\n"); out.write("\t\t\t o = mult_comms.options[i];\n"); out.write("\t\t\t o.selected = false;\n"); out.write("\t\t\t}\n"); out.write("\t\t}\n"); out.write("\t\tfunction highlightComms(commList)\n"); out.write("\t\t{\n"); out.write("\t\t\tmult_comms = document.getElementById('communities');\n"); out.write("\t\t\tfor ( var i = 0, l = mult_comms.options.length, o; i < l; i++ )\n"); out.write("\t\t\t{\n"); out.write("\t\t\t o = mult_comms.options[i];\n"); out.write("\t\t\t if(commList.indexOf(o.value) == -1)\n"); out.write("\t\t\t\to.selected = false;\n"); out.write("\t\t\t else \n"); out.write("\t\t\t \to.selected = true;\n"); out.write("\t\t\t}\n"); out.write("\t\t}\n"); out.write("\tfunction populate()\n"); out.write("\t{\n"); out.write("\t\tvar typerow = document.getElementById('typerow');\n"); out.write("\t\tvar type = document.getElementById('type');\n"); out.write("\t\tvar title = document.getElementById('title');\n"); out.write("\t\tvar description = document.getElementById('description');\n"); out.write("\t\tvar file = document.getElementById('file');\n"); out.write("\t\tvar created = document.getElementById('created');\n"); out.write("\t\tvar DBId = document.getElementById('DBId');\n"); out.write("\t\tvar deleteId = document.getElementById('deleteId');\n"); out.write("\t\tvar deleteButton = document.getElementById('deleteButton');\n"); out.write("\t\tvar share_url = document.getElementById('share_url');\n"); out.write("\t\tvar owner_text = document.getElementById('owner_text');\n"); out.write("\t\tvar owner = document.getElementById('owner');\n"); out.write("\t\tvar url_row = document.getElementById('url_row');\n"); out.write("\t\tvar dropdown = document.getElementById(\"upload_info\");\n"); out.write("\t\tvar list = dropdown.options[dropdown.selectedIndex].value;\n"); out.write("\t\tvar binary = document.getElementById(\"binary\");\n"); out.write("\t\t\n"); out.write("\t\tif (list == \"new\")\n"); out.write("\t\t{\n"); out.write("\t\t\ttitle.value = \"\";\n"); out.write("\t\t\tdescription.value = \"\";\n"); out.write("\t\t\ttype.value = \"binary\";\n"); out.write("\t\t\tcreated.value = \"\";\n"); out.write("\t\t\tDBId.value = \"\";\n"); out.write("\t\t\tdeleteId.value = \"\";\n"); out.write("\t\t\tshare_url.value = \"\";\n"); out.write("\t\t\towner.value = \"\";\n"); out.write("\t\t\ttyperow.className = \"hide\";\n"); out.write("\t\t\turl_row.className = \"hide\";\n"); out.write("\t\t\towner.className = \"hide\";\n"); out.write("\t\t\towner_text.className = \"hide\";\n"); out.write("\t\t\tdeleteButton.className = \"hide\";\n"); out.write("\t\t\tclearCommList();\n"); out.write("\t\t\tbinary.value = \"\";\n"); out.write("\t\t\treturn;\n"); out.write("\t\t}\n"); out.write("\t\t\n"); out.write("\t\tif ( list == \"newJSON\")\n"); out.write("\t\t{\n"); out.write("\t\t\ttitle.value = \"\";\n"); out.write("\t\t\tdescription.value = \"\";\n"); out.write("\t\t\ttype.value = \"\";\n"); out.write("\t\t\tcreated.value = \"\";\n"); out.write("\t\t\tDBId.value = \"\";\n"); out.write("\t\t\tdeleteId.value = \"\";\n"); out.write("\t\t\tshare_url.value = \"\";\n"); out.write("\t\t\towner.value = \"\";\n"); out.write("\t\t\ttyperow.className = \"show\";\n"); out.write("\t\t\turl_row.className = \"hide\";\n"); out.write("\t\t\towner.className = \"hide\";\n"); out.write("\t\t\towner_text.className = \"hide\";\n"); out.write("\t\t\tdeleteButton.className = \"hide\";\n"); out.write("\t\t\tclearCommList();\n"); out.write("\t\t\tbinary.value = \"null\";\n"); out.write("\t\t\treturn;\n"); out.write("\t\t}\n"); out.write("\t\t\n"); out.write("\t\t//_id, created, title, description\n"); out.write("\t\tsplit = list.split(\"$$$\");\n"); out.write("\t\t\n"); out.write("\t\tres_id = split[0];\n"); out.write("\t\tres_created = split[1];\n"); out.write("\t\tres_title = split[2];\n"); out.write("\t\tres_description = split[3];\n"); out.write("\t\tres_url = split[4];\n"); out.write("\t\tcommunities = split[5];\n"); out.write("\t\tres_owner = split[6];\n"); out.write("\t\tres_binary = split[7];\t\t\n"); out.write("\t\tres_type = split[8];\t\t\t\n"); out.write("\t\t\n"); out.write("\t\tif ( res_binary == \"null\" )\n"); out.write("\t\t{\n"); out.write("\t\t\ttyperow.className = \"show\";\n"); out.write("\t\t}\n"); out.write("\t\telse\n"); out.write("\t\t{\n"); out.write("\t\t\ttyperow.className = \"hide\";\n"); out.write("\t\t}\n"); out.write("\t\ttitle.value = res_title;\n"); out.write("\t\tdescription.value = res_description;\n"); out.write("\t\tcreated.value = res_created;\n"); out.write("\t\tDBId.value = res_id;\n"); out.write("\t\tdeleteId.value = res_id;\n"); out.write("\t\tshare_url.value = res_url;\n"); out.write("\t\towner.value = res_owner;\t\t\n"); out.write("\t\tdeleteButton.className = \"show\";\n"); out.write("\t\towner.className = \"show\";\n"); out.write("\t\towner_text.className = \"show\";\n"); out.write("\t\turl_row.className = \"show\";\n"); out.write("\t\thighlightComms(communities);\t\t\n"); out.write("\t\tbinary.value = res_binary;\n"); out.write("\t\ttype.value = res_type;\n"); out.write("\t}\n"); out.write("\t\tfunction validate_fields()\n"); out.write("\t\t{\n"); out.write("\t\t\ttitle = document.getElementById('title').value;\n"); out.write("\t\t\tdescription = document.getElementById('description').value;\n"); out.write("\t\t\tfile = document.getElementById('file').value;\n"); out.write("\t\t\tbinary = document.getElementById(\"binary\").value;\n"); out.write("\t\t\ttype = document.getElementById(\"type\").value;\n"); out.write("\t\t\t//share_url = document.getElementById('share_url').value;\n"); out.write("\t\t\t//file_url = document.getElementById('file_url').value;\n"); out.write("\t\t\t//file_check = document.getElementById('file_check').checked;\n"); out.write("\t\t\t\n"); out.write("\t\t\tif (title == \"\")\n"); out.write("\t\t\t{\n"); out.write("\t\t\t\talert('Please provide a title.');\n"); out.write("\t\t\t\treturn false;\n"); out.write("\t\t\t}\n"); out.write("\t\t\tif (description == \"\")\n"); out.write("\t\t\t{\n"); out.write("\t\t\t\talert('Please provide a description.');\n"); out.write("\t\t\t\treturn false;\n"); out.write("\t\t\t}\n"); out.write("\t\t\tif ( binary == \"null\" && type == \"\")\n"); out.write("\t\t\t{\n"); out.write("\t\t\t\talert('Please provide a type.');\n"); out.write("\t\t\t\treturn false;\n"); out.write("\t\t\t}\n"); out.write("\t\t\t\n"); out.write("\t\t\t\n"); out.write("\t\t}\n"); out.write("\t\tfunction confirmDelete()\n"); out.write("\t\t{\n"); out.write( "\t\t\tvar agree=confirm(\"Are you sure you wish to Delete this file from the File Share?\");\n"); out.write("\t\t\tif (agree)\n"); out.write("\t\t\t\treturn true ;\n"); out.write("\t\t\telse\n"); out.write("\t\t\t\treturn false ;\n"); out.write("\t\t}\n"); out.write("\t\tfunction showResults()\n"); out.write("\t\t{\n"); out.write("\t\t\tvar title = document.getElementById('DBId').value;\n"); out.write("\t\t\tvar url = getEndPointUrl() + \"share/get/\" + title;\n"); out.write("\t\t\twindow.open(url, '_blank');\n"); out.write("\t\t\twindow.focus();\t\t\t\n"); out.write("\t\t}\n"); out.write("\t\t// -->\n"); out.write("\t\t</script>\n"); out.write("\t</script>\n"); out.write( "\t\t<div id=\"uploader_outter_div\" name=\"uploader_outter_div\" align=\"center\" style=\"width:100%\" >\n"); out.write( "\t \t<div id=\"uploader_div\" name=\"uploader_div\" style=\"border-style:solid; border-color:#999999; border-radius: 10px; width:475px; margin:auto\">\n"); out.write("\t \t<h2>File Uploader</h2>\n"); out.write("\t \t<form id=\"search_form\" name=\"search_form\" method=\"get\">\n"); out.write("\t \t\t<div align=\"center\"\">\n"); out.write("\t \t\t<label for=\"ext\">Filter On</label>\n"); out.write("\t\t\t\t\t <select name=\"ext\" id=\"ext\" onchange=\"this.form.submit();\">\n"); out.write("\t\t\t\t\t "); out.print(populateMediaTypes(request, response)); out.write("\n"); out.write("\t\t\t\t\t </select>\n"); out.write("\t\t\t\t\t </div>\n"); out.write("\t\t\t\t\t "); if (showAll) out.print("<input type=\"hidden\" name=\"sudo\" id=\"sudo\" value=\"true\" />"); out.write("\t \t\t\n"); out.write("\t \t</form>\n"); out.write( "\t \t<form id=\"delete_form\" name=\"delete_form\" method=\"post\" enctype=\"multipart/form-data\" onsubmit=\"javascript:return confirmDelete()\" >\n"); out.write( "\t \t\t<select id=\"upload_info\" onchange=\"populate()\" name=\"upload_info\"><option value=\"new\">Upload New File</option><option value=\"newJSON\">Upload New JSON</option> "); out.print(populatePreviousUploads(request, response)); out.write("</select>\n"); out.write( "\t \t\t<input type=\"submit\" name=\"deleteButton\" id=\"deleteButton\" class=\"hidden\" value=\"Delete\" />\n"); out.write("\t \t\t<input type=\"hidden\" name=\"deleteId\" id=\"deleteId\" />\n"); out.write("\t \t\t<input type=\"hidden\" name=\"deleteFile\" id=\"deleteFile\" />\n"); out.write("\t\t\t\t\t "); if (showAll) out.print("<input type=\"hidden\" name=\"sudo\" id=\"sudo\" value=\"true\" />"); out.write("\t \t\t\n"); out.write("\t \t</form>\n"); out.write( "\t <form id=\"upload_form\" name=\"upload_form\" method=\"post\" enctype=\"multipart/form-data\" onsubmit=\"javascript:return validate_fields();\" >\n"); out.write( "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding-left:10px; padding-right:10px\">\n"); out.write("\t <tr>\n"); out.write("\t <td colspan=\"2\" align=\"center\"></td>\n"); out.write("\t </tr>\n"); out.write("\t <tr>\n"); out.write("\t <td>Title:</td>\n"); out.write( "\t <td><input type=\"text\" name=\"title\" id=\"title\" size=\"39\" /></td>\n"); out.write("\t </tr>\n"); out.write("\t <tr>\n"); out.write("\t <td>Description:</td>\n"); out.write( "\t <td><textarea rows=\"4\" cols=\"30\" name=\"description\" id=\"description\" ></textarea></td>\n"); out.write("\t </tr>\n"); out.write("\t <tr id=\"typerow\">\n"); out.write("\t <td>Type:</td>\n"); out.write( "\t <td><input type=\"text\" name=\"type\" id=\"type\" size=\"39\" /></td>\n"); out.write("\t </tr>\n"); out.write("\t <tr>\n"); out.write("\t \t<td>Communities:</td>\n"); out.write("\t \t<td>"); out.print(communityList); out.write("</td>\n"); out.write("\t </tr>\n"); out.write("\t <tr>\n"); out.write("\t \t<td id=\"owner_text\">Owner:</td>\n"); out.write("\t \t<td>\n"); out.write( "\t <input type=\"text\" name=\"owner\" id=\"owner\" readonly=\"readonly\" size=\"25\" />\n"); out.write("\t \t</td>\n"); out.write("\t </tr>\n"); out.write("\t <tr>\n"); out.write("\t <td>File:</td>\n"); out.write("\t <td><input type=\"file\" name=\"file\" id=\"file\" /></td>\n"); out.write("\t </tr>\n"); out.write("\t <tr id=\"url_row\" class=\"hide\">\n"); out.write("\t \t<td>Share URL:</td>\n"); out.write( "\t \t<td><input type=\"text\" name=\"share_url\" id=\"share_url\" readonly=\"readonly\" size=\"38\"/>\n"); out.write( "\t \t<input type=\"button\" onclick=\"showResults()\" value=\"View\"/>\n"); out.write("\t \t</td>\n"); out.write("\t \t<td></td>\n"); out.write("\t </tr>\n"); out.write("\t <tr>\n"); out.write( "\t <td colspan=\"2\" style=\"text-align:right\"><input type=\"submit\" value=\"Submit\" /></td>\n"); out.write("\t </tr>\n"); out.write("\t </table>\n"); out.write("\t\t\t\t\t<input type=\"hidden\" name=\"created\" id=\"created\" />\n"); out.write("\t\t\t\t\t<input type=\"hidden\" name=\"DBId\" id=\"DBId\" />\n"); out.write("\t\t\t\t\t<input type=\"hidden\" name=\"fileUrl\" id=\"fileUrl\" />\n"); out.write("\t\t\t\t\t<input type=\"hidden\" name=\"binary\" id=\"binary\" />\n"); out.write("\t\t\t\t\t "); if (showAll) out.print("<input type=\"hidden\" name=\"sudo\" id=\"sudo\" value=\"true\" />"); out.write("\t \t\t\n"); out.write("\t\t\t\t</form>\n"); out.write("\t </div>\n"); out.write("\t <form id=\"logout_form\" name=\"logout_form\" method=\"post\">\n"); out.write( "\t \t<input type=\"submit\" name=\"logout\" id = \"logout\" value=\"Log Out\" />\n"); out.write("\t </form>\n"); out.write("\t </div>\n"); out.write("\t </p>\n"); out.write("\t\n"); } } else if (isLoggedIn == false) { //localCookie =(request.getParameter("local") != null); //System.out.println("LocalCookie = " + localCookie.toString()); String errorMsg = ""; if (request.getParameter("logintext") != null || request.getParameter("passwordtext") != null) { if (logMeIn(request.getParameter("logintext"), request.getParameter("passwordtext"), request, response)) { showAll = (request.getParameter("sudo") != null); out.println("<meta http-equiv=\"refresh\" content=\"0\">"); out.println("Login Success"); } else { errorMsg = "Log in Failed, Please Try again"; } } out.write("\n"); out.write("\n"); out.write("<script>\n"); out.write("\tfunction validate_fields()\n"); out.write("\t{\n"); out.write("\t\tuname = document.getElementById('logintext').value;\n"); out.write("\t\tpword = document.getElementById('passwordtext').value;\n"); out.write("\t\t\n"); out.write("\t\tif (uname == \"\")\n"); out.write("\t\t{\n"); out.write("\t\t\talert('Please provide your username.');\n"); out.write("\t\t\treturn false;\n"); out.write("\t\t}\n"); out.write("\t\tif (pword == \"\")\n"); out.write("\t\t{\n"); out.write("\t\t\talert('Please provide your password.');\n"); out.write("\t\t\treturn false;\n"); out.write("\t\t}\n"); out.write("\t}\n"); out.write("\n"); out.write("\n"); out.write("</script>\n"); out.write( "\t<div id=\"login_outter_div\" name=\"login_outter_div\" align=\"center\" style=\"width:100%\" >\n"); out.write( " \t<div id=\"login_div\" name=\"login_div\" style=\"border-style:solid; border-color:#999999; border-radius: 10px; width:450px; margin:auto\">\n"); out.write(" \t<h2>Login</h2>\n"); out.write( " <form id=\"login_form\" name=\"login_form\" method=\"post\" onsubmit=\"javascript:return validate_fields();\" >\n"); out.write( " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"padding-left:10px\">\n"); out.write(" <tr>\n"); out.write(" <td>User Name</td>\n"); out.write(" <td> </td>\n"); out.write(" <td>Password</td>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write( " <td><input type=\"text\" name=\"logintext\" id=\"logintext\" width=\"190px\" /></td>\n"); out.write(" <td> </td>\n"); out.write( " <td><input type=\"password\" name=\"passwordtext\" id=\"passwordtext\" width=\"190px\" /></td>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write( " <td colspan=\"3\" align=\"right\"><input name=\"Login\" type=\"submit\" value=\"Login\" /></td>\n"); out.write(" </tr>\n"); out.write(" </table>\n"); out.write("\t\t\t</form>\n"); out.write(" </div>\n"); out.write(" </div>\n"); out.write("\t<div style=\"color: red; text-align: center;\"> "); out.print(errorMsg); out.write(" </div>\n"); } out.write("\n"); out.write(" \n"); out.write(" \n"); out.write("</body>\n"); out.write("</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
From source file:gov.nih.nci.cadsr.sentinel.database.DBAlertOracle.java
static private synchronized int setupPoolX(HttpSession session_, String dsurl_, String username_, String password_) {//from ww w . ja va 2 s . co m // Get the Servlet Context and see if a pool already exists. ServletContext sc = session_.getServletContext(); if (sc.getAttribute(DBAlert._DATASOURCE) != null) return 0; OracleConnectionPoolDataSource ocpds = (OracleConnectionPoolDataSource) sc.getAttribute(_DBPOOL); if (ocpds != null) return 0; ocpds = setupPool(dsurl_, username_, password_); if (ocpds != null) { // Remember the pool in the Servlet Context. sc.setAttribute(_DBPOOL + ".ds", ocpds); sc.setAttribute(_DBPOOL + ".user", username_); sc.setAttribute(_DBPOOL + ".pswd", password_); return 0; } return -1; }
From source file:springapp.web.controller.theme.ProcessThemeController.java
public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { HttpSession session = httpServletRequest.getSession(); String templateIdString = httpServletRequest.getParameter(ApplicationConstants.TEMPLATE_ID); byte templateId = 0; int oldColor = 0; int newColor = 0; int oldHeaderColor = 0; int newHeaderColor = 0; int oldBgColor = 0; int newBgColor = 0; int oldFontColor = 0; int newFontColor = 0; int oldHeaderFontColor = 0; int newHeaderFontColor = 0; int oldBorderColor = 0; int newBorderColor = 0; int oldTransp = 0; int newTransp = 0; byte sizeHeaderFontDiff = 11; byte sizeFontDiff = 11; ThemeParametersHolder themeParametersHolder = null; String toolsetName = httpServletRequest.getParameter(ApplicationConstants.TOOLSET_NAME); String versionString = httpServletRequest.getParameter(ApplicationConstants.VERSION); String version = (null == versionString) ? ApplicationConstants.DEFAULT_EXTJS_VERSION : versionString; String familyHeaderFont = httpServletRequest.getParameter(ApplicationConstants.FAMILY_HEADER_FONT); String familyFont = httpServletRequest.getParameter(ApplicationConstants.FAMILY_FONT); String weightHeaderFont = httpServletRequest.getParameter(ApplicationConstants.WEIGHT_HEADER_FONT); String weightFont = httpServletRequest.getParameter(ApplicationConstants.WEIGHT_FONT); try {//from w w w.ja v a 2 s .c o m templateId = null != templateIdString ? Byte.parseByte(templateIdString) : 0; String oldColorString = (0 == templateId) ? "#DFE8F6" : "#F1F1F1"; String newColorString = httpServletRequest.getParameter(ApplicationConstants.NEW_COLOR); String oldHeaderColorString = (0 == templateId) ? "#CDDEF3" : "#D7D7D7"; String newHeaderColorString = httpServletRequest.getParameter(ApplicationConstants.NEW_HEADER_COLOR); String oldBgColorString = "#FFFFFF"; String newBgColorString = httpServletRequest.getParameter(ApplicationConstants.NEW_BG_COLOR); String oldFontColorString = "#000000"; String newFontColorString = httpServletRequest.getParameter(ApplicationConstants.NEW_FONT_COLOR); String oldHeaderFontColorString = (0 == templateId) ? "#15428B" : "#222222"; String newHeaderFontColorString = httpServletRequest .getParameter(ApplicationConstants.NEW_HEADER_FONT_COLOR); String sizeHeaderFontString = httpServletRequest.getParameter(ApplicationConstants.SIZE_HEADER_FONT); String sizeFontString = httpServletRequest.getParameter(ApplicationConstants.SIZE_FONT); String oldBorderColorString = (0 == templateId) ? "#99BBE8" : "#D0D0D0"; String newBorderColorString = httpServletRequest.getParameter(ApplicationConstants.NEW_BORDER_COLOR); String oldTranspString = "255"; String newTranspString = httpServletRequest.getParameter(ApplicationConstants.NEW_TRANSP); themeParametersHolder = new ThemeParametersHolder(templateIdString, newColorString, newHeaderColorString, newBgColorString, newFontColorString, newHeaderFontColorString, familyHeaderFont, weightHeaderFont, sizeHeaderFontString, familyFont, weightFont, sizeFontString, newBorderColorString, newTranspString, toolsetName, version); oldColor = null != oldColorString ? Integer.parseInt(oldColorString.replaceFirst("#", ""), 16) : 0; newColor = null != newColorString ? Integer.parseInt(newColorString.replaceFirst("#", ""), 16) : 0; oldHeaderColor = null != oldHeaderColorString ? Integer.parseInt(oldHeaderColorString.replaceFirst("#", ""), 16) : 0; newHeaderColor = null != newHeaderColorString ? Integer.parseInt(newHeaderColorString.replaceFirst("#", ""), 16) : 0; oldBgColor = null != oldBgColorString ? Integer.parseInt(oldBgColorString.replaceFirst("#", ""), 16) : 0; newBgColor = null != newBgColorString ? Integer.parseInt(newBgColorString.replaceFirst("#", ""), 16) : 0; oldFontColor = null != oldFontColorString ? Integer.parseInt(oldFontColorString.replaceFirst("#", ""), 16) : 0; newFontColor = null != newFontColorString ? Integer.parseInt(newFontColorString.replaceFirst("#", ""), 16) : 0; oldHeaderFontColor = null != oldHeaderFontColorString ? Integer.parseInt(oldHeaderFontColorString.replaceFirst("#", ""), 16) : 0; newHeaderFontColor = null != newHeaderFontColorString ? Integer.parseInt(newHeaderFontColorString.replaceFirst("#", ""), 16) : 0; oldBorderColor = null != oldBorderColorString ? Integer.parseInt(oldBorderColorString.replaceFirst("#", ""), 16) : 0; newBorderColor = null != newBorderColorString ? Integer.parseInt(newBorderColorString.replaceFirst("#", ""), 16) : 0; oldTransp = null != oldTranspString ? Integer.parseInt(oldTranspString) : 0; newTransp = null != newTranspString ? Integer.parseInt(newTranspString) : 0; sizeHeaderFontDiff = (byte) ((null != sizeHeaderFontString ? Byte.parseByte(sizeHeaderFontString) : 11) - 11); sizeFontDiff = (byte) ((null != sizeFontString ? Byte.parseByte(sizeFontString) : 11) - 11); } catch (Exception e) { logger.error(e); } int oldR = (oldColor >> 16) & 0xff; int oldG = (oldColor >> 8) & 0xff; int oldB = oldColor & 0xff; int newR = (newColor >> 16) & 0xff; int newG = (newColor >> 8) & 0xff; int newB = newColor & 0xff; int oldHeaderR = (oldHeaderColor >> 16) & 0xff; int oldHeaderG = (oldHeaderColor >> 8) & 0xff; int oldHeaderB = oldHeaderColor & 0xff; int newHeaderR = (newHeaderColor >> 16) & 0xff; int newHeaderG = (newHeaderColor >> 8) & 0xff; int newHeaderB = newHeaderColor & 0xff; int oldBgR = (oldBgColor >> 16) & 0xff; int oldBgG = (oldBgColor >> 8) & 0xff; int oldBgB = oldBgColor & 0xff; int newBgR = (newBgColor >> 16) & 0xff; int newBgG = (newBgColor >> 8) & 0xff; int newBgB = newBgColor & 0xff; int oldFontR = (oldFontColor >> 16) & 0xff; int oldFontG = (oldFontColor >> 8) & 0xff; int oldFontB = oldFontColor & 0xff; int newFontR = (newFontColor >> 16) & 0xff; int newFontG = (newFontColor >> 8) & 0xff; int newFontB = newFontColor & 0xff; int oldHeaderFontR = (oldHeaderFontColor >> 16) & 0xff; int oldHeaderFontG = (oldHeaderFontColor >> 8) & 0xff; int oldHeaderFontB = oldHeaderFontColor & 0xff; int newHeaderFontR = (newHeaderFontColor >> 16) & 0xff; int newHeaderFontG = (newHeaderFontColor >> 8) & 0xff; int newHeaderFontB = newHeaderFontColor & 0xff; int oldBorderR = (oldBorderColor >> 16) & 0xff; int oldBorderG = (oldBorderColor >> 8) & 0xff; int oldBorderB = oldBorderColor & 0xff; int newBorderR = (newBorderColor >> 16) & 0xff; int newBorderG = (newBorderColor >> 8) & 0xff; int newBorderB = newBorderColor & 0xff; ServletContext servletContext = session.getServletContext(); WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); ResourcesProcessorFactory resourcesProcessorFactory = (ResourcesProcessorFactory) context .getBean("processorFactory"); ResourcesHolder schemaHolder; ResourcesProcessor processor; /* schemaHolder = getResourcesHolderForProcessing(templateId, ""); processor = resourcesProcessorFactory.getResourcesProcessor(schemaHolder, context);*/ //operation definition //hints HashMap hints = new HashMap(); hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); hints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); hints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); RenderingHints renderingHints = new RenderingHints(hints); int rDiff = newR - oldR; int gDiff = newG - oldG; int bDiff = newB - oldB; int rHeaderDiff = newHeaderR - oldHeaderR; int gHeaderDiff = newHeaderG - oldHeaderG; int bHeaderDiff = newHeaderB - oldHeaderB; int rBgDiff = newBgR - oldBgR; int gBgDiff = newBgG - oldBgG; int bBgDiff = newBgB - oldBgB; int rFontDiff = newFontR - oldFontR; int gFontDiff = newFontG - oldFontG; int bFontDiff = newFontB - oldFontB; int rHeaderFontDiff = newHeaderFontR - oldHeaderFontR; int gHeaderFontDiff = newHeaderFontG - oldHeaderFontG; int bHeaderFontDiff = newHeaderFontB - oldHeaderFontB; int rBorderDiff = newBorderR - oldBorderR; int gBorderDiff = newBorderG - oldBorderG; int bBorderDiff = newBorderB - oldBorderB; float transparencyDiff = newTransp - oldTransp; float[] offsets = { rDiff, gDiff, bDiff, 0f }; float[] offsetsHeader = { rHeaderDiff, gHeaderDiff, bHeaderDiff, 0f }; float[] offsetsBg = { rBgDiff, gBgDiff, bBgDiff, 0f }; float[] offsetsFont = { rFontDiff, gFontDiff, bFontDiff, 0f }; float[] offsetsHeaderFont = { rHeaderFontDiff, gHeaderFontDiff, bHeaderFontDiff, 0f }; float[] offsetsBorder = { rBorderDiff, gBorderDiff, bBorderDiff, 0f }; float[] offsetsTranceparency = (0 == transparencyDiff) ? null : new float[] { 0, 0, 0, transparencyDiff }; float[] offsetsShadowTransparency = { 0, 0, 0, transparencyDiff / 5 }; float liteDivider = 2.5f; float[] liteoffsets = { rDiff / liteDivider, gDiff / liteDivider, bDiff / liteDivider, 0f }; float[] scaleFactors = { 1.0f, 1.0f, 1.0f, 1.0f }; ExtJSRescaleOp brightenOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsets, renderingHints); ExtJSRescaleOp headerOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsetsHeader, renderingHints); ExtJSRescaleOp liteOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 liteoffsets, renderingHints); ExtJSRescaleOp bgOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsetsBg, renderingHints); ExtJSRescaleOp fontOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsetsFont, renderingHints); ExtJSRescaleOp headerFontOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsetsHeaderFont, renderingHints); ExtJSRescaleOp borderOp = new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsetsBorder, renderingHints); ExtJSRescaleOp transparencyOp = (0 == transparencyDiff) ? null : new ExtJSRescaleOp(scaleFactors, // 1 ,1 ,1 offsetsTranceparency, renderingHints); ExtJSRescaleOp shadowTransparencyOp = null/*new ExtJSRescaleOp( scaleFactors,// 1 ,1 ,1 offsetsShadowTransparency, renderingHints)*/; /* ShiftOp shiftOp = new ShiftOp(new float[]{1, 1, 1, 1} , offsets, renderingHints, true); int csRGB = ColorSpace.CS_sRGB; int csGRAY = ColorSpace.CS_GRAY; ColorSpace srcCS = ColorSpace.getInstance(csRGB); ColorSpace destCS = ColorSpace.getInstance(csGRAY); */ //operation with inversion of color #for heading font color ForegroundShiftOp foregroundOp = new ForegroundShiftOp(newR, newG, newB); AffineTransformOp affineTransformOp = null/*new AffineTransformOp( AffineTransform.getScaleInstance(2,2), AffineTransformOp.TYPE_BICUBIC)*/; //end operation definition //get toolset holder ResourceHolderPool holderToolsetPool = this.holderToolsetPool; ResourcesHolder toolsetSchemaHolder = holderToolsetPool.checkOut(); // //get drawable holder ResourceHolderPool holderDrawablePool = this.holderDrawablePool; ResourcesHolder drawableSchemaHolder = holderDrawablePool.checkOut(); // /* process(processor, templateId, schemaHolder, brightenOp, foregroundOp, liteOp, bgOp, fontOp, transparencyOp, session, borderOp, affineTransformOp, headerFontOp, shadowTransparencyOp, headerOp, toolsetSchemaHolder, toolsetName, familyHeaderFont, weightHeaderFont, sizeHeaderFontDiff, familyFont, weightFont, sizeFontDiff, drawableSchemaHolder, "3.2"*//*version*//*); if (!"3.2".equals(version)){*/ schemaHolder = getResourcesHolderForProcessing(templateId, version); processor = resourcesProcessorFactory.getResourcesProcessor(schemaHolder, context); process(processor, themeParametersHolder, templateId, schemaHolder, brightenOp, foregroundOp, liteOp, bgOp, fontOp, transparencyOp, session, borderOp, affineTransformOp, headerFontOp, shadowTransparencyOp, headerOp, toolsetSchemaHolder, toolsetName, familyHeaderFont, weightHeaderFont, sizeHeaderFontDiff, familyFont, weightFont, sizeFontDiff, drawableSchemaHolder, version); /* }*/ logger.info("ProcessThemeController ! IP=" + httpServletRequest.getRemoteAddr()); return new ModelAndView("json/success"); }
From source file:uk.ac.ebi.ep.controller.BrowseTaxonomyController.java
@RequestMapping(value = FILTER_BY_FACETS, method = RequestMethod.GET) public String filterByFacets(@ModelAttribute("searchModel") SearchModel searchModel, @RequestParam(value = "taxId", required = true) Long taxId, @RequestParam(value = "organismName", required = false) String organismName, Model model, HttpServletRequest request, HttpSession session, RedirectAttributes attributes) { List<Species> species = enzymePortalService.findSpeciesByTaxId(taxId); List<Compound> compouds = enzymePortalService.findCompoundsByTaxId(taxId); List<Disease> diseases = enzymePortalService.findDiseasesByTaxId(taxId); List<EcNumber> enzymeFamilies = enzymePortalService.findEnzymeFamiliesByTaxId(taxId); SearchFilters filters = new SearchFilters(); filters.setSpecies(species);/*from w w w . j av a 2s .c om*/ filters.setCompounds(compouds); filters.setDiseases(diseases); filters.setEcNumbers(enzymeFamilies); SearchParams searchParams = searchModel.getSearchparams(); searchParams.setText(organismName); searchParams.setSize(SEARCH_PAGESIZE); searchModel.setSearchparams(searchParams); SearchResults searchResults = new SearchResults(); searchResults.setSearchfilters(filters); searchModel.setSearchresults(searchResults); SearchParams searchParameters = searchModel.getSearchparams(); String compound_autocompleteFilter = request.getParameter("searchparams.compounds"); String specie_autocompleteFilter = request.getParameter("_ctempList_selected"); String diseases_autocompleteFilter = request.getParameter("_DtempList_selected"); // Filter: List<String> specieFilter = searchParameters.getSpecies(); List<String> compoundFilter = searchParameters.getCompounds(); List<String> diseaseFilter = searchParameters.getDiseases(); List<Integer> ecFilter = searchParameters.getEcFamilies(); //remove empty string in the filter to avoid unsual behavior of the filter facets if (specieFilter.contains("")) { specieFilter.remove(""); } if (compoundFilter.contains("")) { compoundFilter.remove(""); } if (diseaseFilter.contains("")) { diseaseFilter.remove(""); } //to ensure that the seleted item is used in species filter, add the selected to the list. this is a workaround. different JS were used for auto complete and normal filter if ((specie_autocompleteFilter != null && StringUtils.hasLength(specie_autocompleteFilter) == true) && StringUtils.isEmpty(compound_autocompleteFilter) && StringUtils.isEmpty(diseases_autocompleteFilter)) { specieFilter.add(specie_autocompleteFilter); } if ((diseases_autocompleteFilter != null && StringUtils.hasLength(diseases_autocompleteFilter) == true) && StringUtils.isEmpty(compound_autocompleteFilter) && StringUtils.isEmpty(specie_autocompleteFilter)) { diseaseFilter.add(diseases_autocompleteFilter); } //both from auto complete and normal selection. selected items are displayed on top the list and returns back to the orignial list when not selected. //SearchResults searchResults = resultSet; List<Species> defaultSpeciesList = searchResults.getSearchfilters().getSpecies(); resetSelectedSpecies(defaultSpeciesList); searchParameters.getSpecies().stream().forEach((selectedItems) -> { defaultSpeciesList.stream() .filter((theSpecies) -> (selectedItems.equals(theSpecies.getScientificname()))) .forEach((theSpecies) -> { theSpecies.setSelected(true); }); }); List<Compound> defaultCompoundList = searchResults.getSearchfilters().getCompounds(); resetSelectedCompounds(defaultCompoundList); searchParameters.getCompounds().stream().forEach((SelectedCompounds) -> { defaultCompoundList.stream().filter((theCompound) -> (SelectedCompounds.equals(theCompound.getName()))) .forEach((theCompound) -> { theCompound.setSelected(true); }); }); List<Disease> defaultDiseaseList = searchResults.getSearchfilters().getDiseases(); resetSelectedDisease(defaultDiseaseList); searchParameters.getDiseases().stream().forEach((selectedDisease) -> { defaultDiseaseList.stream().filter((disease) -> (selectedDisease.equals(disease.getName()))) .forEach((disease) -> { disease.setSelected(true); }); }); List<EcNumber> defaultEcNumberList = searchResults.getSearchfilters().getEcNumbers(); resetSelectedEcNumber(defaultEcNumberList); searchParameters.getEcFamilies().stream().forEach((selectedEcFamily) -> { defaultEcNumberList.stream().filter((ec) -> (selectedEcFamily.equals(ec.getEc()))).forEach((ec) -> { ec.setSelected(true); }); }); Pageable pageable = new PageRequest(0, SEARCH_PAGESIZE, Sort.Direction.ASC, "function", "entryType"); Page<UniprotEntry> page = new PageImpl<>(new ArrayList<>(), pageable, 0); //specie only if (specieFilter.isEmpty() && compoundFilter.isEmpty() && diseaseFilter.isEmpty()) { page = enzymePortalService.filterBySpecie(taxId, pageable); } //specie only if (!specieFilter.isEmpty() && compoundFilter.isEmpty() && diseaseFilter.isEmpty()) { page = enzymePortalService.filterBySpecie(taxId, pageable); } // compounds only if (!compoundFilter.isEmpty() && diseaseFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndCompounds(taxId, compoundFilter, pageable); } // disease only if (compoundFilter.isEmpty() && !diseaseFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndDiseases(taxId, diseaseFilter, pageable); } //ec only if (compoundFilter.isEmpty() && diseaseFilter.isEmpty() && !ecFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndEc(taxId, ecFilter, pageable); } //compound and diseases if (!compoundFilter.isEmpty() && !diseaseFilter.isEmpty() && ecFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndCompoundsAndDiseases(taxId, compoundFilter, diseaseFilter, pageable); } //compound and ec if (!compoundFilter.isEmpty() && !ecFilter.isEmpty() && diseaseFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndCompoundsAndEc(taxId, compoundFilter, ecFilter, pageable); } //disease and ec if (!ecFilter.isEmpty() && !diseaseFilter.isEmpty() && compoundFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndDiseasesAndEc(taxId, diseaseFilter, ecFilter, pageable); } //disease and compounds and ec if (!ecFilter.isEmpty() && !diseaseFilter.isEmpty() && !compoundFilter.isEmpty()) { page = enzymePortalService.filterBySpecieAndCompoundsAndDiseasesAndEc(taxId, compoundFilter, diseaseFilter, ecFilter, pageable); } model.addAttribute("searchFilter", filters); List<UniprotEntry> result = page.getContent(); int current = page.getNumber() + 1; int begin = Math.max(1, current - 5); int end = Math.min(begin + 10, page.getTotalPages()); model.addAttribute("page", page); model.addAttribute("beginIndex", begin); model.addAttribute("endIndex", end); model.addAttribute("currentIndex", current); model.addAttribute("organismName", organismName); model.addAttribute("taxId", taxId); model.addAttribute("summaryEntries", result); searchResults.setTotalfound(page.getTotalElements()); searchResults.setSearchfilters(filters); searchResults.setSummaryentries(result); searchModel.setSearchresults(searchResults); model.addAttribute("searchModel", searchModel); model.addAttribute("searchConfig", searchConfig); String searchKey = getSearchKey(searchModel.getSearchparams()); cacheSearch(session.getServletContext(), searchKey, searchResults); setLastSummaries(session, searchResults.getSummaryentries()); clearHistory(session); addToHistory(session, searchModel.getSearchparams().getType(), searchKey); return RESULT; }
From source file:com.portfolio.data.provider.MysqlAdminProvider.java
@Override public Object postPortfolioZip(MimeType mimeType, MimeType mimeType2, HttpServletRequest httpServletRequest, int userId, int groupId, String modelId) throws FileNotFoundException, IOException { if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); DataInputStream inZip = new DataInputStream(httpServletRequest.getInputStream()); ByteArrayOutputStream byte2 = new ByteArrayOutputStream(); StringBuffer outTrace = new StringBuffer(); String portfolioId = null;/* w ww . ja va 2 s. c om*/ portfolioId = httpServletRequest.getParameter("portfolio"); String foldersfiles = null; String filename; String[] xmlFiles; String[] allFiles; String[] ImgFiles; int formDataLength = httpServletRequest.getContentLength(); byte[] buff = new byte[formDataLength]; // Recuperation de l'heure laquelle le zip est cr //Calendar cal = Calendar.getInstance(); //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss_S"); //String now = sdf.format(cal.getTime()); this.genererPortfolioUuidPreliminaire(); javax.servlet.http.HttpSession session = httpServletRequest.getSession(true); String ppath = session.getServletContext().getRealPath(File.separator); String outsideDir = ppath.substring(0, ppath.lastIndexOf(File.separator)) + "_files" + File.separator; File outsideDirectoryFile = new File(outsideDir); System.out.println(outsideDir); // if the directory does not exist, create it if (!outsideDirectoryFile.exists()) { outsideDirectoryFile.mkdir(); } //Creation du zip filename = outsideDir + "xml_" + this.portfolioUuidPreliminaire + ".zip"; FileOutputStream outZip = new FileOutputStream(filename); int len; while ((len = inZip.read(buff)) != -1) { outZip.write(buff, 0, len); } inZip.close(); outZip.close(); //-- unzip -- foldersfiles = unzip(filename, outsideDir + this.portfolioUuidPreliminaire + File.separator); //TODO Attention si plusieurs XML dans le fichier xmlFiles = findFiles(outsideDir + this.portfolioUuidPreliminaire + File.separator, "xml"); allFiles = findFiles(outsideDir + this.portfolioUuidPreliminaire + File.separator, null); for (int i = 0; i < allFiles.length; i++) { portfolioRessourcesImportPath.add(allFiles[i]); String tmpFileName = allFiles[i].substring(allFiles[i].lastIndexOf(File.separator) + 1); String uuid = tmpFileName.substring(0, tmpFileName.indexOf("_")); portfolioRessourcesImportUuid.add(uuid); tmpFileName = allFiles[i].substring(allFiles[i].lastIndexOf(File.separator) + 1); String lang; try { int tmpPos = tmpFileName.indexOf("_"); lang = tmpFileName.substring(tmpPos + 1, tmpPos + 3); } catch (Exception ex) { lang = ""; } InputStream is = new FileInputStream(allFiles[i]); byte b[] = new byte[is.available()]; is.read(b); String extension; try { extension = tmpFileName.substring(tmpFileName.lastIndexOf(".") + 1); } catch (Exception ex) { extension = null; } // trop long //String tmpMimeType = FileUtils.getMimeType("file://"+allFiles[i]); String tmpMimeType = FileUtils.getMimeTypeFromExtension(extension); // Attention on initialise la ligne file // avec l'UUID d'origine de l'asmContext parent // Il sera mis jour avec l'UUID asmContext final dans writeNode try { UUID tmpUuid = UUID.fromString(uuid); if (tmpUuid.toString().equals(uuid)) this.putFile(uuid, lang, tmpFileName, outsideDir, tmpMimeType, extension, b.length, b, userId); } catch (Exception ex) { // Le nom du fichier ne commence pas par un UUID, // ce n'est donc pas une ressource } } //TODO Supprimer le zip quand a fonctionnera bien //--- Read xml fileL ---- for (int i = 0; i < xmlFiles.length; i++) { BufferedReader br = new BufferedReader(new FileReader(new File(xmlFiles[i]))); String line; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { sb.append(line.trim()); } String xml = "?"; xml = sb.toString(); if (xml.contains("<portfolio id=")) { try { Object returnValue = postPortfolio(new MimeType("text/xml"), new MimeType("text/xml"), xml, userId, groupId, null); return returnValue; } catch (MimeTypeParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return false; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public Object postPortfolioZip(MimeType mimeType, MimeType mimeType2, HttpServletRequest httpServletRequest, int userId, int groupId, String modelId, int substid) throws IOException { if (!credential.isAdmin(userId) && !credential.isCreator(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); boolean isMultipart = ServletFileUpload.isMultipartContent(httpServletRequest); // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Configure a repository (to ensure a secure temp location is used) ServletContext servletContext = httpServletRequest.getSession().getServletContext(); File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); factory.setRepository(repository);// ww w . j av a 2s .c om // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); DataInputStream inZip = null; // Parse the request try { List<FileItem> items = upload.parseRequest(httpServletRequest); // Process the uploaded items Iterator<FileItem> iter = items.iterator(); while (iter.hasNext()) { FileItem item = iter.next(); if (!item.isFormField()) { inZip = new DataInputStream(item.getInputStream()); break; } } } catch (FileUploadException e) { // TODO Auto-generated catch block e.printStackTrace(); } String foldersfiles = null; String filename; String[] xmlFiles; String[] allFiles; // int formDataLength = httpServletRequest.getContentLength(); byte[] buff = new byte[0x100000]; // 1MB buffer // Recuperation de l'heure laquelle le zip est cr //Calendar cal = Calendar.getInstance(); //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss_S"); //String now = sdf.format(cal.getTime()); this.genererPortfolioUuidPreliminaire(); javax.servlet.http.HttpSession session = httpServletRequest.getSession(true); String ppath = session.getServletContext().getRealPath("/"); String outsideDir = ppath.substring(0, ppath.lastIndexOf(File.separator)) + "_files" + File.separator; File outsideDirectoryFile = new File(outsideDir); System.out.println(outsideDir); // if the directory does not exist, create it if (!outsideDirectoryFile.exists()) { outsideDirectoryFile.mkdir(); } //Creation du zip filename = outsideDir + "xml_" + this.portfolioUuidPreliminaire + ".zip"; FileOutputStream outZip = new FileOutputStream(filename); int len; while ((len = inZip.read(buff)) != -1) { outZip.write(buff, 0, len); } inZip.close(); outZip.close(); //-- unzip -- foldersfiles = unzip(filename, outsideDir + this.portfolioUuidPreliminaire + File.separator); //TODO Attention si plusieurs XML dans le fichier xmlFiles = findFiles(outsideDir + this.portfolioUuidPreliminaire + File.separator, "xml"); allFiles = findFiles(outsideDir + this.portfolioUuidPreliminaire + File.separator, null); ////// Lecture du fichier de portfolio StringBuffer outTrace = new StringBuffer(); //// Importation du portfolio //--- Read xml fileL ---- ///// Pour associer l'ancien uuid -> nouveau, pour les fichiers HashMap<String, String> resolve = new HashMap<String, String>(); String portfolioUuid = "erreur"; boolean hasLoaded = false; try { for (int i = 0; i < xmlFiles.length; i++) { String xmlFilepath = xmlFiles[i]; String xmlFilename = xmlFilepath.substring(xmlFilepath.lastIndexOf(File.separator)); if (xmlFilename.contains("_")) continue; // Case when we add an xml in the portfolio BufferedReader br = new BufferedReader(new FileReader(new File(xmlFilepath))); String line; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { sb.append(line.trim()); } String xml = "?"; xml = sb.toString(); portfolioUuid = UUID.randomUUID().toString(); if (xml.contains("<portfolio")) // Le porfolio (peux mieux faire) { Document doc = DomUtils.xmlString2Document(xml, outTrace); Node rootNode = (doc.getElementsByTagName("portfolio")).item(0); if (rootNode == null) throw new Exception("Root Node (portfolio) not found !"); else { rootNode = (doc.getElementsByTagName("asmRoot")).item(0); String uuid = UUID.randomUUID().toString(); insertMysqlPortfolio(portfolioUuid, uuid, 0, userId); writeNode(rootNode, portfolioUuid, null, userId, 0, uuid, null, 0, 0, false, resolve); } updateMysqlPortfolioActive(portfolioUuid, true); /// Finalement on cre un rle designer int groupid = postCreateRole(portfolioUuid, "designer", userId); /// Ajoute la personne dans ce groupe putUserGroup(Integer.toString(groupid), Integer.toString(userId)); hasLoaded = true; } } } catch (Exception e) { e.printStackTrace(); } if (hasLoaded) for (int i = 0; i < allFiles.length; i++) { String fullPath = allFiles[i]; String tmpFileName = allFiles[i].substring(allFiles[i].lastIndexOf(File.separator) + 1); int index = tmpFileName.indexOf("_"); if (index == -1) index = tmpFileName.indexOf("."); int last = tmpFileName.lastIndexOf(File.separator); if (last == -1) last = 0; String uuid = tmpFileName.substring(last, index); // tmpFileName = allFiles[i].substring(allFiles[i].lastIndexOf(File.separator)+1); String lang; try { // int tmpPos = tmpFileName.indexOf("_"); lang = tmpFileName.substring(index + 1, index + 3); if ("un".equals(lang)) // Hack sort of fixing previous implementation lang = "en"; } catch (Exception ex) { lang = ""; } InputStream is = new FileInputStream(allFiles[i]); byte b[] = new byte[is.available()]; is.read(b); String extension; try { extension = tmpFileName.substring(tmpFileName.lastIndexOf(".") + 1); } catch (Exception ex) { extension = null; } // trop long //String tmpMimeType = FileUtils.getMimeType("file://"+allFiles[i]); String tmpMimeType = FileUtils.getMimeTypeFromExtension(extension); // Attention on initialise la ligne file // avec l'UUID d'origine de l'asmContext parent // Il sera mis jour avec l'UUID asmContext final dans writeNode try { UUID tmpUuid = UUID.fromString(uuid); /// base uuid String resolved = resolve.get(uuid); /// New uuid String sessionval = session.getId(); String user = (String) session.getAttribute("user"); // String test = outsideDir+File.separator+this.portfolioUuidPreliminaire+File.separator+tmpFileName; // File file = new File(outsideDir+File.separator+this.portfolioUuidPreliminaire+File.separator+tmpFileName); File file = new File(fullPath); // server backend // fileserver String backend = session.getServletContext().getInitParameter("backendserver"); if (resolved != null) { /// Have to send it in FORM, compatibility with regular file posting PostForm.sendFile(sessionval, backend, user, resolved, lang, file); /// No need to fetch resulting ID, since we provided it /* InputStream objReturn = connect.getInputStream(); StringWriter idResponse = new StringWriter(); IOUtils.copy(objReturn, idResponse); fileid = idResponse.toString(); //*/ } /* if(tmpUuid.toString().equals(uuid)) this.putFile(uuid,lang,tmpFileName,outsideDir,tmpMimeType,extension,b.length,b,userId); //*/ } catch (Exception ex) { // Le nom du fichier ne commence pas par un UUID, // ce n'est donc pas une ressource ex.printStackTrace(); } } File zipfile = new File(filename); zipfile.delete(); File zipdir = new File(outsideDir + this.portfolioUuidPreliminaire + File.separator); zipdir.delete(); return portfolioUuid; }