apache-commons

How to attach a file to an HTML email using apache commons email

I'm using Apache Commons Email 1.1 and I can't figure out how to attach a file to an HtmlEmail. If I run the code below, I get an email with an attachment, but the html message comes across as an attachment also. If I don't call email.attach() the html message come through as you would expect, but I need both the html message to come t...

Can apache FileUtils.writeLines() be made to append to a file if it exists.

The commons FileUtils look pretty cool, and I can't believe that they cannot be made to append to a file. File file = new File(path); FileUtils.writeLines(file, printStats(new DateTime(), headerRequired)); The above just replaces the contents of the file each time, and I would just like to keep tagging this stuff to end just as this c...

Validating Arrays using Struts Validator plugin / Commons Validator

I have a property in a Struts DynaValidatorActionForm that is an array of Integers: <form-property name="ids" type="java.lang.Integer[]"/> I'd like to perform a validation on each of these Integers. For example, let's say I want to validate that none of them is equal to the number 1: <field property="ids" depends="vali...

org.apache.commons.lang.StringEscapeUtils in python

Hello, is there any python module or code that implements the org.apache.commons.lang.StringEscapeUtils.escapeHtml ? exactly the same as in http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String) i googled around but could only find the cgi.escape function that doesn't do the sam...

Copy documentum content with apache IOUtils.copy() and setContent()

I want to copy the content from one object stored in one docbase to another object stored in another docbase. I do not want to create a file because I have more than 300 k files to copy. Below is a part of my code: ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(source.getContent(), baos); [...] targetObj.setCon...

ToStringBuilder append X appendSuper

Hi all... in my classes when writing the toString() method I always use the ToStringBuilder from org.apache.commons And when I'm extending other classes I use appendSuper() and then my appends The question: Are there are any real differences in doing: appendSuper(super.toString()) instead of append(super.toString()) Kind of dum...

Reliable Java libs for general programming

There's always a balance when deciding whether to use a 3rd party library or write your own code. Writing your own takes time and will incur a maintenance cost. Using the 3rd party library has its downsides too, with the potential for version incompatibilities every time you update the dependencies. With some libraries, the downsides ...

rmi error in google app

I dont get the error when I use the following line FileItemIterator it = servletFileUpload.getItemIterator(request); I get it when I use following line List fileItemsList = servletFileUpload.parseRequest(request); How are they different and How is rmi related to servletFileUpload.parseRequest(request);? Error: Caused b...

upload file using inputstream in GAE java

I am trying to upload file to google sites and am obtaining the stream using apache commons file upload. I get the input stream as under InputStream is = fileItem.openStream(); How will I convert this input stream in file object so that below call succeeds and I am able to set the MediaFileSource to above converted file. Atta...

What is the best List implementation for Large lists in java

Hi, I have to create a large list of n elements (could be up to 100,000). each element in the list is an integer equivalent to the index of the list. After this I have to call Collections.shuffle on this list. My question is, which list implementation (either java collections or apache collections) should be used. My gut feeling is Ar...

Why ItemSkippedException?

I am trying to update content in Google sites and am reading the stream in exception VersionConflictException. When I check the stream it is all fine and is completely loaded in POST request but then I get following error. org.apache.commons.fileupload.FileItemStream$ItemSkippedException at org.apache.commons.fileupload.MultipartStr...

Why do updating Google site with file upload throws File ItemSkippedException?

I have a media source object MediaStreamSource ms = new MediaStreamSource(is, mediaType); AttachmentEntry newAttachment = new AttachmentEntry(); and try to insert it and in case it already exists then update it instead of insert. try { return service.insert(new URL(getContentFeedUrl()), newAttachment); } catch (Versi...

Apache commons file upload and percentage progress in Google Apps

I am trying to use ProgressListener update call to obtain percentage completion of each file. Number of files are dynamically chosen and uploaded. public class ProgressListenerImpl implements ProgressListener Will I be able to use the "item" parameter in the update call? update(long bytesRead, long contentLength, int item) And...

Sending an Email Using Commons-Email to Gmail

Email email = new SimpleEmail(); String authuser = "[email protected]"; String authpwd = "*******"; // Very Important, Don't use email.setAuthentication() email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(authuser, authpwd)); email.setDebug(true); // true if you want to debug email.setHostName("smtp.gmail.com"); ema...

Java commons-cli, options with list of possible values

How can I make an option accept only some specified values like in the following example: $ java -jar Mumu.jar -a foo OK $ java -jar Mumu.jar -a bar OK $ java -jar Mumu.jar -a foobar foobar is not a valid value for -a ...

How do I correct this silent failure to write files using Java IO?

I am encountering a strange issue with the commons-io/java-io. Essentially my file creation is failing silently without an exception. FileUtils.writeLines(file, collectionOfStrings); I've looked through the commons code to try and figure why this failing silently, but to me it looks like it should be throwing an exception. (See lines ...

Attachments+Html generated with commons-email doesn't show in some email clients

Hi, I've been using the org.apache.commons.mail.HtmlEmail class, from apache commons-mail, for some time. Eventually, some users complain that the email shows with no attachemnts on their e-mail client (problem reported in Outlook 2007 and Lotus Notes). One user have even analysed the problem and sent me the following link: http://sup...

Problem with Apache Commons Id UUID Version 1 generation

My problem is to generate version 1 UUIDs. We use Jetty 6.x, Maven (to start Jetty among other things) and Apache Commons ID (to generate UUID version 1 from the current time). Apache Commons ID requires a configuration file that is told to the JVM, using a parameter, e.g. 'org.apache.commons.id.uuid.config.resource.filename=commons-id-...

Integer Linear Programming Java: Multiple Open Source and Commercial tools are available. Which one to use?

Hi, I need to use Integer Linear Programming API/Tool for my application. Though my application is in Java but I don’t mind calling an EXE (Tool) from Java providing input using file (MPS, etc). My search analysis is as follows: There are multiple Open Source and Commercial tools available to solve ILP Following I found and think are ...

What is Apache Commons Pool close() behaviour

I've been looking to implement pooling in part of my application. I want to use the Commons Pool library but am slightly concerned about how the close() behaviour works. From looking at the javadocs and source code, it doesn't seem clear whether objects created in the pool will be destroyed when the close() method is called. From what I ...