[Configuration] Bug with XMLConfiguration and getString() ...?!

2008-10-29 Thread Grimm, Markus

Hi guys,

I've got the following problem:
I've got a xml-config-file with that content:

?xml version=1.0 encoding=UTF-8?
config
...
sftp
hostmyhost/host
port22/port
usertestuser/user
pass08,15/pass
/sftp
...
/config

In my application I get the info about pass f.e. like this

String pass = xml_config.getString(sftp.pass);

value of pass: '08' and not '08,15'

I know, that ',' is the default-decollator für list-entries, but I think it 
shouldn't affect the getString()-Method ?!
So it might be a bug?!


Thanks,
Markus

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Configuration] Bug with XMLConfiguration and getString() ...?!

2008-10-29 Thread Oliver Heger

Jörg Schaible schrieb:

Grimm, Markus wrote:

Hi guys,

I've got the following problem:
I've got a xml-config-file with that content:

?xml version=1.0 encoding=UTF-8?
config
...
sftp
hostmyhost/host
port22/port
usertestuser/user
pass08,15/pass
/sftp
...
/config

In my application I get the info about pass f.e. like this

String pass = xml_config.getString(sftp.pass);

value of pass: '08' and not '08,15'

I know, that ',' is the default-decollator für list-entries,
but I think it shouldn't affect the getString()-Method ?!
So it might be a bug?!


Actually, it works as designed. getString() delivers the first list entry. And 
I am sure, that quite everyone will consider this as a bug ... it makes no 
sense to me either :-/

- Jörg


You can disable this behavior by calling
xml_config.setDelimiterParsingDisabled(true);

That said, I fully agree that the default behavior is confusing - I fell 
into this trap more than once myself. For reasons of backwards 
compatibility we cannot change this in the 1.x series. But in a 2.0 
version I am happy to disable delimiter parsing per default.


Oliver

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DigesterPipelineFactory(URL confURL) Is unable to set ruleset

2008-10-29 Thread Pim Tjeertes
Hello,

I'm trying out the Pipeline because the concept intriges me.
Ofcourse I'm starting with a really simple example using the
DigesterPipelineFactory(URL confURL).

But when I do I get a Exception in thread main
java.lang.NoClassDefFoundError: org/apache/commons/digester/RuleSetBase

I think I found out why;
public DigesterPipelineFactory(URL confURL) {
if (confURL == null) throw new
IllegalArgumentException(Configuration file URL may not be
null.);
this.confURL = confURL;

//PipelineRuleSet needs a reference to [EMAIL PROTECTED]
org.apache.commons.digester.RuleSet RuleSet}s
//used to parse the configuration file in case configuration is
split up between multiple
//files.
ruleSets.add(new PipelineRuleSet(ruleSets));
}


I think this is the problem: (Its setting itself to itself instead of the
new file I gave the Digestor)
ruleSets.add(new PipelineRuleSet(ruleSets));
I would have expected something like:
ruleSets.add(new PipelineRuleSet(this.confURL));

Can somebody verify whether my assumption is correct or that I'm doing
something stupid?

Kind regards,
Pim


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



File Upload and request parameters

2008-10-29 Thread sim123

Hello,

I am using FileUpload for multipart request handling, my request
contains three different parameter and one file, I want to read those
parameters first and then read the file as those paramters construct
directory where this file needs to be stored, here is the code

protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException {
   int dir1 = 0 ;
   int dir2 = 0 ;
   int dir3 = 0;
   String uploadLocation = null;
   String fileName = null;
   // parse request
   if(ServletFileUpload.isMultipartContent(request)){
   ServletFileUpload upload = new ServletFileUpload();
   try {
   FileItemIterator iterator =
upload.getItemIterator(request);
   while(iterator.hasNext()){
   FileItemStream item =
iterator.next();
   String name = item.getFieldName();
   InputStream stream =
item.openStream();
   if(item.isFormField()){
   if(dir1.equals(name)){
   dir1 =
Integer.parseInt(Streams.asString(stream));
   }else
if(dir2.equals(name)){
   dir2 =
Integer.parseInt(Streams.asString(stream));
   }else
if(dir3.equals(name)){
   dir3 =
Integer.parseInt(Streams.asString(stream));
   }
   uploadLocation =
server_url+File.separatorChar+tenantId+File.separatorChar+collectionId+File.separatorChar+rowId
;
   new File(uploadLocation).mkdirs();
   }else {
  
System.out.println(File field + name + with file name +
item.getName());
   fileName =
item.getName();
   //perform file
storing operations

   File uploadedFile = new
File(uploadLocation+File.separatorChar+fileName);

   FileOutputStream outputstream = new
FileOutputStream(uploadedFile);
   long number = Streams.copy(testStream,
outputstream, true);
   System.out.println(result from outpoutstream
operation + number);
   }

   }



   } catch (FileUploadException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   } catch(NumberFormatException e){
   e.printStackTrace();
   }
   }

   }


however for some reason FileItem is being read first so I can not
store this file at desired location it is (/usr/sim/0/0/0/filename),
can some one please suggest how can I make sure that I read form item
first then file items.

I do appreciate all the help and time. Thanks

