gpt4 book ai didi

java - Liferay 在 DLFileEntryLocalServiceUtil.addFileEntry 之后向我抛出一个 NoSuchEntryException

转载 作者:行者123 更新时间:2023-12-04 08:36:34 25 4
gpt4 key购买 nike

我正在尝试以编程方式将图像添加到 liferay 文档库。我正在使用 liferay 门户 6.1.30 ee。

这是我的代码:

    protected void addDocument(long userId, Group group, InputStream inputStream, DLFolder dlFolder, String name) throws IOException {
long fileEntryTypeId;
try {
fileEntryTypeId = DLFileEntryTypeLocalServiceUtil.getDefaultFileEntryTypeId(dlFolder.getFolderId());
} catch (NestableException e) {
if(LOGGER.isWarningEnabled())LOGGER.warn("unable to get fileEntryType ",e);
return;
}

ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(group.getCompanyId());
serviceContext.setScopeGroupId(group.getGroupId());
serviceContext.setAssetEntryVisible(true);

try {
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.addFileEntry(userId, group.getGroupId(), dlFolder.getRepositoryId(),
dlFolder.getFolderId(), name, MimeTypesUtil.getContentType(name), name,
StringPool.BLANK, StringPool.BLANK, fileEntryTypeId, null, null,
inputStream, inputStream.available(), new ServiceContext());


//fileEntry = DLFileEntryLocalServiceUtil.updateDLFileEntry(fileEntry);
//fileEntry = DLFileEntryLocalServiceUtil.updateFileEntry(fileEntry.getUserId(),fileEntry.getFileEntryTypeId(),name,MimeTypesUtil.getContentType(name),name,StringPool.BLANK,StringPool.BLANK,false, fileEntryTypeId, new HashMap<String, Fields>(), null, fileEntry.getContentStream(), fileEntry.getSize(),serviceContext);
//fileEntry = DLFileEntryLocalServiceUtil.updateStatus(fileEntry.getUserId(), fileEntry.getFileVersion().getFileVersionId(), WorkflowConstants.STATUS_APPROVED, new HashMap<String, Serializable>(), serviceContext);

if(LOGGER.isTraceEnabled()) LOGGER.trace("file "+name+" added");
} catch (NestableException e) {
if(LOGGER.isWarningEnabled())LOGGER.warn("error adding file "+name+" ",e);
}
}

我尝试使用 DLFileEntryLocalServiceUtil.addFileEntry 但它没有正确创建我的文档,因为我在 this post 中显示为红色没有创建 assetEntry 记录。

所以我尝试了 DLFileEntryLocalServiceUtil.updateStatus(在这里评论)但是我得到了这个错误,仍然没有 assetEntry:

com.liferay.portlet.asset.NoSuchEntryException: No AssetEntry exists with the key {classNameId=10076, classPK=42954}
at com.liferay.portlet.asset.service.persistence.AssetEntryPersistenceImpl.findByC_C(AssetEntryPersistenceImpl.java:2933)
at sun.reflect.GeneratedMethodAccessor1937.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
at com.sun.proxy.$Proxy689.findByC_C(Unknown Source)
at com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.updateVisible(AssetEntryLocalServiceImpl.java:866)
at sun.reflect.GeneratedMethodAccessor1936.invoke(Unknown Source)
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:117)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:52)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:218)
at com.liferay.portal.security.pacl.PACLInvocationHandler.doInvoke(PACLInvocationHandler.java:62)
at com.liferay.portal.security.pacl.PACLInvocationHandler.invoke(PACLInvocationHandler.java:51)
at com.sun.proxy.$Proxy394.updateVisible(Unknown Source)
at com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.updateStatus(DLAppHelperLocalServiceImpl.java:584)
at sun.reflect.GeneratedMethodAccessor1935.invoke(Unknown Source)
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:117)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:52)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:218)
at com.liferay.portal.security.pacl.PACLInvocationHandler.doInvoke(PACLInvocationHandler.java:62)
at com.liferay.portal.security.pacl.PACLInvocationHandler.invoke(PACLInvocationHandler.java:51)
at com.sun.proxy.$Proxy466.updateStatus(Unknown Source)
at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.updateStatus(DLFileEntryLocalServiceImpl.java:1298)
at com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceWrapper.updateStatus(DLFileEntryLocalServiceWrapper.java:624)
at sun.reflect.GeneratedMethodAccessor1933.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
at com.sun.proxy.$Proxy782.updateStatus(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1933.invoke(Unknown Source)
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:117)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:52)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:113)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:218)
at com.liferay.portal.security.pacl.PACLInvocationHandler.doInvoke(PACLInvocationHandler.java:62)
at com.liferay.portal.security.pacl.PACLInvocationHandler.invoke(PACLInvocationHandler.java:51)
at com.sun.proxy.$Proxy468.updateStatus(Unknown Source)
at com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil.updateStatus(DLFileEntryLocalServiceUtil.java:626)
at xxx.addDocument()

我尝试调用方法 DLFileEntryLocalServiceUtil.updateDLFileEntry 或 updateFileEntry 但这没有什么区别

编辑:

我在 addFileEntry 之后找到了使用这段代码的解决方案:

    fileEntry = DLFileEntryLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(),name, MimeTypesUtil.getContentType(name), name,"", "", true, fileEntryTypeId, null, null, null, 0, serviceContext);
Map<String, Serializable> workflowContext = new HashMap<String, Serializable>();
workflowContext.put("event",DLSyncConstants.EVENT_UPDATE);
fileEntry = DLFileEntryLocalServiceUtil.updateStatus(fileEntry.getUserId(), fileEntry.getFileVersion().getFileVersionId(), WorkflowConstants.STATUS_APPROVED, workflowContext, serviceContext);

最佳答案

您可以尝试使用 DLFileAppLocalServiceUtil 中的方法。它们生成文件的元数据和其他必填字段,如文件版本。

HTH.

关于java - Liferay 在 DLFileEntryLocalServiceUtil.addFileEntry 之后向我抛出一个 NoSuchEntryException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20326094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com