Package de.iritgo.aktera.comm

Examples of de.iritgo.aktera.comm.BinaryWrapper


        if ((outputType != null) && outputType.equals("binary"))
        {
          // Binary data, so dump to output stream now....
          log.debug("File Data is available");

          final BinaryWrapper data = (BinaryWrapper) ((Output) re).getContent();

          //          hres.setContentLength(new
          //          Integer(((Long)re.getAttribute("ContentLength")).toString()).intValue());
          final long dataSize = data.getSize();

          if ((dataSize > 0) && (dataSize < Integer.MAX_VALUE))
          {
            // Have a valid content length.
            hres.setContentLength((int) data.getSize());
          }

          hres.setContentType(data.getContentType());
          hres.setHeader("Content-Disposition", (String) re.getAttribute("Content-Disposition"));

          //          String encodings = hreq.getHeader ("Accept-Encoding");
          BufferedOutputStream buffOut = null;

          try
          {
            // BUG #844574:Writing using GZip compression is very
            // slow
            // HACK: Disable GZip compression until speed/threading
            // issues are worked out.
            //            if (encodings != null && encodings.indexOf ("gzip") != -1)
            //            {
            //              log.info ("Writing data using GZip compression");
            //
            //              final OutputStream out = hres.getOutputStream ();
            //
            //              buffOut = new BufferedOutputStream(
            //                  new GZIPOutputStream(out), BUFFER_SIZE);
            //              hres.setHeader ("Content-Encoding", "gzip");
            //            }
            //            else
            //            {
            log.info("Writing data with no compression");

            OutputStream out = hres.getOutputStream();

            buffOut = new BufferedOutputStream(out, BUFFER_SIZE);
            //            }
            data.writeTo(buffOut);
            log.trace("Wrote Buffer.");
          }
          catch (IOException e)
          {
            e.printStackTrace();
            log.error("Exception during file read/write:", e);
            throw new ClientException("Exception during file read/write", e);
          }
          finally
          {
            // Flush all streams, and close input streams
            try
            {
              data.close();
            }
            catch (IOException e1)
            {
              e1.printStackTrace();
            }
View Full Code Here


                // completely serializable
                // TODO: Reset First parameter with Context Name
                // so that this will work over distributed
                // environments(I could not find the call to get
                // it - SPD)
                final BinaryWrapper fileWrapper = new BinaryWrapper(null, hreq.getContentType(),
                        fileInfo.getFileName(), BUFFER_SIZE, null);

                try
                {
                  final long written = fileWrapper.writeFrom(inStream);

                  if (this.log.isDebugEnabled())
                  {
                    log.debug("Read/Wrote " + written + "bytes.");
                  }
                }
                catch (IOException e)
                {
                  throw new ClientException(e.getMessage(), e);
                }
                finally
                {
                  if (inStream != null)
                  {
                    try
                    {
                      inStream.close();
                    }

                    // Done Anyways, so just print for log
                    // (hopefully) and carry on.
                    catch (IOException e)
                    {
                      e.printStackTrace();
                    }
                  } // end if(inStream

                  try
                  {
                    fileWrapper.close();
                  }

                  // Done Anyways, so just print for log
                  // (hopefully) and carry on.
                  catch (IOException e)
                  {
                    e.printStackTrace();
                  }
                } // end finally

                if (log.isDebugEnabled())
                {
                  log.debug("Setting FormFile parameter/value:" + oneName + '/'
                          + fileWrapper.getName());
                }

                kreq.setParameter(oneName, fileWrapper);
              } // end if (fileInfo!= null..
            } // end if(df.get(oneName)!=null
