Forums de discussion

HOWTO Create a DLfolder?

Brahim TARNAOUI, modifié il y a 13 années.

HOWTO Create a DLfolder?

Junior Member Publications: 64 Date d'inscription: 15/06/10 Publications récentes
hello,

i'm looking for code to create a DLfolder for the document_library portlet.
NB:the DLFolder will be create from another portlet not document_library portlet and i will show it when i listing the folder in document_library portlet.

i need your help
thx in advance
thumbnail
Sandeep Nair, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1744 Date d'inscription: 06/11/08 Publications récentes
DLFolderLocalServiceUtil.addFolder(userId,
themeDisplay.getScopeGroupId(), parentFolderId, name,
description, serviceContext)
Use the above method with following parameters

parentFolderId will be 0
name name of folder
description
userid one who creates
ServiceContext serviceContext = ServiceContextFactory.getInstance(
DLFolder.class.getName(), actionRequest);

ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
WebKeys.THEME_DISPLAY);
Brahim TARNAOUI, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Junior Member Publications: 64 Date d'inscription: 15/06/10 Publications récentes
thx for your post,
how can i use it in a class??
my class is in a portlet other than document_library
thumbnail
Sandeep Nair, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1744 Date d'inscription: 06/11/08 Publications récentes
Yes directly use in the portlet which i assume would ask user to give name and description

Use lifecyle method of portlet processAction to process the request, retrieve the parameters. At the end of the day ur portlets processAction would look something like the following

public void processAction(ActionRequest actionRequest,
			ActionResponse actionResponse) throws IOException, PortletException {

ServiceContext serviceContext = ServiceContextFactory.getInstance(
DLFolder.class.getName(), actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
WebKeys.THEME_DISPLAY); 		
long parentFolderId = 0;
long userId = PortalUtil.getUserId(actionRequest);
String name = ParamUtil.getString(actionRequest,"name"); //pass this from jsp
String description = ParamUtil.getString(actionRequest,"description "); //pass this from jsp

DLFolderLocalServiceUtil.addFolder(userId,
themeDisplay.getScopeGroupId(), parentFolderId, name,
description, serviceContext);
}
Brahim TARNAOUI, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Junior Member Publications: 64 Date d'inscription: 15/06/10 Publications récentes
Hello,

i use your code, but it crash this Exception:
java.lang.RuntimeException: Unable to get the portlet request from org.springframework.web.portlet.multipart.DefaultMultipartActionRequest

