1 19 20 package org.apache.cayenne; 21 22 29 public class DeleteDenyException extends CayenneRuntimeException { 30 31 protected Persistent object; 32 protected String relationship; 33 34 public DeleteDenyException() { 35 } 36 37 public DeleteDenyException(String message) { 38 super(message); 39 } 40 41 44 public DeleteDenyException(Persistent object, String relationship, String reason) { 45 super(reason); 46 47 this.object = object; 48 this.relationship = relationship; 49 } 50 51 54 public Persistent getObject() { 55 return object; 56 } 57 58 61 public String getRelationship() { 62 return relationship; 63 } 64 65 public String getMessage() { 66 StringBuffer buffer = new StringBuffer (); 67 buffer.append("Can't delete object"); 68 69 if (object != null && object.getObjectId() != null) { 70 buffer.append(" with OID ").append(object.getObjectId()); 71 } 72 73 if (relationship != null) { 74 buffer.append(". Reason: relationship '").append(relationship).append( 75 "' has 'deny' delete rule"); 76 } 77 78 String message = super.getUnlabeledMessage(); 79 if (message != null) { 80 buffer.append(". Details: ").append(message); 81 } 82 83 return buffer.toString(); 84 } 85 } 86 | Popular Tags |