-sim
-- 
View this message in context: 
http://www.nabble.com/File-Upload-and-request-parameters-tp20238511p20238511.html
Sent from the Commons - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File Upload and request parameters

2008-10-29 Thread Martin Cooper
On Wed, Oct 29, 2008 at 5:10 PM, sim123 [EMAIL PROTECTED] wrote:


 Hello,

 I am using FileUpload for multipart request handling, my request
 contains three different parameter and one file, I want to read those
 parameters first and then read the file as those paramters construct
 directory where this file needs to be stored


The order of the fields in the form you are submitting determines the order
in which those fields occur in the byte stream that FileUpload is reading.
If you need the file to be last, you'll need to reorder the fields in your
HTML form.

--
Martin Cooper



 , here is the code

 protected void doPost(HttpServletRequest request, HttpServletResponse
 response) throws ServletException {
   int dir1 = 0 ;
   int dir2 = 0 ;
   int dir3 = 0;
   String uploadLocation = null;
   String fileName = null;
   // parse request
   if(ServletFileUpload.isMultipartContent(request)){
   ServletFileUpload upload = new ServletFileUpload();
   try {
   FileItemIterator iterator =
 upload.getItemIterator(request);
   while(iterator.hasNext()){
   FileItemStream item =
 iterator.next();
   String name = item.getFieldName();
   InputStream stream =
 item.openStream();
   if(item.isFormField()){
   if(dir1.equals(name)){
   dir1 =
 Integer.parseInt(Streams.asString(stream));
   }else
 if(dir2.equals(name)){
   dir2 =
 Integer.parseInt(Streams.asString(stream));
   }else
 if(dir3.equals(name)){
   dir3 =
 Integer.parseInt(Streams.asString(stream));
   }
   uploadLocation =

 server_url+File.separatorChar+tenantId+File.separatorChar+collectionId+File.separatorChar+rowId
 ;
   new File(uploadLocation).mkdirs();
   }else {

 System.out.println(File field + name + with file name +
 item.getName());
   fileName =
 item.getName();
   //perform file
 storing operations

   File uploadedFile = new
 File(uploadLocation+File.separatorChar+fileName);

   FileOutputStream outputstream = new
 FileOutputStream(uploadedFile);
   long number = Streams.copy(testStream,
 outputstream, true);
   System.out.println(result from outpoutstream
 operation + number);
   }

   }



   } catch (FileUploadException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   } catch(NumberFormatException e){
   e.printStackTrace();
   }
   }

   }


 however for some reason FileItem is being read first so I can not
 store this file at desired location it is (/usr/sim/0/0/0/filename),
 can some one please suggest how can I make sure that I read form item
 first then file items.

 I do appreciate all the help and time. Thanks

 -sim
 --
 View this message in context:
 http://www.nabble.com/File-Upload-and-request-parameters-tp20238511p20238511.html
 Sent from the Commons - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: File Upload and request parameters

2008-10-29 Thread sim123

Thank you very much for quick reply Martin, it worked, I appreciate your
help.


sim123 wrote:
 
 Hello,
 
 I am using FileUpload for multipart request handling, my request
 contains three different parameter and one file, I want to read those
 parameters first and then read the file as those paramters construct
 directory where this file needs to be stored, here is the code
 
 protected void doPost(HttpServletRequest request, HttpServletResponse
 response) throws ServletException {
int dir1 = 0 ;
int dir2 = 0 ;
int dir3 = 0;
String uploadLocation = null;
String fileName = null;
// parse request
if(ServletFileUpload.isMultipartContent(request)){
ServletFileUpload upload = new ServletFileUpload();
try {
FileItemIterator iterator =
 upload.getItemIterator(request);
while(iterator.hasNext()){
FileItemStream item =
 iterator.next();
String name = item.getFieldName();
InputStream stream =
 item.openStream();
if(item.isFormField()){
if(dir1.equals(name)){
dir1 =
 Integer.parseInt(Streams.asString(stream));
}else
 if(dir2.equals(name)){
dir2 =
 Integer.parseInt(Streams.asString(stream));
}else
 if(dir3.equals(name)){
dir3 =
 Integer.parseInt(Streams.asString(stream));
}
uploadLocation =
 server_url+File.separatorChar+tenantId+File.separatorChar+collectionId+File.separatorChar+rowId
 ;
new File(uploadLocation).mkdirs();
}else {
   
 System.out.println(File field + name + with file name +
 item.getName());
fileName =
 item.getName();
//perform file
 storing operations
 
File uploadedFile = new
 File(uploadLocation+File.separatorChar+fileName);
 
FileOutputStream outputstream = new
 FileOutputStream(uploadedFile);
long number = Streams.copy(testStream,
 outputstream, true);
System.out.println(result from
 outpoutstream operation + number);
}
 
}
 
 
 
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch(NumberFormatException e){
e.printStackTrace();
}
}
 
}
 
 
 however for some reason FileItem is being read first so I can not
 store this file at desired location it is (/usr/sim/0/0/0/filename),
 can some one please suggest how can I make sure that I read form item
 first then file items.
 
 I do appreciate all the help and time. Thanks
 
 -sim
 

-- 
View this message in context: 
http://www.nabble.com/File-Upload-and-request-parameters-tp20238511p20239931.html
Sent from the Commons - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]