List of usage examples for org.apache.commons.fileupload FileItem get
byte[] get();
From source file:com.hiperf.common.ui.server.storage.impl.PersistenceHelper.java
@Override public String replaceFile(String fileClass, String fileNameField, String fileStorageField, String fileName, FileItem fileItem, String existingId) throws PersistenceException { String idField = getIdFieldFromFileStorageClass(fileClass); boolean error = false; TransactionContext tc = null;/* www. j a v a 2 s. co m*/ Object id = null; PropertyDescriptor[] pds = propertyDescriptorsByClassName.get(fileClass); try { id = getFileId(existingId, idField, pds); tc = createTransactionalContext(); EntityManager em = tc.getEm(); ITransaction tx = tc.getTx(); tx.begin(); Object o; Class<?> clazz = Class.forName(fileClass); o = em.find(clazz, id); for (PropertyDescriptor pd : pds) { if (fileNameField.equals(pd.getName())) { pd.getWriteMethod().invoke(o, fileName); } else if (fileStorageField.equals(pd.getName())) { pd.getWriteMethod().invoke(o, fileItem.get()); } } em.merge(o); tx.commit(); //idsByClassName.get(fileClass).iterator().next().getReadMethod().invoke(o, new Object[0]); } catch (Exception e) { error = true; logger.log(Level.SEVERE, "Exception in saveFile : " + e.getMessage(), e); try { if (tc != null) tc.rollback(); } catch (Exception ee) { } } finally { if (tc != null) { if (!error) close(tc); else tc.close(); } } if (error) { try { tc = createTransactionalContext(); EntityManager em = tc.getEm(); ITransaction tx = tc.getTx(); tx.begin(); Class<?> clazz = Class.forName(fileClass); em.createQuery("delete from " + fileClass + " o where o." + idField + " = :id") .setParameter("id", id).executeUpdate(); Object newDoc = clazz.newInstance(); for (PropertyDescriptor pd : pds) { if (fileNameField.equals(pd.getName())) { pd.getWriteMethod().invoke(newDoc, fileName); } else if (fileStorageField.equals(pd.getName())) { pd.getWriteMethod().invoke(newDoc, fileItem.get()); } } em.persist(newDoc); tx.commit(); for (PropertyDescriptor pd : pds) { if (idField.equals(pd.getName())) { existingId = pd.getReadMethod().invoke(newDoc, new String[0]).toString(); break; } } } catch (Exception e) { logger.log(Level.SEVERE, "Exception in saveFile : " + e.getMessage(), e); try { if (tc != null) tc.rollback(); } catch (Exception ee) { } throw new PersistenceException(e.getMessage(), e); } finally { if (tc != null) close(tc); } } return existingId; }
From source file:it.eng.spagobi.tools.importexport.services.ImportExportModule.java
/** * Manages the request of the user to import contents of an exported archive * // w w w . j a va 2 s.c om * @param request * Spago SourceBean request * @param response * Spago SourceBean response * @throws EMFUserError */ private void importConf(SourceBean request, SourceBean response) throws EMFUserError { logger.debug("IN"); HashMap<String, String> logParam = new HashMap(); SessionContainer permanentSession = this.getRequestContainer().getSessionContainer() .getPermanentContainer(); IEngUserProfile profile = (IEngUserProfile) permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE); IImportManager impManager = null; // get exported file and eventually the associations file // UploadedFile archive = null; // UploadedFile associationsFile = null; FileItem archive = null; FileItem associationsFileItem = null; UploadedFile associationsFile = null; AssociationFile assFile = null; try { String assKindFromReq = (String) request.getAttribute("importAssociationKind"); boolean isNoAssociationModality = assKindFromReq != null && assKindFromReq.equalsIgnoreCase("noassociations"); List uplFiles = request.getAttributeAsList("UPLOADED_FILE"); if (uplFiles != null) { logger.debug("Uploded files [" + uplFiles.size() + "]"); } Iterator uplFilesIter = uplFiles.iterator(); while (uplFilesIter.hasNext()) { FileItem uplFile = (FileItem) uplFilesIter.next(); logger.debug("Uploded file name [" + uplFile + "]"); logParam.put("ImportFileName", uplFile.getName()); String nameInForm = uplFile.getFieldName(); if (nameInForm.equals("exportedArchive")) { archive = uplFile; } else if (nameInForm.equals("associationsFile")) { associationsFileItem = uplFile; } } // check that the name of the uploaded archive is not empty //String archiveName = archive.getFileName(); String archiveName = GeneralUtilities.getRelativeFileNames(archive.getName()); logger.debug("Archive file name [" + archiveName + "]"); if (archiveName.trim().equals("")) { logger.error("Missing exported file"); response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportLoopbackStopImport"); try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "KO"); } catch (Exception e) { e.printStackTrace(); } throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportedArchive", "8007", ImportManager.messageBundle); } int maxSize = ImportUtilities.getImportFileMaxSize(); if (archive.getSize() > maxSize) { logger.error("File is too large!!!"); response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportLoopbackStopImport"); try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "KO"); } catch (Exception e) { e.printStackTrace(); } throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportedArchive", "202"); } // checks if the association file is bigger than 1 MB, that is more than enough!! if (associationsFileItem != null) { if (associationsFileItem.getSize() > 1048576) { try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "KO"); } catch (Exception e) { e.printStackTrace(); } throw new EMFValidationError(EMFErrorSeverity.ERROR, "associationsFile", "202"); } // loads association file associationsFile = new UploadedFile(); associationsFile.setFileContent(associationsFileItem.get()); associationsFile.setFieldNameInForm(associationsFileItem.getFieldName()); associationsFile.setSizeInBytes(associationsFileItem.getSize()); associationsFile.setFileName(GeneralUtilities.getRelativeFileNames(associationsFileItem.getName())); } // if the user choose to have no associations, checks the form, otherwise set the variable associationsFile = null if (!isNoAssociationModality) { // check if the name of associations file is empty (in this case set // null to the variable) if (associationsFile != null) { String associationsFileName = associationsFile.getFileName(); if (associationsFileName.trim().equals("")) { associationsFile = null; } } // if the association file is empty then check if there is an // association id // rebuild the uploaded file and assign it to associationsFile variable if (associationsFile == null) { String assId = (String) request.getAttribute("hidAssId"); if ((assId != null) && !assId.trim().equals("")) { IAssociationFileDAO assfiledao = new AssociationFileDAO(); assFile = assfiledao.loadFromID(assId); byte[] content = assfiledao.getContent(assFile); UploadedFile uplFile = new UploadedFile(); uplFile.setSizeInBytes(content.length); uplFile.setFileContent(content); uplFile.setFileName("association.xml"); uplFile.setFieldNameInForm(""); associationsFile = uplFile; } } } else { associationsFile = null; } // get the association mode String assMode = IImportManager.IMPORT_ASS_DEFAULT_MODE; if (assKindFromReq.equalsIgnoreCase("predefinedassociations")) { assMode = IImportManager.IMPORT_ASS_PREDEFINED_MODE; } // get bytes of the archive byte[] archiveBytes = archive.get(); // get path of the import tmp directory String pathImpTmpFolder = ImportUtilities.getImportTempFolderPath(); // apply transformation TransformManager transManager = new TransformManager(); archiveBytes = transManager.applyTransformations(archiveBytes, archiveName, pathImpTmpFolder); logger.debug("Transformation applied succesfully"); // prepare import environment impManager = ImportUtilities.getImportManagerInstance(); impManager.setUserProfile(profile); impManager.init(pathImpTmpFolder, archiveName, archiveBytes); impManager.openSession(); impManager.setAssociationFile(assFile); // if the associations file has been uploaded fill the association keeper if (associationsFile != null) { byte[] assFilebys = associationsFile.getFileContent(); String assFileStr = new String(assFilebys); try { impManager.getUserAssociation().fillFromXml(assFileStr); } catch (Exception e) { logger.error("Error while loading association file content:\n " + e); response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportLoopbackStopImport"); throw new EMFValidationError(EMFErrorSeverity.ERROR, "exportedArchive", "8009", ImportManager.messageBundle); } } // set into import manager the association import mode impManager.setImpAssMode(assMode); RequestContainer requestContainer = this.getRequestContainer(); SessionContainer session = requestContainer.getSessionContainer(); session.setAttribute(ImportExportConstants.IMPORT_MANAGER, impManager); // start import operations if (impManager.getImpAssMode().equals(IImportManager.IMPORT_ASS_PREDEFINED_MODE) && !impManager.associateAllExportedRolesByUserAssociation()) { response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportSkipRoleAssociation"); } else { // move to jsp List exportedRoles = impManager.getExportedRoles(); IRoleDAO roleDAO = DAOFactory.getRoleDAO(); List currentRoles = roleDAO.loadAllRoles(); response.setAttribute(ImportExportConstants.LIST_EXPORTED_ROLES, exportedRoles); response.setAttribute(ImportExportConstants.LIST_CURRENT_ROLES, currentRoles); response.setAttribute(ImportExportConstants.PUBLISHER_NAME, "ImportExportRoleAssociation"); } } catch (EMFUserError emfue) { logger.error("Error inr etrieving import configuration ", emfue); if (impManager != null) { impManager.stopImport(); } throw emfue; } catch (ClassNotFoundException cnde) { logger.error("Importer class not found", cnde); if (impManager != null) impManager.stopImport(); try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "ERR"); } catch (Exception e) { e.printStackTrace(); } throw new EMFUserError(EMFErrorSeverity.ERROR, "8004", ImportManager.messageBundle); } catch (InstantiationException ie) { logger.error("Cannot create an instance of importer class ", ie); if (impManager != null) impManager.stopImport(); try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "ERR"); } catch (Exception e) { e.printStackTrace(); } throw new EMFUserError(EMFErrorSeverity.ERROR, "8004", ImportManager.messageBundle); } catch (IllegalAccessException iae) { logger.error("Cannot create an instance of importer class ", iae); if (impManager != null) impManager.stopImport(); try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "ERR"); } catch (Exception e) { e.printStackTrace(); } throw new EMFUserError(EMFErrorSeverity.ERROR, "8004", ImportManager.messageBundle); } catch (SourceBeanException sbe) { logger.error("Error: " + sbe); if (impManager != null) impManager.stopImport(); throw new EMFUserError(EMFErrorSeverity.ERROR, "8004", ImportManager.messageBundle); } catch (Exception e) { logger.error("An unexpected error occured while performing import", e); if (impManager != null) { impManager.stopImport(); } try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "ERR"); } catch (Exception ee) { ee.printStackTrace(); } throw new EMFUserError(EMFErrorSeverity.ERROR, "8004", ImportManager.messageBundle); } finally { if (impManager != null) impManager.closeSession(); logger.debug("OUT"); try { AuditLogUtilities.updateAudit(getHttpRequest(), profile, "IMPORT", logParam, "OK"); } catch (Exception e) { e.printStackTrace(); } } }
From source file:fr.paris.lutece.plugins.plu.web.PluJspBean.java
/** * Generates a message of confirmation for correct a folder * @param request the Http request/*w w w .ja va 2 s .c o m*/ * @return message */ public String getConfirmCorrectFolder(HttpServletRequest request) { if (request.getParameter(PARAMETER_FOLDER_TITLE).equals("") || request.getParameter(PARAMETER_FOLDER_DESCRIPTION).equals("") || request.getParameter(PARAMETER_HISTORY_DESCRIPTION).equals("")) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_REQUIRED_FIELD, AdminMessage.TYPE_STOP); } int nIdPlu = Integer.parseInt(request.getParameter(PARAMETER_PLU_ID)); String folderTitle = request.getParameter(PARAMETER_FOLDER_TITLE); UrlItem url = new UrlItem(JSP_DO_CORRECT_FOLDER); url.addParameter(PARAMETER_PLU_ID, nIdPlu); try { url.addParameter(PARAMETER_FOLDER_ID, URIUtil.encodeAll(request.getParameter(PARAMETER_FOLDER_ID))); url.addParameter(PARAMETER_FOLDER_PARENT_ID, URIUtil.encodeAll(request.getParameter(PARAMETER_FOLDER_PARENT_ID))); url.addParameter(PARAMETER_FOLDER_TITLE, URIUtil.encodeAll(folderTitle)); // url.addParameter( PARAMETER_FOLDER_DESCRIPTION, // URIUtil.encodeAll( request.getParameter( // PARAMETER_FOLDER_DESCRIPTION ) ) ); url.addParameter(PARAMETER_HISTORY_DESCRIPTION, URIUtil.encodeAll(request.getParameter(PARAMETER_HISTORY_DESCRIPTION))); } catch (URIException e) { throw new AppException("An error occured while parsing request parameters"); } // save description into session because it's too large for url request.getSession().setAttribute(PARAMETER_FOLDER_DESCRIPTION, request.getParameter(PARAMETER_FOLDER_DESCRIPTION)); if (request.getParameterValues(PARAMETER_FOLDER_IMAGE_CHECK) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_IMAGE_CHECK); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_IMAGE_CHECK, check[j]); } } if (request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_HTML_CHECK, check[j]); } } if (request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION, check[j]); } } Object[] args = { folderTitle }; Folder folder = _folderServices.findForTestTitle(folderTitle); if ((folder != null) && !folder.getTitle().equals(request.getParameter(PARAMETER_FOLDER_TITLE_OLD))) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_FOLDER_CREATE, args, AdminMessage.TYPE_STOP); } if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; FileItem fileItem = multipartRequest.getFile(PARAMETER_FOLDER_IMAGE); if (fileItem.getSize() > 0) { String name = fileItem.getName(); String type = name.substring(name.lastIndexOf(".")); if (!type.equalsIgnoreCase(".jpg") && !type.equalsIgnoreCase(".png") && !type.equalsIgnoreCase(".gif")) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_FOLDER_IMAGE_TYPE, args, AdminMessage.TYPE_STOP); } PhysicalFile physicalFile = new PhysicalFile(); physicalFile.setValue(fileItem.get()); _folderImage.setImg(physicalFile.getValue()); _folderImage.setNomImage(fileItem.getName()); } } return AdminMessageService.getMessageUrl(request, MESSAGE_CONFIRM_CORRECT_FOLDER, args, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); }
From source file:fr.paris.lutece.plugins.plu.web.PluJspBean.java
/** * Generates a message of confirmation for create a new folder * @param request the Http request//from w w w.j a va 2 s . com * @return message */ public String getConfirmCreateFolder(HttpServletRequest request) { if (request.getParameter(PARAMETER_FOLDER_TITLE).equals("")) { return this.getMessageJsp(request, MESSAGE_ERROR_REQUIRED_FIELD, null, "jsp/admin/plugins/plu/folder/CreateFolder.jsp", null); } int nIdPlu = Integer.parseInt(request.getParameter(PARAMETER_PLU_ID)); String folderTitle = request.getParameter(PARAMETER_FOLDER_TITLE); UrlItem url = new UrlItem(JSP_DO_CREATE_FOLDER); url.addParameter(PARAMETER_PLU_ID, nIdPlu); try { url.addParameter(PARAMETER_FOLDER_PARENT_ID, URIUtil.encodeAll(request.getParameter(PARAMETER_FOLDER_PARENT_ID))); url.addParameter(PARAMETER_FOLDER_TITLE, URIUtil.encodeAll(folderTitle)); // url.addParameter( PARAMETER_FOLDER_DESCRIPTION, // URIUtil.encodeAll( request.getParameter( // PARAMETER_FOLDER_DESCRIPTION ) ) ); } catch (URIException e) { throw new AppException("An error occured while parsing request parameters"); } // save description into session because it's too large for url request.getSession().setAttribute(PARAMETER_FOLDER_DESCRIPTION, request.getParameter(PARAMETER_FOLDER_DESCRIPTION)); if (request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_HTML_CHECK, check[j]); } } if (request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION) != null) { String[] checkImpression = request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION); for (int j = 0; j < checkImpression.length; ++j) { url.addParameter(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION, checkImpression[j]); } } Object[] args = { folderTitle }; Folder folder = _folderServices.findForTestTitle(folderTitle); if (folder != null) { return this.getMessageJsp(request, MESSAGE_ERROR_FOLDER_CREATE, args, "jsp/admin/plugins/plu/folder/CreateFolder.jsp", null); } if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; FileItem fileItem = multipartRequest.getFile(PARAMETER_FOLDER_IMAGE); if (fileItem.getSize() > 0) { String name = fileItem.getName(); String type = name.substring(name.lastIndexOf(".")); if (!type.equalsIgnoreCase(".jpg") && !type.equalsIgnoreCase(".png") && !type.equalsIgnoreCase(".gif")) { return this.getMessageJsp(request, MESSAGE_ERROR_FOLDER_IMAGE_TYPE, args, "jsp/admin/plugins/plu/folder/CreateFolder.jsp", null); } PhysicalFile physicalFile = new PhysicalFile(); physicalFile.setValue(fileItem.get()); _folderImage.setImg(physicalFile.getValue()); } } return this.getMessageJsp(request, MESSAGE_CONFIRM_CREATE_FOLDER, args, "jsp/admin/plugins/plu/folder/CreateFolder.jsp", url.getUrl()); }
From source file:fr.paris.lutece.plugins.plu.web.PluJspBean.java
/** * Generates a message of confirmation for modify a folder * @param request the Http request//from w w w. j ava 2s . c o m * @parma correct true if the modification is a correction, false if the plu * is in "work" state * @return message */ public String getConfirmModifyFolder(HttpServletRequest request, boolean correct) { if (request.getParameter(PARAMETER_FOLDER_TITLE).equals("") || (correct && request.getParameter(PARAMETER_HISTORY_DESCRIPTION).equals(""))) { if (correct) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_REQUIRED_FIELD, AdminMessage.TYPE_STOP); } else { return this.getMessageJsp(request, MESSAGE_ERROR_REQUIRED_FIELD, null, "jsp/admin/plugins/plu/folder/ModifyFolder.jsp", null); } } int nIdPlu = Integer.parseInt(request.getParameter(PARAMETER_PLU_ID)); String folderTitle = request.getParameter(PARAMETER_FOLDER_TITLE); int nIdFolder = Integer.parseInt(request.getParameter(PARAMETER_FOLDER_ID)); Folder folder = _folderServices.findByPrimaryKey(nIdFolder); UrlItem url = new UrlItem(JSP_DO_MODIFY_FOLDER); url.addParameter(PARAMETER_PLU_ID, nIdPlu); try { url.addParameter(PARAMETER_FOLDER_ID, URIUtil.encodeAll(request.getParameter(PARAMETER_FOLDER_ID))); url.addParameter(PARAMETER_FOLDER_PARENT_ID, URIUtil.encodeAll(request.getParameter(PARAMETER_FOLDER_PARENT_ID))); url.addParameter(PARAMETER_FOLDER_TITLE, URIUtil.encodeAll(folderTitle)); if (correct) { url.addParameter(PARAMETER_HISTORY_DESCRIPTION, URIUtil.encodeAll(request.getParameter(PARAMETER_HISTORY_DESCRIPTION))); } } catch (URIException e) { throw new AppException("An error occured while parsing request parameters"); } // save description into session because it's too large for url request.getSession().setAttribute(PARAMETER_FOLDER_DESCRIPTION, request.getParameter(PARAMETER_FOLDER_DESCRIPTION)); if (request.getParameterValues(PARAMETER_FOLDER_IMAGE_CHECK) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_IMAGE_CHECK); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_IMAGE_CHECK, check[j]); } } if (request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_HTML_CHECK, check[j]); } } if (request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION) != null) { String[] check = request.getParameterValues(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION); for (int j = 0; j < check.length; ++j) { url.addParameter(PARAMETER_FOLDER_HTML_CHECK_IMPRESSION, check[j]); } } Object[] args = { folderTitle }; if ((folder != null) && !folder.getTitle().equals(request.getParameter(PARAMETER_FOLDER_TITLE_OLD))) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_FOLDER_CREATE, args, AdminMessage.TYPE_STOP); } if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; FileItem fileItem = multipartRequest.getFile(PARAMETER_FOLDER_IMAGE); if (fileItem.getSize() > 0) { String name = fileItem.getName(); String type = name.substring(name.lastIndexOf(".")); if (!type.equalsIgnoreCase(".jpg") && !type.equalsIgnoreCase(".png") && !type.equalsIgnoreCase(".gif")) { return AdminMessageService.getMessageUrl(request, MESSAGE_ERROR_FOLDER_IMAGE_TYPE, args, AdminMessage.TYPE_STOP); } PhysicalFile physicalFile = new PhysicalFile(); physicalFile.setValue(fileItem.get()); _folderImage.setImg(physicalFile.getValue()); _folderImage.setNomImage(fileItem.getName()); } } return AdminMessageService.getMessageUrl(request, correct ? MESSAGE_CONFIRM_CORRECT_FOLDER : MESSAGE_CONFIRM_MODIFY_FOLDER, args, url.getUrl(), AdminMessage.TYPE_CONFIRMATION); }
From source file:es.sm2.openppm.front.servlets.MaintenanceServlet.java
/** * Save a document or manual//from w ww. jav a 2 s . c o m * @param req * @param resp * @throws IOException * @throws ServletException */ private void saveDocumentation(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { int docId = Integer.parseInt(getMultipartField("idDocumentation")); int idManten = Integer.parseInt(getMultipartField("idManten")); String namePopup = getMultipartField("namePopup"); try { FileItem dataFile = getMultipartFields().get("file"); if (dataFile != null) { Documentation doc = new Documentation(); Contentfile docFile = new Contentfile(); // Declare logics DocumentationLogic docLogic = new DocumentationLogic(); ContentFileLogic fileLogic = new ContentFileLogic(); if (docId != -1) { // Logic find doc doc = docLogic.findById(docId); infoUpdated(req, "maintenance.documentation_manuals.documentation"); } else { infoCreated(req, "maintenance.documentation_manuals.documentation"); } if (dataFile.getSize() > 0) { // Delete old file if update doc if (docId != -1) { fileLogic.delete(fileLogic.findByDocumentation(doc)); } // Set data content file docFile.setExtension(FilenameUtils.getExtension(dataFile.getName())); docFile.setMime(dataFile.getContentType()); docFile.setContent(dataFile.get()); // Logic save content file docFile = fileLogic.save(docFile); // Update doc doc.setNameFile(dataFile.getName()); doc.setContentfile(docFile); } doc.setNamePopup(namePopup); doc.setCompany(getCompany(req)); // Logic save doc docLogic.save(doc); } } catch (Exception e) { ExceptionUtil.evalueException(req, getResourceBundle(req), LOGGER, e); } consMaintenance(req, resp, idManten); }
From source file:com.alkacon.opencms.formgenerator.database.CmsFormDataAccess.java
/** * Stores the content of the given file to a * place specified by the module parameter "uploadfolder".<p> * /*ww w .j a v a 2 s . c om*/ * Also the parameters "uploadvfs" and "uploadproject" can be used to store the file inside the OpenCms VFS.<p> * * The content of the upload file item is only inside a temporary file. * This must be called, when the form submission is stored to the database * as the content would be lost.<p> * * @param item the upload file item to store * @param formHandler only used for exception logging * * @return the absolute path of the created file */ private String storeFile(FileItem item, CmsFormHandler formHandler) { String fullResourceName = ""; CmsModule module = OpenCms.getModuleManager().getModule(CmsForm.MODULE_NAME); if (module == null) { throw new CmsRuntimeException(Messages.get().container(Messages.LOG_ERR_DATAACCESS_MODULE_MISSING_1, new Object[] { CmsForm.MODULE_NAME })); } // read the path to store the files from module parameters String filePath = module.getParameter(CmsForm.MODULE_PARAM_UPLOADFOLDER); if (CmsStringUtil.isEmptyOrWhitespaceOnly(filePath)) { throw new CmsRuntimeException( Messages.get().container(Messages.LOG_ERR_DATAACCESS_MODULE_PARAM_MISSING_2, new Object[] { CmsForm.MODULE_PARAM_UPLOADFOLDER, CmsForm.MODULE_NAME })); } // get the sub folder to store the files String formName = formHandler.getFormConfiguration().getFormId(); if ((formName != null) && formName.startsWith(formHandler.getRequestContext().getSiteRoot())) { // the configuration root path is used as (default) form ID, do NOT use this as sub folder formName = null; } formName = m_cms.getRequestContext().getFileTranslator().translateResource(formName); // generate file name String itemName = item.getName(); // In most cases, this will be the base file name, without path information. However, // some clients, such as the Opera browser, do include path information. // That is why here is to assure that the base name is used. itemName = CmsFormHandler.getTruncatedFileItemName(itemName); // add an (almost) unique prefix to the file to prevent overwriting of files with the same name SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_"); itemName = sdf.format(new Date()) + itemName; // determine upload target: RFS (default) or VFS String vfsUpload = module.getParameter(CmsForm.MODULE_PARAM_UPLOADVFS, CmsStringUtil.FALSE); if (Boolean.valueOf(vfsUpload).booleanValue()) { // upload to OpenCms VFS if (!filePath.endsWith("/")) { filePath += "/"; } // translate resource name to valid VFS resource name itemName = m_cms.getRequestContext().getFileTranslator().translateResource(itemName); // store current project CmsProject currProject = m_cms.getRequestContext().currentProject(); try { // switch to an offline project String projectName = module.getParameter(CmsForm.MODULE_PARAM_UPLOADPROJECT, "Offline"); m_cms.getRequestContext().setCurrentProject(m_cms.readProject(projectName)); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(formName)) { // check if the sub folder exists and create it if necessary String subFolder = filePath + formName; if (!m_cms.existsResource(subFolder)) { try { m_cms.createResource(subFolder, CmsResourceTypeFolder.getStaticTypeId(), null, null); m_cms.unlockResource(subFolder); // publish the folder OpenCms.getPublishManager().publishResource(m_cms, subFolder); // wait a little bit to avoid problems when publishing the uploaded file afterwards OpenCms.getPublishManager().waitWhileRunning(3000); // set the file path to sub folder filePath = subFolder + "/"; } catch (Exception e) { // error creating the folder in VFS LOG.error(e); } } } // create full resource name fullResourceName = filePath + itemName; // determine the resource type id from the given information int resTypeId = OpenCms.getResourceManager().getDefaultTypeForName(itemName).getTypeId(); // create the resource in VFS m_cms.createResource(fullResourceName, resTypeId, item.get(), null); m_cms.unlockResource(fullResourceName); try { // publish the resource OpenCms.getPublishManager().publishResource(m_cms, fullResourceName); } catch (Exception e) { // error publishing the created file LOG.error(e); } } catch (CmsException e) { // error creating the file in VFS LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DATAACCESS_UPLOADFILE_LOST_1, new Object[] { formHandler.createMailTextFromFields(false, false) }), e); } finally { // switch back to stored project m_cms.getRequestContext().setCurrentProject(currProject); } } else { // upload to server RFS try { File folder = new File(filePath); CmsFileUtil.assertFolder(folder, CmsFileUtil.MODE_READ, true); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(formName)) { File subFolder = new File(folder, formName); CmsFileUtil.assertFolder(subFolder, CmsFileUtil.MODE_READ, true); folder = subFolder; } File storeFile = new File(folder, itemName); fullResourceName = storeFile.getAbsolutePath(); byte[] contents = item.get(); try { OutputStream out = new FileOutputStream(storeFile); out.write(contents); out.flush(); out.close(); } catch (IOException e) { // should never happen LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DATAACCESS_UPLOADFILE_LOST_1, new Object[] { formHandler.createMailTextFromFields(false, false) }), e); } } catch (CmsRfsException ex) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DATAACCESS_UPLOADFILE_LOST_1, new Object[] { formHandler.createMailTextFromFields(false, false) }), ex); } } return fullResourceName; }
From source file:com.alkacon.opencms.v8.formgenerator.database.CmsFormDataAccess.java
/** * Stores the content of the given file to a * place specified by the module parameter "uploadfolder".<p> * // w w w . jav a2 s . c o m * Also the parameters "uploadvfs" and "uploadproject" can be used to store the file inside the OpenCms VFS.<p> * * The content of the upload file item is only inside a temporary file. * This must be called, when the form submission is stored to the database * as the content would be lost.<p> * * @param item the upload file item to store * @param formHandler only used for exception logging * * @return the absolute path of the created file */ private String storeFile(FileItem item, CmsFormHandler formHandler) { String fullResourceName = ""; CmsModule module = OpenCms.getModuleManager().getModule(CmsForm.MODULE_NAME); if (module == null) { throw new CmsRuntimeException(Messages.get().container(Messages.LOG_ERR_DATAACCESS_MODULE_MISSING_1, new Object[] { CmsForm.MODULE_NAME })); } // read the path to store the files from module parameters String filePath = module.getParameter(CmsForm.MODULE_PARAM_UPLOADFOLDER); if (CmsStringUtil.isEmptyOrWhitespaceOnly(filePath)) { throw new CmsRuntimeException( Messages.get().container(Messages.LOG_ERR_DATAACCESS_MODULE_PARAM_MISSING_2, new Object[] { CmsForm.MODULE_PARAM_UPLOADFOLDER, CmsForm.MODULE_NAME })); } // get the sub folder to store the files String formName = formHandler.getFormConfiguration().getFormId(); if ((formName != null) && formName.startsWith(formHandler.getRequestContext().getSiteRoot())) { // the configuration root path is used as (default) form ID, do NOT use this as sub folder formName = null; } formName = m_cms.getRequestContext().getFileTranslator().translateResource(formName); // generate file name String itemName = item.getName(); // In most cases, this will be the base file name, without path information. However, // some clients, such as the Opera browser, do include path information. // That is why here is to assure that the base name is used. itemName = CmsFormHandler.getTruncatedFileItemName(itemName); // add an (almost) unique prefix to the file to prevent overwriting of files with the same name SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_"); itemName = sdf.format(new Date()) + itemName; // determine upload target: RFS (default) or VFS String vfsUpload = module.getParameter(CmsForm.MODULE_PARAM_UPLOADVFS, CmsStringUtil.FALSE); if (Boolean.valueOf(vfsUpload).booleanValue()) { // upload to OpenCms VFS if (!filePath.endsWith("/")) { filePath += "/"; } // translate resource name to valid VFS resource name itemName = m_cms.getRequestContext().getFileTranslator().translateResource(itemName); // store current project CmsProject currProject = m_cms.getRequestContext().getCurrentProject(); try { // switch to an offline project String projectName = module.getParameter(CmsForm.MODULE_PARAM_UPLOADPROJECT, "Offline"); m_cms.getRequestContext().setCurrentProject(m_cms.readProject(projectName)); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(formName)) { // check if the sub folder exists and create it if necessary String subFolder = filePath + formName; if (!m_cms.existsResource(subFolder)) { try { m_cms.createResource(subFolder, CmsResourceTypeFolder.getStaticTypeId(), null, null); m_cms.unlockResource(subFolder); // publish the folder OpenCms.getPublishManager().publishResource(m_cms, subFolder); // wait a little bit to avoid problems when publishing the uploaded file afterwards OpenCms.getPublishManager().waitWhileRunning(3000); // set the file path to sub folder filePath = subFolder + "/"; } catch (Exception e) { // error creating the folder in VFS LOG.error(e); } } } // create full resource name fullResourceName = filePath + itemName; // determine the resource type id from the given information int resTypeId = OpenCms.getResourceManager().getDefaultTypeForName(itemName).getTypeId(); // create the resource in VFS m_cms.createResource(fullResourceName, resTypeId, item.get(), null); m_cms.unlockResource(fullResourceName); try { // publish the resource OpenCms.getPublishManager().publishResource(m_cms, fullResourceName); } catch (Exception e) { // error publishing the created file LOG.error(e); } } catch (CmsException e) { // error creating the file in VFS LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DATAACCESS_UPLOADFILE_LOST_1, new Object[] { formHandler.createMailTextFromFields(false, false) }), e); } finally { // switch back to stored project m_cms.getRequestContext().setCurrentProject(currProject); } } else { // upload to server RFS try { File folder = new File(filePath); CmsFileUtil.assertFolder(folder, CmsFileUtil.MODE_READ, true); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(formName)) { File subFolder = new File(folder, formName); CmsFileUtil.assertFolder(subFolder, CmsFileUtil.MODE_READ, true); folder = subFolder; } File storeFile = new File(folder, itemName); fullResourceName = storeFile.getAbsolutePath(); byte[] contents = item.get(); try { OutputStream out = new FileOutputStream(storeFile); out.write(contents); out.flush(); out.close(); } catch (IOException e) { // should never happen LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DATAACCESS_UPLOADFILE_LOST_1, new Object[] { formHandler.createMailTextFromFields(false, false) }), e); } } catch (CmsRfsException ex) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DATAACCESS_UPLOADFILE_LOST_1, new Object[] { formHandler.createMailTextFromFields(false, false) }), ex); } } return fullResourceName; }
From source file:com.slamd.admin.AdminServlet.java
/** * Handles the work of actually accepting an uploaded file and storing it in * the configuration directory.// w w w .j av a 2s .c om * * @param requestInfo The state information for this request. */ static void handleFileUpload(RequestInfo requestInfo) { logMessage(requestInfo, "In handleFileUpload()"); if (!requestInfo.mayManageFolders) { logMessage(requestInfo, "No mayManageFolders permission granted"); generateAccessDeniedBody(requestInfo, "You do not have permission to " + "upload files into job folders."); return; } StringBuilder infoMessage = requestInfo.infoMessage; FileUpload fileUpload = new FileUpload(new DefaultFileItemFactory()); fileUpload.setSizeMax(maxUploadSize); boolean inOptimizing = false; String folderName = null; try { String fileName = null; String fileType = null; String fileDesc = null; int fileSize = -1; byte[] fileData = null; Iterator iterator = requestInfo.multipartFieldList.iterator(); while (iterator.hasNext()) { FileItem fileItem = (FileItem) iterator.next(); String fieldName = fileItem.getFieldName(); if (fieldName.equals(Constants.SERVLET_PARAM_FILE_DESCRIPTION)) { fileDesc = new String(fileItem.get()); } else if (fieldName.equals(Constants.SERVLET_PARAM_JOB_FOLDER)) { folderName = new String(fileItem.get()); } else if (fieldName.equals(Constants.SERVLET_PARAM_UPLOAD_FILE)) { fileData = fileItem.get(); fileSize = fileData.length; fileType = fileItem.getContentType(); fileName = fileItem.getName(); } else if (fieldName.equals(Constants.SERVLET_PARAM_IN_OPTIMIZING)) { String optStr = new String(fileItem.get()); inOptimizing = optStr.equalsIgnoreCase("true"); } } if (fileName == null) { infoMessage.append( "Unable to process file upload: did not receive " + "any actual file data.<BR>" + EOL); if (inOptimizing) { handleViewOptimizing(requestInfo, true, folderName); } else { handleViewJob(requestInfo, Constants.SERVLET_SECTION_JOB_VIEW_COMPLETED, folderName, null); } return; } UploadedFile file = new UploadedFile(fileName, fileType, fileSize, fileDesc, fileData); configDB.writeUploadedFile(file, folderName); infoMessage.append("Successfully uploaded file \"" + fileName + "\"<BR>" + EOL); } catch (Exception e) { infoMessage.append("Unable to process file upload: " + e + "<BR>" + EOL); } if (inOptimizing) { handleViewOptimizing(requestInfo, true, folderName); } else { handleViewJob(requestInfo, Constants.SERVLET_SECTION_JOB_VIEW_COMPLETED, folderName, null); } }
From source file:fr.paris.lutece.plugins.calendar.web.CalendarJspBean.java
/** * Process Event creation// w ww . j a va2s . c o m * * @param request The Http request * @return URL */ public String doCreateEvent(HttpServletRequest request) { String strJspReturn = StringUtils.EMPTY; String strCalendarId = request.getParameter(Constants.PARAMETER_CALENDAR_ID); String strPeriodicity = request.getParameter(Constants.PARAMETER_PERIODICITY); if (StringUtils.isNotBlank(strCalendarId) && StringUtils.isNumeric(strCalendarId) && StringUtils.isNotBlank(strPeriodicity) && StringUtils.isNumeric(strPeriodicity)) { //Retrieving parameters from form int nCalendarId = Integer.parseInt(strCalendarId); int nPeriodicity = Integer.parseInt(strPeriodicity); String strEventDateEnd = request.getParameter(Constants.PARAMETER_EVENT_DATE_END); String strTimeStart = request.getParameter(Constants.PARAMETER_EVENT_TIME_START); String strTimeEnd = request.getParameter(Constants.PARAMETER_EVENT_TIME_END); String strOccurrence = request.getParameter(Constants.PARAMETER_OCCURRENCE); String strEventTitle = request.getParameter(Constants.PARAMETER_EVENT_TITLE); String strDate = request.getParameter(Constants.PARAMETER_EVENT_DATE); String strNotify = request.getParameter(Constants.PARAMETER_NOTIFY); //Retrieve the features of an event from form String strDescription = request.getParameter(Constants.PARAMETER_DESCRIPTION); String strEventTags = request.getParameter(Constants.PARAMETER_EVENT_TAGS).trim(); String strLocationAddress = request.getParameter(Constants.PARAMETER_EVENT_LOCATION_ADDRESS).trim(); String strLocationTown = request.getParameter(Constants.PARAMETER_LOCATION_TOWN).trim(); String strLocation = request.getParameter(Constants.PARAMETER_LOCATION).trim(); String strLocationZip = request.getParameter(Constants.PARAMETER_LOCATION_ZIP).trim(); String strLinkUrl = request.getParameter(Constants.PARAMETER_EVENT_LINK_URL).trim(); String strDocumentId = request.getParameter(Constants.PARAMETER_EVENT_DOCUMENT_ID).trim(); String strPageUrl = request.getParameter(Constants.PARAMETER_EVENT_PAGE_URL).trim(); String strTopEvent = request.getParameter(Constants.PARAMETER_EVENT_TOP_EVENT).trim(); String strMapUrl = request.getParameter(Constants.PARAMETER_EVENT_MAP_URL).trim(); //Retrieving the excluded days String[] arrayExcludedDays = request.getParameterValues(Constants.PARAMETER_EXCLUDED_DAYS); MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest) request; FileItem item = mRequest.getFile(Constants.PARAMETER_EVENT_IMAGE); String[] arrayCategory = request.getParameterValues(Constants.PARAMETER_CATEGORY); //Categories List<Category> listCategories = new ArrayList<Category>(); if (arrayCategory != null) { for (String strIdCategory : arrayCategory) { Category category = CategoryHome.find(Integer.parseInt(strIdCategory), getPlugin()); if (category != null) { listCategories.add(category); } } } String[] strTabEventTags = null; // Mandatory field if (StringUtils.isBlank(strDate) || StringUtils.isBlank(strEventTitle) || StringUtils.isBlank(strDescription)) { return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } if (StringUtils.isNotBlank(strEventTags) && strEventTags.length() > 0) { //Test if there aren't special characters in tag list boolean isAllowedExp = Pattern.matches(PROPERTY_TAGS_REGEXP, strEventTags); if (!isAllowedExp) { return AdminMessageService.getMessageUrl(request, MESSAGE_INVALID_TAG, AdminMessage.TYPE_STOP); } strTabEventTags = strEventTags.split("\\s"); } //Convert the date in form to a java.util.Date object Date dateEvent = DateUtil.formatDate(strDate, getLocale()); if ((dateEvent == null) || !Utils.isValidDate(dateEvent)) { return AdminMessageService.getMessageUrl(request, Constants.PROPERTY_MESSAGE_DATEFORMAT, AdminMessage.TYPE_STOP); } Date dateEndEvent = null; if (StringUtils.isNotBlank(strEventDateEnd)) { dateEndEvent = DateUtil.formatDate(strEventDateEnd, getLocale()); if ((dateEndEvent == null) || !Utils.isValidDate(dateEndEvent)) { return AdminMessageService.getMessageUrl(request, Constants.PROPERTY_MESSAGE_DATEFORMAT, AdminMessage.TYPE_STOP); } } //the number of occurrence is 1 by default int nOccurrence = 1; if ((strOccurrence.length() > 0) && !strOccurrence.equals("")) { try { nOccurrence = Integer.parseInt(strOccurrence); } catch (NumberFormatException e) { return AdminMessageService.getMessageUrl(request, MESSAGE_INVALID_OCCURRENCE_NUMBER, AdminMessage.TYPE_STOP); } } int nDocumentId = -1; if ((strDocumentId.length() > 0) && !strDocumentId.equals("")) { try { nDocumentId = Integer.parseInt(strDocumentId); } catch (NumberFormatException e) { return AdminMessageService.getMessageUrl(request, MESSAGE_INVALID_OCCURRENCE_NUMBER, AdminMessage.TYPE_STOP); } } if (!Utils.checkTime(strTimeStart) || !Utils.checkTime(strTimeEnd)) { return AdminMessageService.getMessageUrl(request, Constants.PROPERTY_MESSAGE_TIMEFORMAT, AdminMessage.TYPE_STOP); } //If a date end is chosen if ((Integer.parseInt(request.getParameter(Constants.PARAMETER_RADIO_PERIODICITY)) == 1) && StringUtils.isNotBlank(strEventDateEnd)) { if (dateEndEvent.before(dateEvent)) { return AdminMessageService.getMessageUrl(request, Constants.PROPERTY_MESSAGE_DATE_END_BEFORE, AdminMessage.TYPE_STOP); } nPeriodicity = 0; nOccurrence = Utils.getOccurrenceWithinTwoDates(dateEvent, dateEndEvent, arrayExcludedDays); } else if ((Integer.parseInt(request.getParameter(Constants.PARAMETER_RADIO_PERIODICITY)) == 1) && StringUtils.isBlank(strEventDateEnd)) { return AdminMessageService.getMessageUrl(request, Constants.PROPERTY_MESSAGE_DATEFORMAT, AdminMessage.TYPE_STOP); } //If a date end is not chosen if ((Integer.parseInt(request.getParameter(Constants.PARAMETER_RADIO_PERIODICITY)) == 0) && StringUtils.isBlank(strEventDateEnd)) { dateEndEvent = Utils.getDateForward(dateEvent, nPeriodicity, nOccurrence, arrayExcludedDays); if (dateEndEvent.before(dateEvent)) { nOccurrence = 0; dateEndEvent = dateEvent; } } SimpleEvent event = new SimpleEvent(); event.setDate(dateEvent); event.setDateEnd(dateEndEvent); event.setDateTimeStart(strTimeStart); event.setDateTimeEnd(strTimeEnd); event.setTitle(strEventTitle); event.setOccurrence(nOccurrence); event.setPeriodicity(nPeriodicity); event.setDescription(strDescription); if (item.getSize() == 0) { HttpSession session = request.getSession(true); if (session.getAttribute(ATTRIBUTE_MODULE_DOCUMENT_TO_CALENDAR_CONTENT_FILE) != null && session.getAttribute(ATTRIBUTE_MODULE_DOCUMENT_TO_CALENDAR_MIME_TYPE_FILE) != null) { ImageResource imageResource = new ImageResource(); imageResource.setImage( (byte[]) session.getAttribute(ATTRIBUTE_MODULE_DOCUMENT_TO_CALENDAR_CONTENT_FILE)); imageResource.setMimeType( (String) session.getAttribute(ATTRIBUTE_MODULE_DOCUMENT_TO_CALENDAR_MIME_TYPE_FILE)); event.setImageResource(imageResource); session.removeAttribute(ATTRIBUTE_MODULE_DOCUMENT_TO_CALENDAR_CONTENT_FILE); session.removeAttribute(ATTRIBUTE_MODULE_DOCUMENT_TO_CALENDAR_MIME_TYPE_FILE); } } if (item.getSize() >= 1) { ImageResource imageResource = new ImageResource(); imageResource.setImage(item.get()); imageResource.setMimeType(item.getContentType()); event.setImageResource(imageResource); } event.setTags(strTabEventTags); event.setLocationAddress(strLocationAddress); event.setLocation(strLocation); event.setLocationTown(strLocationTown); event.setLocationZip(strLocationZip); event.setLinkUrl(strLinkUrl); event.setPageUrl(strPageUrl); event.setTopEvent(Integer.parseInt(strTopEvent)); event.setMapUrl(strMapUrl); event.setDocumentId(nDocumentId); event.setListCategories(listCategories); event.setExcludedDays(arrayExcludedDays); event.setIdCalendar(nCalendarId); _eventListService.doAddEvent(event, null, getPlugin()); List<OccurrenceEvent> listOccurencesEvent = _eventListService.getOccurrenceEvents(nCalendarId, event.getId(), Constants.SORT_ASC, getPlugin()); for (OccurrenceEvent occ : listOccurencesEvent) { IndexationService.addIndexerAction(Integer.toString(occ.getId()), AppPropertiesService.getProperty(CalendarIndexer.PROPERTY_INDEXER_NAME), IndexerAction.TASK_CREATE); CalendarIndexerUtils.addIndexerAction(occ.getId(), IndexerAction.TASK_CREATE); } /* * IndexationService.addIndexerAction( Constants.EMPTY_STRING + * nCalendarId * ,AppPropertiesService.getProperty( * CalendarIndexer.PROPERTY_INDEXER_NAME ), * IndexerAction.TASK_CREATE ); */ boolean isNotify = Boolean.parseBoolean(strNotify); if (isNotify) { int nSubscriber = _agendaSubscriberService.getSubscriberNumber(nCalendarId, getPlugin()); if (nSubscriber > 0) { Collection<CalendarSubscriber> calendarSubscribers = _agendaSubscriberService .getSubscribers(nCalendarId, getPlugin()); _agendaSubscriberService.sendSubscriberMail(request, calendarSubscribers, event, nCalendarId); } } strJspReturn = AppPathService.getBaseUrl(request) + JSP_EVENT_LIST2 + nCalendarId; } else { strJspReturn = AdminMessageService.getMessageUrl(request, MESSAGE_INVALID_NUMBER_FORMAT, AdminMessage.TYPE_STOP); } return strJspReturn; }