Fórum
Access to DLFOLDER PERMISSION
Ahmed Sekka, modificado 9 Anos atrás.
Access to DLFOLDER PERMISSION
Junior Member Postagens: 26 Data de Entrada: 31/03/14 Postagens Recentes
Dear ,
I want to access to dlfolder from the CALENDERPORTLET using the function DLAppServiceUtil.copyFolder(folder1.getRepositoryId(), folder2.getFolderId(), folder1.getFolderId(), calendarName, description, serviceContext);
but , I have this bug :
Caused by: com.liferay.portal.NoSuchResourceActionException: com.liferay.portlet.documentlibrary.model.DLFolder#ADD_DISCUSSION
at com.liferay.portal.service.impl.ResourceActionLocalServiceImpl.getResourceAction(ResourceActionLocalServiceImpl.java:196)
at sun.reflect.GeneratedMethodAccessor236.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy82.getResourceAction(Unknown Source)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.doUpdateResourcePermission(ResourcePermissionLocalServiceImpl.java:1190)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.updateResourcePermission(ResourcePermissionLocalServiceImpl.java:1312)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.setResourcePermissions(ResourcePermissionLocalServiceImpl.java:1076)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy86.setResourcePermissions(Unknown Source)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:751)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:792)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy81.addModelResources(Unknown Source)
at com.liferay.portlet.documentlibrary.service.impl.DLFolderLocalServiceImpl.addFolderResources(DLFolderLocalServiceImpl.java:1094)
at com.liferay.portlet.documentlibrary.service.impl.DLFolderLocalServiceImpl.addFolder(DLFolderLocalServiceImpl.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
I want to access to dlfolder from the CALENDERPORTLET using the function DLAppServiceUtil.copyFolder(folder1.getRepositoryId(), folder2.getFolderId(), folder1.getFolderId(), calendarName, description, serviceContext);
but , I have this bug :
Caused by: com.liferay.portal.NoSuchResourceActionException: com.liferay.portlet.documentlibrary.model.DLFolder#ADD_DISCUSSION
at com.liferay.portal.service.impl.ResourceActionLocalServiceImpl.getResourceAction(ResourceActionLocalServiceImpl.java:196)
at sun.reflect.GeneratedMethodAccessor236.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy82.getResourceAction(Unknown Source)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.doUpdateResourcePermission(ResourcePermissionLocalServiceImpl.java:1190)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.updateResourcePermission(ResourcePermissionLocalServiceImpl.java:1312)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.setResourcePermissions(ResourcePermissionLocalServiceImpl.java:1076)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy86.setResourcePermissions(Unknown Source)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:751)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:792)
at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addModelResources(ResourceLocalServiceImpl.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy81.addModelResources(Unknown Source)
at com.liferay.portlet.documentlibrary.service.impl.DLFolderLocalServiceImpl.addFolderResources(DLFolderLocalServiceImpl.java:1094)
at com.liferay.portlet.documentlibrary.service.impl.DLFolderLocalServiceImpl.addFolder(DLFolderLocalServiceImpl.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
Ahmed Sekka, modificado 9 Anos atrás.
RE: Access to DLFOLDER PERMISSION (Resposta)
Junior Member Postagens: 26 Data de Entrada: 31/03/14 Postagens Recentes
It's ok
Balázs Csönge, modificado 8 Anos atrás.
RE: Access to DLFOLDER PERMISSION
Regular Member Postagens: 107 Data de Entrada: 10/11/14 Postagens Recentes
Please, tell me the secret, what kind of magic eliminates your probplem?!?
Ahmed Sekka, modificado 8 Anos atrás.
RE: Access to DLFOLDER PERMISSION
Junior Member Postagens: 26 Data de Entrada: 31/03/14 Postagens Recentes
use the ressource-action to set the permission
Balázs Csönge, modificado 8 Anos atrás.
RE: Access to DLFOLDER PERMISSION
Regular Member Postagens: 107 Data de Entrada: 10/11/14 Postagens Recentes
I tried to make a folder under a given parent folder. I used the following util:
childFolder = DLAppLocalServiceUtil.addFolder(userId, repositoryId, parentFolderId, childFolderName, childFolderDescription, serviceContext);
I called the method from a workflow (Activiti) and passed that serviceContext what I was able get from workflowcontext.
I got the Caused by: com.liferay.portal.NoSuchResourceActionException: com.liferay.portlet.documentlibrary.model.DLFolder#ADD_DISCUSSION
exception.
I found an another util:
DLFolderLocalServiceUtil.addFolder(userId, repositoryId, repositoryId, false, parentFolderId, childFolderName, childFolderDescription,false, new ServiceContext());
With this, folder has been created, so I thought, I used a wrong util for creation.
But, later I realized its input parameter is a new ServiceContext(), and when I changed it to my serviceContext, got the same error.
So in debug mode I examided the content of the my serviceContext (see in linked pic). Its _groupPermissions attribute contained this ADD_DISCUSSION and the VIEW values.
With more research, I figured what kind of rights can be set for a folder, and the ADD_DISCUSSION is not between those rights.
Both utils, mentioned before, created the new folder with all permissions for OWNER role. I tried to make an algorythm, which sets same roles for child folder as its parent has. I had to get a list of permission settings for the parent, and make new ones for the child based on this list, but I had to skip the OWNER role settings, because those are made with the folde creation.
Finally the test code:
childFolder = DLAppLocalServiceUtil.addFolder(userId, repositoryId, parentFolderId, childFolderName, childFolderDescription, serviceContext);
I called the method from a workflow (Activiti) and passed that serviceContext what I was able get from workflowcontext.
I got the Caused by: com.liferay.portal.NoSuchResourceActionException: com.liferay.portlet.documentlibrary.model.DLFolder#ADD_DISCUSSION
exception.
I found an another util:
DLFolderLocalServiceUtil.addFolder(userId, repositoryId, repositoryId, false, parentFolderId, childFolderName, childFolderDescription,false, new ServiceContext());
With this, folder has been created, so I thought, I used a wrong util for creation.
But, later I realized its input parameter is a new ServiceContext(), and when I changed it to my serviceContext, got the same error.
So in debug mode I examided the content of the my serviceContext (see in linked pic). Its _groupPermissions attribute contained this ADD_DISCUSSION and the VIEW values.
With more research, I figured what kind of rights can be set for a folder, and the ADD_DISCUSSION is not between those rights.
Both utils, mentioned before, created the new folder with all permissions for OWNER role. I tried to make an algorythm, which sets same roles for child folder as its parent has. I had to get a list of permission settings for the parent, and make new ones for the child based on this list, but I had to skip the OWNER role settings, because those are made with the folde creation.
Finally the test code:
// Create folder with rights
Folder parentFolder = null;
Folder childFolder = null;
List<resourcepermission> parentResPerList = null;
String childFolderName = testData;
String childFolderDescription = testData + " folder created with test portlet";
long parentFolderId = 15716L; //Templates folder
long repositoryId = groupId;
try {
parentFolder = DLAppLocalServiceUtil.getFolder(parentFolderId);
} catch (PortalException | SystemException e) {
log.error("Error occured during getting parent folder object. Cause: " + e.getMessage(), e);
parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
}
try {
parentResPerList = ResourcePermissionLocalServiceUtil.getResourceResourcePermissions(companyId, groupId, DLFolder.class.getName(), Long.toString(parentFolderId));
} catch (SystemException e1) {
log.error("Error occured during getting the parent folder permission settings. Cause: " + e1.getMessage(), e1);
}
try {
childFolder = DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, childFolderName);
log.info(childFolderName + " folder has been found.");
} catch (NoSuchFolderException e) {
try {
// DLFolder childFolder2 = DLFolderLocalServiceUtil.addFolder(userId, repositoryId, repositoryId, false, parentFolderId, childFolderName, childFolderDescription,false, serviceContext);
childFolder = DLAppLocalServiceUtil.addFolder(userId, repositoryId, parentFolderId, childFolderName, childFolderDescription, new ServiceContext());
// childFolder = DLAppLocalServiceUtil.getFolder(childFolder2.getFolderId());
log.info(childFolderName + " folder has been created. FolderId: " + Long.toString(childFolder.getFolderId()));
} catch (Exception e2) {
log.error("Error occured during creating a new folder, named as " + childFolderName + " Cause: " + e2.getMessage(), e2);
throw(new RuntimeException("Error occured during creating a new folder, named as " + childFolderName + " Cause: " + e2.getMessage(), e2));
}
if (parentResPerList != null) {
for (ResourcePermission rp : parentResPerList) {
try {
Role selectedRole = RoleLocalServiceUtil.getRole(rp.getRoleId());
if (selectedRole.getName().toLowerCase().contains("owner")) {
continue;
}
} catch (Exception e2) {
log.error("Error occured during getting the role record via ID " + Long.toString(rp.getRoleId()) + " Cause: " + e.getMessage(), e);
continue;
}
try {
ResourcePermission newRP = ResourcePermissionLocalServiceUtil.createResourcePermission(CounterLocalServiceUtil.increment(ResourcePermission.class.getName()));
newRP.setNew(true);
newRP.setScope(rp.getScope());
newRP.setCompanyId(rp.getCompanyId());
newRP.setName(rp.getName());
newRP.setPrimKey(Long.toString(childFolder.getFolderId()));
newRP.setRoleId(rp.getRoleId());
newRP.setActionIds(rp.getActionIds());
ResourcePermissionLocalServiceUtil.addResourcePermission(newRP);
} catch (Exception er) {
log.error("Error occured during creating a new permission for the new folder from one of the permission of the parent folder. Cause: " + er.getMessage(), er);
}
}
}
} catch (SystemException | PortalException e) {
log.error("Error occured during getting the folder named as " + childFolderName + " Cause: " + e.getMessage(), e);
throw(new RuntimeException("Error occured during getting the folder named as " + childFolderName + " Cause: " + e.getMessage(), e));
}
</resourcepermission>
Ahmed Sekka, modificado 8 Anos atrás.
RE: Access to DLFOLDER PERMISSION
Junior Member Postagens: 26 Data de Entrada: 31/03/14 Postagens Recentes
Did u create a new portlet Or use the hook portlet or ...?
Balázs Csönge, modificado 8 Anos atrás.
RE: Access to DLFOLDER PERMISSION
Regular Member Postagens: 107 Data de Entrada: 10/11/14 Postagens Recentes
None of them.
I initiated all stuff from an Activiti workflow process, which was started via the liferay UI (after a DDL creation).
But no future help needed, I found the reason why did I got that error, and just tried to tell my story about it.
I initiated all stuff from an Activiti workflow process, which was started via the liferay UI (after a DDL creation).
But no future help needed, I found the reason why did I got that error, and just tried to tell my story about it.