Changeset 5058
- Timestamp:
- Aug 18, 2009, 2:56:25 PM (14 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/DbControl.java
r5038 r5058 992 992 993 993 /** 994 Reattach a detached item assuming that it has not been 995 updated while it was detached. 996 @see #reattachItem(BasicItem, boolean) 997 */ 998 public void reattachItem(BasicItem item) 999 throws PermissionDeniedException, ItemNotFoundException, BaseException 1000 { 1001 reattachItem(item, false); 1002 } 1003 1004 /** 994 1005 Reattach a detached item from this <code>DbControl</code>. If the 995 1006 reattached already exists in the database it will be managed and … … 997 1008 998 1009 @param item The item to be reattached 1010 @param updated If TRUE, the item has been updated while it was detached 1011 and changes will be saved to the database. If FALSE, the item will 1012 only be saved to the database if it is modified after the 1013 reattachement 999 1014 @throws PermissionDeniedException If the logged in user doesn't have 1000 read permission1015 read/write permission 1001 1016 @throws BaseException If there is another error 1002 1017 @see #detachItem(BasicItem) 1003 */ 1004 public void reattachItem(BasicItem item) 1018 @since 2.13 1019 */ 1020 public void reattachItem(BasicItem item, boolean updated) 1005 1021 throws PermissionDeniedException, ItemNotFoundException, BaseException 1006 1022 { … … 1011 1027 { 1012 1028 item.initPermissions(0, 0); 1013 if (item.hasPermission(Permission.RESTRICTED_WRITE)) 1014 { 1015 HibernateUtil.lockData(hSession, item.getData(), org.hibernate.LockMode.NONE); 1016 // HibernateUtil.updateData(hSession, item.getData()); 1017 } 1018 else if (item.hasPermission(Permission.READ)) 1019 { 1020 HibernateUtil.lockData(hSession, item.getData(), org.hibernate.LockMode.NONE); 1029 if (updated) 1030 { 1031 if (item.hasPermission(Permission.RESTRICTED_WRITE)) 1032 { 1033 HibernateUtil.updateData(hSession, item.getData()); 1034 } 1035 else 1036 { 1037 throw new PermissionDeniedException(Permission.WRITE, item.toString()); 1038 } 1021 1039 } 1022 1040 else 1023 1041 { 1024 throw new PermissionDeniedException(Permission.READ, item.toString()); 1042 if (item.hasPermission(Permission.READ)) 1043 { 1044 HibernateUtil.lockData(hSession, item.getData(), org.hibernate.LockMode.NONE); 1045 } 1046 else 1047 { 1048 throw new PermissionDeniedException(Permission.READ, item.toString()); 1049 } 1025 1050 } 1026 1051 itemCache.put(item.getData(), item); -
trunk/src/test/TestDbControl.java
r4889 r5058 128 128 r.setName("Detached role"); 129 129 dc = TestUtil.getDbControl(); 130 dc.reattachItem(r );130 dc.reattachItem(r, true); 131 131 dc.commit(); 132 132 dc.close();
Note: See TracChangeset
for help on using the changeset viewer.