Skip to Content
1
Former Member
Dec 07, 2011 at 11:19 AM

Get List of user Favorite

22 Views

Hi,

I am trying to get the list of unique user Portal Favorite. The objective is to not use Ajax.

So far I have tried to read the content of the /user/<loginid>/Favorite folder and have got the Favorite name as the link name.

But since user can save any object with any name and the same favorite can be saved twice or more using different name, I would need something unique about the favorites. I have determined that the <navurl> would be a good candidate which I can take to be unique.

Since the favorite(s) are basically links, I want to read the <navurl> of the target objects (which the favorite links point to). Is this possible?

			IUser user=null;
			String userId=request.getUser().getLogonUid();
			try
			{
				
				String resourceURL="";
				user = UMFactory.getUserFactory().getUserByLogonID(userId);
				ResourceContext ctxt = new ResourceContext(user);
				aRid = new RID("/userhome/"+userId+"/Favorites");
				// get an instance of a resource factory
				IResourceFactory aResourceFactory = 	ResourceFactory.getInstance();
				// retrieve a collection with context
				aCollection = (ICollection) aResourceFactory.getResource(aRid, rContext);

				IResourceList resourcelist = aCollection.getChildren();
				favList=new List(resourcelist.size());
				for(int s=0; s<resourcelist.size(); s++)
					{
                                        //get the link names
					IResource resource = resourcelist.get(s);
					//get the navURL of the content link and compare
                                        navURLOfTarget=?;
					favList.add(navURLOfTarge);
					}
				
			} catch (UserManagementException e1) {
				e1.printStackTrace();
			} catch (ResourceException e1) {
				e1.printStackTrace();
			}