[appengine-java] Help needed : "found more than 100 URLMap entries in application configuration"

2010-02-26 Thread mably
I'm hitting the "Found more than 100 URLMap entries in application
configuration" limit.

What is strange is that I have only 82  definitions in my
web.xml (many servlets).

Is it possible to have it increased by someone at Google?  My app ID
is webwinewatch.

Any help will be greatly appreciated as I can't deploy my app anymore.

Thanx in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Datastore migration

2010-02-16 Thread mably
If you need an integrated backup solution in GAE, please "star"
issue :

http://code.google.com/p/googleappengine/issues/detail?id=776


On 2 fév, 19:22, Moritz  wrote:
> Hello everyone,
>
> after a couple of versions of my application I found out that I need
> to change the datamodel fundamentally in order to achieve better
> performance. My approach was as follows:
>
> (Coding)
> - Mark all old API as @Deprecated
> - Create new classes etc.
> - Update views etc.
> - Develop a migration servlet which copies data from the old model to
> the new model
> (Migration)
> - Deploy new app
> - Call migration servlet URL
>
> All tests on my local development environment were successful. The new
> datamodel is less complex than the old one, it contains only
> "implicit" relations and stores large data in a separate entity. That
> perfectly matches the application's scope, only minor refactorings
> were necessary to implement the new datamodel.
>
> However, the migration failed. Of course, I had already so much data
> in the system, that the request timed out. Now my datastore is half
> old and half new.
>
> Bummer.
>
> Luckily, that application is not really in production, so it is not a
> fatal loss.
>
> However, I'm wondering how such migration is usually done.
> - How do Ibackupmy datastore?
> - How do I run migration "scripts" (in my case =servlet)?
>
> Thank you,
> Moritz

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Local datastore is empty after migrating to 1.3.1

2010-02-12 Thread mably
Same thing happened to me.

Got an empty local datastore after updating to 1.3.1.

Hopefully I didn't have much data in it.  But it might not be the case
for everybody.

On 12 fév, 09:35, Al Murauski  wrote:
> The Development Console tells "The datastore is empty" after updating
> to 1.3.1.
>
> Any ideas why? I need my local data back.
>
> The local_db file is not emoty and contain sthe data it contained
> before 1.3.1 migration.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: App Engine cold starts and overly aggressive cycling

2010-02-09 Thread mably
Seems to be the case for me too, I've been noticing instance restarts
pretty often these last 2 or 3 days.

On 8 fév, 19:02, "Ikai L (Google)"  wrote:
> Thanks for the info, Jake. Has anyone else experienced this? That is, has
> anyone else noticed improvement which has since degraded?
>
>
>
>
>
> On Mon, Feb 8, 2010 at 9:10 AM, Jake  wrote:
> > Hey all,
>
> > Since Ikai's post on January 22nd, I haven't had much trouble with my
> > instance rebooting unexpectedly.  However, today the problem has
> > returned.  I'm getting instance restarts within a minute or two of
> > each other on a somewhat regular basis - sometimes even within a few
> > seconds of each other, caused by my first request.
>
> > Jake
>
> > On Jan 30, 3:06 pm, Edwin Hautus  wrote:
> > > I am having this problem for the last week or two after months of good
> > > performance and very little recycling.
> > > As my app start up time is around 15 seconds this is really hitting my
> > > user experience in a negative way.
>
> > > On Jan 16, 12:32 am, Ikai Lan  wrote:
>
> > > > Hey everybody,
>
> > > > We've been seeing more and more reports of applications being cycled
> > out
> > > > overly aggressively, resulting in some folks implementing (discouraged)
> > > > workarounds to keep their application from being cycled out.
>
> > > > - What is your application ID?
>
> > > salsa-amsterdam
>
> > > > - How do you know it is being cycled out? You'll need to insert some
> > code
> > > > that only gets called when the app cold starts.
>
> > > I have some logging which is executed on startup
>
> > > > - How much time of inactivity does it take before your application is
> > cycled
> > > > out?
>
> > > Can be as little as a minute.
>
> > > > - What time or days does this seem to happen?
>
> > > Seems to happen all the time.
>
> > > > - What frameworks or libraries are you loading?
>
> > > Just the plain Servlet API and Groovy.
>
> > > > Any other information you can provide would be helpful.
>
> > > Start up time of the app is about 10 seconds and involves some on the
> > > fly compilation of Groovy scripts.
>
> > > > Ikai Lan
> > > > Developer Programs Engineer, Google App Engine
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com > unsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App 
> Enginehttp://googleappengine.blogspot.com|http://twitter.com/app_engine

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Periodically download backup of datastore?

2010-01-30 Thread mably
What about Google making a copy of our data on their server ?

If you're interested please vote for issue
http://code.google.com/p/googleappengine/issues/detail?id=776

On Jan 29, 10:44 pm, Dominik Steiner
 wrote:
> Hi there,
>
> I finally was able with the great help from Ikai to download the data
> of my application as you can read in the following thread
>
> http://groups.google.com/group/google-appengine-java/browse_thread/th...
>
> now I was wondering what possibilities there are to have a script or
> something running on my computer that would automatically and
> periodically trigger that download in order to backup the data of the
> datastore?
>
> Does anybody already have experience with that? any script out there
> already?
>
> Thanks for any hints you can give me
>
> Dominik

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: After how much time of no traffic does GAE shut-down the instance

2010-01-10 Thread mably
You might be interested in this issue : 
http://code.google.com/p/googleappengine/issues/detail?id=2456

On 10 jan, 14:34, Jorge  wrote:
> It's been some discussion about this topic. You may want to seek posts
> with words "keep warm" or "cold start", for instance. See also the
> "Tragedy of the Commons, and Cold Starts" post in the Google Aps Forum
>
> http://groups.google.com/group/google-appengine/browse_thread/thread/...
>
> Jorge Gonzalez
>
> On Jan 9, 3:16 pm, Locke  wrote:
>
>
>
> > In my testing, apps which are hit every 2 minutes need to "boot" every
> > time (costing beacoup CPU cycles), whereas apps hit every 1 minute
> > stay loaded.
>
> > This limit seems to have changed over time. When I started using
> > appengine several months ago, it would wait ten minutes before
> > subjecting you to the unload/reload penalty.
>
> > I would gladly send google a stick of RAM in the mail if they would
> > just keep my app going!  ;-)
>
> > On Jan 9, 8:16 am, Yossi  wrote:
>
> > > Hi,
>
> > > I've noticed that the same request that takes in average 2 seconds
> > > could take more then 20 seconds after around 10 minutes that the
> > > application is idle (no requests are received). I assume that after
> > > ~10 minutes of no requests, the GAE shuts-down the instance.
> > > Is there an official information about this period of time? Is there a
> > > way to extend this period of time (besides writing a cron job that
> > > runs every minute)?
>
> > > Thanks.
>
> > > Yossi
-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-12-31 Thread mably
Don't forget to star issue : 
http://code.google.com/p/googleappengine/issues/detail?id=965

