Re: [vfs] Issue encountered when connecting to a SFTP
Hi Heshan, You can either do that (tell VFS where the know-hosts file is): FileSystemOptions o = new FileSystemOptions (); SftpFileSystemConfigBuilder.getInstance().setKnownHosts(o, new File(myKnownHostsDir)); FileObject fo = VFS.getManager().resolveFile(myURI, o); or tell it to ignore strict host key checking: FileSystemOptions o = new FileSystemOptions (); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(o, no); FileObject fo = VFS.getManager().resolveFile(myURI, o); see http://commons.apache.org/vfs/apidocs/index.html Cheers, Steve On Thu, Jan 6, 2011 at 12:46 AM, Heshan Suriyaarachchi heshan.suriyaarach...@gmail.com wrote: Hi, I am using VFS to connect to a SFTP. But when I try to connect to it, I am getting the following stacktrace. Do I have to import the certificate key (of the SFTP that I am trying to connect) to VFS? If so, how to do it? Please advice. Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at example.foo.com. at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnecti on(SftpClientFactory.java:233) at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSys tem(SftpFileProvider.java:95) ... 14 more Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: example.foo.com. DSA key fingerprint is 62:fa:a5:c7:1a:34:f4:05:7a:e8:06:b9:57:e5:de:e3 at com.jcraft.jsch.Session.checkHost(Session.java:706) at com.jcraft.jsch.Session.connect(Session.java:307) at com.jcraft.jsch.Session.connect(Session.java:150) at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnecti on(SftpClientFactory.java:229) ... 15 more -- Regards, Heshan Suriyaarachchi http://heshans.blogspot.com/
RE: [Lang] Null safe date comparisson
Look at Joda-Time http://joda-time.sourceforge.net/ Gary Gregory Senior Software Engineer Rocket Software 3340 Peachtree Road, Suite 820 . Atlanta, GA 30326 . USA Tel: +1.404.760.1560 Email: ggreg...@seagullsoftware.com Web: seagull.rocketsoftware.com -Original Message- From: Ludwig Magnusson [mailto:lud...@itcatapult.com] Sent: Thursday, January 06, 2011 11:32 To: user@commons.apache.org Subject: [Lang] Null safe date comparisson Hi! I'm looking for a way to do null safe date comparison. Something like: public static boolean isBefore(Date first, Date second); The method would handle null in an appropriate way. I haven't found any method like that in DateUtils. Is there one somewhere? /Ludwig - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [Lang] Null safe date comparisson
On 6 January 2011 16:31, Ludwig Magnusson lud...@itcatapult.com wrote: Hi! I'm looking for a way to do null safe date comparison. Something like: public static boolean isBefore(Date first, Date second); The method would handle null in an appropriate way. What do you mean by appropriate? Does null mean beginning of time, or end of time, or now, or Y2K or something else? How does one choose the default? I haven't found any method like that in DateUtils. Is there one somewhere? /Ludwig - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
RE: [Lang] Null safe date comparisson
By appropriate I mean that I don't really have a specification for the behavior. All I need is a method that can handle null without throwing an exception. If such methods were to exist, the creators would surely have thought of different ways to solve null arguments and they would probably have solved it in some way if the code standard was good (and apaches usually is). My question was. Does such a method/library exist to anyone's knowledge? If not, perhaps we could build one if people are interested and then we could discuss what behavior is appropriate. /Ludwig From: sebb [mailto:seb...@gmail.com] Sent: den 6 januari 2011 17:39 To: Commons Users List Subject: Re: [Lang] Null safe date comparisson On 6 January 2011 16:31, Ludwig Magnusson lud...@itcatapult.com wrote: Hi! I'm looking for a way to do null safe date comparison. Something like: public static boolean isBefore(Date first, Date second); The method would handle null in an appropriate way. What do you mean by appropriate? Does null mean beginning of time, or end of time, or now, or Y2K or something else? How does one choose the default? I haven't found any method like that in DateUtils. Is there one somewhere? /Ludwig - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org _ No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1191 / Virus Database: 1435/3362 - Release Date: 01/05/11
RE: [Lang] Null safe date comparisson
-Original Message- From: Niall Pemberton [mailto:niall.pember...@gmail.com] Sent: Thursday, January 06, 2011 13:28 To: Commons Users List Subject: Re: [Lang] Null safe date comparisson On Thu, Jan 6, 2011 at 4:38 PM, sebb seb...@gmail.com wrote: On 6 January 2011 16:31, Ludwig Magnusson lud...@itcatapult.com wrote: Hi! I'm looking for a way to do null safe date comparison. Something like: public static boolean isBefore(Date first, Date second); The method would handle null in an appropriate way. What do you mean by appropriate? Does null mean beginning of time, or end of time, or now, or Y2K or something else? How does one choose the default? I was thinking it would be usefule to have a null safe compare method to ObjectUtils - something like public static int compare(Comparable c1, Comparable c2) { return compare(c1, c2, false); } public static int compare(Comparable c1, Comparable c2, boolean nullMoreThan) { int result = 0; if ((c1 == null) || (c2 == null)) { if (nullMoreThan) { result = (c1 == null ? 1 : 0) - (c2 == null ? 1 : 0); } else { result = (c1 == null ? -1 : 0) - (c2 == null ? -1 : 0); } } else { result = c1.compareTo(c2); } return result; } As dates implement comparable it would work for them as well Niall +1 That would be useful. Same for equals? Gary I haven't found any method like that in DateUtils. Is there one somewhere? /Ludwig - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [Lang] Null safe date comparisson
On Thu, Jan 6, 2011 at 6:47 PM, Gary Gregory ggreg...@seagullsoftware.com wrote: -Original Message- From: Niall Pemberton [mailto:niall.pember...@gmail.com] Sent: Thursday, January 06, 2011 13:28 To: Commons Users List Subject: Re: [Lang] Null safe date comparisson On Thu, Jan 6, 2011 at 4:38 PM, sebb seb...@gmail.com wrote: On 6 January 2011 16:31, Ludwig Magnusson lud...@itcatapult.com wrote: Hi! I'm looking for a way to do null safe date comparison. Something like: public static boolean isBefore(Date first, Date second); The method would handle null in an appropriate way. What do you mean by appropriate? Does null mean beginning of time, or end of time, or now, or Y2K or something else? How does one choose the default? I was thinking it would be usefule to have a null safe compare method to ObjectUtils - something like public static int compare(Comparable c1, Comparable c2) { return compare(c1, c2, false); } public static int compare(Comparable c1, Comparable c2, boolean nullMoreThan) { int result = 0; if ((c1 == null) || (c2 == null)) { if (nullMoreThan) { result = (c1 == null ? 1 : 0) - (c2 == null ? 1 : 0); } else { result = (c1 == null ? -1 : 0) - (c2 == null ? -1 : 0); } } else { result = c1.compareTo(c2); } return result; } As dates implement comparable it would work for them as well Niall +1 That would be useful. Same for equals? Its there already! http://tinyurl.com/36e6oes Niall Gary I haven't found any method like that in DateUtils. Is there one somewhere? /Ludwig - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
[cli] help with required parameter without throwing exception
Hi there, My scenario is this: I have one or more required parameters and also have a help and a version parameter (obviously neither of these are required). If the user only passes in a -h or -v (the require parameter is missing) the parser will throw a ParseException and the CommandLine will be null. I want to be able differentiate between a user passing a -h or -v. Is there a solution to this? thanks, Jordan Jordan R. Thompson jor...@thompco.com www.ThompCo.com
[fileupload] ServletFileUpload#isMultipartContent(HttpServletRequest) Always Evals to False
Hi all, Dev Stack: [Java 1.6, Netbeans 6.9, WinXP, Glassfish 3.0.1] I have created a filter to handle file uploads, however the function ServletFileUpload.isMultipartContent(HttpServletRequest) constantly evaluates to false - regardless what I do. Help would be appreciated! Here is the code... Html: h:form enctype=multipart/form-data method=POST accept=application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document prependId=false div id=app_input fieldset ul li label for=DTS Document File:/labelinput type=text id=fileName class=file_input_textbox readonly=readonly / div class=file_input_div input type=button value=Browse... class=file_input_button / input type=file class=file_input_hidden onchange=javascript: document.getElementById('fileName').value = this.value / input id=upload_type name=upload_type type=hidden value=#{cc.attrs.upload_type} / input id=uuid name=uuid type=hidden value=#{cc.attrs.uuid} / /div /li /ul /fieldset /div div id=app_input_nav table cellpadding=0 cellspacing=0 border=0 tr td id=app_input_nav_button align=left style=width:375px p:commandButton actionListener=#{template_New.onClose} update=main_content_region value=Close / /td td id=app_input_nav_button align=right style=width:375px p:commandButton type=button onclick=cdDTSDocUpload.show() value=Next raquo; / /td /tr /table /div /h:form Filter: package Nova.OTM.DTS.Filters; import Novartis.OTM.DTS.UI.CCs.Helpers.FileUploadInfo; import Novartis.OTM.DTS.UI.enumFileUploadType; import java.io.File; import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.UUID; import javax.faces.context.FacesContext; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; @WebFilter(filterName=FileUploadFilter, urlPatterns={/*}) public class FileUploadFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.print(FileUploadFilter invoked.); HttpServletRequest httpRequest = (HttpServletRequest) request; if (ServletFileUpload.isMultipartContent(httpRequest)) { ... Process... // Never enters here! } chain.doFilter(request, response); System.out.print(FileUploadFilter exited.); } Kind regards, Chris
Re: [Lang] Null safe date comparisson
On Thu, Jan 6, 2011 at 6:27 PM, Niall Pemberton niall.pember...@gmail.com wrote: On Thu, Jan 6, 2011 at 4:38 PM, sebb seb...@gmail.com wrote: On 6 January 2011 16:31, Ludwig Magnusson lud...@itcatapult.com wrote: Hi! I'm looking for a way to do null safe date comparison. Something like: public static boolean isBefore(Date first, Date second); The method would handle null in an appropriate way. What do you mean by appropriate? Does null mean beginning of time, or end of time, or now, or Y2K or something else? How does one choose the default? I was thinking it would be usefule to have a null safe compare method to ObjectUtils - something like public static int compare(Comparable c1, Comparable c2) { return compare(c1, c2, false); } public static int compare(Comparable c1, Comparable c2, boolean nullMoreThan) { int result = 0; if ((c1 == null) || (c2 == null)) { if (nullMoreThan) { result = (c1 == null ? 1 : 0) - (c2 == null ? 1 : 0); } else { result = (c1 == null ? -1 : 0) - (c2 == null ? -1 : 0); } } else { result = c1.compareTo(c2); } return result; } As dates implement comparable it would work for them as well I've added this: https://issues.apache.org/jira/browse/LANG-667 http://svn.apache.org/viewvc?view=revisionrevision=1056124 Niall I haven't found any method like that in DateUtils. Is there one somewhere? /Ludwig - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
[COMPRESS]tar 2Gb limit?
Hi While reading the user doc for the commons compress project - http://commons.apache.org/compress/examples.html Under tar section, it says - The tar package does not support the full POSIX tar standard nor more modern GNU extension of said standard. It cannot deal with entries larger than 2 GByte either. I wonder if this is still a limitation or should the limitation changed to 8 GB instead of 2 GB. The reason I am asking is that I saw a link that suggested someone complaining having probs with 10GB - https://issues.apache.org/jira/browse/COMPRESS-16 Thanks much Lin - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org