Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Arthur Grohe
Add DLFile in DLFolder -> Cannot find repository ID
12. November 2012 05:29
Antwort

Arthur Grohe

Rang: Junior Member

Nachrichten: 49

Eintrittsdatum: 5. November 2012

Neue Beiträge

Hello,

after hours of work I got it working to add a DLFolder !
Now I want to add a file to that folder with the following(part of Bean that handles file-upload event)
 1try {
 2
 3                        [b]DLFolder dlFolder = getDlFolder();[/b]
 4
 5                        String name = stripInvalidFileNameCharacters(upldFile
 6                                .getName());
 7                        String title = name;
 8                        String description = null;
 9                        String changeLog = null;
10                        File file = new File(upldFile.getAbsolutePath());
11                        ServiceContext sctx = new ServiceContext();
12                        // community members can view the file
13                        sctx.setAddGroupPermissions(true);
14
15                        try {
16
17                            long fileEntryTypeId = DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT;
18                            Map<String, Fields> fieldsMap = new HashMap<String, Fields>();
19                            FileInputStream inputStream = new FileInputStream(
20                                    file);
21                            [b]DLFileEntryServiceUtil.addFileEntry(
22                                    dlFolder.getGroupId(),
23                                    dlFolder.getRepositoryId(),
24                                    dlFolder.getFolderId(), name,
25                                    upldFile.getContentType(), title,
26                                    description, changeLog, fileEntryTypeId,
27                                    fieldsMap, file, inputStream,
28                                    file.length(), sctx);[/b]
29                            inputStream.close();
30                            file.delete();
31...catch() etc


But the server spits this out:
 110:41:19,948 ERROR [http-bio-8080-exec-1][view_jsp:2660] [b]No Repository exists with the primary key 0[/b]
 210:41:20,491 INFO  [com.liferay.portal.plugin.PluginPackageUtil][PluginPackageUtil:1421] Checking for available updates
 310:41:20,493 INFO  [com.liferay.portal.plugin.PluginPackageUtil][PluginPackageUtil:1465] Finished checking for available updates in 1 ms
 410:41:47,637 ERROR [DocLibBean:207][b] No RepositoryEntry exists with the primary key 11302[/b]
 5com.liferay.portal.NoSuchRepositoryEntryException: [b]No RepositoryEntry exists with the primary key 11302[/b]
 6    at com.liferay.portal.service.persistence.RepositoryEntryPersistenceImpl.findByPrimaryKey(RepositoryEntryPersistenceImpl.java:548)
 7    at com.liferay.portal.service.impl.RepositoryLocalServiceImpl.createRepositoryImpl(RepositoryLocalServiceImpl.java:344)
 8    at com.liferay.portal.service.impl.RepositoryLocalServiceImpl.getLocalRepositoryImpl(RepositoryLocalServiceImpl.java:220)
 9    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
11    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
12    at java.lang.reflect.Method.invoke(Method.java:597)
13    at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
14    at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
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)


How can this be? I mean I added the folder to the System-Repository and with the File I say dlfolder.getRepositoryId().
Which ID does he take? 0 or 11302? ....
Please help!

Thanks, have a great day
Gwowen Fu
RE: Add DLFile in DLFolder -> Cannot find repository ID
12. November 2012 12:02
Antwort

Gwowen Fu

Rang: Expert

Nachrichten: 253

Eintrittsdatum: 27. Dezember 2010

Neue Beiträge

Use site's group ID for repository ID.
Mika Koivisto
RE: Add DLFile in DLFolder -> Cannot find repository ID
14. November 2012 11:07
Antwort

Mika Koivisto

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1499

Eintrittsdatum: 7. August 2006

Neue Beiträge

You are messing with the LiferayRepository internals which will lead to inconsistent data. Use DLAppService to add files or folders. The repository id is the group id if you are using the Liferay repository.
Hemant Behera
RE: Add DLFile in DLFolder -> Cannot find repository ID
20. September 2013 15:42
Antwort

Hemant Behera

Rang: Junior Member

Nachrichten: 34

Eintrittsdatum: 1. Dezember 2009

Neue Beiträge

In my case i am getting repository id is different from group id. I am using a DL hook to create repository through web service in another content source. Is there any way we can get repository ID?