On Dec 31, 3:23 pm, minor-undroid  wrote:
> Hi there,
>
> I reproduced same problem.
> I cannot send attachment file and inline image with HTML mail.
> (Of course, I could send plain text mail without attachment and
>  HTML mail without inline image)
> I don't have any idea.  It would be very helpful to tell me anything.
>
> I build the mime message in HtmlMimeMessage#createMimeMessage method.
> My code is as follows,
> /
> *** 
> **/
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.ArrayList;
> import java.util.regex.Matcher;
> import java.util.regex.Pattern;
> import java.util.regex.PatternSyntaxException;
>
> import javax.activation.DataHandler;
> import javax.mail.MessagingException;
> import javax.mail.internet.MimeBodyPart;
> import javax.mail.internet.MimeMessage;
> import javax.mail.internet.MimeMultipart;
> import javax.mail.util.ByteArrayDataSource;
>
> import com.mnrngsk.test20091217.mail.CommonData;
> import com.mnrngsk.test20091217.mail.DbgLog;
>
> public class HtmlMimeMessage {
>
>         private static final String             CID_DOMAIN              = 
> "@xxx";
>         private static final String             REGEX_IMGTAG    = 
> " [^'\">])*src=(\"[^\"]*\"|'[^']*'|[^'\">])*/?>";
>
>         private MimeMessage                     mmHtmlMsg = null;
>         private MimeMultipart                   mmpHtmlMail = null;
>         private String                  strHtmlSrc = "";
>         private boolean                         bAttach = false;
>         private String                  strAttach = "";
>
>         private ArrayList replacedImgTagList
>                                                         = new 
> ArrayList();
>
>         // constructor
>         public HtmlMimeMessage(MimeMessage msg, boolean bAttach) {
>                 this.mmHtmlMsg = msg;
>                 this.bAttach = bAttach;
>         }
>
>         public void setSource(String strSrc) {
>                 this.strHtmlSrc = strSrc;
>         }
>
>         public void setAttachment(String strAttach) {
>                 if (this.bAttach) {
>                         this.strAttach = strAttach;
>                 }
>         }
>
>         private void addInlineImageTo(MimeMultipart mmp) {
>                 int iImgSrcCount = this.replacedImgTagList.size();
>                 for (int i = 0; i < iImgSrcCount; i++) {
>                         DbgLog.info("HtmlMimeMessage#addInlineImageTo; Inline 
> Image #" +
> Integer.toString(i));
>
>                         ImageMessageBodyFactory imageMbpFactory = new
> ImageMessageBodyFactory(this.replacedImgTagList.get(i));
>                         MimeBodyPart mbpImg = 
> imageMbpFactory.createMessageBody();
>                         try {
>                                 mmp.addBodyPart(mbpImg);
>                                 
> DbgLog.info("HtmlMimeMessage#addInlineImageTo;\n
> mbpImg#ContentType="
>                                                 + mbpImg.getContentType() + 
> "\n  this.mmpHtmlMail#ContentType="
>                                                 + mmp.getContentType());
>                         } catch (MessagingException e) {
>                                 e.printStackTrace();
>                         DbgLog.warning("HtmlMimeMessage#addInlineImageTo;
> MessagingException; " + e.getMessage());
>                         }
>                 }
>         }
>
>     public boolean createMimeMessage() {
>         boolean bRes = false;
>
>         try {
>                 TextByHtmlMessageBodyFactory textMbpFactory = new
> TextByHtmlMessageBodyFactory(this.strHtmlSrc);
>                         MimeBodyPart mbpText = 
> textMbpFactory.createMessageBody();
>
>                         HtmlMessageBodyFactory htmlMbpFactory = new 
> HtmlMessageBodyFactory
> (this.strHtmlSrc, replacedImgTagList);
>                         MimeBodyPart mbpHtml = 
> htmlMbpFactory.createMessageBody();
>
>                         MimeMultipart mmpMixed = null;
>                         MimeBodyPart mbpAttach = null;
>
>                         if (this.bAttach) {
>                                 
> DbgLog.info("HtmlMimeMessage#createMimeMessage; w Attachment
> (mixed);");
>
>                                 AttachedMessageBodyFactory attachMbpFactory = 
> new
> AttachedMessageBodyFactory();
>                                 
> attachMbpFactory.setAttachment(this.strAttach);
>                                 mbpAttach = 
> attachMbpFactory.createMessageBody();
>
>                                 mmpMixed = attachMbpFactory.getMultipart();
>                         }
>
>                         MimeMultipart mmpAlter = new 
> MimeMultipart("alternative");
>
>                         if

[appengine-java] Re: Generating QR Codes with ZXing

2009-12-26 Thread mably
Here is my ZXing ByteMatrix to PNG encoder, derived from the
PNGEncoder from KeyPoint Software distributed under the LGPL license.

It generates GrayScale only PNG bar codes.

/*
 * Copyright (C) 2009 Francois Masurel
 *
 * This program is free software: you can redistribute it and/or
modify
 * it under the terms of the GNU General Public License as published
by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package com.mably.cms.utils.zxing;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;

import com.google.zxing.common.ByteMatrix;

/**
 * PngEncoder takes a Java Image object and creates a byte string
which can be
 * saved as a PNG file. The Image is presumed to use the
DirectColorModel.
 *
 * 
 * Thanks to Jay Denny at KeyPoint Software http://www.keypoint.com/
who let me
 * develop this code on company time.
 * 
 *
 * 
 * You may contact me with (probably very-much-needed) improvements,
comments,
 * and bug fixes at:
 * 
 *
 * 
 * da...@catcode.com
 * 
 *
 * 
 * This library is free software; you can redistribute it and/or
modify it under
 * the terms of the GNU Lesser General Public License as published by
the Free
 * Software Foundation; either version 2.1 of the License, or (at your
option)
 * any later version.
 * 
 *
 * 
 * This library is distributed in the hope that it will be useful, but
WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
for more
 * details.
 * 
 *
 * 
 * You should have received a copy of the GNU Lesser General Public
License
 * along with this library; if not, write to the Free Software
Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA A copy of the
GNU LGPL
 * may be found at http://www.gnu.org/copyleft/lesser.html
 * 
 *
 * @author J. David Eisenberg
 * @version 1.5, 19 Oct 2003
 *
 *  CHANGES:  19-Nov-2002 : CODING STYLE CHANGES ONLY
(by David
 *  Gilbert for Object Refinery Limited); 19-Sep-2003 : Fix
for
 *  platforms using EBCDIC (contributed by Paulo Soares); 19-
Oct-2003 :
 *  Change private fields to protected fields so that
PngEncoderB can
 *  inherit them (JDE) Fixed bug with calculation of nRows
 */

public class ByteMatrixPngEncoder extends Object {

/** IHDR tag. */
protected static final byte IHDR[] = { 73, 72, 68, 82 };

/** IDAT tag. */
protected static final byte IDAT[] = { 73, 68, 65, 84 };

/** IEND tag. */
protected static final byte IEND[] = { 73, 69, 78, 68 };

/** Constants for filter (NONE) */
protected static final int FILTER_NONE = 0;

protected static final byte BLACK = (byte) 0x00;
protected static final byte WHITE = (byte) 0xFF;

/** The png bytes. */
protected byte[] pngBytes;

/** The prior row. */
protected byte[] priorRow;

/** The left bytes. */
protected byte[] leftBytes;

/** The width. */
protected int width, height;

/** The byte position. */
protected int bytePos, maxPos;

/** CRC. */
protected CRC32 crc = new CRC32();

/** The CRC value. */
protected long crcValue;

/** The bytes-per-pixel. */
protected int bytesPerPixel;

/** The compression level. */
protected int compressionLevel;

private ByteMatrix matrix;

/**
 * Class constructor specifying Image source to encode, whether to
encode
 * alpha, filter to use, and compression level.
 *
 * @param image
 *A Java Image object
 * @param encodeAlpha
 *Encode the alpha channel? false=no; true=yes
 * @param whichFilter
 *0=none, 1=sub, 2=up
 * @param compLevel
 *0..9
 * @see java.awt.Image
 */
public ByteMatrixPngEncoder(ByteMatrix matrix, int compLevel) {
this.matrix = matrix;
this.width = matrix.getWidth();
this.height = matrix.getHeight();
this.bytesPerPixel = 1;
if (compLevel >= 0 && compLevel <= 9) {
this.compressionLevel = compLevel;
}
}

/**
 * Creates an array of bytes that is the PNG equivalent of the
current
   

[appengine-java] Re: Generating QR Codes with ZXing

2009-12-20 Thread mably
Hi Roberto, thanx for your answer.

I finally succeeded generating QRCodes with the ZXing QRCode encoder
and a home made PNGEncoder (derivated from the ones found there :
http://catcode.com/pngencoder/).

But I'm still stuck with Datamatrix bar codes coz ZXing doesn't
generate them.

Any help will be greatly appreciated.

François

On 20 déc, 18:27, Roberto Saccon  wrote:
> There is a sample app with ZXing, which runs on GAE, but I don't know
> exactly what it does, but I think to encode QRCodes (generating an
> image) isn't that difficult, I recently did that (just for a test) in
> Javascript, with an Open source code I found after  2 seconds of
> Googeling. If you want to decode Images, then I think the ZXing code
> has some AWT dependencies, which aren't GAE whitelisted.
> --
> Roberto
>
> On Dec 20, 12:16 pm, mably  wrote:
>
>
>
> > More generally, has anybody heard of an open source barcode generator
> > java library running on GAE ?
>
> > We need to generate QR Codes or Datamatrix bar codes from our
> > application running on GAE.
>
> > We are using the Google Charts API for generating QR Codes for the
> > moment.
>
> > Thanx for you help.
>
> > On 19 déc, 18:50, mably  wrote:
>
> > > Has anyone successfully used Google ZXing library on GAE for
> > > generating QR Codes ?
>
> > > Thanx for your help.
>
> > > François

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Generating QR Codes with ZXing

2009-12-20 Thread mably
More generally, has anybody heard of an open source barcode generator
java library running on GAE ?

We need to generate QR Codes or Datamatrix bar codes from our
application running on GAE.

We are using the Google Charts API for generating QR Codes for the
moment.

Thanx for you help.

On 19 déc, 18:50, mably  wrote:
> Has anyone successfully used Google ZXing library on GAE for
> generating QR Codes ?
>
> Thanx for your help.
>
> François

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Generating QR Codes with ZXing

2009-12-19 Thread mably
Has anyone successfully used Google ZXing library on GAE for
generating QR Codes ?

Thanx for your help.

François

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Multipart mail regression in 1.2.8 ?

2009-12-08 Thread mably
If you encounter the same problem, please vote for issue
http://code.google.com/p/googleappengine/issues/detail?id=965

On 8 déc, 12:16, mably  wrote:
> Hi Ikai,
>
> Effectively the code you provided seems to work but not exactly as I
> hoped.
>
> Before 1.2.8, I was able to send an html email with inline images
> using the previous code.
>
> Now the image is sent as an external attachment.
>
> It's really sad we can't send nice html messages with images anymore.
>
> Do you know if it will work again anytime soon ?
>
> Thanx again for your help.
>
> François
>
> On 8 déc, 02:54, "Ikai L (Google)"  wrote:
>
>
>
> > François,
>
> > Can you give this a try?
>
> > ByteArrayDataSource mimePartDataSource = new ByteArrayDataSource(imgData,
> > inboundMimeBodyPart.getContentType());
> > attachment.setDataHandler(new DataHandler(mimePartDataSource));
>
> > On Sat, Dec 5, 2009 at 1:47 AM, mably  wrote:
> > > This code doesn't work anymore for me :
>
> > >    public void test() throws Exception{
>
> > >        String from = "x...@gmail.com";
> > >        String to = "x...@gmail.com";
> > >        String subject = "Testing multipart email";
> > >        String htmlText = "Hello";
> > >        byte[] imgData = this.obtainByteData(
> > >                        "/com/mably/cms/themes/standard/resources/images/
> > > enveloppe.gif");
>
> > >        Properties props = new Properties();
> > >        Session session = Session.getDefaultInstance(props, null);
>
> > >        Message msg = new MimeMessage(session);
> > >        msg.setFrom(new InternetAddress(from));
> > >        msg.addRecipient(Message.RecipientType.TO, new InternetAddress
> > > (to));
> > >        msg.setSubject(subject);
>
> > >        Multipart mp = new MimeMultipart("related");
>
> > >        MimeBodyPart htmlPart = new MimeBodyPart();
> > >        htmlPart.setContent(htmlText, "text/html");
> > >        mp.addBodyPart(htmlPart);
>
> > >        MimeBodyPart attachment = new MimeBodyPart();
> > >        attachment.setFileName("test.gif");
> > >        attachment.setContent(imgData, "image/gif");
> > >        attachment.setHeader("Content-ID","");
> > >        mp.addBodyPart(attachment);
>
> > >        msg.setContent(mp);
>
> > >        Transport.send(msg);
> > >    }
>
> > > What needs to be changed ?
>
> > > Any help will be greatly appreciated.
>
> > > François
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > > "Google App Engine for Java" group.
> > > To post to this group, send email to
> > > google-appengine-j...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > google-appengine-java+unsubscr...@googlegroups.com > >  unsubscr...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine-java?hl=en.
>
> > --
> > Ikai Lan
> > Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Multipart mail regression in 1.2.8 ?

2009-12-08 Thread mably
Hi Ikai,

Effectively the code you provided seems to work but not exactly as I
hoped.

Before 1.2.8, I was able to send an html email with inline images
using the previous code.

Now the image is sent as an external attachment.

It's really sad we can't send nice html messages with images anymore.

Do you know if it will work again anytime soon ?

Thanx again for your help.

François


On 8 déc, 02:54, "Ikai L (Google)"  wrote:
> François,
>
> Can you give this a try?
>
> ByteArrayDataSource mimePartDataSource = new ByteArrayDataSource(imgData,
> inboundMimeBodyPart.getContentType());
> attachment.setDataHandler(new DataHandler(mimePartDataSource));
>
>
>
>
>
> On Sat, Dec 5, 2009 at 1:47 AM, mably  wrote:
> > This code doesn't work anymore for me :
>
> >    public void test() throws Exception{
>
> >        String from = "x...@gmail.com";
> >        String to = "x...@gmail.com";
> >        String subject = "Testing multipart email";
> >        String htmlText = "Hello";
> >        byte[] imgData = this.obtainByteData(
> >                        "/com/mably/cms/themes/standard/resources/images/
> > enveloppe.gif");
>
> >        Properties props = new Properties();
> >        Session session = Session.getDefaultInstance(props, null);
>
> >        Message msg = new MimeMessage(session);
> >        msg.setFrom(new InternetAddress(from));
> >        msg.addRecipient(Message.RecipientType.TO, new InternetAddress
> > (to));
> >        msg.setSubject(subject);
>
> >        Multipart mp = new MimeMultipart("related");
>
> >        MimeBodyPart htmlPart = new MimeBodyPart();
> >        htmlPart.setContent(htmlText, "text/html");
> >        mp.addBodyPart(htmlPart);
>
> >        MimeBodyPart attachment = new MimeBodyPart();
> >        attachment.setFileName("test.gif");
> >        attachment.setContent(imgData, "image/gif");
> >        attachment.setHeader("Content-ID","");
> >        mp.addBodyPart(attachment);
>
> >        msg.setContent(mp);
>
> >        Transport.send(msg);
> >    }
>
> > What needs to be changed ?
>
> > Any help will be greatly appreciated.
>
> > François
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com > unsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Multipart mail regression in 1.2.8 ?

2009-12-05 Thread mably
This code doesn't work anymore for me :

public void test() throws Exception{

String from = "x...@gmail.com";
String to = "x...@gmail.com";
String subject = "Testing multipart email";
String htmlText = "Hello";
byte[] imgData = this.obtainByteData(
"/com/mably/cms/themes/standard/resources/images/
enveloppe.gif");

Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);

Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress
(to));
msg.setSubject(subject);

Multipart mp = new MimeMultipart("related");

MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(htmlText, "text/html");
mp.addBodyPart(htmlPart);

MimeBodyPart attachment = new MimeBodyPart();
attachment.setFileName("test.gif");
attachment.setContent(imgData, "image/gif");
attachment.setHeader("Content-ID","");
mp.addBodyPart(attachment);

msg.setContent(mp);

Transport.send(msg);
}

What needs to be changed ?

Any help will be greatly appreciated.

François

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: HttpSession and setMaxInactiveInterval

2009-11-26 Thread mably
The session cookie is lost when you close your browser.

So no way to get back to the original session once you reconnect.

Nothing in common with an eventual authentication cookie.

On 26 nov, 22:32, Peter Hulsen  wrote:
> Hi,
>
> I am writing a custom authentication process and like the app to leave
> the user signed in after the browser closes (i.e., when the user
> revisits the app she is directly signed in). I thought the following
> piece of code would accomplish this:
>
> HttpSession session = req.getSession(true);
> session.setMaxInactiveInterval(60*60*24*14); // 2 weeks
> session.setAttribute("Username", username);
>
> But when I restart the browser and visit the app a user has to sign in
> again. What is missing to keep user signed in after browser restarts?
> Thanks.
>
> Regards,
> Peter

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.




[appengine-java] Re: Help With Images In Java

2009-11-23 Thread mably
Found this doc on Google, it might help you :

http://balusc.blogspot.com/2007/04/imageservlet.html#ImageServletServingFromDatabase

On 20 nov, 05:09, java-dev  wrote:
> hi all,
>
> I need some help with images in appengine using java. Now I have
> sucessfully uploaded an image file and stored it to the datastore. I
> am also able to read back the stored image (as a byte[] array). Now
> the issue is, how do I display this image in my jsp page?
>
> ***
>
> //gets the image file Object  from the read data d
> ImageFile f = d.getImg();
>
> //gets the byte array of this image
> byte[] imb = f.getImg();
>
> //futile attempt to display this image
> for(int i=0; i out.println(imb[i]);
>
> ***
> The above code displays the raw bytes on the jsp pageHow can I get
> this to display the image itself?
>
> Any help would be greatly appreciated..
>
> Thanks.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=.




[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-19 Thread mably
By the way, do you know if Google plans to open source some parts of
GAE librairies so we could investigate deeper when we encounter such a
problem ?

On 19 nov, 21:01, mably  wrote:
> Any chance to see this bug fixed in the future ?
>
> Is there any documentation on the meaning of "Converting
> attachment data failed" error message ?
>
> On 19 nov, 20:55, "Ikai L (Google)"  wrote:
>
>
>
> > Looks like you're right. As far as I know there are no hidden methods.
>
> > Another workaround for this limitation could be to store incoming images in
> > the data store on an incoming email, then reference them in the emails that
> > get sent out. It's not ideal, but it may be the solution to what you are
> > looking for.
>
> > On Wed, Nov 18, 2009 at 3:36 PM, mably  wrote:
> > > I haven't found a way to set a Content-ID header on a mimebodypart/
> > > attachment using the low-level API.  The MailService.Attachment class
> > > is quite rudimentary (only filename and data).
>
> > > May be some part of the low level API are still undocumented ?
>
> > > Thanx for all.
>
> > > On Nov 19, 12:25 am, "Ikai L (Google)"  wrote:
> > > > That's good information to know. We are not using Sun's JavaMail
> > > > implementation, so it's possible there are points of incompatibility.
> > > > There's one last thing you may want to try:
>
> > > >http://code.google.com/appengine/docs/java/javadoc/com/google/appengi...
>
> > > > The above page documents the Low-Level API. Try creating an email object
> > > via
> > > > that API, setting the Content-ID of the attachment and the HTML tag to
> > > point
> > > > to the cid. You're already doing that in the example you sent using
> > > > javax.mail, but I'm wondering if the low-level API is capable of doing
> > > this.
> > > > If not, I'll open an issue.
>
> > > > On Wed, Nov 18, 2009 at 3:06 PM, mably  wrote:
> > > > > Of course, the code above doesn't need to be run in mail handler
> > > > > servlet :-)
>
> > > > > On Nov 19, 12:01 am, mably  wrote:
> > > > > > I've written a simple class sending an HTML email with an embedded
> > > > > > image (cf. below) via GMail SMTP.  It works perfectly fine when run
> > > > > > locally from Eclipse.
>
> > > > > > The same code in a GAE mail servlet handler produce the infamous
> > > > > > "Converting attachment data failed" error.
>
> > > > > > So it really seems to be a problem in GAE javamail implementation.
>
> > > > > > /*
> > > > > >  * Copyright (C) 2009 Francois Masurel
> > > > > >  *
> > > > > >  * This program is free software: you can redistribute it and/or
> > > > > > modify
> > > > > >  * it under the terms of the GNU General Public License as published
> > > > > > by
> > > > > >  * the Free Software Foundation, either version 3 of the License, or
> > > > > >  * any later version.
> > > > > >  *
> > > > > >  * This program is distributed in the hope that it will be useful,
> > > > > >  * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > > > >  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > > > >  * GNU General Public License for more details.
> > > > > >  *
> > > > > >  * You should have received a copy of the GNU General Public License
> > > > > >  * along with this program.  If not, see <
> > >http://www.gnu.org/licenses/>.
>
> > > > > >  */
>
> > > > > > import java.io.ByteArrayOutputStream;
> > > > > > import java.io.IOException;
> > > > > > import java.io.InputStream;
> > > > > > import java.util.Properties;
>
> > > > > > import javax.mail.Message;
> > > > > > import javax.mail.Multipart;
> > > > > > import javax.mail.Session;
> > > > > > import javax.mail.Transport;
> > > > > > import javax.mail.internet.InternetAddress;
> > > > > > import javax.mail.internet.MimeBodyPart;
> > > > > > import javax.mail.internet.MimeMessage;
> > > > > > import javax.mail.internet.MimeMultipart;

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-19 Thread mably
Any chance to see this bug fixed in the future ?

Is there any documentation on the meaning of "Converting
attachment data failed" error message ?

On 19 nov, 20:55, "Ikai L (Google)"  wrote:
> Looks like you're right. As far as I know there are no hidden methods.
>
> Another workaround for this limitation could be to store incoming images in
> the data store on an incoming email, then reference them in the emails that
> get sent out. It's not ideal, but it may be the solution to what you are
> looking for.
>
>
>
> On Wed, Nov 18, 2009 at 3:36 PM, mably  wrote:
> > I haven't found a way to set a Content-ID header on a mimebodypart/
> > attachment using the low-level API.  The MailService.Attachment class
> > is quite rudimentary (only filename and data).
>
> > May be some part of the low level API are still undocumented ?
>
> > Thanx for all.
>
> > On Nov 19, 12:25 am, "Ikai L (Google)"  wrote:
> > > That's good information to know. We are not using Sun's JavaMail
> > > implementation, so it's possible there are points of incompatibility.
> > > There's one last thing you may want to try:
>
> > >http://code.google.com/appengine/docs/java/javadoc/com/google/appengi...
>
> > > The above page documents the Low-Level API. Try creating an email object
> > via
> > > that API, setting the Content-ID of the attachment and the HTML tag to
> > point
> > > to the cid. You're already doing that in the example you sent using
> > > javax.mail, but I'm wondering if the low-level API is capable of doing
> > this.
> > > If not, I'll open an issue.
>
> > > On Wed, Nov 18, 2009 at 3:06 PM, mably  wrote:
> > > > Of course, the code above doesn't need to be run in mail handler
> > > > servlet :-)
>
> > > > On Nov 19, 12:01 am, mably  wrote:
> > > > > I've written a simple class sending an HTML email with an embedded
> > > > > image (cf. below) via GMail SMTP.  It works perfectly fine when run
> > > > > locally from Eclipse.
>
> > > > > The same code in a GAE mail servlet handler produce the infamous
> > > > > "Converting attachment data failed" error.
>
> > > > > So it really seems to be a problem in GAE javamail implementation.
>
> > > > > /*
> > > > >  * Copyright (C) 2009 Francois Masurel
> > > > >  *
> > > > >  * This program is free software: you can redistribute it and/or
> > > > > modify
> > > > >  * it under the terms of the GNU General Public License as published
> > > > > by
> > > > >  * the Free Software Foundation, either version 3 of the License, or
> > > > >  * any later version.
> > > > >  *
> > > > >  * This program is distributed in the hope that it will be useful,
> > > > >  * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > > >  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > > > >  * GNU General Public License for more details.
> > > > >  *
> > > > >  * You should have received a copy of the GNU General Public License
> > > > >  * along with this program.  If not, see <
> >http://www.gnu.org/licenses/>.
>
> > > > >  */
>
> > > > > import java.io.ByteArrayOutputStream;
> > > > > import java.io.IOException;
> > > > > import java.io.InputStream;
> > > > > import java.util.Properties;
>
> > > > > import javax.mail.Message;
> > > > > import javax.mail.Multipart;
> > > > > import javax.mail.Session;
> > > > > import javax.mail.Transport;
> > > > > import javax.mail.internet.InternetAddress;
> > > > > import javax.mail.internet.MimeBodyPart;
> > > > > import javax.mail.internet.MimeMessage;
> > > > > import javax.mail.internet.MimeMultipart;
>
> > > > > /**
> > > > >  * @author Francois
> > > > >  *
> > > > >  */
> > > > > public class GMailSMTP {
>
> > > > >     private static final String SMTP_HOST_NAME = "smtp.gmail.com";
> > > > >     private static final int SMTP_HOST_PORT = 465;
> > > > >     private static final String SMTP_AUTH_USER = "x...@gmail.com";
> > > > >     private static final String SMTP_AUTH_PWD  = "yyy&qu

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-18 Thread mably
I haven't found a way to set a Content-ID header on a mimebodypart/
attachment using the low-level API.  The MailService.Attachment class
is quite rudimentary (only filename and data).

May be some part of the low level API are still undocumented ?

Thanx for all.

On Nov 19, 12:25 am, "Ikai L (Google)"  wrote:
> That's good information to know. We are not using Sun's JavaMail
> implementation, so it's possible there are points of incompatibility.
> There's one last thing you may want to try:
>
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengi...
>
> The above page documents the Low-Level API. Try creating an email object via
> that API, setting the Content-ID of the attachment and the HTML tag to point
> to the cid. You're already doing that in the example you sent using
> javax.mail, but I'm wondering if the low-level API is capable of doing this.
> If not, I'll open an issue.
>
> On Wed, Nov 18, 2009 at 3:06 PM, mably  wrote:
> > Of course, the code above doesn't need to be run in mail handler
> > servlet :-)
>
> > On Nov 19, 12:01 am, mably  wrote:
> > > I've written a simple class sending an HTML email with an embedded
> > > image (cf. below) via GMail SMTP.  It works perfectly fine when run
> > > locally from Eclipse.
>
> > > The same code in a GAE mail servlet handler produce the infamous
> > > "Converting attachment data failed" error.
>
> > > So it really seems to be a problem in GAE javamail implementation.
>
> > > /*
> > >  * Copyright (C) 2009 Francois Masurel
> > >  *
> > >  * This program is free software: you can redistribute it and/or
> > > modify
> > >  * it under the terms of the GNU General Public License as published
> > > by
> > >  * the Free Software Foundation, either version 3 of the License, or
> > >  * any later version.
> > >  *
> > >  * This program is distributed in the hope that it will be useful,
> > >  * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > >  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > >  * GNU General Public License for more details.
> > >  *
> > >  * You should have received a copy of the GNU General Public License
> > >  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
> > >  */
>
> > > import java.io.ByteArrayOutputStream;
> > > import java.io.IOException;
> > > import java.io.InputStream;
> > > import java.util.Properties;
>
> > > import javax.mail.Message;
> > > import javax.mail.Multipart;
> > > import javax.mail.Session;
> > > import javax.mail.Transport;
> > > import javax.mail.internet.InternetAddress;
> > > import javax.mail.internet.MimeBodyPart;
> > > import javax.mail.internet.MimeMessage;
> > > import javax.mail.internet.MimeMultipart;
>
> > > /**
> > >  * @author Francois
> > >  *
> > >  */
> > > public class GMailSMTP {
>
> > >     private static final String SMTP_HOST_NAME = "smtp.gmail.com";
> > >     private static final int SMTP_HOST_PORT = 465;
> > >     private static final String SMTP_AUTH_USER = "x...@gmail.com";
> > >     private static final String SMTP_AUTH_PWD  = "yyy";
>
> > >     public static void main(String[] args) throws Exception{
> > >        new GMailSMTP().test();
> > >     }
>
> > >     public void test() throws Exception{
> > >         Properties props = new Properties();
>
> > >         props.put("mail.transport.protocol", "smtps");
> > >         props.put("mail.smtps.host", SMTP_HOST_NAME);
> > >         props.put("mail.smtps.auth", "true");
> > >         // props.put("mail.smtps.quitwait", "false");
>
> > >         String from = SMTP_AUTH_USER;
> > >         String to = SMTP_AUTH_USER;
> > >         String subject = "Testing SMTP-SSL";
> > >         String htmlText = "Hello";
> > >         byte[] imgData = this.obtainByteData("enveloppe.gif");
>
> > >         Session mailSession = Session.getDefaultInstance(props);
> > >         mailSession.setDebug(true);
>
> > >         Message msg = new MimeMessage(mailSession);
> > >         msg.setFrom(new InternetAddress(from));
> > >         msg.addRecipient(Message.RecipientType.TO, new InternetAddress
> > >

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-18 Thread mably
Of course, the code above doesn't need to be run in mail handler
servlet :-)

On Nov 19, 12:01 am, mably  wrote:
> I've written a simple class sending an HTML email with an embedded
> image (cf. below) via GMail SMTP.  It works perfectly fine when run
> locally from Eclipse.
>
> The same code in a GAE mail servlet handler produce the infamous
> "Converting attachment data failed" error.
>
> So it really seems to be a problem in GAE javamail implementation.
>
> /*
>  * Copyright (C) 2009 Francois Masurel
>  *
>  * This program is free software: you can redistribute it and/or
> modify
>  * it under the terms of the GNU General Public License as published
> by
>  * the Free Software Foundation, either version 3 of the License, or
>  * any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
>  */
>
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.util.Properties;
>
> import javax.mail.Message;
> import javax.mail.Multipart;
> import javax.mail.Session;
> import javax.mail.Transport;
> import javax.mail.internet.InternetAddress;
> import javax.mail.internet.MimeBodyPart;
> import javax.mail.internet.MimeMessage;
> import javax.mail.internet.MimeMultipart;
>
> /**
>  * @author Francois
>  *
>  */
> public class GMailSMTP {
>
>     private static final String SMTP_HOST_NAME = "smtp.gmail.com";
>     private static final int SMTP_HOST_PORT = 465;
>     private static final String SMTP_AUTH_USER = "x...@gmail.com";
>     private static final String SMTP_AUTH_PWD  = "yyy";
>
>     public static void main(String[] args) throws Exception{
>        new GMailSMTP().test();
>     }
>
>     public void test() throws Exception{
>         Properties props = new Properties();
>
>         props.put("mail.transport.protocol", "smtps");
>         props.put("mail.smtps.host", SMTP_HOST_NAME);
>         props.put("mail.smtps.auth", "true");
>         // props.put("mail.smtps.quitwait", "false");
>
>         String from = SMTP_AUTH_USER;
>         String to = SMTP_AUTH_USER;
>         String subject = "Testing SMTP-SSL";
>         String htmlText = "Hello";
>         byte[] imgData = this.obtainByteData("enveloppe.gif");
>
>         Session mailSession = Session.getDefaultInstance(props);
>         mailSession.setDebug(true);
>
>         Message msg = new MimeMessage(mailSession);
>         msg.setFrom(new InternetAddress(from));
>         msg.addRecipient(Message.RecipientType.TO, new InternetAddress
> (to));
>         msg.setSubject(subject);
>
>         Multipart mp = new MimeMultipart("related");
>
>         MimeBodyPart htmlPart = new MimeBodyPart();
>         htmlPart.setContent(htmlText, "text/html");
>         mp.addBodyPart(htmlPart);
>
>         MimeBodyPart attachment = new MimeBodyPart();
>         attachment.setFileName("test.gif");
>         attachment.setContent(imgData, "image/gif");
>         attachment.setHeader("Content-ID","");
>         mp.addBodyPart(attachment);
>
>         msg.setContent(mp);
>
>         Transport transport = mailSession.getTransport();
>
>         transport.connect
>           (SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER,
> SMTP_AUTH_PWD);
>
>         transport.sendMessage(msg,
>             msg.getRecipients(Message.RecipientType.TO));
>
>         transport.close();
>     }
>
>     /**
>      * Constructs a byte array and fills it with data that is read
> from the
>      * specified resource.
>      * @param filename the path to the resource
>      * @return the specified resource as a byte array
>      * @throws java.io.IOException if the resource cannot be read, or
> the
>      *   bytes cannot be written, or the streams cannot be closed
>      */
>     private byte[] obtainByteData(String filename) throws IOException
> {
>         InputStream inputStream = getClass().getResourceAsStream
> (filename);
>         ByteArrayOutputStream outputStream = new ByteArrayOutputStream
> (1024);
>         byte[] bytes = new byte[512];
>
>         // Read bytes from the input stre

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-18 Thread mably
I've written a simple class sending an HTML email with an embedded
image (cf. below) via GMail SMTP.  It works perfectly fine when run
locally from Eclipse.

The same code in a GAE mail servlet handler produce the infamous
"Converting attachment data failed" error.

So it really seems to be a problem in GAE javamail implementation.

/*
 * Copyright (C) 2009 Francois Masurel
 *
 * This program is free software: you can redistribute it and/or
modify
 * it under the terms of the GNU General Public License as published
by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/
>.
 */

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

/**
 * @author Francois
 *
 */
public class GMailSMTP {

private static final String SMTP_HOST_NAME = "smtp.gmail.com";
private static final int SMTP_HOST_PORT = 465;
private static final String SMTP_AUTH_USER = "x...@gmail.com";
private static final String SMTP_AUTH_PWD  = "yyy";

public static void main(String[] args) throws Exception{
   new GMailSMTP().test();
}

public void test() throws Exception{
Properties props = new Properties();

props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.host", SMTP_HOST_NAME);
props.put("mail.smtps.auth", "true");
// props.put("mail.smtps.quitwait", "false");

String from = SMTP_AUTH_USER;
String to = SMTP_AUTH_USER;
String subject = "Testing SMTP-SSL";
String htmlText = "Hello";
byte[] imgData = this.obtainByteData("enveloppe.gif");

Session mailSession = Session.getDefaultInstance(props);
mailSession.setDebug(true);

Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress
(to));
msg.setSubject(subject);

Multipart mp = new MimeMultipart("related");

MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(htmlText, "text/html");
mp.addBodyPart(htmlPart);

MimeBodyPart attachment = new MimeBodyPart();
attachment.setFileName("test.gif");
attachment.setContent(imgData, "image/gif");
attachment.setHeader("Content-ID","");
mp.addBodyPart(attachment);

msg.setContent(mp);

Transport transport = mailSession.getTransport();

transport.connect
  (SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER,
SMTP_AUTH_PWD);

transport.sendMessage(msg,
msg.getRecipients(Message.RecipientType.TO));

transport.close();
}

/**
 * Constructs a byte array and fills it with data that is read
from the
 * specified resource.
 * @param filename the path to the resource
 * @return the specified resource as a byte array
 * @throws java.io.IOException if the resource cannot be read, or
the
 *   bytes cannot be written, or the streams cannot be closed
 */
private byte[] obtainByteData(String filename) throws IOException
{
InputStream inputStream = getClass().getResourceAsStream
(filename);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream
(1024);
byte[] bytes = new byte[512];

// Read bytes from the input stream in bytes.length-sized
chunks and write
// them into the output stream
int readBytes;
while ((readBytes = inputStream.read(bytes)) > 0) {
outputStream.write(bytes, 0, readBytes);
}

// Convert the contents of the output stream into a byte array
byte[] byteData = outputStream.toByteArray();

// Close the streams
inputStream.close();
outputStream.close();

return byteData;
}

}


On Nov 18, 11:11 pm, "Ikai L (Google)"  wrote:
> What I mean is, is this code working on a different mail server?
>
> On Wed, Nov 18, 2009 at 2:00 PM, mably  wrote:
> > I'm just sending a simple mail from my Gmail

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-18 Thread mably
I'm just sending a simple mail from my Gmail account with an embedded
gif image.

I can perfectly read it from my mail servlet handler but when I try to
relay it (cf. code from first message) I get this annoying "Converting
attachment data failed" error which seems to be specific to GAE.

Here is the mail sent data :


MIME-Version: 1.0
Sender: x...@gmail.com
Received: by 10.142.204.15 with HTTP; Wed, 18 Nov 2009 13:57:20 -0800
(PST)
Date: Wed, 18 Nov 2009 22:57:20 +0100
Delivered-To: x...@gmail.com
X-Google-Sender-Auth: c9f34852bdb4f249
Message-ID:
<75c1488c0911181357w4e8efdc2r7e82d8e1c3e03...@mail.gmail.com>
Subject: Test
From: Francois MASUREL 
To: contact-test 
Content-Type: multipart/related; boundary=001636e90e61aa516e0478ac5398

--001636e90e61aa516e0478ac5398
Content-Type: multipart/alternative;
boundary=001636e90e61aa516b0478ac5397

--001636e90e61aa516b0478ac5397
Content-Type: text/plain; charset=UTF-8

[image:
?
ui=2&view=att&th=125094c9bff3199b&attid=0.1&disp=attd&realattid=ii_125094c9bff3199b&zw]

--001636e90e61aa516b0478ac5397
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable




--001636e90e61aa516b0478ac5397--
--001636e90e61aa516e0478ac5398
Content-Type: image/gif; name="enveloppe.gif"
Content-Transfer-Encoding: base64
Content-ID: 
X-Attachment-Id: ii_125094c9bff3199b

R0lGODlhEAAQAPeYAP39/tHR5MrK4fLy99PT6NfX6Nvb6/
f3+ff3+uDg7sPD3fHx9ra206qqyrKy
0eLi8Onp8bCwz
+jo8cvL4WVlm7y81cLC2fPz96ysyrCwzcXF3c7O487O4tDQ5Le30+fn8cvL4ufn
8PDw9/Ly+fDw9PLy+N7e66Skx8/
P46mpymBglNLS5KKixoWFsYaGs56ewNXV5pqawKyszuTk7pyc
wdra6Pr6/
Ht7qnt7qXl5qry82LGx0MbG3pCQsrOz0qyszZubucjI3eLi7eDg6eDg7X5+rJSUu9zc
54uLtvz8/b+/2KenyPX1+K6uzpmZwOvr9a6uz8XF3Ovr9tLS5uPj8Hx8qvv7/
ZiYwLm50NPT5tjY
6K+v0M7O5IGBqtzc68/
P3mpqnoeHsLCwynJypNjY60ZGgJ2dw1hYjc7O4bi40nh4qWlpnNjY5fn5
+5SUvcTE2oCAqbOz0Le31tzc7L292vj4+sPD2by81unp8s/P5s3N3fPz
+VxckqOjyHZ2psLC23p6
pt3d7d7e7PDw+L292JOTu/z8/Kury7Ozyra20ubm8MTE1/b2/Pn5/
Hd3qJCQvOnp876+2tHR5tHR
4oaGrbW10pmZv/7+/v///
wAA




ACH5BAEAAJgALAAQABAA
AAjlADEJHCiwzSQjamYQXIjAAo0fAq5gWChwgB03PiBdkhDkxgKCITywiLLn0qUkU2A4ESPQRKIm
K5iYNIlHCREefg5gMjNBBICZAKx4SUGlQA4smOJw
+BAAjaJLABh1aBCITJ8uNmrIuDRAS4Uldwyk
OZQFhQIKXxCcEGLSkCBLOKowoKNDARJKmN5AMQmghIBIEfKAICTnURlMFwotuNQogYYHcwJsYDDm
DCKBGXZcGiQpgIECf1zwAUJiIIQWI6RwSUAghooeQyi
+cPCEwBYwcI5QFMimSCVHgPTsHlgnzJpF
OncHBAA7
--001636e90e61aa516e0478ac5398--

On Nov 18, 10:34 pm, "Ikai L (Google)"  wrote:
> François,
>
> I'm not familiar with any standards with regard to inline images. Do you
> have this working outside of App Engine? Do you have working code from that?
> If there are discrepancies in our implementation of javax.mail.* and
> standard implementations we should be aware.
>
> On Mon, Nov 16, 2009 at 10:30 PM, mably  wrote:
> > In fact standards attachments works.
>
> > But it's not what I'm trying do do.
>
> > I'm need to relay HTML messages with inline images and this is still
> > not working.
>
> > Is it a kind of limitation of GAE or is it supposed to work ?
>
> > Thanx for your help.
>
> > François
>
> > On 16 nov, 23:09, mably  wrote:
> > > Hi Ikai, thanx for you help.
>
> > > I've copy pasted your code on my webapp (webwinewatch), I've no error
> > > but the mail isn't correctly relayed, all attachements are removed.
>
> > > I've just modified the sender, from and recipient lines :
>
> > > message.setSender(new InternetAddress("@gmail.com", "Relay
> > > account"));
> > > message.setFrom(message.getSender());
> > > message.setRecipient(Message.RecipientType.TO, message.getSender());
>
> > > Do you have any clue ?
>
> > > You can test it, sending an email to : contact-
> > > t...@webwinewatch.appspotmail.com
>
> > > Thanx again for your help.
>
> > > On 16 nov, 21:35, "Ikai L (Google)"  wrote:
>
> > > > I couldn't reproduce your exact error, but I was able to put together a
> > > > working example of an inbound email handler to relay messages. I'm
> > going to
> > > > expand the documentation about processing inbound emails. Here's some
> > > > working code:http://pastie.org/701517
>
> > > > Does this example help any? Code is also pasted below, but it'

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-16 Thread mably
In fact standards attachments works.

But it's not what I'm trying do do.

I'm need to relay HTML messages with inline images and this is still
not working.

Is it a kind of limitation of GAE or is it supposed to work ?

Thanx for your help.

François

On 16 nov, 23:09, mably  wrote:
> Hi Ikai, thanx for you help.
>
> I've copy pasted your code on my webapp (webwinewatch), I've no error
> but the mail isn't correctly relayed, all attachements are removed.
>
> I've just modified the sender, from and recipient lines :
>
> message.setSender(new InternetAddress("@gmail.com", "Relay
> account"));
> message.setFrom(message.getSender());
> message.setRecipient(Message.RecipientType.TO, message.getSender());
>
> Do you have any clue ?
>
> You can test it, sending an email to : contact-
> t...@webwinewatch.appspotmail.com
>
> Thanx again for your help.
>
> On 16 nov, 21:35, "Ikai L (Google)"  wrote:
>
>
>
> > I couldn't reproduce your exact error, but I was able to put together a
> > working example of an inbound email handler to relay messages. I'm going to
> > expand the documentation about processing inbound emails. Here's some
> > working code:http://pastie.org/701517
>
> > Does this example help any? Code is also pasted below, but it'll be easier
> > for you to look at the Pastie.
>
> > import javax.servlet.http.HttpServlet;
> > import javax.servlet.http.HttpServletRequest;
> > import javax.servlet.http.HttpServletResponse;
> > import javax.servlet.ServletException;
> > import javax.mail.*;
> > import javax.mail.util.ByteArrayDataSource;
> > import javax.mail.internet.MimeMessage;
> > import javax.mail.internet.MimeMultipart;
> > import javax.mail.internet.MimeBodyPart;
> > import javax.mail.internet.InternetAddress;
> > import javax.activation.DataHandler;
> > import java.io.IOException;
> > import java.io.InputStream;
> > import java.util.logging.Logger;
> > import java.util.Properties;
>
> > public class MailHandlerServlet extends HttpServlet {
> >     private static final Logger log =
> > Logger.getLogger(MailHandlerServlet.class.getName());
> >     private static final String RECIPIENT = "recipi...@gmail.com";
> >     private static final String SENDER = "sen...@google.com";
>
> >     protected void doPost(HttpServletRequest request, HttpServletResponse
> > response) throws ServletException, IOException {
> >         Properties props = new Properties();
> >         Session session = Session.getDefaultInstance(props, null);
> >         try {
> >             MimeMessage message = new MimeMessage(session,
> > request.getInputStream());
>
> >             Object content = message.getContent(); // You could also
> > probably just use message.getInputStream() here
> >                                                    // and avoid the
> > conditional type check
>
> >             if (content instanceof String) {
> >                 log.info("Received a string");
> >             } else if (content instanceof InputStream) {
> >                 // My somewhat limited testing indicates that this is always
> > getting returned as an
> >                 // InputStream
>
> >                 InputStream inputStream = (InputStream) content;
> >                 ByteArrayDataSource inboundDataSource = new
> > ByteArrayDataSource(inputStream, message.getContentType());
> >                 Multipart inboundMultipart = new
> > MimeMultipart(inboundDataSource);
>
> >                 // Set the body with whatever text you want
> >                 Multipart outboundMultipart = new MimeMultipart();
> >                 MimeBodyPart messageBodyPart = new MimeBodyPart();
> >                 messageBodyPart.setText("Set your body here");
> >                 outboundMultipart.addBodyPart(messageBodyPart);
>
> >                 // Loop over the multipart message coming in and
> >                 // append them to the outbound Multipart object
> >                 for (int i = 0; i < inboundMultipart.getCount(); i++) {
> >                     BodyPart part = inboundMultipart.getBodyPart(i);
> >                     /*
> >                         The content-disposition header is optional:
> >                        http://www.ietf.org/rfc/rfc1806.txt
>
> >                         This header specifies the filename and type of
> >                         a MIME part.
> >                     */
> >                     if(part.getDispositio

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-16 Thread mably
meBodyPart and set this
> as the handler
>                         MimeBodyPart outboundMimeBodyPart = new
> MimeBodyPart();
>                         outboundMimeBodyPart.setDataHandler(new
> DataHandler(mimePartDataSource));
>
> outboundMimeBodyPart.setFileName(inboundMimeBodyPart.getFileName());
>                         outboundMultipart.addBodyPart(outboundMimeBodyPart);
>
>                     }
>
>                 }
>                 message.setContent(outboundMultipart);
>
>             }
>             message.setFrom(new InternetAddress(SENDER, "Relay account"));
>             message.setRecipient(Message.RecipientType.TO, new
> InternetAddress(RECIPIENT, "Recipient"));
>
>             Transport.send(message);
>
>         } catch (MessagingException e) {
>             throw new ServletException(e);
>         }
>     }
>
>
>
> }
> On Sat, Nov 14, 2009 at 1:11 AM, mably  wrote:
> > Hi Ikai, have you been able to reproduce my "Converting attachment
> > data failed" exception ?
>
> > I'm still stuck on this strange bug.
>
> > Thanx for your help.
>
> > On 11 nov, 00:00, mably  wrote:
> > > Of course, here is below my email relay servlet class.  What I'm
> > > willing to do is to hide my customers email addresses by relaying
> > > email to them via my google app email adress.
>
> > > I would like to be able to relay html emails with images which is
> > > quite common nowadays.  I am sending my test emails from a gmail
> > > account.
>
> > > Thanx for your help.
>
> > > /*
> > >  * Copyright (C) 2009 Francois Masurel
> > >  *
> > >  * This program is free software: you can redistribute it and/or
> > > modify
> > >  * it under the terms of the GNU General Public License as published
> > > by
> > >  * the Free Software Foundation, either version 3 of the License, or
> > >  * any later version.
> > >  *
> > >  * This program is distributed in the hope that it will be useful,
> > >  * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > >  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > >  * GNU General Public License for more details.
> > >  *
> > >  * You should have received a copy of the GNU General Public License
> > >  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
> > >  */
>
> > > package com.mably.cms.web;
>
> > > import java.io.IOException;
> > > import java.io.InputStream;
> > > import java.util.Arrays;
> > > import java.util.Properties;
>
> > > import javax.activation.DataHandler;
> > > import javax.activation.DataSource;
> > > import javax.mail.BodyPart;
> > > import javax.mail.Message;
> > > import javax.mail.MessagingException;
> > > import javax.mail.Multipart;
> > > import javax.mail.Session;
> > > import javax.mail.Transport;
> > > import javax.mail.internet.InternetAddress;
> > > import javax.mail.internet.MimeBodyPart;
> > > import javax.mail.internet.MimeMessage;
> > > import javax.mail.internet.MimeMultipart;
> > > import javax.mail.internet.MimeMessage.RecipientType;
> > > import javax.mail.util.ByteArrayDataSource;
> > > import javax.servlet.ServletException;
> > > import javax.servlet.http.HttpServlet;
> > > import javax.servlet.http.HttpServletRequest;
> > > import javax.servlet.http.HttpServletResponse;
>
> > > import org.slf4j.Logger;
> > > import org.slf4j.LoggerFactory;
>
> > > import com.google.inject.Inject;
> > > import com.google.inject.Singleton;
> > > import com.mably.cms.model.ContentManager;
> > > import com.mably.cms.utils.TraitementStream;
>
> > > /**
> > >  * @author f.masurel
> > >  *
> > >  */
> > > @Singleton
> > > public class ContactMailServlet extends HttpServlet {
>
> > >     /** serialVersionUID. */
> > >     private static final long serialVersionUID = 7131942698661805870L;
>
> > >     /** Logger. */
> > >     private static final Logger LOG =
> > >         LoggerFactory.getLogger(ContactMailServlet.class);
>
> > >     @Inject private ContentManager contentManager;
>
> > >     /**
> > >      * {...@inheritdoc}
> > >      */
> > >     public void doPost(HttpServletRequest req, HttpServletResponse
> > > res)
> > >             throws ServletException, IOException {
>
> > >        

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-14 Thread mably
Hi Ikai, have you been able to reproduce my "Converting attachment
data failed" exception ?

I'm still stuck on this strange bug.

Thanx for your help.

On 11 nov, 00:00, mably  wrote:
> Of course, here is below my email relay servlet class.  What I'm
> willing to do is to hide my customers email addresses by relaying
> email to them via my google app email adress.
>
> I would like to be able to relay html emails with images which is
> quite common nowadays.  I am sending my test emails from a gmail
> account.
>
> Thanx for your help.
>
> /*
>  * Copyright (C) 2009 Francois Masurel
>  *
>  * This program is free software: you can redistribute it and/or
> modify
>  * it under the terms of the GNU General Public License as published
> by
>  * the Free Software Foundation, either version 3 of the License, or
>  * any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
>  */
>
> package com.mably.cms.web;
>
> import java.io.IOException;
> import java.io.InputStream;
> import java.util.Arrays;
> import java.util.Properties;
>
> import javax.activation.DataHandler;
> import javax.activation.DataSource;
> import javax.mail.BodyPart;
> import javax.mail.Message;
> import javax.mail.MessagingException;
> import javax.mail.Multipart;
> import javax.mail.Session;
> import javax.mail.Transport;
> import javax.mail.internet.InternetAddress;
> import javax.mail.internet.MimeBodyPart;
> import javax.mail.internet.MimeMessage;
> import javax.mail.internet.MimeMultipart;
> import javax.mail.internet.MimeMessage.RecipientType;
> import javax.mail.util.ByteArrayDataSource;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> import com.google.inject.Inject;
> import com.google.inject.Singleton;
> import com.mably.cms.model.ContentManager;
> import com.mably.cms.utils.TraitementStream;
>
> /**
>  * @author f.masurel
>  *
>  */
> @Singleton
> public class ContactMailServlet extends HttpServlet {
>
>     /** serialVersionUID. */
>     private static final long serialVersionUID = 7131942698661805870L;
>
>     /** Logger. */
>     private static final Logger LOG =
>         LoggerFactory.getLogger(ContactMailServlet.class);
>
>     @Inject private ContentManager contentManager;
>
>     /**
>      * {...@inheritdoc}
>      */
>     public void doPost(HttpServletRequest req, HttpServletResponse
> res)
>             throws ServletException, IOException {
>
>         Properties props = new Properties();
>         Session session = Session.getDefaultInstance(props, null);
>
>         try {
>
>                 MimeMessage msg = new MimeMessage(session, req.getInputStream
> ());
>
>                         String contentType = msg.getContentType();
>
>                         LOG.info("Mail content type : " + contentType);
>                         LOG.info("Mail sent to " + Arrays.toString(
>                                         msg.getRecipients(RecipientType.TO)));
>                         LOG.info("Mail received from " + msg.getSender());
>
>                         MimeMessage resmsg = new MimeMessage(session);
>
>                         resmsg.setSubject(msg.getSubject());
>                         resmsg.setRecipient(Message.RecipientType.TO, 
> msg.getSender());
>
>                         Multipart rescontent = new MimeMultipart();
>
>                         Object content = msg.getContent();
>                         if (content instanceof String) {
>                                 LOG.info("Content : string");
>                         } else if (content instanceof Multipart) {
>                                 LOG.info("Content : multipart");
>                                 Multipart mpcontent = (Multipart) 
> msg.getContent();
>                                 for (int i = 0; i < mpcontent.getCount(); 
> i++) {
>                                         BodyPart part = 
> mpcontent.getBodyPart(i);
>                                         MimeBodyPart respart = new 
> MimeBodyPart();
>                      

[appengine-java] Re: Can't send mail with attachment using JavaMail API

2009-11-10 Thread mably

Of course, here is below my email relay servlet class.  What I'm
willing to do is to hide my customers email addresses by relaying
email to them via my google app email adress.

I would like to be able to relay html emails with images which is
quite common nowadays.  I am sending my test emails from a gmail
account.

Thanx for your help.

/*
 * Copyright (C) 2009 Francois Masurel
 *
 * This program is free software: you can redistribute it and/or
modify
 * it under the terms of the GNU General Public License as published
by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

package com.mably.cms.web;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeMessage.RecipientType;
import javax.mail.util.ByteArrayDataSource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.mably.cms.model.ContentManager;
import com.mably.cms.utils.TraitementStream;

/**
 * @author f.masurel
 *
 */
@Singleton
public class ContactMailServlet extends HttpServlet {

/** serialVersionUID. */
private static final long serialVersionUID = 7131942698661805870L;

/** Logger. */
private static final Logger LOG =
LoggerFactory.getLogger(ContactMailServlet.class);

@Inject private ContentManager contentManager;

/**
 * {...@inheritdoc}
 */
public void doPost(HttpServletRequest req, HttpServletResponse
res)
throws ServletException, IOException {

Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);

try {

MimeMessage msg = new MimeMessage(session, req.getInputStream
());

String contentType = msg.getContentType();

LOG.info("Mail content type : " + contentType);
LOG.info("Mail sent to " + Arrays.toString(
msg.getRecipients(RecipientType.TO)));
LOG.info("Mail received from " + msg.getSender());

MimeMessage resmsg = new MimeMessage(session);

resmsg.setSubject(msg.getSubject());
resmsg.setRecipient(Message.RecipientType.TO, 
msg.getSender());

Multipart rescontent = new MimeMultipart();

Object content = msg.getContent();
if (content instanceof String) {
LOG.info("Content : string");
} else if (content instanceof Multipart) {
LOG.info("Content : multipart");
Multipart mpcontent = (Multipart) 
msg.getContent();
for (int i = 0; i < mpcontent.getCount(); i++) {
BodyPart part = 
mpcontent.getBodyPart(i);
MimeBodyPart respart = new 
MimeBodyPart();
respart.setContent(
part.getContent(), 
part.getContentType());
rescontent.addBodyPart(respart);
}
} else if (content instanceof InputStream) {
LOG.info("Content : inputstream");
InputStream inputStream = (InputStream) content;
ByteArrayDataSource ds =
new ByteArrayDataSource(inputStream, 
contentType);
Multipart mpcontent = new MimeMultipart(ds);
for (int i = 0; i < mpcontent.getCount(); i++) {
BodyPart part = 
mpcontent.getBodyPart(i);
  

[appengine-java] Can't send mail with attachment using JavaMail API

2009-11-07 Thread mably

I keep getting this exception :

javax.mail.SendFailedException: Send failure
(javax.mail.MessagingException: Converting attachment data failed)

Seems related to issue :

http://code.google.com/p/googleappengine/issues/detail?id=1764 (please
star)

Does anybody knows if there is fix or workaround available ?

Thanx for your help.

François
Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: Need GAE logs explanation

2009-09-25 Thread mably

Thanx for your answer, the response times seems to be back to normal.
I'll keep an eye on it.

May be the two pages where served from different machines ?

On 25 sep, 16:48, Toby Reyelts  wrote:
> Is your application being initialized when you hit that URL? (One way to
> tell is by registering a load-on-startup servlet and logging from its init
> method). If so, what's likely happening is that you're not including your
> app initialization when you only time the service method of your servlet.
>
>
>
> On Thu, Sep 24, 2009 at 11:41 AM, mably  wrote:
>
> > Hello everybody,
>
> > I dont really understand the logs GAE shows me in the admin console :
>
> > I have a first URI showing a simple search form that gives me :
>
> > 09-24 08:24AM 30.341 /default/ftsearch.do?_contenttype_=content 200
> > 117ms 103cpu_ms 73api_cpu_ms
>
> > But my servlet service method lasts only :
>
> > INFO : com.mably.cms.web.DispatcherServlet service: 6ms
>
> > And I have a second URI listing data from the datastore that gives
> > me :
>
> > 09-24 08:24AM 28.575 /default/notifications.do 200 38ms 27cpu_ms
> > 13api_cpu_ms
>
> > INFO : com.mably.cms.web.DispatcherServlet service: 10ms
>
> > What's annoying me is that the fastest (6ms versus 10ms) servlet seems
> > to last longer for GAE (117ms vs 38ms) and to take more CPU.
>
> > Can somebody explain these numbers to me ?
>
> > Thanx in advance.
>
> > Francois
> > Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: Datastore index deletion

2009-09-25 Thread mably

Thanx for your help.  I just starred the corresponding issue :
http://code.google.com/p/googleappengine/issues/detail?id=1893

On 25 sep, 05:47, klong86  wrote:
> The vacuum action is only available on the Python version.  You have
> to download the Python SDK to delete the indexes.  The instructions in
> the post below worked for me.
>
> http://groups.google.com/group/google-appengine-java/browse_thread/th...
>
> Kevin
>
> On Sep 24, 11:44 am, mably  wrote:
>
>
>
> > I tried to use appcfg command line with action "update_indexes" but it
> > doesn't delete my unnecessary indexes.
>
> > It seems there is no "vacuum" action like in the python version, am I
> > right ?
>
> > So, does anybody have another solution to delete a datastore index
> > with the java SDK ?
>
> > Francois
> > Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: PDF Generator Library

2009-09-24 Thread mably

Are you sure that JasperReports works fine on GAE ?

I thought it was using iText which doesn't seem to run on GAE (it
needs an unsupported patch).

Mian Rashid a écrit :
> Use can use Jasper Report and there is also designer tool available
> for that is IReport.
>
> On Sep 23, 6:57 pm, mably  wrote:
> > Does anybody know of a java PDF generator library working with Google
> > App Engine ?  Even a low-level one.
> >
> > Any help would be greatly appreciated.
> >
> > Thanx in advance.
> >
> > Francois
> > Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Datastore index deletion

2009-09-24 Thread mably

I tried to use appcfg command line with action "update_indexes" but it
doesn't delete my unnecessary indexes.

It seems there is no "vacuum" action like in the python version, am I
right ?

So, does anybody have another solution to delete a datastore index
with the java SDK ?

Francois
Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Need GAE logs explanation

2009-09-24 Thread mably

Hello everybody,

I dont really understand the logs GAE shows me in the admin console :

I have a first URI showing a simple search form that gives me :

09-24 08:24AM 30.341 /default/ftsearch.do?_contenttype_=content 200
117ms 103cpu_ms 73api_cpu_ms

But my servlet service method lasts only :

INFO : com.mably.cms.web.DispatcherServlet service: 6ms

And I have a second URI listing data from the datastore that gives
me :

09-24 08:24AM 28.575 /default/notifications.do 200 38ms 27cpu_ms
13api_cpu_ms

INFO : com.mably.cms.web.DispatcherServlet service: 10ms

What's annoying me is that the fastest (6ms versus 10ms) servlet seems
to last longer for GAE (117ms vs 38ms) and to take more CPU.

Can somebody explain these numbers to me ?

Thanx in advance.

Francois
Bordeaux, FRANCE


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] PDF Generator Library

2009-09-23 Thread mably

Does anybody know of a java PDF generator library working with Google
App Engine ?  Even a low-level one.

Any help would be greatly appreciated.

Thanx in advance.

Francois
Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] java.lang.IllegalArgumentException: id or name, but not both, must be set in each key path element

2009-09-15 Thread mably

I get this exception in my application.  Anybody knows what is it
about ?

java.lang.IllegalArgumentException: id or name, but not both, must be
set in each key path element
at
com.google.appengine.api.datastore.DatastoreApiHelper.translateError
(DatastoreApiHelper.java:29)
at com.google.appengine.api.datastore.DatastoreApiHelper.makeSyncCall
(DatastoreApiHelper.java:56)
at com.google.appengine.api.datastore.DatastoreServiceImpl$2.run
(DatastoreServiceImpl.java:170)
at
com.google.appengine.api.datastore.TransactionRunner.runInTransaction
(TransactionRunner.java:30)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put
(DatastoreServiceImpl.java:158)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put
(DatastoreServiceImpl.java:138)
at com.google.appengine.api.datastore.DatastoreServiceImpl.put
(DatastoreServiceImpl.java:134)
at com.mably.webwinewatch.model.DatastoreEntity.save
(DatastoreEntity.java:84)
[...]

Thanx for your help.

François
Bordeaux, FRANCE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---