Changeset 265
- Timestamp:
- 01/06/08 00:10:44 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lex/trunk/src/com/qwirx/lex/emdros/EmdrosDatabase.java
r259 r265 322 322 try 323 323 { 324 if (!canWriteTo(objectType, id_ds)) 325 { 326 throw new DatabaseException("You do not have permission "+ 327 "to modify this object", changeType + " " + objectType + 328 " " + objectIds); 324 if (changeType != EmdrosChange.CREATE) 325 { 326 if (id_ds != null && !canWriteTo(objectType, id_ds)) 327 { 328 throw new DatabaseException("You do not have permission "+ 329 "to modify this object", changeType + " " + objectType + 330 " " + objectIds); 331 } 332 // must check access to monads later 329 333 } 330 334 } … … 452 456 } 453 457 454 public boolean canWriteTo(String objectType, int[] objectIds)455 throws DatabaseException , EmdrosException458 public SetOfMonads getObjectMonads(String type, int [] objectIds) 459 throws DatabaseException 456 460 { 457 461 String query = "GET MONADS FROM OBJECTS WITH ID_DS = "; … … 466 470 } 467 471 468 Table table = getTable(query + " ["+ objectType+"]");472 Table table = getTable(query + " ["+type+"]"); 469 473 470 474 TableIterator rows = table.iterator(); … … 481 485 } 482 486 } 483 catch ( TableException e)487 catch (EmdrosException e) 484 488 { 485 489 throw new DatabaseException("Failed to get monads from object", … … 487 491 } 488 492 489 return canWriteTo(monads); 490 } 491 492 private boolean canWriteTo(SetOfMonads monads) 493 return monads; 494 } 495 496 public boolean canWriteTo(String objectType, int[] objectIds) 497 throws DatabaseException 498 { 499 return canWriteTo(getObjectMonads(objectType, objectIds)); 500 } 501 502 public boolean canWriteTo(SetOfMonads monads) 493 503 throws DatabaseException 494 504 { … … 497 507 498 508 String query = "SELECT Monad_First, Monad_Last " + 499 "FROM user_text_access " +500 "WHERE (User_Name = ? OR User_Name = 'anonymous') " +501 "AND Write_Access = '1'";509 "FROM user_text_access " + 510 "WHERE (User_Name = ? OR User_Name = 'anonymous') " + 511 "AND Write_Access = '1'"; 502 512 503 513 try … … 515 525 int first = 0; 516 526 int last = 0; 527 528 SetOfMonads copy = new SetOfMonads(monads); 517 529 518 530 try … … 523 535 last = rs.getInt(2); 524 536 MonadSetElement mse = new MonadSetElement(first, last); 525 monads.removeMSE(mse);537 copy.removeMSE(mse); 526 538 } 527 539 … … 540 552 } 541 553 542 return monads.isEmpty();554 return copy.isEmpty(); 543 555 } 544 556
