Package org.infoglue.deliver.util

Examples of org.infoglue.deliver.util.HttpHelper


          {
            debugInfo.add(new String[]{"" + deliverUrl, "Error", "Server not available for status query"});         
          }
          else
          {
            HttpHelper httpHelper = new HttpHelper();
            String response = httpHelper.getUrlContent(address, 2000);
            logger.info("response:" + response);
            if(response != null && response.indexOf("status=Unknown;") > -1)
            {
              debugInfo.add(new String[]{"" + deliverUrl, "N/A", "No information found"});             
            }
View Full Code Here


      {
        throw new Exception("Server down... could not get start date");         
      }
      else
      {
        HttpHelper httpHelper = new HttpHelper();
        String response = httpHelper.getUrlContent(address, 2000);
        logger.info("response:" + response);
        if(response != null && response.indexOf("status=Unknown;") > -1)
        {
          if(response.indexOf("serverStartDateTime:") > -1)
          {
View Full Code Here

    List<CacheEvictionBean> beans = new ArrayList<CacheEvictionBean>();
   
    String address = baseUrl + "/UpdateCache!getOngoingPublications.action";
    try
    {
      HttpHelper httpHelper = new HttpHelper();
      String response = httpHelper.getUrlContent(address, 2000);
     
      Gson gson = new Gson();
     
      java.lang.reflect.Type listOfCacheEvictionBeans = new TypeToken<List<CacheEvictionBean>>(){}.getType();
      beans = gson.fromJson(response, listOfCacheEvictionBeans);
View Full Code Here

    List<CacheEvictionBean> beans = new ArrayList<CacheEvictionBean>();
   
    String address = baseUrl + "/UpdateCache!getLatestPublications.action";
    try
    {
      HttpHelper httpHelper = new HttpHelper();
      String response = httpHelper.getUrlContent(address, 2000);
     
      Gson gson = new Gson();
     
      java.lang.reflect.Type listOfCacheEvictionBeans = new TypeToken<List<CacheEvictionBean>>(){}.getType();
      beans = gson.fromJson(response, listOfCacheEvictionBeans);
View Full Code Here

      DigitalAsset digitalAsset = DigitalAssetController.getDigitalAssetWithId(digitalAssetVO.getId(), db);
     
      String cmsBaseUrl = CmsPropertyHandler.getCmsFullBaseUrl();
      if(CmsPropertyHandler.getEnableDiskAssets().equals("true"))
      {
        HttpHelper httpHelper = new HttpHelper();
        httpHelper.downloadFile("" + cmsBaseUrl + "/DownloadProtectedAsset.action?digitalAssetId=" + digitalAssetVO.getId(), tmpOutputFile);
      }
     
      if(tmpOutputFile.exists())
      {
        if(logger.isInfoEnabled())
        {
          logger.info("Time for dumping file " + fileName + ":" + timer.getElapsedTime() + ":" + tmpOutputFile.exists() + ":" + tmpOutputFile.lastModified());
          logger.info("tmpOutputFile:" + tmpOutputFile.length() + ":" + tmpOutputFile.exists())
        }
       
        if(tmpOutputFile.length() == 0 || outputFile.exists())
        {
          if(logger.isInfoEnabled())
            logger.info("written file:" + tmpOutputFile.length() + " - removing temp and not renaming it...")
         
          tmpOutputFile.delete();
         
          if(logger.isInfoEnabled())
            logger.info("Time for deleting file " + timer.getElapsedTime());
        }
        else
        {
          logger.info("written file:" + tmpOutputFile.getAbsolutePath() + " - renaming it to " + outputFile.getAbsolutePath())

          logger.info("written file:" + tmpOutputFile.length() + " - renaming it to " + outputFile.getAbsolutePath())
          tmpOutputFile.renameTo(outputFile);
          logger.info("Time for renaming file " + timer.getElapsedTime());
       

      }
      else
      {
        InputStream inputStream = digitalAsset.getAssetBlob();
        if(inputStream != null)
        {
          synchronized(inputStream)
          {
            logger.info("reading inputStream and writing to disk....");
           
            FileOutputStream fos = new FileOutputStream(tmpOutputFile);
            BufferedOutputStream bos = new BufferedOutputStream(fos);
            BufferedInputStream bis = new BufferedInputStream(inputStream);
           
            int character;
            int i=0;
                while ((character = bis.read()) != -1)
                {
              bos.write(character);
              i++;
                }
               
                if(i == 0)
                  logger.info("Wrote " + i + " chars to " + fileName);
               
            bos.flush();
              fos.close();
            bos.close();
             
                bis.close();
   
                logger.info("done reading inputStream and writing to disk....");
          }
        }
        else
        {
          logger.warn("There was no asset blob in the database - checking the cms-disk - could be a mistake:" + digitalAssetVO.getDigitalAssetId());
         
          try
          {
            HttpHelper httpHelper = new HttpHelper();
            httpHelper.downloadFile("" + cmsBaseUrl + "/DownloadProtectedAsset.action?digitalAssetId=" + digitalAssetVO.getId(), tmpOutputFile);
         
            if(tmpOutputFile.exists())
            {
              if(logger.isInfoEnabled())
              {
View Full Code Here

        {
          logger.info("Was a deliver request and no asset was found on " + tmpOutputFile.getName() + " so let's get it from the cms.");
          String cmsBaseUrl = CmsPropertyHandler.getCmsFullBaseUrl();
          if(CmsPropertyHandler.getEnableDiskAssets().equals("true"))
          {
            HttpHelper httpHelper = new HttpHelper();
            httpHelper.downloadFile("" + cmsBaseUrl + "/DownloadProtectedAsset.action?digitalAssetId=" + digitalAssetVO.getId(), outputFile);
          }
        }
      }
      logger.info("end");
     
View Full Code Here

        return responseBody;
    }

  private String addParameters(String redirectLocation, Map<String, String> requestParameters) throws Exception
  {
    String params = new HttpHelper().toEncodedString(requestParameters, "utf-8");
    String url = redirectLocation + (redirectLocation.indexOf("?") > -1 ? "&" : "?") + params;
     
    return url;
  }
View Full Code Here

TOP

Related Classes of org.infoglue.deliver.util.HttpHelper

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.