1 64 65 package com.jcorporate.expresso.ext.dbobj; 66 67 import com.jcorporate.expresso.core.db.DBConnection; 68 import com.jcorporate.expresso.core.db.DBException; 69 import com.jcorporate.expresso.core.dbobj.DBObject; 70 import com.jcorporate.expresso.core.dbobj.RequestContext; 71 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 72 import com.jcorporate.expresso.core.security.User; 73 74 84 public class RestrictedOverrides 85 extends SecuredDBObject { 86 static public final String FLD_EXPUID = "ExpUID"; 87 static public final String FLD_ALLOWED = "IsAllowed"; 88 89 95 static public final int OVERRIDE_ALLOWED = 1; 96 97 102 static public final int OVERRIDE_DENIED = 0; 103 104 109 static public final int OVERRIDE_NOT_FOUND = -1; 110 111 116 public RestrictedOverrides() 117 throws DBException { 118 super(); 119 } 120 121 127 public RestrictedOverrides(DBConnection myConnection) 128 throws DBException { 129 super(myConnection); 130 } 131 132 139 public RestrictedOverrides(int uid) 140 throws DBException { 141 super(uid); 142 } 143 144 151 public RestrictedOverrides(RequestContext request) 152 throws DBException { 153 super(request); 154 } 155 156 161 public synchronized DBObject getThisDBObj() 162 throws DBException { 163 return new RestrictedOverrides(); 164 } 165 166 167 174 public int isAllowed(User aUser) 175 throws DBException { 176 int expUID = aUser.getUid(); 177 this.setField(FLD_EXPUID, expUID); 178 179 if (this.find()) { 180 if (getFieldBoolean(FLD_ALLOWED)) { 181 return OVERRIDE_ALLOWED; 182 } else { 183 return OVERRIDE_DENIED; 184 } 185 } else { 186 return OVERRIDE_NOT_FOUND; 187 } 188 } 189 190 193 protected void setupFields() 194 throws DBException { 195 setTargetTable("RESTRICTOVRRIDE"); 196 setDescription("Restricted Downloads Overrides"); 197 setCharset("ISO-8859-1"); 198 addField(FLD_EXPUID, "int", 0, false, "User ID Number"); 199 addField(FLD_ALLOWED, "boolean", 0, false, "Is Download Allowed"); 200 addKey(FLD_EXPUID); 201 getMetaData().setAttribute(FLD_ALLOWED, "checkbox", "Y"); 202 } 203 204 205 } | Popular Tags |