List of usage examples for java.net MalformedURLException MalformedURLException
public MalformedURLException(String msg)
From source file:org.springframework.js.resource.ResourceServlet.java
private void prepareResponse(HttpServletResponse response, URL[] resources, String rawResourcePath) throws IOException { long lastModified = -1; int contentLength = 0; String mimeType = null;/*from ww w .j av a 2 s . c o m*/ for (URL resource : resources) { URLConnection resourceConn = resource.openConnection(); if (resourceConn.getLastModified() > lastModified) { lastModified = resourceConn.getLastModified(); } String currentMimeType = getServletContext().getMimeType(resource.getPath()); if (currentMimeType == null) { String extension = resource.getPath().substring(resource.getPath().lastIndexOf('.')); currentMimeType = defaultMimeTypes.get(extension); } if (mimeType == null) { mimeType = currentMimeType; } else if (!mimeType.equals(currentMimeType)) { throw new MalformedURLException("Combined resource path: " + rawResourcePath + " is invalid. All resources in a combined resource path must be of the same mime type."); } contentLength += resourceConn.getContentLength(); } response.setContentType(mimeType); response.setHeader(HTTP_CONTENT_LENGTH_HEADER, Long.toString(contentLength)); response.setDateHeader(HTTP_LAST_MODIFIED_HEADER, lastModified); if (cacheTimeout > 0) { configureCaching(response, cacheTimeout); } }
From source file:org.impalaframework.web.servlet.ResourceServlet.java
private void prepareResponse(HttpServletResponse response, URL[] resources, String rawResourcePath) throws IOException { long lastModified = -1; int contentLength = 0; String mimeType = null;//from w w w. j ava 2s. c o m for (int i = 0; i < resources.length; i++) { URLConnection resourceConn = resources[i].openConnection(); if (resourceConn.getLastModified() > lastModified) { lastModified = resourceConn.getLastModified(); } String currentMimeType = getServletContext().getMimeType(resources[i].getPath()); if (currentMimeType == null) { String extension = resources[i].getPath().substring(resources[i].getPath().lastIndexOf('.')); currentMimeType = (String) defaultMimeTypes.get(extension); } if (mimeType == null) { mimeType = currentMimeType; } else if (!mimeType.equals(currentMimeType)) { throw new MalformedURLException("Combined resource path: " + rawResourcePath + " is invalid. All resources in a combined resource path must be of the same mime type."); } contentLength += resourceConn.getContentLength(); } response.setContentType(mimeType); response.setHeader(HTTP_CONTENT_LENGTH_HEADER, Long.toString(contentLength)); response.setDateHeader(HTTP_LAST_MODIFIED_HEADER, lastModified); if (cacheTimeout > 0) { configureCaching(response, cacheTimeout); } }
From source file:marytts.tools.voiceimport.VoicePackager.java
/** * Check various properties for invalid values * //w w w . ja v a 2 s. c om * @throws Exception */ protected void validateProperties() throws Exception { // ensure that voice type is supported: if (!getProp(VOICETYPE).toLowerCase().matches("(unit selection|fdpsola|hnm|hsmm)")) { throw new Exception("Unsupported voice type: " + getProp(VOICETYPE)); } // check for valid license URL: try { new URL(getProp(LICENSEURL)); } catch (MalformedURLException e) { throw new MalformedURLException(getProp(LICENSEURL) + " is not a valid URL!"); } }
From source file:ws.argo.probe.Probe.java
/** * Add a URL that specifies where the Responder should send the response. * Provide a label as a hint to the Responder about why this URL was included. * For example: give a "internal" label for a respondToURL that is only * accessible from inside a NATed network. * /*from www . ja va 2s . c o m*/ * @param label - hint about the URL * @param respondToURL - the URL the responder will POST a payload to * @throws MalformedURLException if the URL is bad */ public void addRespondToURL(String label, String respondToURL) throws MalformedURLException { // Sanity check on the respondToURL // The requirement for the respondToURL is a REST POST call, so that means // only HTTP and HTTPS schemes. // Localhost is allowed as well as a valid response destination String[] schemes = { "http", "https" }; UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_LOCAL_URLS); if (!urlValidator.isValid(respondToURL)) throw new MalformedURLException("The probe respondTo URL is invalid: " + respondToURL); _probe.addRespondToURL(label, respondToURL); }
From source file:org.ops4j.pax.scanner.obr.internal.ObrScanner.java
/** * Creates an obr filter from a symbolic-name/version by transforming it to * (&(symbolicname=symbolic-name)(version=version)) * * @param path obr spec//from w w w.jav a 2 s .c o m * * @return an obr filter * * @throws MalformedURLException if path doesn't conform to expected syntax or contains invalid chars */ private String createObrFilter(final String path) throws MalformedURLException { if (path == null || path.trim().length() == 0) { throw new MalformedURLException("OBR spec cannot be null or empty"); } final String[] segments = path.split("/"); if (segments.length > 2) { throw new MalformedURLException("OBR spec cannot contain more then one '/'"); } final StringBuilder builder = new StringBuilder(); // add bundle symbolic name filter builder.append("(symbolicname=").append(segments[0]).append(")"); if (!m_filterValidator.validate(builder.toString())) { throw new MalformedURLException("Invalid symbolic name value."); } // add bundle version filter if (segments.length > 1) { builder.insert(0, "(&").append("(version=").append(segments[1]).append("))"); if (!m_filterValidator.validate(builder.toString())) { throw new MalformedURLException("Invalid version value."); } } return builder.toString(); }
From source file:lucee.commons.net.http.httpclient3.HTTPEngine3Impl.java
/** * merge to pathes to one//from www .j a v a2 s . co m * @param current * @param relPath * @return * @throws MalformedURLException */ private static String mergePath(String current, String relPath) throws MalformedURLException { // get current directory String currDir; if (current == null || current.indexOf('/') == -1) currDir = "/"; else if (current.endsWith("/")) currDir = current; else currDir = current.substring(0, current.lastIndexOf('/') + 1); // merge together String path; if (relPath.startsWith("./")) path = currDir + relPath.substring(2); else if (relPath.startsWith("/")) path = relPath; else if (!relPath.startsWith("../")) path = currDir + relPath; else { while (relPath.startsWith("../") || currDir.length() == 0) { relPath = relPath.substring(3); currDir = currDir.substring(0, currDir.length() - 1); int index = currDir.lastIndexOf('/'); if (index == -1) throw new MalformedURLException("invalid relpath definition for URL"); currDir = currDir.substring(0, index + 1); } path = currDir + relPath; } return path; }
From source file:com.sonicle.webtop.core.app.servlet.PublicRequest.java
@Override protected String[] splitPath(String pathInfo) throws MalformedURLException { /*//from w w w .j av a 2 s .c om URL path is something like this: .../{domainPublicName}/{servicePublicName}/remaining/path/ - domainPublicName: the hashed (adler32) name of the domain ID - servicePublicName: the public name of the service */ String[] tokens = StringUtils.split(pathInfo, "/", 3); if (tokens.length < 1) throw new MalformedURLException("No domain provided"); if (tokens.length < 2) throw new MalformedURLException("No service provided"); return new String[] { tokens[0], tokens[1], (tokens.length == 3) ? tokens[2] : "" }; }
From source file:org.nordapp.web.servlet.DEVServlet.java
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try {// w w w. j av a2 s . c om //@SuppressWarnings("unused") final String mandatorId = RequestPath.getMandator(req); final String uuid = RequestPath.getSession(req); // // Session handler (HTTP) and session control (OSGi) // //SessionControl ctrl = new HttpSessionControlImpl(context, req.getSession()); SessionControl ctrl = new SessionControlImpl(context); ctrl.setMandatorID(mandatorId); ctrl.setCertID(uuid); //RequestHandler rqHdl = new RequestHandler(context, ctrl); ctrl.loadTempSession(); ctrl.getAll(); ctrl.incRequestCounter(); ctrl.setAll(); ctrl.saveTempSession(); // // Session and other services // String cert = null; //The '0' session of the mandator Session mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), "0"); //The 'user' session mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), ctrl.decodeCert().toString()); if (mSession == null) { List<String> list = ctrl.getShortTimePassword(); if (ctrl.getCertID() == null || (!list.contains(ctrl.getCertID()))) throw new UnavailableException("Needs a valid User-Session."); } //The mandator Mandator mandator = MandatorServiceImpl.getMandator(context, ctrl.getMandatorID()); if (mandator == null) { throw new UnavailableException("Needs a valid mandator id:" + ctrl.getMandatorID() + "."); } // // Get some data // FilePath tmpLoc = FilePath.get(mandator.getPath()).add("temp"); // // prepare the engine // String[] elem = RequestPath.getPath(req); if (elem.length != 0) throw new MalformedURLException("The URL needs the form '" + req.getServletPath() + "' but was '" + req.getRequestURI() + "'"); // // Initialize the work // ServiceReference<DeployService> srDeploy = context.getServiceReference(DeployService.class); if (srDeploy == null) throw new IOException( "The deploy service reference is not available (maybe down or a version conflict)."); DeployService svDeploy = context.getService(srDeploy); if (svDeploy == null) throw new IOException("The deploy service is not available (maybe down or a version conflict)."); String processID = IdGen.getURLSafeString(IdGen.getUUID()); String mandatorID = ctrl.getMandatorID(); String groupID = ctrl.getGroupID(); String artifactID = ctrl.getArtifactID(); // // Process upload // // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // sets memory threshold - beyond which files are stored in disk factory.setSizeThreshold(MEMORY_THRESHOLD); File repository = tmpLoc.add("http-upload").toFile(); if (!repository.exists()) { repository.mkdirs(); } factory.setRepository(repository); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // sets maximum size of upload file upload.setFileSizeMax(MAX_FILE_SIZE); // sets maximum size of request (include file + form data) upload.setSizeMax(MAX_REQUEST_SIZE); try { // parses the request's content to extract file data //@SuppressWarnings("unchecked") List<FileItem> formItems = upload.parseRequest(req); if (formItems != null && formItems.size() > 0) { // iterates over form's fields for (FileItem item : formItems) { // processes only fields that are not form fields if (item.isFormField()) { //data } else { File zip = svDeploy.createEmptyZip(processID, mandatorID, groupID, artifactID); OutputStream os = new FileOutputStream(zip); InputStream is = item.getInputStream(); try { IOUtils.copy(is, os); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } svDeploy.zipToData(processID, mandatorID, groupID, artifactID, zip.getName()); } //fi } //for } //fi } catch (Exception ex) { req.setAttribute("message", "There was an error: " + ex.getMessage()); } // // Prints the result from the user-session // StringBuffer buffer = new StringBuffer(); ResponseHandler rsHdl = new ResponseHandler(context, ctrl); logger.debug("The user session is{}found mandatorId:{}, sessionId:{}.", (mSession == null ? " not " : " "), ctrl.getMandatorID(), ctrl.getCertID()); rsHdl.getSessionData(buffer, mSession); // // // byte[] bytes = buffer.toString().getBytes(); // // Send the resource // rsHdl.avoidCaching(resp); rsHdl.sendData(bytes, resp); } catch (Exception e) { ResponseHandler rsHdl = new ResponseHandler(context, null); rsHdl.sendError(logger, e, resp, null); } }
From source file:api.wireless.gdata.docs.client.DocsClient.java
public Feed<DocumentEntry> getDocumentsByTitle(String title) throws ServiceException, IOException, ParseException { String[] parameters = null;/* w w w.j a v a 2s . c o m*/ try { parameters = new String[] { "title=" + URLEncoder.encode(title, "UTF-8") }; } catch (UnsupportedEncodingException e) { throw new MalformedURLException("Unable to create parameters"); } URL url = buildUrl(URL_DEFAULT + URL_DOCLIST_FEED, parameters); DocumentEntry doc = null; Feed<DocumentEntry> docs = getFeed(DocumentEntry.class, url); return docs; }
From source file:com.twinsoft.convertigo.engine.servlets.ReverseProxyServlet.java
/** * Executes the {@link HttpMethod} passed in and sends the proxy response * back to the client via the given {@link HttpServletResponse} * //from w ww. j a v a 2 s .c o m * @param httpMethodProxyRequest * An object representing the proxy request to be made * @param httpServletResponse * An object by which we can send the proxied response back to * the client * @throws IOException * Can be thrown by the {@link HttpClient}.executeMethod * @throws ServletException * Can be thrown to indicate that another error has occurred * @throws EngineException */ private void doRequest(HttpMethodType httpMethodType, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException { try { Engine.logEngine.debug("(ReverseProxyServlet) Starting request handling"); if (Boolean.parseBoolean(EnginePropertiesManager.getProperty(PropertyName.SSL_DEBUG))) { System.setProperty("javax.net.debug", "all"); Engine.logEngine.trace("(ReverseProxyServlet) Enabling SSL debug mode"); } else { System.setProperty("javax.net.debug", ""); Engine.logEngine.debug("(ReverseProxyServlet) Disabling SSL debug mode"); } String baseUrl; String projectName; String connectorName; String contextName; String extraPath; { String requestURI = httpServletRequest.getRequestURI(); Engine.logEngine.trace("(ReverseProxyServlet) Requested URI : " + requestURI); Matcher m = reg_fields.matcher(requestURI); if (m.matches() && m.groupCount() >= 5) { baseUrl = m.group(1); projectName = m.group(2); connectorName = m.group(3); contextName = m.group(4); extraPath = m.group(5); } else { throw new MalformedURLException( "The request doesn't contains needed fields : projectName, connectorName and contextName"); } } String sessionID = httpServletRequest.getSession().getId(); Engine.logEngine.debug("(ReverseProxyServlet) baseUrl : " + baseUrl + " ; projectName : " + projectName + " ; connectorName : " + connectorName + " ; contextName : " + contextName + " ; extraPath : " + extraPath + " ; sessionID : " + sessionID); Context context = Engine.theApp.contextManager.get(null, contextName, sessionID, null, projectName, connectorName, null); Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName); context.projectName = projectName; context.project = project; ProxyHttpConnector proxyHttpConnector = (ProxyHttpConnector) project.getConnectorByName(connectorName); context.connector = proxyHttpConnector; context.connectorName = proxyHttpConnector.getName(); HostConfiguration hostConfiguration = proxyHttpConnector.hostConfiguration; // Proxy configuration String proxyServer = Engine.theApp.proxyManager.getProxyServer(); String proxyUser = Engine.theApp.proxyManager.getProxyUser(); String proxyPassword = Engine.theApp.proxyManager.getProxyPassword(); int proxyPort = Engine.theApp.proxyManager.getProxyPort(); if (!proxyServer.equals("")) { hostConfiguration.setProxy(proxyServer, proxyPort); Engine.logEngine.debug("(ReverseProxyServlet) Using proxy: " + proxyServer + ":" + proxyPort); } else { // Remove old proxy configuration hostConfiguration.setProxyHost(null); } String targetHost = proxyHttpConnector.getServer(); Engine.logEngine.debug("(ReverseProxyServlet) Target host: " + targetHost); int targetPort = proxyHttpConnector.getPort(); Engine.logEngine.debug("(ReverseProxyServlet) Target port: " + targetPort); // Configuration SSL Engine.logEngine.debug("(ReverseProxyServlet) Https: " + proxyHttpConnector.isHttps()); CertificateManager certificateManager = proxyHttpConnector.certificateManager; boolean trustAllServerCertificates = proxyHttpConnector.isTrustAllServerCertificates(); if (proxyHttpConnector.isHttps()) { Engine.logEngine.debug("(ReverseProxyServlet) Setting up SSL properties"); certificateManager.collectStoreInformation(context); Engine.logEngine.debug( "(ReverseProxyServlet) CertificateManager has changed: " + certificateManager.hasChanged); if (certificateManager.hasChanged || (!targetHost.equalsIgnoreCase(hostConfiguration.getHost())) || (hostConfiguration.getPort() != targetPort)) { Engine.logEngine .debug("(ReverseProxyServlet) Using MySSLSocketFactory for creating the SSL socket"); Protocol myhttps = new Protocol("https", MySSLSocketFactory.getSSLSocketFactory(certificateManager.keyStore, certificateManager.keyStorePassword, certificateManager.trustStore, certificateManager.trustStorePassword, trustAllServerCertificates), targetPort); hostConfiguration.setHost(targetHost, targetPort, myhttps); } Engine.logEngine.debug("(ReverseProxyServlet) Updated host configuration for SSL purposes"); } else { hostConfiguration.setHost(targetHost, targetPort); } HttpMethod httpMethodProxyRequest; String targetPath = proxyHttpConnector.getBaseDir() + extraPath; // Handle the query string if (httpServletRequest.getQueryString() != null) { targetPath += "?" + httpServletRequest.getQueryString(); } Engine.logEngine.debug("(ReverseProxyServlet) Target path: " + targetPath); Engine.logEngine.debug("(ReverseProxyServlet) Requested method: " + httpMethodType); if (httpMethodType == HttpMethodType.GET) { // Create a GET request httpMethodProxyRequest = new GetMethod(); } else if (httpMethodType == HttpMethodType.POST) { // Create a standard POST request httpMethodProxyRequest = new PostMethod(); ((PostMethod) httpMethodProxyRequest) .setRequestEntity(new InputStreamRequestEntity(httpServletRequest.getInputStream())); } else { throw new IllegalArgumentException("Unknown HTTP method: " + httpMethodType); } String charset = httpMethodProxyRequest.getParams().getUriCharset(); URI targetURI; try { targetURI = new URI(targetPath, true, charset); } catch (URIException e) { // Bugfix #1484 String newTargetPath = ""; for (String part : targetPath.split("&")) { if (!newTargetPath.equals("")) { newTargetPath += "&"; } String[] pair = part.split("="); try { newTargetPath += URLDecoder.decode(pair[0], "UTF-8") + "=" + (pair.length > 1 ? URLEncoder.encode(URLDecoder.decode(pair[1], "UTF-8"), "UTF-8") : ""); } catch (UnsupportedEncodingException ee) { newTargetPath = targetPath; } } targetURI = new URI(newTargetPath, true, charset); } httpMethodProxyRequest.setURI(targetURI); // Tells the method to automatically handle authentication. httpMethodProxyRequest.setDoAuthentication(true); HttpState httpState = getHttpState(proxyHttpConnector, context); String basicUser = proxyHttpConnector.getAuthUser(); String basicPassword = proxyHttpConnector.getAuthPassword(); String givenBasicUser = proxyHttpConnector.getGivenAuthUser(); String givenBasicPassword = proxyHttpConnector.getGivenAuthPassword(); // Basic authentication configuration String realm = null; if (!basicUser.equals("") || (basicUser.equals("") && (givenBasicUser != null))) { String userName = ((givenBasicUser == null) ? basicUser : givenBasicUser); String userPassword = ((givenBasicPassword == null) ? basicPassword : givenBasicPassword); httpState.setCredentials(new AuthScope(targetHost, targetPort, realm), new UsernamePasswordCredentials(userName, userPassword)); Engine.logEngine.debug("(ReverseProxyServlet) Credentials: " + userName + ":******"); } // Setting basic authentication for proxy if (!proxyServer.equals("") && !proxyUser.equals("")) { httpState.setProxyCredentials(new AuthScope(proxyServer, proxyPort), new UsernamePasswordCredentials(proxyUser, proxyPassword)); Engine.logEngine.debug("(ReverseProxyServlet) Proxy credentials: " + proxyUser + ":******"); } // Forward the request headers setProxyRequestHeaders(httpServletRequest, httpMethodProxyRequest, proxyHttpConnector); // Use the CEMS HttpClient HttpClient httpClient = Engine.theApp.httpClient; httpMethodProxyRequest.setFollowRedirects(false); // Execute the request int intProxyResponseCode = httpClient.executeMethod(hostConfiguration, httpMethodProxyRequest, httpState); // Check if the proxy response is a redirect // The following code is adapted from // org.tigris.noodle.filters.CheckForRedirect // Hooray for open source software if (intProxyResponseCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */ && intProxyResponseCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */) { String stringStatusCode = Integer.toString(intProxyResponseCode); String stringLocation = httpMethodProxyRequest.getResponseHeader(STRING_LOCATION_HEADER).getValue(); if (stringLocation == null) { throw new ServletException("Received status code: " + stringStatusCode + " but no " + STRING_LOCATION_HEADER + " header was found in the response"); } // Modify the redirect to go to this proxy servlet rather that // the // proxied host String redirect = handleRedirect(stringLocation, baseUrl, proxyHttpConnector); httpServletResponse.sendRedirect(redirect); Engine.logEngine.debug("(ReverseProxyServlet) Send redirect (" + redirect + ")"); return; } else if (intProxyResponseCode == HttpServletResponse.SC_NOT_MODIFIED) { // 304 needs special handling. See: // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304 // We get a 304 whenever passed an 'If-Modified-Since' // header and the data on disk has not changed; server // responds w/ a 304 saying I'm not going to send the // body because the file has not changed. httpServletResponse.setIntHeader(STRING_CONTENT_LENGTH_HEADER_NAME, 0); httpServletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED); Engine.logEngine.debug("(ReverseProxyServlet) NOT MODIFIED (304)"); return; } // Pass the response code back to the client httpServletResponse.setStatus(intProxyResponseCode); // Pass response headers back to the client Engine.logEngine.debug("(ReverseProxyServlet) Response headers back to the client:"); Header[] headerArrayResponse = httpMethodProxyRequest.getResponseHeaders(); for (Header header : headerArrayResponse) { String headerName = header.getName(); String headerValue = header.getValue(); if (!headerName.equalsIgnoreCase("Transfer-Encoding") && !headerName.equalsIgnoreCase("Set-Cookie")) { httpServletResponse.setHeader(headerName, headerValue); Engine.logEngine.debug(" " + headerName + "=" + headerValue); } } String contentType = null; Header[] contentTypeHeaders = httpMethodProxyRequest.getResponseHeaders("Content-Type"); for (Header contentTypeHeader : contentTypeHeaders) { contentType = contentTypeHeader.getValue(); break; } String pageCharset = "UTF-8"; if (contentType != null) { int iCharset = contentType.indexOf("charset="); if (iCharset != -1) { pageCharset = contentType.substring(iCharset + "charset=".length()).trim(); } Engine.logEngine.debug("(ReverseProxyServlet) Using charset: " + pageCharset); } InputStream siteIn = httpMethodProxyRequest.getResponseBodyAsStream(); // Handle gzipped content Header[] contentEncodingHeaders = httpMethodProxyRequest.getResponseHeaders("Content-Encoding"); boolean bGZip = false, bDeflate = false; for (Header contentEncodingHeader : contentEncodingHeaders) { HeaderElement[] els = contentEncodingHeader.getElements(); for (int j = 0; j < els.length; j++) { if ("gzip".equals(els[j].getName())) { Engine.logBeans.debug("(ReverseProxyServlet) Decode GZip stream"); siteIn = new GZIPInputStream(siteIn); bGZip = true; } else if ("deflate".equals(els[j].getName())) { Engine.logBeans.debug("(ReverseProxyServlet) Decode Deflate stream"); siteIn = new InflaterInputStream(siteIn, new Inflater(true)); bDeflate = true; } } } byte[] bytesDataResult; ByteArrayOutputStream baos = new ByteArrayOutputStream(2048); // String resourceUrl = projectName + targetPath; String t = context.statistics.start(EngineStatistics.APPLY_USER_REQUEST); try { // Read either from the cache, either from the remote server // InputStream is = proxyCacheManager.getResource(resourceUrl); // if (is != null) { // Engine.logEngine.debug("(ReverseProxyServlet) Getting data from cache"); // siteIn = is; // } int c = siteIn.read(); while (c > -1) { baos.write(c); c = siteIn.read(); } // if (is != null) is.close(); } finally { context.statistics.stop(t, true); } bytesDataResult = baos.toByteArray(); baos.close(); Engine.logEngine.debug("(ReverseProxyServlet) Data retrieved!"); // if (isDynamicContent(httpServletRequest.getPathInfo(), // proxyHttpConnector.getDynamicContentFiles())) { Engine.logEngine.debug("(ReverseProxyServlet) Dynamic content"); bytesDataResult = handleStringReplacements(baseUrl, contentType, pageCharset, proxyHttpConnector, bytesDataResult); String billingClassName = context.getConnector().getBillingClassName(); if (billingClassName != null) { try { Engine.logContext.debug("Billing class name required: " + billingClassName); AbstractBiller biller = (AbstractBiller) Class.forName(billingClassName).newInstance(); Engine.logContext.debug("Executing the biller"); biller.insertBilling(context); } catch (Throwable e) { Engine.logContext.warn("Unable to execute the biller (the billing is thus ignored): [" + e.getClass().getName() + "] " + e.getMessage()); } } // } // else { // Engine.logEngine.debug("(ReverseProxyServlet) Static content: " + // contentType); // // // Determine if the resource has already been cached or not // CacheEntry cacheEntry = // proxyCacheManager.getCacheEntry(resourceUrl); // if (cacheEntry instanceof FileCacheEntry) { // FileCacheEntry fileCacheEntry = (FileCacheEntry) cacheEntry; // File file = new File(fileCacheEntry.fileName); // if (!file.exists()) // proxyCacheManager.removeCacheEntry(cacheEntry); // cacheEntry = null; // } // if (cacheEntry == null) { // bytesDataResult = handleStringReplacements(contentType, // proxyHttpConnector, bytesDataResult); // // if (intProxyResponseCode == 200) { // Engine.logEngine.debug("(ReverseProxyServlet) Resource stored: " // + resourceUrl); // cacheEntry = proxyCacheManager.storeResponse(resourceUrl, // bytesDataResult); // cacheEntry.contentLength = bytesDataResult.length; // cacheEntry.contentType = contentType; // Engine.logEngine.debug("(ReverseProxyServlet) Cache entry: " + // cacheEntry); // } // } // } // Send the content to the client if (Engine.logEngine.isDebugEnabled() && MimeType.Html.is(contentType)) { Engine.logEngine.debug("Data proxied:\n" + new String(bytesDataResult, pageCharset)); } if (bGZip || bDeflate) { baos = new ByteArrayOutputStream(); OutputStream compressedOutputStream = bGZip ? new GZIPOutputStream(baos) : new DeflaterOutputStream(baos, new Deflater(Deflater.DEFAULT_COMPRESSION | Deflater.DEFAULT_STRATEGY, true)); compressedOutputStream.write(bytesDataResult); compressedOutputStream.close(); bytesDataResult = baos.toByteArray(); baos.close(); } httpServletResponse.setContentLength(bytesDataResult.length); OutputStream outputStreamClientResponse = httpServletResponse.getOutputStream(); outputStreamClientResponse.write(bytesDataResult); Engine.logEngine.debug("(ReverseProxyServlet) End of document retransmission"); } catch (Exception e) { Engine.logEngine.error("Error while trying to proxy page", e); throw new ServletException("Error while trying to proxy page", e); } }