Hello,
While Adding a file to Document Library in Liferay 6.1 GA2 , I am getting an Error saying
com.liferay.portlet.documentlibrary.FileNameExceptionAction Class :
1
2
3UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
4 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
5 WebKeys.THEME_DISPLAY);
6
7 String sourceFileName =uploadRequest.getFullFileName("file");
8 _log.info("sourceFile Full Name ------------------------------------------- ----- " + sourceFileName); //I am getting the proper FileName
9
10 String contentType = MimeTypesUtil.getContentType(sourceFileName);
11 FileEntry fileEntry=null;
12 File file = null ;
13
14 ServiceContext serviceContext =null;
15 long userId = themeDisplay.getUserId();
16 String folderDiscription = "folderDiscription";
17 String userID = String.valueOf(visit.getUserid());
18 String folderName = UserID + "-" + visit.getUsername() ;
19 Folder folder = null;
20
21 long groupId = themeDisplay.getScopeGroupId();
22 long folderId = ParamUtil.getLong(uploadRequest, "folderId");
23 long repositoryId = ParamUtil.getLong(uploadRequest, "repositoryId");
24 String changeLog = ParamUtil.getString(uploadRequest, "changeLog");
25 String name = ParamUtil.getString(uploadRequest, "file");
26 String fileName = uploadRequest.getFileName("file");
27
28 //check if in the next line fileName is not overriden
29 String description = ParamUtil.getString(uploadRequest,
30 "description", fileName);
31
32 if(folderId == 0){
33
34 try {
35 folder = DLAppServiceUtil.getFolder(repositoryId, 0, folderName);
36 System.out.println("Here is a folder data *************************************************** == " +folder.getName() + " "+folderName);
37 }
38 catch (Exception e) {
39 if (e instanceof NoSuchFolderException ||
40 e instanceof DuplicateFileException ||
41 e instanceof DuplicateFolderNameException) {
42 }else {
43 System.out.println("Error ");
44 }
45 }
46 try {
47 System.out.println("I am inside second try Block " );
48 serviceContext = ServiceContextFactory.getInstance(
49 DLFileEntry.class.getName(), actionRequest);
50 System.out.println("I am before IF condition ");
51 if(folder.getName().equalsIgnoreCase(folderName) || folder.getName() == folderName){
52 System.out.println("I am inside IF condition 1");
53
54 // I am getting Error while addFileEntry -- Exception com.liferay.portlet.documentlibrary.FileNameException
55 fileEntry = DLAppServiceUtil.addFileEntry(
56 repositoryId, folder.getFolderId(),sourceFileName , contentType, "",
57 description, "", file, serviceContext);
58 }else {
59
60 folder = DLAppServiceUtil.addFolder(
61 repositoryId, 0, folderName,folderDiscription ,
62 serviceContext);
63 // I am getting Error while addFileEntry -- Exception com.liferay.portlet.documentlibrary.FileNameException
64 fileEntry = DLAppServiceUtil.addFileEntry(
65 repositoryId, folder.getFolderId(), sourceFileName, contentType, "",
66 sourceFileName+" upload", "", file, serviceContext);
67 }
68 } catch (PortalException e) {
69 // TODO Auto-generated catch block
70 e.printStackTrace();
71 } catch (SystemException e) {
72 // TODO Auto-generated catch block
73 e.printStackTrace();
74 }catch (Exception e) {
75 if (e instanceof NoSuchFolderException ||
76 e instanceof DuplicateFileException ||
77 e instanceof DuplicateFolderNameException) {
78 }else if (e instanceof DuplicateFileException ||
79 e instanceof DuplicateFolderNameException ||
80 e instanceof FileExtensionException ||
81 e instanceof FileMimeTypeException ||
82 e instanceof FileNameException ||
83 e instanceof FileSizeException ||
84 e instanceof NoSuchFolderException ||
85 e instanceof NoSuchFileEntryException ||
86 e instanceof SourceFileNameException) {
87 System.out.println("Error ");
88 }
89 }
90 }
Below is the Console --Log 1
2com.liferay.portlet.documentlibrary.FileNameException
3 at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.addFileEntry(DLFileEntryLocalServiceImpl.j
4ava:123)
5 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
6 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
7 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
8 at java.lang.reflect.Method.invoke(Method.java:597)
9 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
10 at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
11 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
12 at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
13 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
14 at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
15 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
16 at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
17 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
18 at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
19 at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
20 at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
21 at $Proxy184.addFileEntry(Unknown Source)
22 at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryServiceImpl.addFileEntry(DLFileEntryServiceImpl.java:62)
23 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
24 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
25 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
26 at java.lang.reflect.Method.invoke(Method.java:597)
27 ................................................
28 ...........................................
Please help me to resolve it
Please sign in to flag this as inappropriate.