Foren

Creating user's specific folders in document library

thumbnail
Praveen P, geändert vor 11 Jahren.

Creating user's specific folders in document library

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
Hello every one

how to create a user specific folder in document library in liferay 6.1? because my plan is to create separate folders for every users and so that they can upload their images and get its image gallery. so how to create user specific folders programmatically? what services i want to make use?


Thanks in advance
Praveen
thumbnail
Praveen P, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
Atleast help me to create a folder in document and media by program. and i want to maintain a each user's specific folders like image gallery, or photos in facebook so that users can have their own album in their account but not getting how to create a folder???????????

If anybody knows about it, if possible let me know how to do?

Thanks
thumbnail
Rajeeva Lochana .B.R, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Junior Member Beiträge: 67 Beitrittsdatum: 04.01.10 Neueste Beiträge
Hi Praveen,

Check the below example to create user specific folder.
To achieve this functionality create hook, extend the business logic.

Necessary import class


import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil;
import com.liferay.portal.kernel.repository.model.Folder;


Code :


ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long repositoryId = themeDisplay.getScopeGroupId();    		
    	
ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileShortcut.class.getName(), actionRequest);

	//DLAppServiceUtil.addFolder(long repositoryId, long parentFolderId, String name, String description, ServiceContext serviceContext);
Folder folder = DLAppServiceUtil.addFolder(repositoryId, 0l, user.getUserId(), "dummy description", serviceContext);



If you have any concern let me know.

Thanks and Regards,
Rajeeva Lochana.b.R
thumbnail
Praveen P, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
Hi rajeev Thanks for your replay, I am not getting which service i have to invoke while creating hook, can u mention it in detail?
thumbnail
Rajeeva Lochana .B.R, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Junior Member Beiträge: 67 Beitrittsdatum: 04.01.10 Neueste Beiträge
Hi Praveen,


Find the attached hook example,I have tested, it is working fine, before deploy just change the repositoryId
Check point for the repositoryId : goto control panel >> sites >> click Action button >> Edit Settings .
Site ID : 10180(for Example).
Hard coding the repositoryId is not a good solution for testing purpose i am creating this.
change the code base on your requirement.


Thanks and Regards,
Rajeeva Lochana.B.R
thumbnail
Praveen P, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
hi i am getting exception which is

Failed to connect to a valid mail server. Please make sure one is properly configured. Could not connect to SMTP host: localhost, port: 25
com.liferay.portal.security.auth.PrincipalException
thumbnail
Praveen P, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
Getting the error
Failed to connect to a valid mail server. Please make sure one is properly configured. Could not connect to SMTP host: localhost, port: 25


How to rectify it? account is creating but its not creating any folders in user's document library emoticon what is the need of connecting to SMTP here?????????
My intention is to create a folder inside document and media by default while user is creating a account. but with the above code, folder is not creating but user account is creating..........!
thumbnail
Praveen P, geändert vor 11 Jahren.

RE: Creating user's specific folders in document library

Regular Member Beiträge: 100 Beitrittsdatum: 21.02.12 Neueste Beiträge
Hi rajeeva

No RepositoryEntry exists with the primary key 14002(userID)


Its showing error with this reason, and temporarily not available.
thumbnail
Andrew Jardine, geändert vor 5 Jahren.

RE: Creating user's specific folders in document library

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge

depending on what version of the product you are using, the package for the class you are looking for will change. In fact, if you are using Liferay 7, then the way you reference the service will change (or should change) as well.

 

The original post was a question for 6.1 -- Which version of the product are you on?