[KULRICE-5970] Can not copy a permission Created: 16/Nov/11  Updated: 05/Mar/12  Resolved: 27/Dec/11

Status: Closed
Project: Kuali Rice Development
Component/s: Development
Affects Version/s: None
Fix Version/s: 2.0.0-b6, 2.0
Security Level: Public (Public: Anyone can view)

Type: Bug Fix Priority: Critical
Reporter: Peter Giles (Inactive) Assignee: Sona Sona (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
cloned to KULRICE-6451 Can not create KNS maintenance documents Closed
Relate
relates to KULRICE-6892 Constraint violation on OBJ_ID upon s... Closed
Rely
relies on KULRICE-6390 Edit/Copy actions not being displayed... Closed
Similar issues:
KULRICE-11907Copy Permission throws org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException
KULRICE-8673Copy Permission not validating New Copy for duplicate Permission Name
KULRICE-7881Copying/Creating a permission is not populating permission identifier even when the document is routed.
KULRICE-8854Permission doc creating a duplicate permission can be submitted but routes to exception
KULRICE-10773Add permission check the Transactional Document copy method
KULRICE-8644When trying to copy certain permissions, doc gets stuck 'Enroute'
KULRICE-7536getPermissionTypeServicesByTemplateId can fetch permission type more than once
KULRICE-7832Role 54 user can edit person, group, role, parameter documents
KULRICE-6999When creating, copying, or editing a permission the "Permission ID" shows up as a blank value
KULRICE-10417Inquiry Permission Gap Analysis: checks for if a hidden field can be displayed
Rice Module:
KRAD
KAI Review Status: Not Required
KTI Review Status: Not Required

 Description   

Copying a permission doesn't work because the OBJ_ID gets copied, and isn't reset before attempting persistence. I suspect this will be a problem for other maint docs too.



 Comments   
Comment by Eric Westfall [ 17/Nov/11 ]

This seems like a critical bug, escalating the priority.

Comment by Peter Giles (Inactive) [ 28/Nov/11 ]

Some additional info here. The following snippet from the table creation sql for krim_perm_t shows that the constraint being violated is a unique constraint on obj_id:

CREATE TABLE `krim_perm_t` (
  `PERM_ID` varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '',
  `OBJ_ID` varchar(36) COLLATE utf8_bin NOT NULL,
  `VER_NBR` decimal(8,0) NOT NULL DEFAULT '1',
  `PERM_TMPL_ID` varchar(40) COLLATE utf8_bin DEFAULT NULL,
  `NMSPC_CD` varchar(40) COLLATE utf8_bin NOT NULL,
  `NM` varchar(100) COLLATE utf8_bin NOT NULL,
  `DESC_TXT` varchar(400) COLLATE utf8_bin DEFAULT NULL,
  `ACTV_IND` varchar(1) COLLATE utf8_bin DEFAULT 'Y',
  PRIMARY KEY (`PERM_ID`),
  UNIQUE KEY `KRIM_PERM_TC0` (`OBJ_ID`),
  UNIQUE KEY `KRIM_PERM_T_TC1` (`NM`,`NMSPC_CD`),
  KEY `KRIM_PERM_TR1` (`PERM_TMPL_ID`),
  CONSTRAINT `KRIM_PERM_TR1` FOREIGN KEY (`PERM_TMPL_ID`) REFERENCES `krim_perm_tmpl_t` (`PERM_TMPL_ID`)
)

Here's the stack trace:

2011-11-28 15:12:46,926 [TRAVEL/KSB-pool-1-thread-3] u:admin/d:3040 ERROR org.apache.ojb.broker.accesslayer.JdbcAccessImpl - 
* SQLException during execution of sql-statement:
* sql statement was 'INSERT INTO KRIM_PERM_T (PERM_ID,NMSPC_CD,NM,DESC_TXT,PERM_TMPL_ID,ACTV_IND,VER_NBR,OBJ_ID) VALUES (?,?,?,?,?,?,?,?) '
* Exception message is [Duplicate entry 'AE3195EDFF2500E2E0404F8189D822AE' for key 'KRIM_PERM_TC0']
* Vendor error code [1062]
* SQL state code [23000=INTEGRITY CONSTRAINT VIOLATION]
* Target class is 'org.kuali.rice.kim.impl.permission.PermissionBo'
* PK of the target object is [id=10003]
* Source object: org.kuali.rice.kim.impl.permission.PermissionBo@1c80b08[id=10003,namespaceCode=KR-SAP,name=Maintain KRMS Agenda,description=Allows creation and modification of agendas via the agenda editor,templateId=10001,active=true,template=org.kuali.rice.kim.impl.permission.PermissionTemplateBo@159972c[id=10001,namespaceCode=KR-RULE,name=KRMS Agenda Permission,description=View/Maintain Agenda,kimTypeId=67,active=true,versionNumber=1,objectId=AE3195EDFF2400E2E0404F8189D822AE,newCollectionRecord=false,extension=<null>],attributeDetails=[],attributes={},rolePermissions=org.springframework.util.AutoPopulatingList@1,dataDictionaryService=<null>,kimTypeInfoService=<null>,versionNumber=2,objectId=AE3195EDFF2500E2E0404F8189D822AE,newCollectionRecord=false,extension=<null>]
* The root stack trace is --> 
* com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'AE3195EDFF2500E2E0404F8189D822AE' for key 'KRIM_PERM_TC0'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
	at com.mysql.jdbc.Util.getInstance(Util.java:382)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
	at org.enhydra.jdbc.core.CorePreparedStatement.executeUpdate(CorePreparedStatement.java:102)
	at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown Source)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown Source)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)
	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)
	at org.springmodules.orm.ojb.PersistenceBrokerTemplate$9.doInPersistenceBroker(PersistenceBrokerTemplate.java:246)
	at org.springmodules.orm.ojb.PersistenceBrokerTemplate.execute(PersistenceBrokerTemplate.java:141)
	at org.springmodules.orm.ojb.PersistenceBrokerTemplate.store(PersistenceBrokerTemplate.java:244)
	at org.kuali.rice.krad.dao.impl.BusinessObjectDaoOjb.save(BusinessObjectDaoOjb.java:238)
	at org.kuali.rice.krad.dao.proxy.BusinessObjectDaoProxy.save(BusinessObjectDaoProxy.java:245)
	at sun.reflect.GeneratedMethodAccessor951.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
	at $Proxy54.save(Unknown Source)
	at org.kuali.rice.krad.service.impl.BusinessObjectServiceImpl.save(BusinessObjectServiceImpl.java:70)
	at sun.reflect.GeneratedMethodAccessor950.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
	at $Proxy55.save(Unknown Source)
	at org.kuali.rice.kim.impl.permission.PermissionServiceImpl.createPermission(PermissionServiceImpl.java:496)
	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)
...
Comment by Sona Sona (Inactive) [ 21/Dec/11 ]

When you do a copy the objectId already has a value which does not get reset and there is unique constraint on that column. This seems to be the problem with a lot of other maintainable documents also.
Responsibility
Namespace
Component
Campus
Country
PostalCode
State
Campus Type

Comment by Sona Sona (Inactive) [ 22/Dec/11 ]

I committed a fix for the other maintainable documents except responsibility. The template info and the edit/copy actions disappear when you do an edit/copy for Responsibility. Cannot test Permissions since the Edit/Copy actions do not show up for Permissions. I have created a separate jira for that.

Comment by Sona Sona (Inactive) [ 23/Dec/11 ]

Edit/Copy Responsibility has also been fixed.

Comment by Sona Sona (Inactive) [ 27/Dec/11 ]

Edit/copy is now working for Permissions.

Comment by Jessica Coltrin (Inactive) [ 23/Feb/12 ]

Closing since these items are now in the release notes.

Generated at Sat Jul 11 00:40:48 CDT 2020 using JIRA 6.1.5#6160-sha1:a61a0fc278117a0da0ec9b89167b8f29b6afdab2.