Package com.knowgate.dfs

Examples of com.knowgate.dfs.StreamPipe


       // (usually with a com.sun.mail.util.SharedByteArrayInputStream)
       // Decode content as an ISO-8859-1 string
       if (DebugFile.trace) DebugFile.writeln("No data handler found for Content-Type, decoding as ISO-8859-1 string");
       InputStream oInStrm = (InputStream) oContent;
       ByteArrayOutputStream oBaStrm = new ByteArrayOutputStream();
       StreamPipe oPipe = new StreamPipe();
       oPipe.between(oInStrm, oBaStrm);
       oRetVal = new MimeBodyPart();
       oRetVal.setText(oBaStrm.toString("ISO8859_1"));
     }
     else {
       throw new MessagingException("Unparsed Mime Content " + oContent.getClass().getName());
View Full Code Here


      File oFile = oDBF.getFile();
      MboxFile oMBox = new MboxFile(oFile, MboxFile.READ_ONLY);

      InputStream oInStrm = oMBox.getMessageAsStream(oPos.longValue(), iLen);
      StreamPipe oPipe = new StreamPipe();
      oPipe.between(oInStrm, oOutStrm);
      oInStrm.close();
      oMBox.close();
    }
    else {
      Multipart oDBParts = getParts();
View Full Code Here

        int iSize = oPart.getSize();
        if (iSize<=0) iSize = 4000;
        InputStream oInStrm = oPart.getInputStream();
        ByteArrayOutputStream oByStrm = new java.io.ByteArrayOutputStream(iSize);
        new StreamPipe().between(oInStrm, oByStrm);
        oInStrm.close();

        if (DebugFile.trace) DebugFile.writeln("part " + String.valueOf(p) + " size is " + String.valueOf(oByStrm.size()));

        ByteArrayDataSource oDataSrc = new ByteArrayDataSource(oByStrm.toByteArray(), oPart.getContentType());
View Full Code Here

    throws ElementNotFoundException, IOException {
    Item item = getDocument().item();
    sItemName = Gadgets.removeChars(sItemName, "\"\\/?*:|<>;&");
    item.setName(sItemName);
    OutputStream outstrm = item.getOutputStream();
    StreamPipe pipe = new StreamPipe();
    pipe.between(instrm, outstrm);
    outstrm.close();
    Log.out.debug(getClass().getName()+".insertContentFromInputStream("+sItemName+")");
    DAO.log(oSes, getDocument(), getClass(), "INSERT ITEM", AtrilEvent.Level.INFO, sItemName);
  }
View Full Code Here

        User oSender = new User(getSession(), getSessionAttribute("user_docid"));
        disconnect();
        String[] aTaxPayers = getParam("taxPayer").split(",");
        ByteArrayOutputStream oTxt = new ByteArrayOutputStream();
        ByteArrayOutputStream oHtm = new ByteArrayOutputStream();
        new StreamPipe().between(getClass().getResourceAsStream("Invitation.txt"), oTxt);
        new StreamPipe().between(getClass().getResourceAsStream("Invitation.html"),oHtm);
       
        for (int e=0; e<=6; e++) {
          final String sEmail = getParam("email["+String.valueOf(e)+"]","").trim().toLowerCase();
          if (sEmail.trim().length()>0) {
            new AsyncSendInvitation(sEmail, getParam("email["+String.valueOf(e)+"]"), getParam("firstName["+String.valueOf(e)+"]"), getParam("lastName["+String.valueOf(e)+"]"), oSender.getFirstName(), oSender.getLastName(), aTaxPayers, getSessionAttribute("customer_account_docid"), bCreateEmployee, getParam("approve","").length()>0, getParam("settle","").length()>0, getParam("premium","").length()>0,new StringBuffer(new String(oTxt.toByteArray())),new StringBuffer(new String(oHtm.toByteArray()))).start();
View Full Code Here

    public void run() {
      final float MaxWidth = 512f;
      final float MaxHeight = 640f;
      AtrilSession oSes = null;
      StreamPipe oPipe;
      try {
        oSes = DAO.getAdminSession("ThumbnailCreator");
        oSes.autoCommit(true);
        Dms oDms = oSes.getDms();
        Document oDoc = oDms.getDocument(sParent);
        Item oItm = oDms.getDocument(sItem).item();
        String sFileName = oItm.name().toLowerCase();
        oPipe = new StreamPipe();
        ByteArrayOutputStream oByOut = new ByteArrayOutputStream();
        if (sFileName.endsWith(".pdf")) {
          Log.out.debug("Item.getInputStreamTranscodedToMime(image/jpeg)");
          oPipe.between(oItm.getInputStreamTranscodedToMime("image/jpeg"), oByOut);
        } else {
            Log.out.debug("Item.getInputStream()");
            oPipe.between(oItm.getInputStream(), oByOut);         
        }
        byte[] aBytes = oByOut.toByteArray();
        oByOut.close();
        oByOut = null;
        Log.out.debug("new Picture()");
        Picture oPic = new Picture();
        Log.out.debug("Before Picture.dimensions()");
        int[] aWidthHeight = oPic.dimensions(aBytes, "jpeg");
        Log.out.debug("After Picture.dimensions()");
        if (null==aWidthHeight)
          throw new NullPointerException("Unable to get dimensions for image "+oItm.name());
        Log.out.debug("Image width="+String.valueOf(aWidthHeight[0])+" height="+String.valueOf(aWidthHeight[1]));
        int iWidth, iHeight;
        if (aWidthHeight[0]<=MaxWidth && aWidthHeight[0]<=MaxHeight) {
          iWidth = aWidthHeight[0];
          iHeight = aWidthHeight[1];
        } else {
          float fWidthRatio = ((float) aWidthHeight[0]) / MaxWidth;
          float fHeightRatio = ((float) aWidthHeight[1]) / MaxHeight;
          if (fWidthRatio>fHeightRatio) {
            iWidth = (int) MaxWidth;
            iHeight = (int) (MaxWidth*aWidthHeight[1])/aWidthHeight[0];
          } else {
            iWidth = (int) (aWidthHeight[0]*MaxHeight)/aWidthHeight[1];
            iHeight = (int) MaxHeight;
          }
        }
        Log.out.debug("Resampled width="+String.valueOf(iWidth)+" height="+String.valueOf(iHeight));
        String sCodec = null;
        if (sFileName.endsWith(".jpg") || sFileName.endsWith(".jpeg") || sFileName.endsWith(".pdf"))
          sCodec = "jpeg";
        else if (sFileName.endsWith(".gif"))
          sCodec = "gif";
        else if (sFileName.endsWith(".tif") || sFileName.endsWith(".tiff"))
          sCodec = "tiff";
        else {
          Log.out.error("ThumbnailCreator.run()  Could not find suitable codec for file "+oItm.name());
          throw new InstantiationException("Could not find suitable codec for file "+oItm.name());
        }
        Log.out.debug("Picture.createThumbBitmap("+sCodec+","+String.valueOf(iWidth)+","+String.valueOf(iHeight)+",80)");
        byte[] byThumb = oPic.createThumbBitmap(aBytes, sCodec, iWidth, iHeight, 80);
       
        Document oThl = oDms.newDocument(oDms.getDocumentType(oDoc.type().name()+"Thumbnail"), oDoc);
        AttributeMultiValue oAtr = oThl.attribute("width");
      oAtr.set((long) iWidth);
      oAtr = oThl.attribute("height");
      oAtr.set((long) iHeight);
      oThl.save("");
        Item oThi = oThl.item();
        String sItemName = "th"+oDoc.id()+".jpg";
        oThi.setName(sItemName);
        oThi.mimeType("image/jpeg");
        OutputStream oOutStrm = oThi.getOutputStream();
        oPipe = new StreamPipe();
        oPipe.between(new ByteArrayInputStream(byThumb), oOutStrm);
        oThl.save("");
        oOutStrm.close();
        Log.out.debug("Thumbnail creation done");
        DAO.log(oSes, oThl, Class.forName("com.zesped.model."+oDoc.type().name()+"Thumbnail"), "INSERT THUMBNAIL", AtrilEvent.Level.INFO, sItemName);
        oSes.disconnect();
View Full Code Here

TOP

Related Classes of com.knowgate.dfs.StreamPipe

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.