List of usage examples for javax.servlet.http HttpServletRequest getHeaderNames
public Enumeration<String> getHeaderNames();
From source file:it.greenvulcano.gvesb.adapter.http.mapping.ForwardHttpServletMapping.java
@SuppressWarnings("deprecation") @Override/*from w ww . j ava 2s . com*/ public void handleRequest(String methodName, HttpServletRequest req, HttpServletResponse resp) throws InboundHttpResponseException { logger.debug("BEGIN forward: " + req.getRequestURI()); final HttpURLConnection httpConnection = (HttpURLConnection) connection; ; try { httpConnection.setRequestMethod(methodName); httpConnection.setReadTimeout(soTimeout); httpConnection.setDoInput(true); httpConnection.setDoOutput(true); if (dump) { StringBuffer sb = new StringBuffer(); DumpUtils.dump(req, sb); logger.info(sb.toString()); } String mapping = req.getPathInfo(); if (mapping == null) { mapping = "/"; } String destPath = contextPath + mapping; String queryString = req.getQueryString(); if (queryString != null) { destPath += "?" + queryString; } if (!destPath.startsWith("/")) { destPath = "/" + destPath; } logger.info("Resulting QueryString: " + destPath); Collections.list(req.getHeaderNames()).forEach(headerName -> { httpConnection.setRequestProperty(headerName, Collections.list(req.getHeaders(headerName)).stream().collect(Collectors.joining(";"))); }); if (methodName.equalsIgnoreCase("POST") || methodName.equalsIgnoreCase("PUT")) { httpConnection.setDoOutput(true); IOUtils.copy(req.getInputStream(), httpConnection.getOutputStream()); } httpConnection.connect(); int status = httpConnection.getResponseCode(); resp.setStatus(status, httpConnection.getResponseMessage()); httpConnection.getHeaderFields().entrySet().stream().forEach(header -> { resp.addHeader(header.getKey(), header.getValue().stream().collect(Collectors.joining(";"))); }); ByteArrayOutputStream bodyOut = new ByteArrayOutputStream(); IOUtils.copy(httpConnection.getInputStream(), bodyOut); OutputStream out = resp.getOutputStream(); out.write(bodyOut.toByteArray()); //IOUtils.copy(method.getResponseBodyAsStream(), out); out.flush(); out.close(); if (dump) { StringBuffer sb = new StringBuffer(); DumpUtils.dump(resp, bodyOut, sb); logger.info(sb.toString()); } } catch (Exception exc) { logger.error("ERROR on forwarding: " + req.getRequestURI(), exc); throw new InboundHttpResponseException("GV_CALL_SERVICE_ERROR", new String[][] { { "message", exc.getMessage() } }, exc); } finally { try { if (httpConnection != null) { httpConnection.disconnect(); } } catch (Exception exc) { logger.warn("Error while releasing connection", exc); } logger.debug("END forward: " + req.getRequestURI()); } }
From source file:cn.bc.web.util.DebugUtils.java
public static StringBuffer getDebugInfo(HttpServletRequest request, HttpServletResponse response) { @SuppressWarnings("rawtypes") Enumeration e;/*from w w w . j a va2 s .c om*/ String name; StringBuffer html = new StringBuffer(); //session HttpSession session = request.getSession(); html.append("<div><b>session:</b></div><ul>"); html.append(createLI("Id", session.getId())); html.append(createLI("CreationTime", new Date(session.getCreationTime()).toString())); html.append(createLI("LastAccessedTime", new Date(session.getLastAccessedTime()).toString())); //session:attributes e = session.getAttributeNames(); html.append("<li>attributes:<ul>\r\n"); while (e.hasMoreElements()) { name = (String) e.nextElement(); html.append(createLI(name, String.valueOf(session.getAttribute(name)))); } html.append("</ul></li>\r\n"); html.append("</ul>\r\n"); //request html.append("<div><b>request:</b></div><ul>"); html.append(createLI("URL", request.getRequestURL().toString())); html.append(createLI("QueryString", request.getQueryString())); html.append(createLI("Method", request.getMethod())); html.append(createLI("CharacterEncoding", request.getCharacterEncoding())); html.append(createLI("ContentType", request.getContentType())); html.append(createLI("Protocol", request.getProtocol())); html.append(createLI("RemoteAddr", request.getRemoteAddr())); html.append(createLI("RemoteHost", request.getRemoteHost())); html.append(createLI("RemotePort", request.getRemotePort() + "")); html.append(createLI("RemoteUser", request.getRemoteUser())); html.append(createLI("ServerName", request.getServerName())); html.append(createLI("ServletPath", request.getServletPath())); html.append(createLI("ServerPort", request.getServerPort() + "")); html.append(createLI("Scheme", request.getScheme())); html.append(createLI("LocalAddr", request.getLocalAddr())); html.append(createLI("LocalName", request.getLocalName())); html.append(createLI("LocalPort", request.getLocalPort() + "")); html.append(createLI("Locale", request.getLocale().toString())); //request:headers e = request.getHeaderNames(); html.append("<li>Headers:<ul>\r\n"); while (e.hasMoreElements()) { name = (String) e.nextElement(); html.append(createLI(name, request.getHeader(name))); } html.append("</ul></li>\r\n"); //request:parameters e = request.getParameterNames(); html.append("<li>Parameters:<ul>\r\n"); while (e.hasMoreElements()) { name = (String) e.nextElement(); html.append(createLI(name, request.getParameter(name))); } html.append("</ul></li>\r\n"); html.append("</ul>\r\n"); //response html.append("<div><b>response:</b></div><ul>"); html.append(createLI("CharacterEncoding", response.getCharacterEncoding())); html.append(createLI("ContentType", response.getContentType())); html.append(createLI("BufferSize", response.getBufferSize() + "")); html.append(createLI("Locale", response.getLocale().toString())); html.append("<ul>\r\n"); return html; }
From source file:org.bigmouth.nvwa.network.http.HttpServletRequestLogger.java
public void info(final HttpServletRequest request) { if (null == request) return;/*from w w w . j av a2 s . c om*/ if (LOGGER.isInfoEnabled()) { StringBuilder url = new StringBuilder(256); StringBuilder parameter = new StringBuilder(256); StringBuilder headers = new StringBuilder(256); StringBuilder body = new StringBuilder(); String uri = request.getRequestURI(); String address = request.getRemoteAddr(); Map<?, ?> map = request.getParameterMap(); if (MapUtils.isNotEmpty(map)) { parameter.append("?"); } for (Entry<?, ?> entry : map.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); parameter.append(key); if (value instanceof String[]) { parameter.append("="); String[] values = (String[]) value; for (int i = 0; i < values.length; i++) { parameter.append(values[i]); } } parameter.append("&"); } url.append(uri).append(StringUtils.removeEnd(parameter.toString(), "&")); String method = request.getMethod(); int contentLength = request.getContentLength(); Enumeration<?> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { Object nextElement = headerNames.nextElement(); String value = request.getHeader(String.valueOf(nextElement)); headers.append(nextElement).append(": ").append(value).append(";"); } HttpServletRequestLog log = new HttpServletRequestLog(); log.setAddress(address); log.setContentLength(contentLength); log.setHeaders(StringUtils.removeEnd(headers.toString(), ";")); log.setMethod(method); log.setUri(url.toString()); log.setBody(body.toString()); LOGGER.info(log.toString()); } }
From source file:it.publisys.liferay.hook.shibboleth.ShibbolethAutoLogin.java
@SuppressWarnings("unchecked") public String[] login(HttpServletRequest request, HttpServletResponse response) throws AutoLoginException { if (_log.isDebugEnabled()) { _log.debug(" - start"); }//from ww w. j a v a 2s. c om String[] credentials = null; // boolean _isNew = false; long companyId = 0; // String _ltype = request.getParameter(LTYPE_PARAM); String _login = null; User _user = null; try { // verifico se il request path e' quello di login if (request.getRequestURI().contains(LOGIN_PATH)) { if (_log.isDebugEnabled()) { _log.debug(LTYPE_PARAM + ": " + _ltype); } // verifico che il parametro 'ltype' sia 'shibb' if (Validator.isNotNull(_ltype) && LTYPE_VALUE.equals(_ltype)) { if (_log.isDebugEnabled()) { Enumeration<Object> _ens = request.getHeaderNames(); while (_ens.hasMoreElements()) { Object _o = _ens.nextElement(); if (_o.toString().startsWith(SHIB_PREFIX)) { _log.debug("*=*=* " + _o + ": " + request.getHeader(_o.toString())); } } } String authType = getAuthType(companyId); // Parametro trasmesso dallo ShibbolethSP assunto come default _login = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_EMAIL); if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { _login = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_FISCAL_NUMBER); } else if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { _login = request.getHeader(ShibbolethPropsValues.SHIBBOLETH_EMAIL); } if (Validator.isNotNull(_login)) { _login = _login.toUpperCase(); companyId = PortalUtil.getCompany(request).getCompanyId(); if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { _log.info("Login by ScreenName: " + _login); _user = loginByScreenName(companyId, _login); } else if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { _log.info("Login by Email: " + _login); _user = loginByEmail(companyId, _login); } if (_user == null) { _log.warn( String.format("Utente non presente in archivio Liferay. [_login:%s]", _login)); throw new NoSuchUserException("Utente non presente in archivio Liferay."); } credentials = new String[] { String.valueOf(_user.getUserId()), _user.getPassword(), String.valueOf(_user.isPasswordEncrypted()) }; request.getSession().setAttribute(WebKeys.USER_ID, _user.getUserId()); } else { SessionMessages.add(request, "shibbError", "Parametri per la login non ricevuti."); throw new AutoLoginException("Parametri per la login non ricevuti."); } } } } catch (NoSuchUserException e) { _log.warn("No Such User with login: " + _login + ". Insert new User."); _isNew = true; } catch (Exception e) { _log.error("Generic Error.", e); SessionMessages.add(request, "shibbError", "Si è verificato un errore. Riprovare più tardi."); throw new AutoLoginException(e); } // creare nuovo utente se _isNew if (_isNew) { _user = _createNewUser(companyId, request); if (_user != null) { credentials = new String[] { String.valueOf(_user.getUserId()), _user.getPassword(), String.valueOf(_user.isPasswordEncrypted()) }; request.getSession().setAttribute(WebKeys.USER_ID, _user.getUserId()); } } if (_user != null) { _updateUser(_user, request); // aggiorno la data di ultimo accesso try { UserLocalServiceUtil.updateLastLogin(_user.getUserId(), request.getRemoteAddr()); } catch (PortalException e) { _log.warn( "Impossibile aggiornare la data di ultimo accesso dell'utente [" + _user.getUserId() + "]", e); } catch (SystemException e) { _log.warn( "Impossibile aggiornare la data di ultimo accesso dell'utente [" + _user.getUserId() + "]", e); } } String _redirecturl = request.getParameter("redirecturl"); if (_redirecturl != null && "true".equals(_redirecturl)) { _log.info("============================================"); _log.info("[Redirect URL] " + _redirecturl); _log.info("Effettuo la redirect"); String _sname = request.getParameter("sname"); _log.info("[sname] " + _sname); String _path = request.getParameter("path"); _log.info("[path] " + _path); Map<String, String[]> params = new HashMap<String, String[]>(); params.put("sname", new String[] { _sname }); LastPath lastPath = new LastPath("/", _path, params); request.getSession().setAttribute(WebKeys.LAST_PATH, lastPath); _log.info("[LastPath] " + lastPath); _log.info("============================================"); } return credentials; }
From source file:org.apache.hadoop.fs.webdav.WebdavServlet.java
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.info("/--------------------------------------------------"); log.debug(request.getMethod() + " " + request.getRequestURL().toString()); log.info(request.getMethod() + " " + request.getRequestURL().toString()); log.info(request.getMethod() + " " + request.getRequestURI().toString()); log.info(" RemoteHost: " + request.getRemoteHost()); log.info("| ATTRIBUTES: "); Enumeration e1 = request.getAttributeNames(); while (e1.hasMoreElements()) { String name = (String) e1.nextElement(); log.info("|| " + name + ": "); }/*from w ww. ja v a 2 s . c om*/ log.info("| PARAMETERS: "); Enumeration e2 = request.getParameterNames(); while (e2.hasMoreElements()) { String name = (String) e2.nextElement(); log.info("|| " + name + ": "); } log.info("HEADERS: "); Enumeration e6 = request.getHeaderNames(); while (e6.hasMoreElements()) { String name = (String) e6.nextElement(); log.info("-- " + name + ": " + request.getHeader(name)); } log.info("RemoteUser: " + request.getRemoteUser()); log.info("AuthType: " + request.getAuthType()); currentUserName = request.getRemoteUser(); String roles = ""; if (currentUserRoles != null) { for (String roleName : currentUserRoles) { roles += roleName + ", "; } if (roles.length() > 2) { roles = roles.substring(0, roles.length() - 2); } } log.debug("Roles: " + roles); try { super.service(request, response); } catch (Exception e) { if (e.getCause() instanceof AccessControlException) { log.info("EXCEPTION: Can't access to resource. You don't have permissions."); MultiStatusResponse msr = new MultiStatusResponse(request.getRequestURL().toString(), 401, "Can't access to resource. You don't have permissions."); MultiStatus ms = new MultiStatus(); ms.addResponse(msr); WebdavResponse webdavResponse = new WebdavResponseImpl(response); webdavResponse.sendMultiStatus(ms); } else new WebdavResponseImpl(response).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } log.info("\\--------------------------------------------------"); }
From source file:it.geosolutions.httpproxy.HTTPProxy.java
/** * Retrieves all of the headers from the servlet request and sets them on the proxy request * /*ww w. j av a 2 s . c o m*/ * @param httpServletRequest The request object representing the client's request to the servlet engine * @param httpMethodProxyRequest The request that we are about to send to the proxy host * @return ProxyInfo */ @SuppressWarnings("rawtypes") private ProxyInfo setProxyRequestHeaders(URL url, HttpServletRequest httpServletRequest, HttpMethod httpMethodProxyRequest) { final String proxyHost = url.getHost(); final int proxyPort = url.getPort(); final String proxyPath = url.getPath(); final ProxyInfo proxyInfo = new ProxyInfo(proxyHost, proxyPath, proxyPort); // //////////////////////////////////////// // Get an Enumeration of all of the header // names sent by the client. // //////////////////////////////////////// Enumeration enumerationOfHeaderNames = httpServletRequest.getHeaderNames(); while (enumerationOfHeaderNames.hasMoreElements()) { String stringHeaderName = (String) enumerationOfHeaderNames.nextElement(); if (stringHeaderName.equalsIgnoreCase(Utils.CONTENT_LENGTH_HEADER_NAME)) continue; // //////////////////////////////////////////////////////////////////////// // As per the Java Servlet API 2.5 documentation: // Some headers, such as Accept-Language can be sent by clients // as several headers each with a different value rather than // sending the header as a comma separated list. // Thus, we get an Enumeration of the header values sent by the client // //////////////////////////////////////////////////////////////////////// Enumeration enumerationOfHeaderValues = httpServletRequest.getHeaders(stringHeaderName); while (enumerationOfHeaderValues.hasMoreElements()) { String stringHeaderValue = (String) enumerationOfHeaderValues.nextElement(); // //////////////////////////////////////////////////////////////// // In case the proxy host is running multiple virtual servers, // rewrite the Host header to ensure that we get content from // the correct virtual server // //////////////////////////////////////////////////////////////// if (stringHeaderName.equalsIgnoreCase(Utils.HOST_HEADER_NAME)) { stringHeaderValue = Utils.getProxyHostAndPort(proxyInfo); } // //////////////////////// // Skip GZIP Responses // //////////////////////// if (stringHeaderName.equalsIgnoreCase(Utils.HTTP_HEADER_ACCEPT_ENCODING) && stringHeaderValue.toLowerCase().contains("gzip")) continue; if (stringHeaderName.equalsIgnoreCase(Utils.HTTP_HEADER_CONTENT_ENCODING) && stringHeaderValue.toLowerCase().contains("gzip")) continue; if (stringHeaderName.equalsIgnoreCase(Utils.HTTP_HEADER_TRANSFER_ENCODING)) continue; Header header = new Header(stringHeaderName, stringHeaderValue); // ///////////////////////////////////////////// // Set the same header on the proxy request // ///////////////////////////////////////////// httpMethodProxyRequest.setRequestHeader(header); } } return proxyInfo; }
From source file:com.kurento.kmf.repository.internal.http.RepositoryHttpServlet.java
private void logRequest(HttpServletRequest req) { log.info("Request received " + req.getRequestURL()); log.info(" Method: " + req.getMethod()); Enumeration<String> headerNames = req.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); Enumeration<String> values = req.getHeaders(headerName); List<String> valueList = new ArrayList<>(); while (values.hasMoreElements()) { valueList.add(values.nextElement()); }/*from w w w . ja v a2 s . c o m*/ log.info(" Header {}: {}", headerName, valueList); } }
From source file:es.tid.fiware.fiwareconnectors.cygnus.handlers.OrionRestHandler.java
@Override public List<Event> getEvents(javax.servlet.http.HttpServletRequest request) throws Exception { // get a transaction id and store it in the log4j Mapped Diagnostic Context (MDC); this way it will be // accessible by the whole source code String transId = generateTransId(); MDC.put(Constants.TRANSACTION_ID, transId); logger.info("Starting transaction (" + transId + ")"); // check the method String method = request.getMethod().toUpperCase(Locale.ENGLISH); if (!method.equals("POST")) { logger.warn("Bad HTTP notification (" + method + " method not supported)"); throw new MethodNotSupportedException(method + " method not supported"); } // if//from ww w . j a v a 2 s .c o m // check the notificationsTarget String target = request.getRequestURI(); if (!target.equals(notificationsTarget)) { logger.warn("Bad HTTP notification (" + target + " target not supported)"); throw new HTTPBadRequestException(target + " target not supported"); } // if // check the headers looking for not supported user agents, content type and tenant/organization Enumeration headerNames = request.getHeaderNames(); String contentType = null; String organization = null; while (headerNames.hasMoreElements()) { String headerName = ((String) headerNames.nextElement()).toLowerCase(Locale.ENGLISH); String headerValue = request.getHeader(headerName).toLowerCase(Locale.ENGLISH); if (headerName.equals(Constants.USER_AGENT)) { if (!headerValue.startsWith("orion")) { logger.warn("Bad HTTP notification (" + headerValue + " user agent not supported)"); throw new HTTPBadRequestException(headerValue + " user agent not supported"); } // if } else if (headerName.equals(Constants.CONTENT_TYPE)) { if (!headerValue.contains("application/json") && !headerValue.contains("application/xml")) { logger.warn("Bad HTTP notification (" + headerValue + " content type not supported)"); throw new HTTPBadRequestException(headerValue + " content type not supported"); } else { contentType = headerValue; } // if else } else if (headerName.equals(Constants.ORG_HEADER)) { if (headerValue.length() > Constants.ORG_MAX_LEN) { logger.warn("Bad HTTP notification (organization length greater than " + Constants.ORG_MAX_LEN + ")"); throw new HTTPBadRequestException( "organization length greater than " + Constants.ORG_MAX_LEN + ")"); } else { organization = Utils.encode(headerValue); } // if else } // if else if } // for // get the data content String data = ""; String line; BufferedReader reader = request.getReader(); while ((line = reader.readLine()) != null) { data += line; } // while if (data.length() == 0) { logger.warn("Bad HTTP notification (No content in the request)"); throw new HTTPBadRequestException("No content in the request"); } // if // data adaptation; two replacements: // 1. replace all the appearances of "contextValue" with "value" in order Orion versions under 0.10.0 may // work (Json content type only) // 2. replace all the white lines between tags with nothing; the regex ">[ ]*<" means "all the white spaces // between '>' and '<', e.g. "<tag1>1</tag1> <tag2>2</tag2>" becomes "<tag1>1</tag1><tag2>2</tag2>" if (contentType.equals("application/json")) { data = data.replaceAll("contextValue", "value"); } // if data = data.replaceAll(">[ ]*<", "><"); logger.info("Received data (" + data + ")"); // create the appropiate headers Map<String, String> eventHeaders = new HashMap<String, String>(); eventHeaders.put(Constants.CONTENT_TYPE, contentType); logger.debug("Adding flume event header (name=" + Constants.CONTENT_TYPE + ", value=" + contentType + ")"); eventHeaders.put(Constants.ORG_HEADER, organization == null ? defaultOrg : organization); logger.debug("Adding flume event header (name=" + Constants.ORG_HEADER + ", value=" + (organization == null ? defaultOrg : organization) + ")"); eventHeaders.put(Constants.TRANSACTION_ID, transId); logger.debug("Adding flume event header (name=" + Constants.TRANSACTION_ID + ", value=" + transId + ")"); eventHeaders.put(Constants.TTL, eventsTTL); logger.debug("Adding flume event header (name=" + Constants.TTL + ", value=" + eventsTTL + ")"); // create the event list containing only one event ArrayList<Event> eventList = new ArrayList<Event>(); Event event = EventBuilder.withBody(data.getBytes(), eventHeaders); eventList.add(event); logger.info("Event put in the channel (id=" + event.hashCode() + ", ttl=" + eventsTTL + ")"); return eventList; }
From source file:org.kurento.repository.internal.http.RepositoryHttpServlet.java
private void logRequest(HttpServletRequest req) { log.debug("Request received " + req.getRequestURL()); log.debug(" Method: " + req.getMethod()); Enumeration<String> headerNames = req.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); Enumeration<String> values = req.getHeaders(headerName); List<String> valueList = new ArrayList<>(); while (values.hasMoreElements()) { valueList.add(values.nextElement()); }/* w w w . j a v a2 s . c om*/ log.debug(" Header {}: {}", headerName, valueList); } }
From source file:ru.org.linux.exception.ExceptionResolver.java
/** * ? E-mail ?./*w w w . ja v a 2 s. com*/ * * @param request ? web- * @param exception ? * @return , ? ??? ? ? */ private String sendEmailToAdmin(HttpServletRequest request, Exception exception) { InternetAddress mail; String adminEmailAddress = configuration.getAdminEmailAddress(); try { mail = new InternetAddress(adminEmailAddress, true); } catch (AddressException e) { return EMAIL_NOT_SENT + " ? e-mail ?: " + adminEmailAddress; } StringBuilder text = new StringBuilder(); if (exception.getMessage() == null) { text.append(exception.getClass().getName()); } else { text.append(exception.getMessage()); } text.append("\n\n"); Template tmpl = Template.getTemplate(request); // text.append("Main URL: ").append(tmpl.getMainUrl()).append(request.getAttribute("javax.servlet.error.request_uri")); String mainUrl = "<unknown>"; mainUrl = configuration.getMainUrl(); text.append("Main URL: ").append(mainUrl).append(request.getServletPath()); if (request.getQueryString() != null) { text.append('?').append(request.getQueryString()).append('\n'); } text.append('\n'); text.append("IP: " + request.getRemoteAddr() + '\n'); text.append(" Headers: "); Enumeration enu = request.getHeaderNames(); while (enu.hasMoreElements()) { String paramName = (String) enu.nextElement(); text.append("\n ").append(paramName).append(": ").append(request.getHeader(paramName)); } text.append("\n\n"); StringWriter exceptionStackTrace = new StringWriter(); exception.printStackTrace(new PrintWriter(exceptionStackTrace)); text.append(exceptionStackTrace.toString()); Properties props = new Properties(); props.put("mail.smtp.host", "localhost"); Session mailSession = Session.getDefaultInstance(props, null); MimeMessage emailMessage = new MimeMessage(mailSession); try { emailMessage.setFrom(new InternetAddress("no-reply@linux.org.ru")); emailMessage.addRecipient(Message.RecipientType.TO, mail); emailMessage.setSubject("Linux.org.ru: " + exception.getClass()); emailMessage.setSentDate(new Date()); emailMessage.setText(text.toString(), "UTF-8"); } catch (Exception e) { logger.error("An error occured while creating e-mail!", e); return EMAIL_NOT_SENT; } try { Transport.send(emailMessage); return EMAIL_SENT; } catch (Exception e) { return EMAIL_NOT_SENT; } }