The problem is “fileList” parameter is not an array of string as expected but an array of pointer (according to the pipeline’s icon for this field) so the consumer of my webService can’t read it :
As consequence, I have to loop against this array in a Flow in order to
build a real string array. Any way more efficient way to do that ? How
can I get directly an array of string as output of my java service ?
IDataCursor idcPipeline = pipeline.getCursor();
String filterString = null;
if (idcPipeline.first("filter")) {
filterString = (String) idcPipeline.getValue();
}
String directory = null;
if (idcPipeline.first("directory")){
directory = (String) idcPipeline.getValue();
} else {
throw new ServiceException("Directory is null!");
}
String MaxNum = null;
if (idcPipeline.first("MaxFiles")) {
MaxNum = (String) idcPipeline.getValue();
}
Integer FromDate = null;
if (idcPipeline.first("FromDate")) {
FromDate = Integer.valueOf((String) idcPipeline.getValue()).intValue();
}
Integer ToDate = null;
if (idcPipeline.first("ToDate")) {
ToDate = Integer.valueOf((String) idcPipeline.getValue()).intValue();
}
File dir = new File(directory);
if (!dir.exists() || !dir.isDirectory()) {
throw new ServiceException("Error reading inbox directory!");
}
String dir_list[];
if ((filterString != null) && filterString.length() > 0){
JZOOWildCardFilter filter = new JZOOWildCardFilter(filterString);
dir_list = dir.list(filter);
} else {
dir_list = dir.list();
}
Arrays.sort(dir_list, Collections.reverseOrder());
if(FromDate != null){
[B] Vector lst = new Vector();
int i;[/b]
[B] for(i=0; i<dir_list.length; i++){
Integer j = Integer.valueOf(dir_list[i].substring(0,8)).intValue();
if(j >= FromDate && j <= ToDate)
lst.add(dir_list[i]);
}
Object res[] = lst.toArray();
idcPipeline.insertAfter("fileList", res);
return;[/b]
} else if(MaxNum != null){
int i = Integer.valueOf(MaxNum).intValue();
if ( i != 0 && i < dir_list.length){
String ndl[] = new String[ i ];
System.arraycopy(dir_list,0, ndl, 0, i);
idcPipeline.insertAfter("fileList", ndl);
return;
}
}
idcPipeline.insertAfter("fileList", dir_list);
In my case, MaxFiles is empty and I use FromDate and ToDate … I suspect the “Vector” manipulation to convert to pointer I’m not a java expert so it was the most logical way I found to do that.