cancel
Showing results for 
Search instead for 
Did you mean: 

Checking whether a resource exists within collection

Former Member
0 Kudos

Hi All,

I'd like to check whether a Resource with a certain name exists within a Collection.

I can do this by using a IResourceList and a IResourceListIterator but does anyone know a more direct way to do this check??

I will be gratefull!

Kind regards,

Maarten

Accepted Solutions (0)

Answers (1)

Answers (1)

michael3
Advisor
Advisor
0 Kudos

Hi Maarten,

you are able to check the existence of a Resource with the ResourceFactory. ResourceFactory.getInstance().checkExistence(RID, IResourceContext).

This method return true in case of a Resource with the given RID already exists.

Regards,

Michael

Former Member
0 Kudos

As Michal said, you can do that using checkExistence(). On the other hand, almost every case where I have seen it used was an instance of bad programming, so I really have to ask: "why do you think you need checking at all"?

For instance:

- for accessing a resource, don't check existence, but just do getResource and properly handle null response,

- when overwriting a resource, just rely on the frameworks overwrite and exception handling.

And so on...