cancel
Showing results for 
Search instead for 
Did you mean: 

Get Subfodler contents

Former Member
0 Kudos

Hi All,

I am using the following code to access the contents in a folder:

RID rid = RID.getRID(path);

ICollection currentFolder = null;

currentFolder =(ICollection) ResourceFactory.getInstance().getResource(rid,irCtx);

IResourceList children = null;

children = currentFolder.getChildren();

But this gives only the current folder contents, not its subfolder contents.

How can I get the subfolder contents also?

Thanks and Regards,

Ajay.

Accepted Solutions (0)

Answers (3)

Answers (3)

nikhil_bose
Active Contributor
0 Kudos

yeah. It gives current only. you have to again create/set RID for each children you got.

actually RID points to one level, it gets all the elements including files and folders. If you want only folders you have to restrict them say if it is a Collection represents a folder.

And for each folder, you set the RID and do the same steps to get the inner folders/files.

refer Mandeep's code and you can use it accordingly.

nikhil

Former Member
0 Kudos

Hi,

you have to give the access permission for that, suppose one folder name XMLFILE is there inside that department folder is there then you have to give path upto XMLFILE with permission for that to the user and need to attach the sub folder as a property for the user.

Same scenario was there for me what we have done at that time is like at the time of user creation you have to specify the subfolder name as a one of property. And to get the subfolder as property you have to touch the config tool to add extra property/ attribute to the UME..

You have to search blog for Adding attribute to UME or UME changes.

Hope that may help you.

Regards,

Deepak

Former Member
0 Kudos

Hi

In your current path you are able to access root folder.

Give this path a name prefix

Eg.

String prefix = "/documents/Public Documents/Store Data/";

Suppose you are displaying data in table. In leadaselect action specify the path of subfolders

Eg.

String postfix = "/Reports/Broadcast_Reports/";

And then concatenate Prefix and postfix string to get full path to subfolder.

Refer this block of code


 public void getAllStores( )
  {
    //@@begin getAllStores()
	String prefix = "/documents/Public Documents/Store Data/";

	wdContext.nodeStoreTable().invalidate();
	IPrivateDocManageView.IStoreTableElement contentElement;
	try {
		IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
		com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

		com.sapportals.portal.security.usermanagement.IUser ep5user =
					WPUMFactory.getUserFactory().getEP5User(sapUser);

		IResourceContext resourceontext = new ResourceContext(ep5user);

		IResourceFactory resourcefactory =
					com.sapportals.wcm.repository.ResourceFactory.getInstance();

		RID pathRID = RID.getRID(prefix);

		com.sapportals.wcm.repository.IResource resource =
					resourcefactory.getResource(pathRID, resourceontext);

		ICollection collection = (ICollection) resource;

		IResourceList resoucelist = collection.getChildren();

		IResourceListIterator resourelistiterator =
					resoucelist.listIterator();

		while (resourelistiterator.hasNext()) {
			String store = null;
			com.sapportals.wcm.repository.IResource tempresouce =
						resourelistiterator.next();

			if (tempresouce.getName().equals(
					wdContext.currentFilterDataElement().getFromStore())) {
						
				contentElement = wdContext.createStoreTableElement();
				contentElement.setObjectName(
							prefix + tempresouce.getName());
				wdContext.nodeStoreTable().addElement(contentElement);
				tempresouce = resourelistiterator.next();
				while (!tempresouce.getName().equals(
						wdContext.currentFilterDataElement().getToStore())) {
							
					contentElement = wdContext.createStoreTableElement();
					contentElement.setObjectName(
								prefix + tempresouce.getName());
					wdContext.nodeStoreTable().addElement(contentElement);
					tempresouce = resourelistiterator.next();
				}
				tempresouce = resourelistiterator.next();
				break;

			}

		} // while iterate

	} catch (Exception e) {
				e.printStackTrace();
	}
    getFolderList();
    //@@end
  }

  //@@begin javadoc:getFolderList()
  /** Declared method. */
  //@@end
  public void getFolderList( )
  {
    //@@begin getFolderList()
	String postfix = "/Reports/Broadcast_Reports/";
	IPrivateDocManageView.IFoldersElement folder;
	wdContext.nodeFolders().invalidate();
	try {
		IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
		com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

		com.sapportals.portal.security.usermanagement.IUser ep5user =
					WPUMFactory.getUserFactory().getEP5User(sapUser);

		IResourceContext resourceontext = new ResourceContext(ep5user);

		IResourceFactory resourcefactory =
					com.sapportals.wcm.repository.ResourceFactory.getInstance();
			
		for(int i=0; i<wdContext.nodeStoreTable().size(); i++) {
			String prefix = wdContext.nodeStoreTable().getStoreTableElementAt(i).getObjectName();
			RID pathRID = RID.getRID(prefix+
								postfix);
			

			com.sapportals.wcm.repository.IResource resource =
					resourcefactory.getResource(pathRID, resourceontext);

			ICollection collection = (ICollection) resource;

			IResourceList resoucelist = collection.getChildren();

			IResourceListIterator resourelistiterator =
					resoucelist.listIterator();
			IResource tempresource = null; 
			while (resourelistiterator.hasNext()) {
				tempresource = resourelistiterator.next();
				folder = wdContext.createFoldersElement();
				folder.setFolder(prefix+postfix+tempresource.getName()+"/");
				wdContext.nodeFolders().addElement(folder);
				
			}
		}//for size
	} catch (Exception e) {
	}
	getFiles();
    //@@end
  }

Mandeep Virk