Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
I am using Windchill PDMLink Release 10.1 and Datecode with CPS M010
Due to business needs, we customized a button to rename documents. In the code logic called by this button, we temporarily set the session user as an administrator through SessionHelper.manager.setAdministrator, and then execute the renaming API - WTDocumentHelper.service.changeWTDocumentMasterIdentity, but the code execution reports a permission error.
According to our understanding, the administrator should have the authority to rename the document. So we are very confused, can you help us solve this problem? Thank you
Here are the errors that I faced
2024-06-24 10:23:13,314 INFO [ajp-bio-8010-exec-1] wt.system.out user2 - CommonUtil.java.3163: 重命名失败!Message: Resource bundle/Message key = wt.vc.vcResource/55
2024-06-24 10:23:13,325 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - (wt.vc.vcResource/55) wt.vc.VersionControlException: H-ZJ-188, JSZJ_00087886 可能不允许更改其标识。只有当此项未被检出并且您具有所有版本的 修改 权限时,才可以更改此项的标识。
2024-06-24 10:23:13,326 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.vc.StandardVersionControlService.changeIdentityAccessCheck(StandardVersionControlService.java:6772)
2024-06-24 10:23:13,326 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.vc.StandardVersionControlService$19.notifyVetoableMultiObjectEvent(StandardVersionControlService.java:831)
2024-06-24 10:23:13,326 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.events.StandardKeyedEventBranch.intDispatchEvent(StandardKeyedEventBranch.java:298)
2024-06-24 10:23:13,327 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.events.StandardKeyedEventBranch.dispatchVetoableMultiObjectEvent(StandardKeyedEventBranch.java:263)
2024-06-24 10:23:13,327 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.events.StandardKeyedEventDispatcher.intDispatchEvent(StandardKeyedEventDispatcher.java:288)
2024-06-24 10:23:13,327 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.events.StandardKeyedEventDispatcher.dispatchVetoableMultiObjectEvent(StandardKeyedEventDispatcher.java:231)
2024-06-24 10:23:13,328 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.services.StandardManagerService.intDispatchVetoableEvent(StandardManagerService.java:408)
2024-06-24 10:23:13,328 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.services.StandardManagerService.dispatchVetoableMultiObjectEvent(StandardManagerService.java:313)
2024-06-24 10:23:13,328 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.fc.StandardIdentityService.dispatchVetoableMultiObjectEvent(StandardIdentityService.java:525)
2024-06-24 10:23:13,329 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.fc.StandardIdentityService.changeIdentities(StandardIdentityService.java:241)
2024-06-24 10:23:13,329 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.fc.StandardIdentityService.changeIdentity(StandardIdentityService.java:197)
2024-06-24 10:23:13,329 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-06-24 10:23:13,329 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2024-06-24 10:23:13,330 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2024-06-24 10:23:13,330 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at java.lang.reflect.Method.invoke(Method.java:606)
2024-06-24 10:23:13,330 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.services.ServiceFactory$ServerInvocationHandler.invoke(ServiceFactory.java:399)
2024-06-24 10:23:13,331 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at com.sun.proxy.$Proxy169.changeIdentity(Unknown Source)
2024-06-24 10:23:13,331 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.doc.StandardWTDocumentService.changeWTDocumentMasterIdentity(StandardWTDocumentService.java:1193)
2024-06-24 10:23:13,331 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-06-24 10:23:13,331 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2024-06-24 10:23:13,332 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2024-06-24 10:23:13,332 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at java.lang.reflect.Method.invoke(Method.java:606)
2024-06-24 10:23:13,332 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at wt.services.ServiceFactory$ServerInvocationHandler.invoke(ServiceFactory.java:399)
2024-06-24 10:23:13,332 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at com.sun.proxy.$Proxy168.changeWTDocumentMasterIdentity(Unknown Source)
2024-06-24 10:23:13,333 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at ext.ali2.util.CommonUtil.renameObject(CommonUtil.java:3148)
2024-06-24 10:23:13,333 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at ext.ali2.processor.CustomRenameObjectProcessor.doOperation(CustomRenameObjectProcessor.java:48)
2024-06-24 10:23:13,333 INFO [ajp-bio-8010-exec-1] wt.system.err user2 - at com.ptc.core.components.forms.DefaultFormProcessorController.executeDoOperation(DefaultFormProcessorController.java:537)
2024
---------------------------------------------------------------
Translated text from Simplified Chinese to English using google translate
Subject - 自定义重命名按钮
Body - 因为业务需要我们自定义了一个重命名文档的按钮,这个按钮调用的代码逻辑里我们通过SessionHelper.manager.setAdministrator将会话用户临时置为管理员,然后再执行重命名的API——WTDocumentHelper.service.changeWTDocumentMasterIdentity,但是代码执行报权限错误。
按照我们的理解,管理员应该是有权限来重命名文档的。所以我们很疑惑,能帮助我们解决这个问题吗?谢谢
-By Community Moderation Tean
---------------------------------------------------------------
Solved! Go to Solution.
Hi @SW_10353216
As I wrote,
Check the ACL rules on the object for the specific administrator user. The admin really can have a deny rules for that object even though he is the Site admin,..
PetrH
Hi @SW_10353216
Please share your code how do you set admin user and what is on the line 48 from CustomRenameObjectProcessor.java
Also check what user is the admin, for example if you change a session to an administrator, get the session user who really admin is.
for example if it is changed to site admin he can not have permission. >D
PS just example
PetrH
the code is:
WTPrincipal principal = SessionHelper.getPrincipal();
try {
Debug.P("current user is:" + principal.getName());
WTUser adminUser = (WTUser) SessionHelper.manager.getAdministrator();
Debug.P("the admin is:" + adminUser.getName());
SessionHelper.manager.setAdministrator();
....
WTDocument document = (WTDocument) refObject;
WTDocumentMaster master = (WTDocumentMaster) document.getMaster();
WTOrganization organization = document.getOrganization();
Debug.P("当前用户为:" + SessionHelper.getPrincipal().getName());
WTDocumentMasterIdentity identity = (WTDocumentMasterIdentity) master.getIdentificationObject();
identity.setName(newName);
master = (WTDocumentMaster) IdentityHelper.service.changeIdentity(master, identity);
PersistenceServerHelper.manager.update(master);
}
Hi @SW_10353216
As I wrote,
Check the ACL rules on the object for the specific administrator user. The admin really can have a deny rules for that object even though he is the Site admin,..
PetrH
Thank you!