1 9 package org.webdocwf.dods.access; 10 11 import java.sql.ResultSet ; 12 import java.sql.SQLException ; 13 import com.lutris.appserver.server.sql.DBRowUpdateException; 14 import com.lutris.appserver.server.sql.DBTransaction; 15 import com.lutris.appserver.server.sql.DatabaseManagerException; 16 import com.lutris.appserver.server.sql.ObjectId; 17 import com.lutris.appserver.server.sql.ObjectIdException; 18 import com.lutris.dods.builder.generator.dataobject.GenericDO; 19 import com.lutris.dods.builder.generator.query.DataObjectException; 20 import com.lutris.dods.builder.generator.query.QueryException; 21 import com.lutris.dods.builder.generator.query.RefAssertionException; 22 23 public abstract class SecureDO extends GenericDO { 24 25 32 public abstract void delete() throws SQLException , DatabaseManagerException, DataObjectException, RefAssertionException, DBRowUpdateException, QueryException; 33 34 45 public abstract void delete(DBTransaction dbt) throws SQLException , DatabaseManagerException, DataObjectException, RefAssertionException, DBRowUpdateException, QueryException; 46 47 53 protected abstract void checkLoad() throws DataObjectException; 54 55 public abstract String getHandle() throws DatabaseManagerException; 56 57 public abstract String get_Handle() throws DatabaseManagerException; 58 59 public abstract boolean hasMatchingHandle(String handle); 60 61 65 public abstract boolean isReadOnly(); 66 67 74 public abstract void makeReadOnly(); 75 76 82 public abstract void makeReadWrite(); 83 84 public SecureDO() throws DatabaseManagerException, ObjectIdException { 85 super(); 86 } 87 88 public SecureDO(String dbName) throws DatabaseManagerException, ObjectIdException { 89 super(dbName); 90 } 91 92 public SecureDO(boolean isView) throws ObjectIdException, DatabaseManagerException { 93 super(isView); 94 } 95 96 public SecureDO(String dbName, boolean isView) throws ObjectIdException, DatabaseManagerException { 97 super(dbName, isView); 98 } 99 100 public SecureDO(ObjectId id) throws ObjectIdException, DatabaseManagerException { 101 super(id); 102 } 103 104 public SecureDO(String dbName, ObjectId id) throws ObjectIdException, DatabaseManagerException { 105 super(dbName, id); 106 } 107 108 public SecureDO(ResultSet rs) throws SQLException , ObjectIdException, DatabaseManagerException { 109 super(rs); 110 } 111 112 public SecureDO(String dbName, ResultSet rs) throws SQLException , ObjectIdException, DatabaseManagerException { 113 super(dbName, rs); 114 } 115 116 130 public void delete(org.webdocwf.dods.access.User usr) 131 throws SQLException , DatabaseManagerException, DataObjectException, RefAssertionException, DBRowUpdateException, QueryException, AccessException { 132 assertDODeleteAccess(usr); 133 delete(); 134 } 135 136 147 public void assertDODeleteAccess(org.webdocwf.dods.access.User usr) 148 throws AccessException { 149 if (!hasDODeleteAccess(usr)) { 150 throw new AccessRightException("No access !", usr, "Delete", this, 151 null, null, null, null, null, null); 152 } 153 } 154 155 167 public boolean hasDODeleteAccess(org.webdocwf.dods.access.User usr) 168 throws AccessEvalException { 169 try { 170 checkLoad(); 171 } catch (Exception e) { 172 throw new AccessEvalException("Error in hasDODeleteAccess/checkLoad !", 173 e, usr, "Delete", this, null, null, null, null, null, null); 174 } 175 return usr.hasDODeleteAccess(this); 176 } 177 178 193 public void delete(DBTransaction dbt, org.webdocwf.dods.access.User usr) 194 throws SQLException , DatabaseManagerException, DataObjectException, RefAssertionException, DBRowUpdateException, QueryException, AccessException { 195 assertDODeleteAccess(usr); 196 delete(dbt); 197 } 198 199 210 public void assertDOCopyAccess(org.webdocwf.dods.access.User usr) 211 throws AccessException { 212 if (!hasDOCopyAccess(usr)) { 213 throw new AccessRightException("No access !", usr, "Copy", this, 214 null, null, null, null, null, null); 215 } 216 } 217 218 227 public boolean hasDOCopyAccess(org.webdocwf.dods.access.User usr) 228 throws AccessEvalException { 229 try { 230 checkLoad(); 231 } catch (Exception e) { 232 throw new AccessEvalException("Error in hasDoCopyAccess/checkLoad !", 233 e, usr, "Copy", this, null, null, null, null, null, null); 234 } 235 return usr.hasDOCopyAccess(this); 236 } 237 238 256 public String get_Handle(org.webdocwf.dods.access.User usr) 257 throws DatabaseManagerException, AccessException { 258 assertDOGetAccess(usr); 259 return getHandle(); 260 } 261 262 280 public String getHandle(org.webdocwf.dods.access.User usr) 281 throws DatabaseManagerException, AccessException { 282 return get_Handle(); 283 } 284 285 299 public boolean hasMatchingHandle(String handle, org.webdocwf.dods.access.User usr) 300 throws AccessException { 301 assertDOGetAccess(usr); 302 return hasMatchingHandle(handle); 303 } 304 305 319 public boolean hasDOGetAttrAccess(String attrName, Object value, org.webdocwf.dods.access.User usr) 320 throws AccessEvalException { 321 try { 322 checkLoad(); 323 } catch (Exception e) { 324 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 325 e, usr, "GetAttr", this, null, attrName, null, null, 326 "Object", null); 327 } 328 return usr.hasDOGetAttrAccess(this, attrName, value); 329 } 330 331 343 public boolean hasDOGetAttrAccess(String attrName, boolean value, org.webdocwf.dods.access.User usr) 344 throws AccessEvalException { 345 try { 346 checkLoad(); 347 } catch (Exception e) { 348 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 349 e, usr, "GetAttr", this, null, attrName, null, null, 350 "boolean", null); 351 } 352 return usr.hasDOGetAttrAccess(this, attrName, value); 353 } 354 355 367 public boolean hasDOGetAttrAccess(String attrName, byte value, org.webdocwf.dods.access.User usr) 368 throws AccessEvalException { 369 try { 370 checkLoad(); 371 } catch (Exception e) { 372 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 373 e, usr, "GetAttr", this, null, attrName, null, null, "byte", 374 null); 375 } 376 return usr.hasDOGetAttrAccess(this, attrName, value); 377 } 378 379 391 public boolean hasDOGetAttrAccess(String attrName, short value, org.webdocwf.dods.access.User usr) 392 throws AccessEvalException { 393 try { 394 checkLoad(); 395 } catch (Exception e) { 396 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 397 e, usr, "GetAttr", this, null, attrName, null, null, "short", 398 null); 399 } 400 return usr.hasDOGetAttrAccess(this, attrName, value); 401 } 402 403 415 public boolean hasDOGetAttrAccess(String attrName, int value, org.webdocwf.dods.access.User usr) 416 throws AccessEvalException { 417 try { 418 checkLoad(); 419 } catch (Exception e) { 420 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 421 e, usr, "GetAttr", this, null, attrName, null, null, "int", 422 null); 423 } 424 return usr.hasDOGetAttrAccess(this, attrName, value); 425 } 426 427 439 public boolean hasDOGetAttrAccess(String attrName, long value, org.webdocwf.dods.access.User usr) 440 throws AccessEvalException { 441 try { 442 checkLoad(); 443 } catch (Exception e) { 444 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 445 e, usr, "GetAttr", this, null, attrName, null, null, "long", 446 null); 447 } 448 return usr.hasDOGetAttrAccess(this, attrName, value); 449 } 450 451 463 public boolean hasDOGetAttrAccess(String attrName, float value, org.webdocwf.dods.access.User usr) 464 throws AccessEvalException { 465 try { 466 checkLoad(); 467 } catch (Exception e) { 468 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 469 e, usr, "GetAttr", this, null, attrName, null, null, "float", 470 null); 471 } 472 return usr.hasDOGetAttrAccess(this, attrName, value); 473 } 474 475 487 public boolean hasDOGetAttrAccess(String attrName, double value, org.webdocwf.dods.access.User usr) 488 throws AccessEvalException { 489 try { 490 checkLoad(); 491 } catch (Exception e) { 492 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 493 e, usr, "GetAttr", this, null, attrName, null, null, 494 "double", null); 495 } 496 return usr.hasDOGetAttrAccess(this, attrName, value); 497 } 498 499 511 public boolean hasDOGetAttrAccess(String attrName, byte[] value, org.webdocwf.dods.access.User usr) 512 throws AccessEvalException { 513 try { 514 checkLoad(); 515 } catch (Exception e) { 516 throw new AccessEvalException("Error in hasDoGetAttrAccess/checkLoad !", 517 e, usr, "GetAttr", this, null, attrName, null, null, 518 "byte[]", null); 519 } 520 return usr.hasDOGetAttrAccess(this, attrName, value); 521 } 522 523 536 protected boolean hasDOSetAttrAccess(String attrName, Object oldValue, Object newValue, org.webdocwf.dods.access.User usr) 537 throws AccessEvalException { 538 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 539 } 540 541 554 protected boolean hasDOSetAttrAccess(String attrName, boolean oldValue, boolean newValue, org.webdocwf.dods.access.User usr) 555 throws AccessEvalException { 556 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 557 } 558 559 572 protected boolean hasDOSetAttrAccess(String attrName, byte oldValue, byte newValue, org.webdocwf.dods.access.User usr) 573 throws AccessEvalException { 574 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 575 } 576 577 590 protected boolean hasDOSetAttrAccess(String attrName, short oldValue, short newValue, org.webdocwf.dods.access.User usr) 591 throws AccessEvalException { 592 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 593 } 594 595 608 protected boolean hasDOSetAttrAccess(String attrName, int oldValue, int newValue, org.webdocwf.dods.access.User usr) 609 throws AccessEvalException { 610 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 611 } 612 613 626 protected boolean hasDOSetAttrAccess(String attrName, long oldValue, long newValue, org.webdocwf.dods.access.User usr) 627 throws AccessEvalException { 628 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 629 } 630 631 644 protected boolean hasDOSetAttrAccess(String attrName, float oldValue, float newValue, org.webdocwf.dods.access.User usr) 645 throws AccessEvalException { 646 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 647 } 648 649 662 protected boolean hasDOSetAttrAccess(String attrName, double oldValue, double newValue, org.webdocwf.dods.access.User usr) 663 throws AccessEvalException { 664 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 665 } 666 667 680 protected boolean hasDOSetAttrAccess(String attrName, byte[] oldValue, byte[] newValue, org.webdocwf.dods.access.User usr) 681 throws AccessEvalException { 682 return usr.hasDOSetAttrAccess(this, attrName, oldValue, newValue); 683 } 684 685 699 public void assertDOGetDOValueAccess(String attrName, SecureDO value, org.webdocwf.dods.access.User usr) 700 throws AccessException { 701 if (value != null) { 702 if (!value.hasDOGetAccess(usr)) { 703 throw new AccessRightException("No access !", usr, "GETDOValue", 704 this, null, attrName, null, null, null, null); 705 } 706 } 707 } 708 709 720 protected boolean hasDOGetDOValueAccess(SecureDO value, org.webdocwf.dods.access.User usr) 721 throws AccessEvalException { 722 return value.hasDOGetAccess(usr); 723 } 724 725 731 protected boolean hasDOGetDOValueAccess(Object value, org.webdocwf.dods.access.User usr) 732 throws AccessEvalException { 733 if (false) { 734 throw new AccessEvalException("Should never occur !"); 735 } 736 return true; 737 } 738 739 745 protected boolean hasDOGetDOValueAccess(boolean value, org.webdocwf.dods.access.User usr) 746 throws AccessEvalException { 747 if (false) { 748 throw new AccessEvalException("Should never occur !"); 749 } 750 return true; 751 } 752 753 759 protected boolean hasDOGetDOValueAccess(byte value, org.webdocwf.dods.access.User usr) 760 throws AccessEvalException { 761 if (false) { 762 throw new AccessEvalException("Should never occur !"); 763 } 764 return true; 765 } 766 767 773 protected boolean hasDOGetDOValueAccess(short value, org.webdocwf.dods.access.User usr) 774 throws AccessEvalException { 775 if (false) { 776 throw new AccessEvalException("Should never occur !"); 777 } 778 return true; 779 } 780 781 787 protected boolean hasDOGetDOValueAccess(int value, org.webdocwf.dods.access.User usr) 788 throws AccessEvalException { 789 if (false) { 790 throw new AccessEvalException("Should never occur !"); 791 } 792 return true; 793 } 794 795 801 protected boolean hasDOGetDOValueAccess(long value, org.webdocwf.dods.access.User usr) 802 throws AccessEvalException { 803 if (false) { 804 throw new AccessEvalException("Should never occur !"); 805 } 806 return true; 807 } 808 809 815 protected boolean hasDOGetDOValueAccess(float value, org.webdocwf.dods.access.User usr) 816 throws AccessEvalException { 817 if (false) { 818 throw new AccessEvalException("Should never occur !"); 819 } 820 return true; 821 } 822 823 829 protected boolean hasDOGetDOValueAccess(double value, org.webdocwf.dods.access.User usr) 830 throws AccessEvalException { 831 if (false) { 832 throw new AccessEvalException("Should never occur !"); 833 } 834 return true; 835 } 836 837 843 protected boolean hasDOGetDOValueAccess(byte[] value, org.webdocwf.dods.access.User usr) 844 throws AccessEvalException { 845 if (false) { 846 throw new AccessEvalException("Should never occur !"); 847 } 848 return true; 849 } 850 851 857 protected void assertDOGetDOValueAccess(String attrName, Object value, org.webdocwf.dods.access.User usr) 858 throws AccessException { 859 if (false) { 860 throw new AccessEvalException("Should never occur !"); 861 } 862 } 863 864 870 protected void assertDOGetDOValueAccess(String attrName, boolean value, org.webdocwf.dods.access.User usr) 871 throws AccessException { 872 if (false) { 873 throw new AccessEvalException("Should never occur !"); 874 } 875 } 876 877 883 protected void assertDOGetDOValueAccess(String attrName, byte value, org.webdocwf.dods.access.User usr) 884 throws AccessException { 885 if (false) { 886 throw new AccessEvalException("Should never occur !"); 887 } 888 } 889 890 896 protected void assertDOGetDOValueAccess(String attrName, short value, org.webdocwf.dods.access.User usr) 897 throws AccessException { 898 if (false) { 899 throw new AccessEvalException("Should never occur !"); 900 } 901 } 902 903 909 protected void assertDOGetDOValueAccess(String attrName, int value, org.webdocwf.dods.access.User usr) 910 throws AccessException { 911 if (false) { 912 throw new AccessEvalException("Should never occur !"); 913 } 914 } 915 916 922 protected void assertDOGetDOValueAccess(String attrName, long value, org.webdocwf.dods.access.User usr) 923 throws AccessException { 924 if (false) { 925 throw new AccessEvalException("Should never occur !"); 926 } 927 } 928 929 935 protected void assertDOGetDOValueAccess(String attrName, float value, org.webdocwf.dods.access.User usr) 936 throws AccessException { 937 if (false) { 938 throw new AccessEvalException("Should never occur !"); 939 } 940 } 941 942 948 protected void assertDOGetDOValueAccess(String attrName, double value, org.webdocwf.dods.access.User usr) 949 throws AccessException { 950 if (false) { 951 throw new AccessEvalException("Should never occur !"); 952 } 953 } 954 955 961 protected void assertDOGetDOValueAccess(String attrName, byte[] value, org.webdocwf.dods.access.User usr) 962 throws AccessException { 963 if (false) { 964 throw new AccessEvalException("Should never occur !"); 965 } 966 } 967 968 978 public boolean hasQueryFindAccess(org.webdocwf.dods.access.User usr) 979 throws AccessEvalException { 980 if (usr == null) { 981 return false; 982 } 983 try { 984 checkLoad(); 985 } catch (Exception e) { 986 throw new AccessEvalException("Error in hasQueryFindAccess/checkLoad !", 987 e, usr, "Query", this, null, null, null, null, null, null); 988 } 989 return usr.hasQueryFindAccess(this); 990 } 991 992 999 public int getVersion() { 1000 return get_Version(); 1001 } 1002 1003 1011 public int get_Version() { 1012 return super.get_Version(); 1013 } 1014 1015 1024 public int get_Version(org.webdocwf.dods.access.User usr) 1025 throws AccessException { 1026 assertDOGetVersionAccess(usr); 1027 return get_Version(); 1028 } 1029 1030 1038 public void assertDOGetVersionAccess(org.webdocwf.dods.access.User usr) 1039 throws AccessException { 1040 if (!hasDOGetVersionAccess(usr)) { 1041 throw new AccessRightException("No access !", usr, "GetVersion", 1042 this, null, null, null, null, null, null); 1043 } 1044 } 1045 1046 1055 public boolean hasDOGetVersionAccess(org.webdocwf.dods.access.User usr) 1056 throws AccessEvalException { 1057 try { 1058 checkLoad(); 1059 } catch (Exception e) { 1060 throw new AccessEvalException("Error in hasDOGetVersionAccess/checkLoad !", 1061 e, usr, "GetVersion", this, null, null, null, null, null, 1062 null); 1063 } 1064 return usr.hasDOGetVersionAccess(this); 1065 } 1066 1067 1077 public boolean isReadOnly(org.webdocwf.dods.access.User usr) 1078 throws AccessException { 1079 assertDOIsReadOnlyAccess(usr); 1080 return isReadOnly(); 1081 } 1082 1083 1091 public void assertDOIsReadOnlyAccess(org.webdocwf.dods.access.User usr) 1092 throws AccessException { 1093 if (!hasDOIsReadOnlyAccess(usr)) { 1094 throw new AccessRightException("No access !", usr, "IsReadOnly", 1095 this, null, null, null, null, null, null); 1096 } 1097 } 1098 1099 1108 public boolean hasDOIsReadOnlyAccess(org.webdocwf.dods.access.User usr) 1109 throws AccessEvalException { 1110 try { 1111 checkLoad(); 1112 } catch (Exception e) { 1113 throw new AccessEvalException("Error in hasDOIsReadOnlyAccess/checkLoad !", 1114 e, usr, "IsReadOnly", this, null, null, null, null, null, 1115 null); 1116 } 1117 return usr.hasDOIsReadOnlyAccess(this); 1118 } 1119 1120 1131 public void assertDOGetAccess(org.webdocwf.dods.access.User usr) 1132 throws AccessException { 1133 if (!hasDOGetAccess(usr)) { 1134 throw new AccessRightException("No access", usr, "Get", this, null, 1135 null, null, null, null, null); 1136 } 1137 } 1138 1139 1148 public boolean hasDOGetAccess(org.webdocwf.dods.access.User usr) 1149 throws AccessEvalException { 1150 try { 1151 checkLoad(); 1152 } catch (Exception e) { 1153 throw new AccessEvalException("Error in hasDoGetAccess/checkLoad !", 1154 e, usr, "Get", this, null, null, null, null, null, null); 1155 } 1156 return usr.hasDOGetAccess(this); 1157 } 1158 1159 1170 public void makeReadOnly(org.webdocwf.dods.access.User usr) 1171 throws AccessException { 1172 assertDOMakeReadOnlyAccess(usr); 1173 makeReadOnly(); 1174 } 1175 1176 1184 public void assertDOMakeReadOnlyAccess(org.webdocwf.dods.access.User usr) 1185 throws AccessException { 1186 if (!hasDOMakeReadOnlyAccess(usr)) { 1187 throw new AccessRightException("No access", usr, "MakeReadOnly", 1188 this, null, null, null, null, null, null); 1189 } 1190 } 1191 1192 1201 public boolean hasDOMakeReadOnlyAccess(org.webdocwf.dods.access.User usr) 1202 throws AccessEvalException { 1203 try { 1204 checkLoad(); 1205 } catch (Exception e) { 1206 throw new AccessEvalException("Error in hasDOMakeReadOnlyAccess/checkLoad !", 1207 e, usr, "MakeReadOnly", this, null, null, null, null, null, 1208 null); 1209 } 1210 return usr.hasDOMakeReadOnlyAccess(this); 1211 } 1212 1213 1221 public void makeReadWrite(org.webdocwf.dods.access.User usr) 1222 throws AccessException { 1223 assertDOMakeReadWriteAccess(usr); 1224 makeReadWrite(); 1225 } 1226 1227 1235 public void assertDOMakeReadWriteAccess(org.webdocwf.dods.access.User usr) 1236 throws AccessException { 1237 if (!hasDOMakeReadWriteAccess(usr)) { 1238 throw new AccessRightException("No access", usr, "MakeReadWrite", 1239 this, null, null, null, null, null, null); 1240 } 1241 } 1242 1243 1252 public boolean hasDOMakeReadWriteAccess(org.webdocwf.dods.access.User usr) 1253 throws AccessEvalException { 1254 try { 1255 checkLoad(); 1256 } catch (Exception e) { 1257 throw new AccessEvalException("Error in hasDOMakeReadWriteAccess/checkLoad !", 1258 e, usr, "MakeReadWrite", this, null, null, null, null, null, 1259 null); 1260 } 1261 return usr.hasDOMakeReadWriteAccess(this); 1262 } 1263 } 1265 | Popular Tags |