掲示板

Add DLFile in DLFolder -> Cannot find repository ID

thumbnail
11年前 に Arthur Grohe によって更新されました。

Add DLFile in DLFolder -> Cannot find repository ID

Junior Member 投稿: 49 参加年月日: 12/11/05 最新の投稿
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)
try {

						[b]DLFolder dlFolder = getDlFolder();[/b] 

						String name = stripInvalidFileNameCharacters(upldFile
								.getName());
						String title = name;
						String description = null;
						String changeLog = null;
						File file = new File(upldFile.getAbsolutePath());
						ServiceContext sctx = new ServiceContext();
						// community members can view the file
						sctx.setAddGroupPermissions(true);

						try {

							long fileEntryTypeId = DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT;
							Map<string, fields> fieldsMap = new HashMap<string, fields>();
							FileInputStream inputStream = new FileInputStream(
									file);
							[b]DLFileEntryServiceUtil.addFileEntry(
									dlFolder.getGroupId(),
									dlFolder.getRepositoryId(),
									dlFolder.getFolderId(), name,
									upldFile.getContentType(), title,
									description, changeLog, fileEntryTypeId,
									fieldsMap, file, inputStream,
									file.length(), sctx);[/b]
							inputStream.close();
							file.delete();
...catch() etc</string,></string,>


But the server spits this out:
10:41:19,948 ERROR [http-bio-8080-exec-1][view_jsp:2660] [b]No Repository exists with the primary key 0[/b]
10:41:20,491 INFO  [com.liferay.portal.plugin.PluginPackageUtil][PluginPackageUtil:1421] Checking for available updates
10:41:20,493 INFO  [com.liferay.portal.plugin.PluginPackageUtil][PluginPackageUtil:1465] Finished checking for available updates in 1 ms
10:41:47,637 ERROR [DocLibBean:207][b] No RepositoryEntry exists with the primary key 11302[/b]
com.liferay.portal.NoSuchRepositoryEntryException: [b]No RepositoryEntry exists with the primary key 11302[/b]
	at com.liferay.portal.service.persistence.RepositoryEntryPersistenceImpl.findByPrimaryKey(RepositoryEntryPersistenceImpl.java:548)
	at com.liferay.portal.service.impl.RepositoryLocalServiceImpl.createRepositoryImpl(RepositoryLocalServiceImpl.java:344)
	at com.liferay.portal.service.impl.RepositoryLocalServiceImpl.getLocalRepositoryImpl(RepositoryLocalServiceImpl.java:220)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
	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
11年前 に Gwowen Fu によって更新されました。

RE: Add DLFile in DLFolder -> Cannot find repository ID (回答)

Expert 投稿: 315 参加年月日: 10/12/27 最新の投稿
Use site's group ID for repository ID.
thumbnail
11年前 に Mika Koivisto によって更新されました。

RE: Add DLFile in DLFolder -> Cannot find repository ID

Liferay Legend 投稿: 1519 参加年月日: 06/08/07 最新の投稿
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.
thumbnail
10年前 に Hemant Behera によって更新されました。

RE: Add DLFile in DLFolder -> Cannot find repository ID

Junior Member 投稿: 36 参加年月日: 09/12/01 最新の投稿
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?