View Full Code Here

   * @return The created file
   */
  public static File storeUploadedAudioFile(ModelRequest req, String paramName, String dir, String extensions,
          boolean useDataFileName, boolean convert)
  {
    BinaryWrapper data = (BinaryWrapper) req.getParameter(paramName);

    if (data == null)
    {
      return null;
    }

    String fileName = FilenameUtils.getBaseName(data.getName()).replaceAll("\\s", "-");
    String fileExt = FilenameUtils.getExtension(data.getName()).toLowerCase();

    boolean ok = false;
    String[] exts = extensions.split("\\|");

    for (int i = 0; i < exts.length; ++i)
    {
      if (fileExt.equals(exts[i]))
      {
        ok = true;

        break;
      }
    }

    if (ok)
    {
      File outFile = FileTools.newAkteraFile(dir);

      outFile.mkdirs();

      if (useDataFileName)
      {
        outFile = FileTools.newAkteraFile(dir, fileName + "." + fileExt);
      }

      try
      {
        outFile.delete();
        outFile.createNewFile();
        data.write(outFile);
      }
      catch (IOException x)
      {
        System.out.println("[FileTools.storeUploadedAudioFile] Error: " + x);
      }
View Full Code Here

   * @param req The model request.
   * @param paramName Request paramter name.
   */
  public static String getFilename(ModelRequest req, String paramName)
  {
    BinaryWrapper data = (BinaryWrapper) req.getParameter(paramName);

    if (data == null)
    {
      return "";
    }

    return data.getName().replaceAll("\\s", "-");
  }
View Full Code Here

        if ((outputType != null) && outputType.equals("binary"))
        {
          // Binary data, so dump to output stream now....
          log.debug("File Data is available");

          final BinaryWrapper data = (BinaryWrapper) ((Output) re).getContent();

          // hres.setContentLength(new
          // Integer(((Long)re.getAttribute("ContentLength")).toString()).intValue());
          final long dataSize = data.getSize();

          if ((dataSize > 0) && (dataSize < Integer.MAX_VALUE))
          {
            // Have a valid content length.
            response.setContentLength((int) data.getSize());
          }

          response.setContentType(data.getContentType());
          response.setHeader("Content-Disposition", (String) re.getAttribute("Content-Disposition"));

          // String encodings = hreq.getHeader ("Accept-Encoding");
          BufferedOutputStream buffOut = null;

          try
          {
            log.info("Writing data with no compression");

            OutputStream out = response.getOutputStream();

            buffOut = new BufferedOutputStream(out, BUFFER_SIZE);
            data.writeTo(buffOut);
            log.trace("Wrote Buffer.");
          }
          catch (IOException e)
          {
            e.printStackTrace();
            log.error("Exception during file read/write:", e);
            throw new ClientException("Exception during file read/write", e);
          }
          finally
          {
            try
            {
              data.close();
            }
            catch (IOException e1)
            {
              e1.printStackTrace();
            }
View Full Code Here

      FormTools.addError(response, result, "xslt", "Aktera:noCsvTypeSpecified");
    }

    if (request.getParameter("fileUpload1") != null)
    {
      BinaryWrapper data = (BinaryWrapper) request.getParameter("fileUpload1");

      if (data != null)
      {
        File outDir = FileTools.newAkteraFile("/var/tmp/iritgo");

        outDir.mkdirs();

        File outFile = FileTools.newAkteraFile("/var/tmp/iritgo/import.data");

        try
        {
          outFile.delete();
          outFile.createNewFile();
          data.write(outFile);
        }
        catch (IOException x)
        {
          System.out.println("[ImportDefineFormularHandler] Unable to store import file: " + x);
        }
      }
    }
    else if (request.getParameter("fileUpload2") != null)
    {
      BinaryWrapper data = (BinaryWrapper) request.getParameter("fileUpload2");

      if (data != null)
      {
        File outDir = FileTools.newAkteraFile("/var/tmp/iritgo");

        outDir.mkdirs();

        File outFile = FileTools.newAkteraFile("/var/tmp/iritgo/import.data");

        try
        {
          outFile.delete();
          outFile.createNewFile();
          data.write(outFile);
        }
        catch (IOException x)
        {
          System.out.println("[ImportDefineFormularHandler] Unable to store import file: " + x);
        }
View Full Code Here

      Configuration fileConfig = getConfiguration().getChild("file", false);

      if (fileConfig != null)
      {
        BinaryWrapper data = new BinaryWrapper(fileConfig.getAttribute("name"),
                fileConfig.getAttribute("type"), fileConfig.getAttribute("path"), 1024 * 1024, null);

        out.setContent(data);
      }

View Full Code Here

    }
    else if (req.getParameter("fileUpload1") != null)
    {
      try
      {
        BinaryWrapper data = (BinaryWrapper) req.getParameter("fileUpload1");

        if (data != null)
        {
          File file = new File(System.getProperty("iritgo.license.path"));

          data.write(file);
        }
      }
      catch (Exception x)
      {
        System.out.println("[StoreLicense] " + x);
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.comm.BinaryWrapper

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.