[opencms-dev] Code: File Exists?

Jens Rickhoff jens at visualteam.de
Fri Jul 25 17:10:34 CEST 2003


Hi Tim,

I solved it by trying to access a property of the resource (i.e.
file/folder). If that
method throws a CmsException, I know the file does not exist (or that any
other
serious exception occured). It works fine for me, here's the JSP snippet:

  private boolean exist(CmsJspActionElement cms, String resource) {
    boolean result = true;
    try {
      String test = cms.getCmsObject().readProperty(resource, "title",
false, "title");
    } catch (com.opencms.core.CmsException e) {
      result = false;
    }
    return result;
  }

However, I'd prefer a "real" CmsObject.resourceExists() method...

Hope that helps,

Jens

----- Original Message -----
From: Tim Mundy
To: opencms-dev at opencms.org
Sent: Wednesday, July 16, 2003 11:46 PM
Subject: [opencms-dev] Code: File Exists?


Hello List,

In a module that I'm developing, I'm trying to confirm that a path (string)
points to an existing file. I can't seem to find a method that will return a
boolean if a file exists or not. Does anyone know of a method in OpenCms
that would do the job? I'm sure someone else has had this issue come up
before.

Thanks,

Tim Mundy
Software Developer
E-mail: Tim.Mundy at babelfish.com
Phone: 780.944-9964
Fax: 780.432.5700

The Babel Fish Corporation
Where the World comes to Communicate!!



This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure. If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------
Le présent message électronique (y compris les pièces qui y sont annexées,
le cas échéant) s'adresse au destinataire indiqué et peut contenir des
renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le
destinataire de ce document, nous vous signalons qu'il est strictement
interdit de le diffuser, de le distribuer ou de le reproduire. Si ce
message vous a été transmis par erreur, veuillez en informer l'expéditeur
et le supprimer immédiatement.
www.babelfish.com




More information about the opencms-dev mailing list