Re : Problem with bad fileName with a + =>%20 not %2B

Stephane huette <[email protected]> Tue, 3 Jul 2007 14:21:35 +0000 (GMT)
Newsgroups gmane.comp.jakarta.slide.user
Message-ID <[email protected]>
Hi again,=0A=0AOk, i've a start of solution to list the good filename.=0A=
=0AURLCodec urlCodec =3D new URLCodec();=0A=0A........=0A=0A    WebdavResou=
rce[] tabWDresources =3D  wdr.listWebdavResources();=0A   =0A    long wdLen=
gth =3D tabWDresources.length;=0A    WebdavResource currentResource =3D nul=
l;=0A    Element elt =3D null;=0A    for (int i =3D 0; i < wdLength; i++) =
=0A    {=0A           ......=0A            elt.setName(urlCodec.encode(curr=
entResource.getDisplayName()));=0A           .......=0A     }=0A=0Abut now =
il i want to see files in folder "lost+found"=0Aso....=0AurlWebDavComplete =
=3D http://SERVER:PORT/folder1/temp/lost+found=0A=0Athat's doens't work =3D=
> 404 Not found.=0AI tried to : urlWebDavComplete =3D "http://SERVER:PORT/f=
older1/temp/" + urlCodec.decode("lost+found");=0A=0Abut nothing....=0A=0Ath=
x for your help.=0A=0A----- Message d'origine ----=0ADe : Stephane huette <=
[email protected]>=0A=C0 : [email protected]=0AEnvoy=E9 le :=
 Mardi, 3 Juillet 2007, 13h24mn 14s=0AObjet : Problem with bad fileName wit=
h a + =3D>%20 not %2B=0A=0A=0AHi all,=0AI'm developping a Web application w=
ith Slide 2.0, to list, to download, to upload, to edit files.=0AI've a pro=
blem to list files when its name is with a "+". Exemple 'lost+found' on uni=
x system.=0A=0AWebdavResource[] tabWDresources =3D  wdr.listWebdavResources=
(); =0A=0AI  debug it and I saw that the displayedName was "lost%20found". =
=0A=0ABut %20 is like a space %2B is "+" so the dispayedName should be "los=
t%2Bfound".=0A=0AAnd i create a new folder "Shu+name", and the same problem=
 happens.=0A=0AI don't know how i can resolve it.=0A=0Athis code is How I l=
ist the filname from a folder :=0A=0AurlWebDavComplete =3D http://SERVER:PO=
RT/folder1/temp=0A=0Apublic List listerElements(String urlWebDavComplete) t=
hrows ServicesException, Exception=0A{=0A  logger.debug("<listerElements>")=
;=0A  WebdavResource wdr =3D null;=0A  List listeElements =3D new ArrayList=
();=0A  =0A  try =0A  {=0A   HttpURL hrl =3D new HttpURL(urlWebDavComplete)=
;=0A   hrl.setUserinfo(getLoginWDServer(), getPwdWDServer());=0A   wdr =3D =
new WebdavResource(hrl);=0A   =0A   if (wdr !=3D null) =0A   {=0A    //Expl=
orer un sous dossier =0A=0A    // Here the list is filled with bad name=0A =
   // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv=0A    =0A    WebdavResource[] tabWDres=
ources =3D  wdr.listWebdavResources();=0A   =0A    long wdLength =3D tabWDr=
esources.length;=0A    WebdavResource currentResource =3D null;=0A    Eleme=
nt elt =3D null;=0A    for (int i =3D 0; i < wdLength; i++) =0A    {=0A    =
 //.......create my list of fileName........=0A    }=0A   }=0A  } =0A  catc=
h (URIException e) =0A  {=0A   if (wdr !=3D null)=0A    logger.error("liste=
rElements :"+urlWebDavComplete+" =3D=3D> ERREUR HTTP :"+wdr.getStatusCode()=
);=0A   else=0A    logger.error(e.getMessage(),e);=0A   throw new ServicesE=
xception(MSG_LOGGER +e.getMessage(),e);=0A  } =0A  catch (HttpException e) =
=0A  {=0A   String msgErreur =3D e.getMessage();=0A   if (wdr !=3D null)=0A=
    logger.error("listerElements :"+urlWebDavComplete+" =3D=3D> ERREUR HTTP=
 :"+wdr.getStatusCode());=0A   else=0A   {=0A    if (msgErreur =3D=3D null)=
=0A    {=0A     msgErreur =3D String.valueOf(e.getReasonCode());=0A    }=0A=
    logger.error(msgErreur, e);=0A   }=0A    =0A   throw new ServicesExcept=
ion(MSG_LOGGER +msgErreur,e);=0A  } =0A  catch (IOException e) =0A  {=0A   =
if (wdr !=3D null)=0A    logger.error("listerElements :"+urlWebDavComplete+=
" =3D=3D> ERREUR HTTP :"+wdr.getStatusCode());=0A   else=0A    logger.error=
(e.getMessage(),e);=0A   throw new ServicesException(MSG_LOGGER +e.getMessa=
ge(),e);=0A  }=0A  catch (Exception e) =0A  {=0A   String msg;=0A   if (wdr=
 !=3D null)=0A   {=0A    msg =3D wdr.getStatusMessage();=0A    logger.error=
("listerElements :"+urlWebDavComplete+" =3D=3D> ERREUR HTTP :"+wdr.getStatu=
sCode());=0A   }=0A   else=0A   {=0A    msg =3D e.getMessage();=0A    logge=
r.error(msg,e);=0A   }=0A   throw new ServicesException(MSG_LOGGER + msg,e)=
;=0A  }=0A  finally=0A  {=0A   if (wdr !=3D null)=0A   {=0A    try =0A    {=
=0A     wdr.close();=0A    } =0A    catch (IOException e) =0A    {=0A     l=
ogger.error(e.getMessage(),e);=0A    }=0A   }=0A  }=0A  =0A  Collections.so=
rt(listeElements, new TrierElementsParNom());=0A  logger.debug("<listerElem=
ents/>");=0A  return listeElements;=0A}=0A=0AThx,=0A=0AStephane=0A=0A=0A   =
   ________________________________________________________________________=
_____ =0ANe gardez plus qu'une seule adresse mail ! Copiez vos mails vers Y=
ahoo! Mail =0A=0A----------------------------------------------------------=
-----------=0ATo unsubscribe, e-mail: [email protected]=
.org=0AFor additional commands, e-mail: [email protected]=
=0A=0A=0A=09=0A=0A=09=0A=09=09=0A__________________________________________=
_________________________________ =0AD=E9couvrez une nouvelle fa=E7on d'obt=
enir des r=E9ponses =E0 toutes vos questions ! =0AProfitez des connaissance=
s, des opinions et des exp=E9riences des internautes sur Yahoo! Questions/R=
=E9ponses =0Ahttp://fr.answers.yahoo.com