how to create a folder inside a folder in document library?

sudheer kumar, modified 12 Years ago. Junior Member Posts: 54 Join Date: 9/25/13 Recent Posts
my Requirement is:
Adding Parent folders, Child folders and Their files to Document and Library from Particular location.

Case-1: If Folder is already exists then get that id and add file

( Here I am using
addFileEntry(repositoryId, folderId,sourceFileName, mimeType, title, description, changeLog, is, size, serviceContext) of DLAppServiceUtil class ).

Case-2: If Folder is not exits add folder then add file

(Here I am using for adding folder
addFolder() method of DLAppServiceUtil class)
thumbnail
Pankaj Kathiriya, modified 12 Years ago. Liferay Master Posts: 722 Join Date: 8/5/10 Recent Posts
This is Out of Box functionality available , once you click on any folder it will show option to add Subfolder in it.
sudheer kumar, modified 12 Years ago. Junior Member Posts: 54 Join Date: 9/25/13 Recent Posts
means liferay does not provide this type of functionality?
Hi sudheer,

Which version of Liferay you are using? I can add Subfolder by clicking on the Action button in Document Library portlet in 6.0.12 and I can add subfolder as well in 6.1.20 but there isn't document library portlet.

Best,
Anna
sudheer kumar, modified 12 Years ago. Junior Member Posts: 54 Join Date: 9/25/13 Recent Posts
iam using liferay 6.1
thumbnail
Krzysztof Gołębiowski, modified 12 Years ago. Liferay Master Posts: 549 Join Date: 6/25/11 Recent Posts
Use this to get folder if it does exists or create if not:

try {
folder = DLFolderLocalServiceUtil.getFolder(
groupId, parentFolderId, folderName);
} catch(NoSuchFolderException e) {
_log.info("Folder '" + folderName + "' for groupId: " + groupId + " does not exists. Creating...");
try {
folder = DLFolderLocalServiceUtil.addFolder(this.getUserId(), groupId, this.getRepositoryId(groupId),
false, parentFolderId, folderName, folderName, this.getServiceContext());
} catch(PortalException e2) {
throw new PortalException("Error while creating '" + folderName +
"' folder for groupId: " + groupId + ", parentFolderId: " + parentFolderId, e2);
}
}


parentFolderId in case of ROOT folder is 0.

Regards,
KG
thumbnail
meera prince, modified 12 Years ago. Liferay Legend Posts: 1111 Join Date: 2/8/11 Recent Posts
HI

I want ask you two things
you want create from code or from admin screen..

if admin screen go to Document and Medial portlet from conrole panel
and create see following image


If you want from code
use
DLAppLocalServiceUtil

DLAppServiceUtil

or

DLFolderLocalServiceUtil

DLFolderServiceUtil


this clasess provide different methods use appropriate one and create.
thumbnail
Pankaj Kathiriya, modified 12 Years ago. Liferay Master Posts: 722 Join Date: 8/5/10 Recent Posts
Out of Box means default functionality of Liferay. Liferay itself provide this functions by default.