[commons-vfs] accessing exploded WAR content at runtime
What'd be a good way to get access to a deployed WAR's content using VFS? Right now, I'm doing: servletContext.getRealPath("") + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + path; And this quite inconvenient to rely on servletContext since I don't have access to it in lower layers, not speaking about the test, which in isolation don't even run in a ServletContext. I don't see any other way than using the local file system. But if I do so, I'll get an absolute path, not a relative to the deployment folder one. Any idea? -- View this message in context: http://www.nabble.com/-commons-vfs--accessing-exploded-WAR-content-at-runtime-tp25971229p25971229.html Sent from the Commons - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
math KMeansPlusPlusClusterer Failing unittest
Hi all, I have a problem with KMeansPlusPlusClusterer in the trunk. See below for the unittest. Am I doing something wrong here or is there a bug? Kind Regards, Erik @Test public void testPerformClusterAnalysis2() { KMeansPlusPlusClusterer transformer = new KMeansPlusPlusClusterer(new Random(1746432956321l)); EuclideanIntegerPoint[] points = new EuclideanIntegerPoint[] { new EuclideanIntegerPoint(new int[] { 1959,325100 }), new EuclideanIntegerPoint(new int[] { 1960,373200 }), }; List> clusters = transformer.cluster(Arrays.asList(points), 1, 1); assertEquals(1, clusters.size()); }
[SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions
Dear Rahul, dear all, the result value of an XPath-selection is limited to an XPathConstants.NODE as of XPathEvaluator#evalLocation(Context, String). Having a root element is reasonable for assignments etc. but I'd need to select a NodeSet based on the XPath predicates first (and then wrap it evt. into a result element). My use case resembles the form interpretation algorithm (FIA) of VXML: the of a state is updated continually by the payload of arriving events (inputs). There is an UI (form) which reflects the current datamodel and on each change the remaining "empty" items should be selected and presented for completion: ... Although the XPathEvaluator accpets XPathFunctions as constructor arguments, there are no public accessors to the namespace and variable contexts. Could you please provide an exmaple how to accomplish access to a data NodeSet using an XPathFunction or an other way ? Many thanks ! Jaro -- Jaroslav Pullmann Web Compliance Center - Fraunhofer FIT Schloss Birlinghoven, D-53757 Sankt Augustin, Germany Phone: +49-2241-142623Fax: +49-2241-142065 - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: math KMeansPlusPlusClusterer Failing unittest
Can you say more about exactly what problem you are having? On Tue, Oct 20, 2009 at 2:54 AM, VanIngen, Erik (FIES) < erik.vanin...@fao.org> wrote: > Hi all, > > I have a problem with KMeansPlusPlusClusterer in the trunk. See below for > the > unittest. Am I doing something wrong here or is there a bug? > > Kind Regards, > Erik > > > > > @Test >public void testPerformClusterAnalysis2() { >KMeansPlusPlusClusterer transformer = >new KMeansPlusPlusClusterer(new > Random(1746432956321l)); >EuclideanIntegerPoint[] points = new EuclideanIntegerPoint[] { >new EuclideanIntegerPoint(new int[] { 1959,325100 > }), >new EuclideanIntegerPoint(new int[] { 1960,373200 > }), >}; >List> clusters = >transformer.cluster(Arrays.asList(points), 1, 1); >assertEquals(1, clusters.size()); > >} > > -- Ted Dunning, CTO DeepDyve
RE: math KMeansPlusPlusClusterer Failing unittest
can we see the import statement for Test? thanks, Martin __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > From: ted.dunn...@gmail.com > Date: Tue, 20 Oct 2009 09:50:21 -0700 > Subject: Re: math KMeansPlusPlusClusterer Failing unittest > To: user@commons.apache.org > > Can you say more about exactly what problem you are having? > > On Tue, Oct 20, 2009 at 2:54 AM, VanIngen, Erik (FIES) < > erik.vanin...@fao.org> wrote: > > > Hi all, > > > > I have a problem with KMeansPlusPlusClusterer in the trunk. See below for > > the > > unittest. Am I doing something wrong here or is there a bug? > > > > Kind Regards, > > Erik > > > > > > > > > > @Test > >public void testPerformClusterAnalysis2() { > >KMeansPlusPlusClusterer transformer = > >new KMeansPlusPlusClusterer(new > > Random(1746432956321l)); > >EuclideanIntegerPoint[] points = new EuclideanIntegerPoint[] { > >new EuclideanIntegerPoint(new int[] { 1959,325100 > > }), > >new EuclideanIntegerPoint(new int[] { 1960,373200 > > }), > >}; > >List> clusters = > >transformer.cluster(Arrays.asList(points), 1, 1); > >assertEquals(1, clusters.size()); > > > >} > > > > > > > -- > Ted Dunning, CTO > DeepDyve _ Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. http://clk.atdmt.com/GBL/go/171222985/direct/01/
Re: FileCleanerCleanup question
Hi, is anyone on this list familiar with commons-io / commons-fileupload? If not, is there somewhere else I should be asking questions? I still have the issue indicated below, and I have an additional question. When you parse the request... => final List items = (List) upload.parseRequest(request); commons-fileupload also generates files for form field items (e.g. text box values). This is an undesired side effect. I want it to generate a file for the actual file that is uploaded, but not the form fields. Is there a way to control that? Thanks in advance, Davis On Mon, Oct 19, 2009 at 12:06 PM, Davis Ford wrote: > Hi, it is my understanding from the commons-io javadoc, that if you create > a FileCleanerCleanup it will remove files in a directory once the reference > to the File is GC'd. > > Given that, I'm using commons-fileupload, and I set the listener in web.xml > as: > > > > org.apache.commons.fileupload.servlet.FileCleanerCleanup > > > In my servlet, I have this: > > private static FileCleaningTracker tracker; > > @Override > protected void initServletContext(ServletContext servletContext) { > super.initServletContext(servletContext); > tracker = > FileCleanerCleanup.getFileCleaningTracker(servletContext); > } > > ...and in my method that accepts a file upload, I add the > FileCleanerCleanup: > > final DiskFileItemFactory factory = new DiskFileItemFactory(0, tempDir); > factory.setFileCleaningTracker(tracker); > final ServletFileUpload upload = new ServletFileUpload(factory); > > My files are uploaded and stored in the temp directory as expected. In the > processing of a file upload, I store the FileItem object in the session as > an attribute. Now, if the session expires, I expect the attribute to be > GC'd and as a result, the FileCleanerCleanup would go and cleanup the > directory, but it does not. > > Can anyone tell me what I may be doing wrong? > > Thanks in advance, > Davis > > > -- Zeno Consulting, Inc. home: http://www.zenoconsulting.biz blog: http://zenoconsulting.wikidot.com p: 248.894.4922 f: 313.884.2977
Re: [JCI] Complication Error
Hi, Is the JspGenerator mean to be production ready? As I don't believe it working correctly. Given the simple.jsp it generates the simple.java which just writes everything to the http response. simple.jsp <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="javax.jcr.Node" %> http://www.w3.org/TR/html4/loose.dtd";> <% Node currentNode = (Node)request.getAttribute("currentNode"); %> Simple jsp page Place your content here simple.java import java.io.PrintWriter; import java.io.IOException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.ServletException; public class simple extends HttpServlet { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final PrintWriter out = response.getWriter(); out.write("<%@ page contentType=\"text/html;charset=UTF-8\" language=\"java\" %>"); out.write("<%@ page import=\"javax.jcr.Node\" %>"); out.write("http://www.w3.org/TR/html4/loose.dtd\";>"); out.write(""); out.write("<%"); out.write("Node currentNode = (Node)request.getAttribute(\"currentNode\");"); out.write("%>"); out.write(""); out.write(""); out.write(" Simple jsp page"); out.write(" Place your content here"); out.write(""); out.close(); out.flush(); } } 2009/10/19 Ben Short : > Ah I think I have cracked it... > > Changed > > ResourceReader resourceReader = new ResourceReader() { > public byte[] getBytes(String s) { > return jspSource; > } > > public boolean isAvailable(String s) { > return true; > } > }; > > > to > > ResourceReader resourceReader = new ResourceReader() { > public byte[] getBytes(String s) { > return jspSource; > } > > public boolean isAvailable(String s) { > return "simple.jsp".equals(s); > } > }; > > Thanks. > > Ben > > 2009/10/19 Ben Short : >> lol sorry that's the object id isn't it. >> >> Then I have no more information to give you at present. >> >> 2009/10/19 Torsten Curdt : >>> http://commons.apache.org/jci/xref/org/apache/commons/jci/compilers/EclipseCompilationProblem.html >>> >>> I count only 79 lines :) >>> >>> On Mon, Oct 19, 2009 at 19:09, Ben Short wrote: Hi Torsten, The CompilationResult reports the problem on line 1747 of the following file org.apache.commons.jci.compilers.EclipseCompilationProblem Regards Ben Short 2009/10/19 Torsten Curdt : > Do you fail to compile or fail to load the page created? > Looks like a class loading problem. > > cheers > -- > Torsten > > - > 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 >>> >>> >> > - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [SCXML] Retrieving a (wrapped) NodeSet for an XPath / user defined XPath functions
On Tue, Oct 20, 2009 at 10:42 AM, Jaroslav Pullmann wrote: > > Dear Rahul, dear all, > > the result value of an XPath-selection is limited to an XPathConstants.NODE > as of XPathEvaluator#evalLocation(Context, String). Having a root element > is > reasonable for assignments etc. but I'd need to select a NodeSet based on > the > XPath predicates first (and then wrap it evt. into a result element). > Right, the XPathEvaluator only supports types that it needs to fulfill its contracts (generic expression, boolean or node result). Executing an operation or task with arbitrary semantics requires either extension functions or custom actions. > My use case resembles the form interpretation algorithm (FIA) of VXML: the > of a state is updated continually by the payload of arriving > events > (inputs). There is an UI (form) which reflects the current datamodel and on > each > change the remaining "empty" items should be selected and presented > for > completion: > > > > ... > > > > > > > > location="$statedata/datait...@id = $_eventdata/data/@id]"/> > > > location="$empty" /> > > > > > > /> > > > > > Although the XPathEvaluator accpets XPathFunctions as constructor > arguments, > there are no public accessors to the namespace and variable contexts. Could > you > please provide an exmaple how to accomplish access to a data NodeSet using > an > XPathFunction or an other way ? > You're correct that the namespace and variable contexts are not trivially exposed to the functions and that is also sort of a thumb rule on whether to use a function or an action. I'd recommend using a custom action that captures these specific semantics aiding behavior akin to the FIA, rather than having it happen as a side-effect of a function invocation in an assignment expression. IOW, if you have an action to the effect of the following that has the behavior above: it (a) offers you access to the namespace and variable contexts, and (b) models this separately from since it is indeed a composite operation. -Rahul > Many thanks ! > Jaro > > > > -- > Jaroslav Pullmann > Web Compliance Center - Fraunhofer FIT > Schloss Birlinghoven, D-53757 Sankt Augustin, Germany > Phone: +49-2241-142623 Fax: +49-2241-142065 > - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: monitor file update help
Thanks for the reply :) I had a look the sites before I post the question. So far I have this code, but when there's an event for the folder it doesn't trigger the monitor. I would like to monitor a folder for any event, such as file creation, delete, or update. Any idea what did I do wrong? [CODE] public void watchFile() { FileSystemManager fsManager; try { fsManager = VFS.getManager(); FileObject sourceFile = fsManager.resolveFile("ftp://username:passw...@host/myfolder"; ,authenticate()); FileSystem fs = sourceFile.getFileSystem(); DefaultFileMonitor monitor = new DefaultFileMonitor(new FileListener(){ @Override public void fileChanged(FileChangeEvent event) throws Exception { System.out.println("File Changed" + event.getFile().getName().getBaseName()); } @Override public void fileCreated(FileChangeEvent event) throws Exception { System.out.println("File Changed" + event.getFile().getName().getBaseName()); } @Override public void fileDeleted(FileChangeEvent event) throws Exception { System.out.println("File Changed" + event.getFile().getName().getBaseName()); } }); monitor.addFile(sourceFile); monitor.start(); } catch (FileSystemException e) { e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } [/CODE] From: Anand Shankar To: Commons Users List Sent: Tue, 20 October, 2009 2:54:31 PM Subject: Re: monitor file update help Hi I am giving some links and hope will be helpful for you. http://commons.apache.org/vfs/ http://ant.apache.org/ivy/history/latest-milestone/resolver/vfs.html Thanks! Anand Shankar On Tue, Oct 20, 2009 at 8:33 AM, geek.shrek wrote: > Hi, > > I would like to monitor a file creation, file update in particular folder. > I'm not sure how can I achieve this using VFS apache version 1.0 > > Can someone please point me to an example or tutorial. > > Much appreciate. > > Thanks, > > > > > > __ > Get more done like never before with Yahoo!7 Mail. > Learn more: http://au.overview.mail.yahoo.com/ > -- Anand Shankar __ Get more done like never before with Yahoo!7 Mail. Learn more: http://au.overview.mail.yahoo.com/
Re: FileCleanerCleanup question
Hi You can get both form fields as well as non form fields ( file fields) by commons file upload and store where you want. I am giving a complete code for file upload. Hope it will be helpful for you. import java.io.*; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import java.sql.*; import java.util.*; import org.apache.commons.fileupload.*; import org.apache.commons.fileupload.servlet.*; import org.apache.commons.fileupload.disk.*; public class MyUpload extends HttpServlet { public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); if(ServletFileUpload.isMultipartContent(request)) { FileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload=new ServletFileUpload(factory); List fileItem=upload.parseRequest(request); Iterator itr= fileItem.iterator(); while(itr.hasNext()) { FileItem fi=(FileItem)itr.next(); if(fi.isFormField()) { out.print(fi.getFieldName() + fi.getString()); } else { String filename=fi.getName(); InputStream is=fi.getInputStream(); size=is.available(); conttype=fi.getContentType(); // thus you can get file as a InputStream. Now, You can save it in database or in a dir as you wish. } } } } Thanks! Anand Shankar t) upload.parseRequest(request); > > commons-fileupload also generates files for form field items (e.g. text box > values). This is an undesired side effect. I want it to generate a file > for the actual file that is uploaded, but not the form fields. Is there a > way to control that? > > Thanks in advance, > Davis > > > On Mon, Oct 19, 2009 at 12:06 PM, Davis Ford > wrote: > > > Hi, it is my understanding from the commons-io javadoc, that if you > create > > a FileCleanerCleanup it will remove files in a directory once the > reference > > to the File is GC'd. > > > > Given that, I'm using commons-fileupload, and I set the listener in > web.xml > > as: > > > > > > > > > org.apache.commons.fileupload.servlet.FileCleanerCleanup > > > > > > In my servlet, I have this: > > > > private static FileCleaningTracker tracker; > > > > @Override > > protected void initServletContext(ServletContext servletContext) { > > super.initServletContext(servletContext); > > tracker = > > FileCleanerCleanup.getFileCleaningTracker(servletContext); > > } > > > > ...and in my method that accepts a file upload, I add the > > FileCleanerCleanup: > > > > final DiskFileItemFactory factory = new DiskFileItemFactory(0, tempDir); > > factory.setFileCleaningTracker(tracker); > > final ServletFileUpload upload = new ServletFileUpload(factory); > > > > My files are uploaded and stored in the temp directory as expected. In > the > > processing of a file upload, I store the FileItem object in the session > as > > an attribute. Now, if the session expires, I expect the attribute to be > > GC'd and as a result, the FileCleanerCleanup would go and cleanup the > > directory, but it does not. > > > > Can anyone tell me what I may be doing wrong? > > > > Thanks in advance, > > Davis > > > > > > > > > -- > Zeno Consulting, Inc. > home: http://www.zenoconsulting.biz > blog: http://zenoconsulting.wikidot.com > p: 248.894.4922 > f: 313.884.2977 > -- Anand Shankar
Re: FileCleanerCleanup question
On Tue, Oct 20, 2009 at 10:22 AM, Davis Ford wrote: > Hi, is anyone on this list familiar with commons-io / commons-fileupload? > > If not, is there somewhere else I should be asking questions? > > I still have the issue indicated below, and I have an additional question. > > When you parse the request... => > > final List items = (List) upload.parseRequest(request); > > commons-fileupload also generates files for form field items (e.g. text box > values). This is an undesired side effect. I want it to generate a file > for the actual file that is uploaded, but not the form fields. Is there a > way to control that? Whether a file is created depends on whether the size is over the (customisable) threshold. Below the threshold, the item's content will be kept in memory; above the threshold, it will be written to disk. If that's not flexible enough for your needs, you can provide your own FileItem class and your own factory to instantiate it. -- Martin Cooper > > Thanks in advance, > Davis > > > On Mon, Oct 19, 2009 at 12:06 PM, Davis Ford > wrote: > >> Hi, it is my understanding from the commons-io javadoc, that if you create >> a FileCleanerCleanup it will remove files in a directory once the reference >> to the File is GC'd. >> >> Given that, I'm using commons-fileupload, and I set the listener in web.xml >> as: >> >> >> >> org.apache.commons.fileupload.servlet.FileCleanerCleanup >> >> >> In my servlet, I have this: >> >> private static FileCleaningTracker tracker; >> >> @Override >> protected void initServletContext(ServletContext servletContext) { >> super.initServletContext(servletContext); >> tracker = >> FileCleanerCleanup.getFileCleaningTracker(servletContext); >> } >> >> ...and in my method that accepts a file upload, I add the >> FileCleanerCleanup: >> >> final DiskFileItemFactory factory = new DiskFileItemFactory(0, tempDir); >> factory.setFileCleaningTracker(tracker); >> final ServletFileUpload upload = new ServletFileUpload(factory); >> >> My files are uploaded and stored in the temp directory as expected. In the >> processing of a file upload, I store the FileItem object in the session as >> an attribute. Now, if the session expires, I expect the attribute to be >> GC'd and as a result, the FileCleanerCleanup would go and cleanup the >> directory, but it does not. >> >> Can anyone tell me what I may be doing wrong? >> >> Thanks in advance, >> Davis >> >> >> > > > -- > Zeno Consulting, Inc. > home: http://www.zenoconsulting.biz > blog: http://zenoconsulting.wikidot.com > p: 248.894.4922 > f: 313.884.2977 > - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org