Package org.apache.axis.attachments

Examples of org.apache.axis.attachments.AttachmentPart


          /*=================================================================
          * Get the object's content, and ingest the document
          *================================================================*/
          try
          {
            AttachmentPart ap = meridio_.getLatestVersionFile((int)docId);
            if (null == ap)
            {
              if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Meridio: Failed to get content for document '" + new Long(docId).toString() + "'");
              // No document.  Delete what's there
              activities.deleteDocument(documentIdentifier,docVersion);
              i++;
              continue;
            }
            try
            {
              // Get the file name.
              String fileName = ap.getDataHandler().getName();
              // Log what we are about to do.
              if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("Meridio: File data is supposedly in "+fileName);
              File theTempFile = new File(fileName);
              if (theTempFile.isFile())
              {
                long fileSize = theTempFile.length();                   // ap.getSize();
                if (activities.checkLengthIndexable(fileSize))
                {
                  InputStream is = new FileInputStream(theTempFile);      // ap.getDataHandler().getInputStream();
                  try
                  {
                    repositoryDocument.setBinary(is, fileSize);

                    if (null != activities)
                    {
                      activities.ingestDocument(documentIdentifier, docVersion,
                        fileURL, repositoryDocument);
                    }
                  }
                  finally
                  {
                    is.close();
                  }
                }
                else
                  activities.deleteDocument(documentIdentifier, docVersion);
              }
              else
              {
                if (Logging.connectors.isDebugEnabled())
                  Logging.connectors.debug("Meridio: Expected temporary file was not present - skipping document '"+new Long(docId).toString() + "'");
                activities.deleteDocument(documentIdentifier, docVersion);
              }
            }
            finally
            {
              ap.dispose();
            }

          }
          catch (java.net.SocketTimeoutException ioex)
          {
View Full Code Here


        {
          if (oLog != null) oLog.debug("Meridio: Exiting getLatestVersionFile method with null.");
            return null;
        }

        AttachmentPart ap = (AttachmentPart) attachments[0];
        if (oLog != null && oLog.isDebugEnabled())
          oLog.debug("Meridio: Temp File is <" + ap.getAttachmentFile() + ">");

        if (oLog != null) oLog.debug("Meridio: Exiting getLatestVersionFile method.");
          return ap;
      }
      catch (RemoteException e)
View Full Code Here

        call.setTargetEndpointAddress( new URL(opts.getURL()) ); //Set the target service host and service location,

        java.util.Stack rev= new java.util.Stack();
        //Create an attachment referenced by a generated contentId.
        AttachmentPart ap= new AttachmentPart(new javax.activation.DataHandler(
          "Now is the time", "text/plain" ));
         refs.add(ap.getContentIdRef()); //reference the attachment by contentId.
         ap.setMimeHeader(positionHTTPHeader, ""+refs.size() ); //create a MIME header indicating postion.
        call.addAttachmentPart(ap);
        rev.push(ap);

        //Create an attachment referenced by a set contentId.
        String setContentId="rick_did_this";
        ap= new AttachmentPart(new DataHandler(" for all good", "text/plain" ));
          //new MemoryOnlyDataSource(
         ap.setContentId(setContentId)
         refs.add("cid:" + setContentId); //reference the attachment by contentId.
         ap.setMimeHeader(positionHTTPHeader, ""+refs.size() ); //create a MIME header indicating postion.
        call.addAttachmentPart(ap);
        rev.push(ap);

        //Create an attachment referenced by a absolute contentLocation.
        ap= new AttachmentPart(new DataHandler( " men to", "text/plain" ));
          //new MemoryOnlyDataSource( " men to", "text/plain" )));
        ap.setContentLocation(baseLoc+ "/firstLoc")
         refs.add(baseLoc+ "/firstLoc"); //reference the attachment by contentId.
         ap.setMimeHeader(positionHTTPHeader, ""+refs.size() ); //create a MIME header indicating postion.
        call.addAttachmentPart(ap);
        rev.push(ap);

        //Create an attachment referenced by relative location to a absolute location.
        ap= new AttachmentPart(new DataHandler( " come to", "text/plain" ));
          // new MemoryOnlyDataSource( " come to", "text/plain" )));
        ap.setContentLocation(baseLoc+ "/secondLoc")
        refs.add("secondLoc"); //reference the attachment by contentId.
        ap.setMimeHeader(positionHTTPHeader, ""+refs.size() ); //create a MIME header indicating postion.
        call.addAttachmentPart(ap);
        rev.push(ap);

        //Create an attachment referenced by relative location to a relative location.
        ap= new AttachmentPart(new DataHandler( " the aid of their country.", "text/plain" ));
          // new MemoryOnlyDataSource( " the aid of their country.", "text/plain" )));
        ap.setContentLocation("thirdLoc")
        refs.add("thirdLoc"); //reference the attachment by contentId.
        ap.setMimeHeader(positionHTTPHeader, ""+refs.size() ); //create a MIME header indicating postion.
        call.addAttachmentPart(ap);
        rev.push(ap);


        //Now build the message....
