List of usage examples for javax.servlet.http HttpServletRequest getCharacterEncoding
public String getCharacterEncoding();
From source file:com.joseflavio.uxiamarelo.servlet.UxiAmareloServlet.java
@Override protected void doPost(HttpServletRequest requisicao, HttpServletResponse resposta) throws ServletException, IOException { String tipo = requisicao.getContentType(); if (tipo == null || tipo.isEmpty()) tipo = "text/plain"; String codificacao = requisicao.getCharacterEncoding(); if (codificacao == null || codificacao.isEmpty()) codificacao = "UTF-8"; resposta.setCharacterEncoding(codificacao); PrintWriter saida = resposta.getWriter(); try {//from w w w.j a v a2 s .co m JSON json; if (tipo.contains("json")) { json = new JSON(IOUtils.toString(requisicao.getInputStream(), codificacao)); } else { json = new JSON(); } Enumeration<String> parametros = requisicao.getParameterNames(); while (parametros.hasMoreElements()) { String chave = parametros.nextElement(); String valor = URLDecoder.decode(requisicao.getParameter(chave), codificacao); json.put(chave, valor); } if (tipo.contains("multipart")) { Collection<Part> arquivos = requisicao.getParts(); if (!arquivos.isEmpty()) { File diretorio = new File(uxiAmarelo.getDiretorio()); if (!diretorio.isAbsolute()) { diretorio = new File(requisicao.getServletContext().getRealPath("") + File.separator + uxiAmarelo.getDiretorio()); } if (!diretorio.exists()) diretorio.mkdirs(); String diretorioStr = diretorio.getAbsolutePath(); String url = uxiAmarelo.getDiretorioURL(); if (uxiAmarelo.isDiretorioURLRelativo()) { String url_esquema = requisicao.getScheme(); String url_servidor = requisicao.getServerName(); int url_porta = requisicao.getServerPort(); String url_contexto = requisicao.getContextPath(); url = url_esquema + "://" + url_servidor + ":" + url_porta + url_contexto + "/" + url; } if (url.charAt(url.length() - 1) == '/') { url = url.substring(0, url.length() - 1); } Map<String, List<JSON>> mapa_arquivos = new HashMap<>(); for (Part arquivo : arquivos) { String chave = arquivo.getName(); String nome_original = getNome(arquivo, codificacao); String nome = nome_original; if (nome == null || nome.isEmpty()) { try (InputStream is = arquivo.getInputStream()) { String valor = IOUtils.toString(is, codificacao); valor = URLDecoder.decode(valor, codificacao); json.put(chave, valor); continue; } } if (uxiAmarelo.getArquivoNome().equals("uuid")) { nome = UUID.randomUUID().toString(); } while (new File(diretorioStr + File.separator + nome).exists()) { nome = UUID.randomUUID().toString(); } arquivo.write(diretorioStr + File.separator + nome); List<JSON> lista = mapa_arquivos.get(chave); if (lista == null) { lista = new LinkedList<>(); mapa_arquivos.put(chave, lista); } lista.add((JSON) new JSON().put("nome", nome_original).put("endereco", url + "/" + nome)); } for (Entry<String, List<JSON>> entrada : mapa_arquivos.entrySet()) { List<JSON> lista = entrada.getValue(); if (lista.size() > 1) { json.put(entrada.getKey(), lista); } else { json.put(entrada.getKey(), lista.get(0)); } } } } String copaiba = (String) json.remove("copaiba"); if (StringUtil.tamanho(copaiba) == 0) { throw new IllegalArgumentException("copaiba = nome@classe@metodo"); } String[] copaibaParam = copaiba.split("@"); if (copaibaParam.length != 3) { throw new IllegalArgumentException("copaiba = nome@classe@metodo"); } String comando = (String) json.remove("uxicmd"); if (StringUtil.tamanho(comando) == 0) comando = null; if (uxiAmarelo.isCookieEnviar()) { Cookie[] cookies = requisicao.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { String nome = cookie.getName(); if (uxiAmarelo.cookieBloqueado(nome)) continue; if (!json.has(nome)) { try { json.put(nome, URLDecoder.decode(cookie.getValue(), "UTF-8")); } catch (UnsupportedEncodingException e) { json.put(nome, cookie.getValue()); } } } } } if (uxiAmarelo.isEncapsulamentoAutomatico()) { final String sepstr = uxiAmarelo.getEncapsulamentoSeparador(); final char sep0 = sepstr.charAt(0); for (String chave : new HashSet<>(json.keySet())) { if (chave.indexOf(sep0) == -1) continue; String[] caminho = chave.split(sepstr); if (caminho.length > 1) { Util.encapsular(caminho, json.remove(chave), json); } } } String resultado; if (comando == null) { try (CopaibaConexao cc = uxiAmarelo.conectarCopaiba(copaibaParam[0])) { resultado = cc.solicitar(copaibaParam[1], json.toString(), copaibaParam[2]); if (resultado == null) resultado = ""; } } else if (comando.equals("voltar")) { resultado = json.toString(); comando = null; } else { resultado = ""; } if (comando == null) { resposta.setStatus(HttpServletResponse.SC_OK); resposta.setContentType("application/json"); saida.write(resultado); } else if (comando.startsWith("redirecionar")) { resposta.sendRedirect(Util.obterStringDeJSON("redirecionar", comando, resultado)); } else if (comando.startsWith("base64")) { String url = comando.substring("base64.".length()); resposta.sendRedirect(url + Base64.getUrlEncoder().encodeToString(resultado.getBytes("UTF-8"))); } else if (comando.startsWith("html_url")) { HttpURLConnection con = (HttpURLConnection) new URL( Util.obterStringDeJSON("html_url", comando, resultado)).openConnection(); con.setRequestProperty("User-Agent", "Uxi-amarelo"); if (con.getResponseCode() != HttpServletResponse.SC_OK) throw new IOException("HTTP = " + con.getResponseCode()); resposta.setStatus(HttpServletResponse.SC_OK); resposta.setContentType("text/html"); try (InputStream is = con.getInputStream()) { saida.write(IOUtils.toString(is)); } con.disconnect(); } else if (comando.startsWith("html")) { resposta.setStatus(HttpServletResponse.SC_OK); resposta.setContentType("text/html"); saida.write(Util.obterStringDeJSON("html", comando, resultado)); } else { throw new IllegalArgumentException(comando); } } catch (Exception e) { resposta.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); resposta.setContentType("application/json"); saida.write(Util.gerarRespostaErro(e).toString()); } saida.flush(); }
From source file:org.xwiki.portlet.controller.DispatchedRequest.java
/** * Parses the query string of the initial request that reached the portal. The request received by the dispatch * filter wraps the initial request and hides the initial query string which usually contains only portal related * information. In some cases the initial query string contains parameters set through JavaScript. The reason for * parsing the initial query string is to expose those parameters set from JavaScript. * //from w ww. ja v a2 s . c o m * @return the map of initial query string parameters * @throws ServletException if decoding the parameters fails */ private Map<String, List<String>> parseInitialQueryString() throws ServletException { HttpServletRequest initialRequest = (HttpServletRequest) getRequest(); while (initialRequest instanceof HttpServletRequestWrapper) { initialRequest = (HttpServletRequest) ((HttpServletRequestWrapper) initialRequest).getRequest(); } if (initialRequest.getQueryString() != null) { try { return queryStringParser.parse(initialRequest.getQueryString(), initialRequest.getCharacterEncoding()); } catch (UnsupportedEncodingException e) { throw new ServletException("Failed to decode the initial query string parameters.", e); } } else { return Collections.emptyMap(); } }
From source file:eionet.gdem.utils.FileUpload.java
/** * Uploads file from client to the server. Parses HttpRequestInputstream and writes bytes to the specified folder in the same * computer, where servlet runs//from w ww. j a v a2s .c o m * * @param req request * @throws GDEMException If an error occurs. */ public File uploadFile(HttpServletRequest req) throws GDEMException { // helper arrays byte[] bt1 = new byte[4096]; byte[] bt2 = new byte[4096]; int[] int1 = new int[1]; int[] int2 = new int[1]; ServletInputStream si = null; try { si = req.getInputStream(); String contentType = req.getContentType(); String charEncoding = req.getCharacterEncoding(); // +RV020508 int contentLength = req.getContentLength(); lenRcvd = 0; if (contentLength == -1) { throw new GDEMException("Invalid HTTP POST. Content length is unknown."); } // int boundaryPos; if ((boundaryPos = contentType.indexOf("boundary=")) != -1) { contentType = contentType.substring(boundaryPos + 9); contentType = "--" + contentType; } // end if // Find filename String fileName; while ((fileName = readLine(bt1, int1, si, charEncoding)) != null) { int i = fileName.indexOf("filename="); if (i >= 0) { fileName = fileName.substring(i + 10); i = fileName.indexOf("\""); if (i > 0) { FileOutputStream fileOut = null; boolean fWrite = false; File tmpFile = new File(_folderName, getSessionId()); try { fileName = fileName.substring(0, i); fileName = getFileName(fileName); // _fileName is returned by getFileName() method _fileName = fileName; String line2 = readLine(bt1, int1, si, charEncoding); if (line2.indexOf("Content-Type") >= 0) { readLine(bt1, int1, si, charEncoding); } fileOut = new FileOutputStream(tmpFile); String helpStr = null; long l = 0L; // changes to true, if something is written to the output file // remains false, if user has entered a wrong filename or the file's size is 0kB // parse the file in the MIME message while ((line2 = readLine(bt1, int1, si, charEncoding)) != null) { if (line2.indexOf(contentType) == 0 && bt1[0] == 45) { break; } if (helpStr != null && l <= 75L) { fWrite = true; fileOut.write(bt2, 0, int2[0]); fileOut.flush(); } // endif helpStr = readLine(bt2, int2, si, charEncoding); if (helpStr == null || helpStr.indexOf(contentType) == 0 && bt2[0] == 45) { break; } fWrite = true; fileOut.write(bt1, 0, int1[0]); fileOut.flush(); } // end while byte bt0; if (lineSep.length() == 1) { bt0 = 2; } else { bt0 = 1; } if (helpStr != null && bt2[0] != 45 && int2[0] > lineSep.length() * bt0) { fileOut.write(bt2, 0, int2[0] - lineSep.length() * bt0); fWrite = true; } if (line2 != null && bt1[0] != 45 && int1[0] > lineSep.length() * bt0) { fileOut.write(bt1, 0, int1[0] - lineSep.length() * bt0); fWrite = true; } } finally { IOUtils.closeQuietly(fileOut); } if (fWrite) { try { synchronized (fileLock) { File file = new File(_folderName, fileName); int n = 0; while (file.exists()) { n++; fileName = genFileName(fileName, n); file = new File(_folderName, fileName); } setFileName(fileName); try { file.delete(); } catch (Exception _ex) { throw new GDEMException("Error deleting temporary file: " + _ex.toString()); } tmpFile.renameTo(file); return file; } // sync } catch (Exception _ex) { throw new GDEMException("Error renaming temporary file: " + _ex.toString()); } } else { // end-if file = 0kb or does not exist tmpFile.delete(); throw new GDEMException("File: " + fileName + " does not exist or contains no data."); } } // break; } // end if (filename found) } // end while // +RV020508 if (contentLength != lenRcvd) { throw new GDEMException( "Canceled upload: expected " + contentLength + " bytes, received " + lenRcvd + " bytes."); } } catch (IOException e) { throw new GDEMException("Error uploading file: " + e.toString()); } finally { IOUtils.closeQuietly(si); } return null; }
From source file:org.pentaho.di.www.AddExportServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (isJettyMode() && !request.getRequestURI().startsWith(CONTEXT_PATH)) { return;// w ww .j a v a2s. c om } if (log.isDebug()) { logDebug("Addition of export requested"); } PrintWriter out = response.getWriter(); InputStream in = request.getInputStream(); // read from the client if (log.isDetailed()) { logDetailed("Encoding: " + request.getCharacterEncoding()); } boolean isJob = TYPE_JOB.equalsIgnoreCase(request.getParameter(PARAMETER_TYPE)); String load = request.getParameter(PARAMETER_LOAD); // the resource to load response.setContentType("text/xml"); out.print(XMLHandler.getXMLHeader()); response.setStatus(HttpServletResponse.SC_OK); OutputStream outputStream = null; try { FileObject tempFile = KettleVFS.createTempFile("export", ".zip", System.getProperty("java.io.tmpdir")); outputStream = KettleVFS.getOutputStream(tempFile, false); // Pass the input directly to a temporary file // // int size = 0; int c; while ((c = in.read()) != -1) { outputStream.write(c); // size++; } outputStream.flush(); outputStream.close(); outputStream = null; // don't close it twice String archiveUrl = tempFile.getName().toString(); String fileUrl = null; String carteObjectId = null; SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(CONTEXT_PATH, LoggingObjectType.CARTE, null); // Now open the top level resource... // if (!Const.isEmpty(load)) { fileUrl = "zip:" + archiveUrl + "!" + load; if (isJob) { // Open the job from inside the ZIP archive // KettleVFS.getFileObject(fileUrl); JobMeta jobMeta = new JobMeta(fileUrl, null); // never with a repository // Also read the execution configuration information // String configUrl = "zip:" + archiveUrl + "!" + Job.CONFIGURATION_IN_EXPORT_FILENAME; Document configDoc = XMLHandler.loadXMLFile(configUrl); JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration( XMLHandler.getSubNode(configDoc, JobExecutionConfiguration.XML_TAG)); carteObjectId = UUID.randomUUID().toString(); servletLoggingObject.setContainerObjectId(carteObjectId); servletLoggingObject.setLogLevel(jobExecutionConfiguration.getLogLevel()); Job job = new Job(null, jobMeta, servletLoggingObject); // Do we need to expand the job when it's running? // Note: the plugin (Job and Trans) job entries need to call the delegation listeners in the parent job. // if (jobExecutionConfiguration.isExpandingRemoteJob()) { job.addDelegationListener(new CarteDelegationHandler(getTransformationMap(), getJobMap())); } // store it all in the map... // synchronized (getJobMap()) { getJobMap().addJob(job.getJobname(), carteObjectId, job, new JobConfiguration(jobMeta, jobExecutionConfiguration)); } // Apply the execution configuration... // log.setLogLevel(jobExecutionConfiguration.getLogLevel()); job.setArguments(jobExecutionConfiguration.getArgumentStrings()); jobMeta.injectVariables(jobExecutionConfiguration.getVariables()); // Also copy the parameters over... // Map<String, String> params = jobExecutionConfiguration.getParams(); for (String param : params.keySet()) { String value = params.get(param); jobMeta.setParameterValue(param, value); } } else { // Open the transformation from inside the ZIP archive // TransMeta transMeta = new TransMeta(fileUrl); // Also read the execution configuration information // String configUrl = "zip:" + archiveUrl + "!" + Trans.CONFIGURATION_IN_EXPORT_FILENAME; Document configDoc = XMLHandler.loadXMLFile(configUrl); TransExecutionConfiguration executionConfiguration = new TransExecutionConfiguration( XMLHandler.getSubNode(configDoc, TransExecutionConfiguration.XML_TAG)); carteObjectId = UUID.randomUUID().toString(); servletLoggingObject.setContainerObjectId(carteObjectId); servletLoggingObject.setLogLevel(executionConfiguration.getLogLevel()); Trans trans = new Trans(transMeta, servletLoggingObject); // store it all in the map... // getTransformationMap().addTransformation(trans.getName(), carteObjectId, trans, new TransConfiguration(transMeta, executionConfiguration)); } } else { fileUrl = archiveUrl; } out.println(new WebResult(WebResult.STRING_OK, fileUrl, carteObjectId)); } catch (Exception ex) { out.println(new WebResult(WebResult.STRING_ERROR, Const.getStackTracker(ex))); } finally { if (outputStream != null) { outputStream.close(); } } }
From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java
protected void prepareCharacterEncodingIfNeeds(HttpServletRequest request) throws UnsupportedEncodingException { if (request.getCharacterEncoding() == null) { // logging filter calls parameters for debug // but if no setting of encoding, Tomcat parses parameters as latin1 // and keep the parameters parsed by wrong encoding in request object // so needs to set encoding here // (it is set in spite of log level for same behavior in several environments) request.setCharacterEncoding(requestCharacterEncoding != null ? requestCharacterEncoding : "UTF-8"); }//from w ww.ja va 2s . c o m }
From source file:presentation.ui.ExtendedMultiPartRequestHandler.java
/** * Adds a regular text parameter to the set of text parameters for this * request and also to the list of all parameters. Handles the case of * multiple values for the same parameter by using an array for the * parameter value./*w w w . j ava 2 s . c o m*/ * * @param request * The request in which the parameter was specified. * @param item * The file item for the parameter to add. */ protected void addTextParameter(HttpServletRequest request, FileItem item) { String name = item.getFieldName(); String value = null; boolean haveValue = false; String encoding = request.getCharacterEncoding(); if (encoding != null) { try { value = item.getString(encoding); haveValue = true; } catch (Exception e) { // Handled below, since haveValue is false. } } if (!haveValue) { try { value = item.getString("ISO-8859-15"); } catch (java.io.UnsupportedEncodingException uee) { value = item.getString(); } haveValue = true; } if (request instanceof MultipartRequestWrapper) { MultipartRequestWrapper wrapper = (MultipartRequestWrapper) request; wrapper.setParameter(name, value); } String[] oldArray = (String[]) elementsText.get(name); String[] newArray; if (oldArray != null) { newArray = new String[oldArray.length + 1]; System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); newArray[oldArray.length] = value; } else { newArray = new String[] { value }; } elementsText.put(name, newArray); elementsAll.put(name, newArray); }
From source file:org.primeframework.mvc.parameter.RequestBodyWorkflowTest.java
@Test public void parse() throws IOException, ServletException { HttpServletRequest request = createStrictMock(HttpServletRequest.class); expect(request.getParameterMap()).andReturn(new HashMap<>()); expect(request.getContentType()).andReturn("application/x-www-form-urlencoded"); String body = "param1=value1¶m2=value2¶m+space+key=param+space+value¶m%2Bencoded%2Bkey=param%2Bencoded%2Bvalue"; expect(request.getInputStream()).andReturn(new MockServletInputStream(body.getBytes())); expect(request.getContentLength()).andReturn(body.getBytes().length); expect(request.getCharacterEncoding()).andReturn("UTF-8"); replay(request);/* w ww . jav a 2 s .co m*/ WorkflowChain chain = createStrictMock(WorkflowChain.class); chain.continueWorkflow(); replay(chain); HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request); RequestBodyWorkflow workflow = new RequestBodyWorkflow(wrapper); workflow.perform(chain); @SuppressWarnings("unchecked") Map<String, String[]> actual = wrapper.getParameterMap(); Map<String, String[]> expected = MapBuilder.<String, String[]>map().put("param1", new String[] { "value1" }) .put("param2", new String[] { "value2" }) .put("param space key", new String[] { "param space value" }) .put("param+encoded+key", new String[] { "param+encoded+value" }).done(); assertParameterMapsEquals(actual, expected); verify(request, chain); }
From source file:org.tinygroup.weblayer.webcontext.parser.valueparser.impl.ParameterParserImpl.java
/** ?query string */ private void parseQueryString(ParserWebContext requestContext, HttpServletRequest wrappedRequest) { // useBodyEncodingForURI=truerequest.setCharacterEncoding()???URIEncodingUTF-8 // useBodyEncodingForURItrue // tomcat?tomcat8859_1 String charset = requestContext.isUseBodyEncodingForURI() ? wrappedRequest.getCharacterEncoding() : requestContext.getURIEncoding(); QueryStringParser parser = new QueryStringParser(charset, DEFAULT_CHARSET_ENCODING) { protected void add(String key, String value) { ParameterParserImpl.this.add(key, value); }/*ww w . j a va 2 s. co m*/ }; parser.parse(wrappedRequest.getQueryString()); }
From source file:org.cerberus.servlet.crud.countryenvironment.CreateApplicationObject.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w.ja v a2 s. c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs * @throws CerberusException * @throws JSONException */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException, JSONException { JSONObject jsonResponse = new JSONObject(); Answer ans = new Answer(); MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED); msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "")); ans.setResultMessage(msg); PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS); String charset = request.getCharacterEncoding(); response.setContentType("application/json"); // Calling Servlet Transversal Util. ServletUtil.servletStart(request); Map<String, String> fileData = new HashMap<String, String>(); FileItem file = null; FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List<FileItem> fields = upload.parseRequest(request); Iterator<FileItem> it = fields.iterator(); if (!it.hasNext()) { return; } while (it.hasNext()) { FileItem fileItem = it.next(); boolean isFormField = fileItem.isFormField(); if (isFormField) { fileData.put(fileItem.getFieldName(), ParameterParserUtil .parseStringParamAndDecode(fileItem.getString("UTF-8"), null, charset)); } else { file = fileItem; } } } catch (FileUploadException e) { e.printStackTrace(); } /** * Parsing and securing all required parameters. */ // Parameter that are already controled by GUI (no need to decode) --> We SECURE them // Parameter that needs to be secured --> We SECURE+DECODE them String application = fileData.get("application"); String object = fileData.get("object"); String value = fileData.get("value"); String usrcreated = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getRemoteUser(), "", charset); String datecreated = new Timestamp(new java.util.Date().getTime()).toString(); String usrmodif = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getRemoteUser(), "", charset); String datemodif = new Timestamp(new java.util.Date().getTime()).toString(); // Parameter that we cannot secure as we need the html --> We DECODE them /** * Checking all constrains before calling the services. */ if (StringUtil.isNullOrEmpty(application)) { msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED); msg.setDescription(msg.getDescription().replace("%ITEM%", "ApplicationObject") .replace("%OPERATION%", "Create").replace("%REASON%", "Application name is missing!")); ans.setResultMessage(msg); } else if (StringUtil.isNullOrEmpty(object)) { msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED); msg.setDescription(msg.getDescription().replace("%ITEM%", "ApplicationObject") .replace("%OPERATION%", "Create").replace("%REASON%", "Object name is missing!")); ans.setResultMessage(msg); } else { /** * All data seems cleans so we can call the services. */ ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); IApplicationObjectService applicationobjectService = appContext .getBean(IApplicationObjectService.class); IFactoryApplicationObject factoryApplicationobject = appContext .getBean(IFactoryApplicationObject.class); String fileName = ""; if (file != null) { fileName = file.getName(); } ApplicationObject applicationData = factoryApplicationobject.create(-1, application, object, value, fileName, usrcreated, datecreated, usrmodif, datemodif); ans = applicationobjectService.create(applicationData); if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) { /** * Object created. Adding Log entry. */ ILogEventService logEventService = appContext.getBean(LogEventService.class); logEventService.createPrivateCalls("/CreateApplicationObject", "CREATE", "Create Application Object: ['" + application + "','" + object + "']", request); if (file != null) { AnswerItem an = applicationobjectService.readByKey(application, object); if (an.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && an.getItem() != null) { applicationData = (ApplicationObject) an.getItem(); ans = applicationobjectService.uploadFile(applicationData.getID(), file); if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) { } } } } } /** * Formating and returning the json result. */ jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString()); jsonResponse.put("message", ans.getResultMessage().getDescription()); response.getWriter().print(jsonResponse); response.getWriter().flush(); }
From source file:org.deegree.services.controller.AbstractOWS.java
/** * Called by the {@link OGCFrontController} to allow this <code>AbstractOGCServiceController</code> to handle a SOAP * request./* w ww. ja v a 2s. c o m*/ * * @param soapDoc * <code>XMLAdapter</code> for parsing the SOAP request document * @param request * provides access to all information of the original HTTP request (NOTE: may be GET or POST) * @param response * response that is sent to the client * @param multiParts * A list of multiparts contained in the request. If the request was not a multipart request the list * will be <code>null</code>. If multiparts were found, the requestDoc will be the first (xml-lized) * {@link FileItem} in the list. * @param factory * initialized to the soap version of the request. * @throws ServletException * @throws IOException * if an IOException occurred * @throws SecurityException */ @Override public void doSOAP(SOAPEnvelope soapDoc, HttpServletRequest request, HttpResponseBuffer response, List<FileItem> multiParts, SOAPFactory factory) throws ServletException, IOException, SecurityException { sendSOAPException(soapDoc.getHeader(), factory, response, null, null, null, "SOAP DCP is not implemented for this service.", request.getServerName(), request.getCharacterEncoding()); }