have you a solution please?
thumbnail
Sandeep Nair, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1744 Date d'inscription: 06/11/08 Publications récentes
Can you show whats in ur jsp and Portlet class. I was assuming u were using MVCPortlet or GenericPortlet but u seem to be using Spring portlet
Brahim TARNAOUI, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Junior Member Publications: 64 Date d'inscription: 15/06/10 Publications récentes
Hello,
this is my source code of Spring Portlet :
@RequestMapping(params="action=AddClient") // action phase
public void submitAddFormationForm(ActionRequest actionRequest, ActionResponse response,
@ModelAttribute("client") Patient patient, BindingResult result, Model model,
PortletRequest portletRequest, RenderRequest renderRequest) {
if (actionRequest.getParameter("_cancel") != null) {
}else if (actionRequest.getParameter("_add") != null) {
clientValidator.validate(client, result);
if (result.hasErrors()) {
response.setRenderParameter("action", "AddClient");
}else {
Date date = new Date();
long id = date.getTime();
id = id%1000000;
client.setClientId(id);
client.setFolderId(id);
client.setCreateDate(date);
client.setModifiedDate(date);

client = (Client) clientService.save(client);

try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFolder.class.getName(), renderRequest);
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

long parentFolderId = 0;
long userId = PortalUtil.getUserId(portletRequest);
String folderName = "Name of FOlder";
String description = "Description Of Folder";

DLFolderLocalServiceUtil.addFolder(userId,themeDisplay.getScopeGroupId(), parentFolderId, folderName,description, serviceContext);
} catch (PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
}



in jsp page, i have this link :

<portlet:defineObjects />
<portlet:actionURL var="AddPatientUrl">
<portlet:param name="action" value="AddPatient"/>
</portlet:actionURL>

<a href ="<%=AddPatientURL %>">Add Patient</a>



thx in advance
Brahim TARNAOUI, modifié il y a 13 années.

RE: HOWTO Create a DLfolder?

Junior Member Publications: 64 Date d'inscription: 15/06/10 Publications récentes
hello,
i come to create a DLFolder by this code:


DLFolder folder = DLFolderLocalServiceUtil.createDLFolder(id);
folder.setName(folderName);
folder.setParentFolderId(0);
folder.setDescription("folder test");
folder.setGroupId(groupId);
folder.setCompanyId(companyId);
folder.setUserId(userId);
folder.setCreateDate(date);
folder.setModifiedDate(date);
folder.setLastPostDate(date);

DLFolderLocalServiceUtil.addDLFolder(folder);
thumbnail
mohammad azaruddin, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Hi
Sandeep
I'm using LR 6.1.1 and Your missing one argument "mountPoint".what will be value of mountPoint
Thanks
thumbnail
mohammad azaruddin, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Hi
MountPoint set to true if you want to create seperate resipotary.And default value is false

hope this is correct...correct me if i'm wrong
thumbnail
Mika Koivisto, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
Don't use DLFolder directly in 6.1. It's internal implementation for LiferayRepository and should not be messed with. Everything should go through DLAppServiceUtil.
thumbnail
mohammad azaruddin, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Mika Koivisto:
Don't use DLFolder directly in 6.1. It's internal implementation for LiferayRepository and should not be messed with. Everything should go through DLAppServiceUtil.


Hi Mika Koivisto

hope this is legal way to create dlfolder
Folder folder=DLAppServiceUtil.addFolder(themeDisplay.getLayout().getGroupId(), 0L, name, description, serviceContext);
thumbnail
Mika Koivisto, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
mohammad azaruddin:

hope this is legal way to create dlfolder
Folder folder=DLAppServiceUtil.addFolder(themeDisplay.getLayout().getGroupId(), 0L, name, description, serviceContext);


That's much better. For the repositoryId you can also use themeDisplay.getScopeGroupId().
thumbnail
mohammad azaruddin, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Hi
Mika Koivisto

Thank you.and for adding file entry we use same (DLAppServiceUtil).emoticon
Rgards
azhar
thumbnail
mohammad azaruddin, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Hi
Mika Koivisto

I used DLServiceUtil to add folder as well as DLfile
Folder dlFolder = DLAppServiceUtil.addFolder(themeDisplay.getScopeGroupId(), 0L, name, Description, serviceContext);

DLAppServiceUtil.addFileEntry(repositoryIds, folderId, sourceFileName, MimeTypesUtil.getContentType(file), sourceFileName, sourceFileName, StringPool.BLANK, null, size, serviceContext);


And what is the use of ChangeLog and InputStream.I'm Just passing null value for that.


can we pass this as InputStream inputStream=uploadPortletRequest.getInputStream();

And i'm unable to download the file.file is stored as 0kb size..and i'm getting this error

13:52:18,785 ERROR [ImageProcessor:219] java.lang.ArrayIndexOutOfBoundsException: 0
java.lang.ArrayIndexOutOfBoundsException: 0
at com.sun.media.jai.codecimpl.PNMCodec.isFormatRecognized(PNMCodec.java:152)
at com.liferay.portal.image.ImageProcessorImpl.read(ImageProcessorImpl.java:195)
at com.liferay.portal.kernel.image.ImageProcessorUtil.read(ImageProcessorUtil.java:67)
at com.liferay.portlet.documentlibrary.util.ImageProcessor._generateImages(ImageProcessor.java:172)
at com.liferay.portlet.documentlibrary.util.ImageProcessor.generateImages(ImageProcessor.java:63)
at com.liferay.portlet.documentlibrary.messaging.ImageProcessorMessageListener.doReceive(ImageProcessorMessageListener.java:31)
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:25)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:65)
at com.liferay.portal.kernel.messaging.SerialDestination$1.run(SerialDestination.java:101)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:669)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:580)
at java.lang.Thread.run(Thread.java:619)
thumbnail
meera prince, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1111 Date d'inscription: 08/02/11 Publications récentes
HI
long id=long =CounterLocalServiceUtil.increment();
DLFolder folder = DLFolderLocalServiceUtil.createDLFolder(id);
folder.setName(folderName);
folder.setParentFolderId(0);
folder.setDescription("folder test");
folder.setGroupId(groupId);
folder.setCompanyId(companyId);
folder.setUserId(userId);
folder.setCreateDate(date);
folder.setModifiedDate(date);
folder.setLastPostDate(date);
DLFolderLocalServiceUtil.addDLFolder(folder);

http://www.liferaysavvy.com/2013/02/best-way-to-add-data-to-life-ray-tables.html

Regards,

Meera Prince

http://www.liferaysavvy.com
thumbnail
meera prince, modifié il y a 11 années.

RE: HOWTO Create a DLfolder?

Liferay Legend Publications: 1111 Date d'inscription: 08/02/11 Publications récentes
ok Thank you