View Full Code Here

              + al.size() + " attachment href elements");  
        }

        // fiddle the cid: for each attachment
        for (int i = 0; i < attachments.size(); i++ ) {
          AttachmentPart attachment = (AttachmentPart) attachments.get(i);
            Element attachmentElement = (Element) al.get(i);
            attachmentElement.setAttribute("href", "cid:" + attachment.getContentId());                    
        }
    }
View Full Code Here

    for (int i = 0; i < inputMIMEParts.size(); i++) {
            Part p = (Part) inputMIMEParts.get(i);
      try {
                String partName = p.getName();
                Object value = inMsg.getObjectPart(partName);
                AttachmentPart ap = MIMEHelper.getAttachementPart(value);
        call.addAttachmentPart(ap);
        attachments.add(ap);
      } catch (WSIFException e) {
        throw new WSIFException("attachment part '" + p.getName() + "' not in input WSIFMessage");
      }
View Full Code Here

    public static boolean addAttachementIfMIMEPart(Call call, Object o) {
    Trc.entry(null, call, o);
    boolean ok;
   
    if (o instanceof DataHandler) {
            call.addAttachmentPart(new AttachmentPart((DataHandler)o));
            ok = true;
    } else {
      ok = false;
    }
                   
View Full Code Here

    return ok;
    }

    public static AttachmentPart getAttachementPart(Object o) throws WSIFException {
    Trc.entry(null, o);
        AttachmentPart ap = null;
    if (o instanceof DataHandler) {
            ap = new AttachmentPart((DataHandler) o);
    } else {
      throw new WSIFException("Object is not a DataHandler: " + o);
    }
    Trc.exit(ap);
    return ap;
View Full Code Here

    Class valueType = value == null ? null : value.getClass();
    try {
      if (valueType != null
        && DataHandler.class.equals(type)
        && AttachmentPart.class.isAssignableFrom(valueType)) {
        AttachmentPart ap = (AttachmentPart) value;
        DataHandler dh = ap.getDataHandler();
        msg.setObjectPart(name, dh);
      } else if (
      //            Attachments that are Strings, Images, etc are unsupported at present.
      //            Attachments can only be DataHandlers.
      valueType
        != null
          && (String.class.equals(type)
            || Image.class.equals(type)
            || StreamSource.class.equals(type)
            || DOMSource.class.equals(type)
            || SAXSource.class.equals(type)
            || MimeMultipart.class.equals(type))
          && AttachmentPart.class.isAssignableFrom(valueType)) {

        AttachmentPart ap = (AttachmentPart) value;
        InputStream is = ap.getDataHandler().getInputStream();

        if (String.class.equals(type)) {
          byte[] bBuff = new byte[is.available()];
          is.read(bBuff);
          msg.setObjectPart(name, new String(bBuff));
        } else if (Image.class.equals(type)) {
          byte[] bBuff = new byte[is.available()];
          is.read(bBuff);
          msg.setObjectPart(name, new ImageIcon(bBuff).getImage());
        } else if (StreamSource.class.equals(type))
          // Warning: this next line of code has never been tested.
          msg.setObjectPart(name, new StreamSource(is));
        else if (DOMSource.class.equals(type))
          throw new WSIFException("DOMSource is not supported");
        else if (SAXSource.class.equals(type))
          throw new WSIFException("SAXSource is not supported");
        else if (MimeMultipart.class.equals(type))
          // Warning: this next line of code has never been tested.
          msg.setObjectPart(
            name,
            new MimeMultipart(ap.getDataHandler().getDataSource()));
      } else if (
        valueType != null
          && type != null // will be null for async responses
          && !type.isPrimitive()
          && !(type.isAssignableFrom(valueType))) {
View Full Code Here

        // Add any attachments to the call
        for (Iterator iterator = event.getMessage().getOutboundAttachmentNames().iterator(); iterator.hasNext();)
        {
            String name = (String)iterator.next();
            DataHandler dh = event.getMessage().getOutboundAttachment(name);
            AttachmentPart part = new AttachmentPart(dh);
            call.addAttachmentPart(part);
        }
    }
View Full Code Here

            SOAPMessage soapMessage = ctx.getMessage();
            int x = 1;
            for (Iterator<?> i = soapMessage.getAttachments(); i.hasNext(); x++)
            {
                String name = String.valueOf(x);
                AttachmentPart attachmentPart = (AttachmentPart)i.next();
                message.addOutboundAttachment(name, attachmentPart.getActivationDataHandler());
            }
        }
        catch (Exception e)
        {
            // this will not happen
View Full Code Here

TOP

Related Classes of org.apache.axis.attachments.AttachmentPart

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.