on 09-18-2008 12:15 PM
Hi,
Is it possible to check whether an RID is valid or nor, ie, the corresponding folder actually exists or not?
I am using th following code to get the RID:
String path = "/KM/"+"SAP IMPLEMENTATION PROJECTS/"+project+rs_prop.getString("folder");
RID rid=RID.getRID(path);
In the next line I want to check whether the RID path actually exists before proceeding further. How can this be done? I tried if(rid!=null). But it didnt work.
Please Help.
Thanks,
Das.
Hi Krishna
U can validate like this
ICollection folder = null;
folder =(ICollection) resourceFactory.getResource(
RID.getRID(properties.getProperty("Folder")),
resourceContext);
if(folder!=null){
}
Regards
BP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bobu,
I have already tried this. But in our case since there are more than 30 folders which doesnt have a valid path, it is taking a lot of time to execute the line:
folder =(ICollection) resourceFactory.getResource(
RID.getRID(properties.getProperty("Folder")),
resourceContext);
Seems it is time consuming to try to get a resource which does not exist. Is there anything that can be done to validate the RID other than trying to access the resource and then checking its value?
Thanks,
Das.
Hi Krishna
Why dont u use resource iterator?
It will give u only valid resources.
and also u can use isCollection() method to validate whether its folder or file
IResourceFactory resourceFactory;
IResourceContext resourceContext;
IUser cmAdminUser = null;
try {
cmAdminUser =
WPUMFactory.getServiceUserFactory().getServiceUser(
"cmadmin_service");
} catch (UserManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
resourceFactory = ResourceFactory.getInstance();
resourceContext = new ResourceContext(cmAdminUser);
ICollection folder = null;
folder = (ICollection) resourceFactory.getResource(
RID.getRID(properties.getProperty("/documents/Folder/")),
resourceContext);
IResourceList resList = null;
try {
resList = folder.getChildren();
} catch (AccessDeniedException e1) {
// TODO Auto-generated catch block
response.write(
"You dont have enough permission!!!<br>"
+ e1.getLocalizedMessage());
e1.printStackTrace();
} catch (ResourceException e1) {
// TODO Auto-generated catch block
response.write(e1.getLocalizedMessage());
e1.printStackTrace();
}
IResourceListIterator iter = resourceList.listIterator();
while (iter.hasNext()) {
IResource tempres = iter.next();
if (!tempres.isCollection()) {
}
}
This may help u
Regards
BP
Hi,
you have to check by getting the Collection under the RID:
bolean exists = false;
try {
IResourceContext rContext = new ResourceContext(curUser);
IResource res = ResourceFactory.getInstance().getResource(rid, rContext);
if(res!=null) {
exists = true;
}
} catch (Exception e) {
//...
}
Romano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.