1 package org.tigris.scarab.om; 2 3 48 49 import org.apache.torque.om.Persistent; 50 import org.apache.torque.util.Criteria; 51 import org.tigris.scarab.services.security.ScarabSecurity; 52 import org.apache.fulcrum.security.util.TurbineSecurityException; 53 import org.tigris.scarab.util.ScarabConstants; 54 import java.util.List ; 55 import java.util.Iterator ; 56 57 64 public class RModuleUserAttribute 65 extends org.tigris.scarab.om.BaseRModuleUserAttribute 66 implements Persistent 67 { 68 72 public void delete(ScarabUser user) throws Exception 73 { 74 boolean hasPermission = true; 75 if (getModule() != null) 76 { 77 hasPermission = user.hasPermission(ScarabSecurity.USER__EDIT_PREFERENCES,getModule()); 78 } 79 else { 81 List moduleList = user.getCurrentMITList().getModules(); 82 for (Iterator iter = moduleList.iterator(); iter.hasNext(); ) 83 { 84 hasPermission = user.hasPermission(ScarabSecurity.USER__EDIT_PREFERENCES,(Module)iter.next()); 85 if (!hasPermission) 86 { 87 break; 88 } 89 } 90 } 91 if (hasPermission) 92 { 93 Criteria c = new Criteria() 94 .add(RModuleUserAttributePeer.MODULE_ID, getModuleId()) 95 .add(RModuleUserAttributePeer.USER_ID, getUserId()) 96 .add(RModuleUserAttributePeer.ISSUE_TYPE_ID, getIssueTypeId()) 97 .add(RModuleUserAttributePeer.LIST_ID, getListId()) 98 .add(RModuleUserAttributePeer.ATTRIBUTE_ID, getAttributeId()); 99 RModuleUserAttributePeer.doDelete(c); 100 } 101 else 102 { 103 throw new TurbineSecurityException(ScarabConstants.NO_PERMISSION_MESSAGE); } 105 } 106 } 107 | Popular Tags |