Package org.jasig.portal.utils

Examples of org.jasig.portal.utils.AddressTester


            String skip_protocol = value.substring(7);
            String domain_only = skip_protocol.substring(0,skip_protocol.indexOf("/"));
            String work_value = value;
            if (PROXY_REWRITE_NO_REDIRECT_DOMAIN.length() > 0 && !domain_only.endsWith(PROXY_REWRITE_NO_REDIRECT_DOMAIN)) {
              while (true) {
                AddressTester tester = new AddressTester(work_value, true);
                try {
                  int responseCode = tester.getResponseCode();
                  if (responseCode != HttpURLConnection.HTTP_MOVED_PERM &&
                      responseCode != HttpURLConnection.HTTP_MOVED_TEMP) {
                    log.debug(
                      "ProxyWriter::capture3XXCodes(): could not get deeper in getting the image.");
                    return work_value;
                  }

                  /* At this point we will have a redirect directive */

                  HttpURLConnection httpUrlConnect = (HttpURLConnection) tester.getConnection();
                  httpUrlConnect.connect();

                  work_value = httpUrlConnect.getHeaderField("Location"); ;
                } finally {
                  tester.disconnect();
                }
              }
            }

            return value;
View Full Code Here


            filePath = PROXIED_FILES_PATH + fileName;
            File outputFile = new File(filePath);
            if (!outputFile.exists() || (System.currentTimeMillis()-outputFile.lastModified() > 1800 * 1000))
            {
              try{
                AddressTester tester = new AddressTester(scriptUri);
                try {
                  if (!tester.URLAvailable()){
                    log.error("ProxyWriter::rewrite(): The adress " + scriptUri + " is not available. ");
                    return scriptUri;
                  }
                  HttpURLConnection httpUrlConnect = (HttpURLConnection) tester.getConnection();
                  httpUrlConnect.connect();
                  BufferedReader in = new BufferedReader(new InputStreamReader(httpUrlConnect.getInputStream()));
                  try {
                    FileWriter out = new FileWriter(outputFile);
                    try {
                      String line;
                      while ((line = in.readLine()) != null) {
                        out.write(processLine(line) + "\t\n");
                      }
                    } finally {
                      out.close();
                    }
                  } finally {
                    in.close();
                  }
                } finally {
                  tester.disconnect();
                }
              } catch(Exception e) {
                 log.error(
                                "ProxyWriter::rewrite():Failed to rewrite the file for: " +
                                scriptUri, e);
                 outputFile.delete();
                 return scriptUri;
               } //end catch
             }
             String newScriptPath = PROXIED_FILES_URI + fileName;
             AddressTester tester = new AddressTester(newScriptPath);
             try {
               if (!tester.URLAvailable()) {
                 log.error(
                                "ProxyWriter::rewrite(): The file  " + filePath +
                                " is written but cannot be reached at " +
                                newScriptPath);
                 return scriptUri;
               } else {
                 return PROXY_REWRITE_PREFIX + PROXIED_FILES_URI.substring(7) +
                   fileName;
               }
             } finally {
               tester.disconnect();
             }

         } catch(Exception e) {
             log.error("Failed to read the file at : "  + filePath, e);
             return scriptUri;
View Full Code Here

TOP

Related Classes of org.jasig.portal.utils.AddressTester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.