1 19 20 package com.sslexplorer.policyframework; 21 22 import com.sslexplorer.boot.Util; 23 import com.sslexplorer.core.CoreAttributeConstants; 24 import com.sslexplorer.core.CoreEvent; 25 import com.sslexplorer.security.SessionInfo; 26 27 33 public class ResourceDeleteEvent extends CoreEvent { 34 35 private Resource resource; 36 37 46 public ResourceDeleteEvent(Object source, int id, 47 SessionInfo session, Throwable exception) { 48 super(source, id, exception, session, STATE_UNSUCCESSFUL); 49 addAttribute(CoreAttributeConstants.EVENT_ATTR_EXCEPTION_MESSAGE, 50 Util.getExceptionMessageChain(exception)); 51 52 53 } 54 55 64 public ResourceDeleteEvent(Object source, int id, Resource resource, 65 SessionInfo session, int state) { 66 super(source, id, resource, session, state); 67 this.resource = resource; 68 if(state == CoreEvent.STATE_UNSUCCESSFUL || ( state == CoreEvent.STATE_SUCCESSFUL && resource != null) ) { 69 if(resource != null) { 70 addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_NAME, resource.getResourceName()); 71 if(resource instanceof OwnedResource) { 72 OwnedResource or = (OwnedResource)resource; 73 if(or.getOwnerUsername() != null) { 74 addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_OWNER, or.getOwnerUsername()); 75 } 76 } 77 } 78 } 79 else { 80 throw new IllegalArgumentException ("Must provide a non-null resource if the event was successful."); 81 } 82 } 83 84 89 public Resource getResource() { 90 return resource; 91 } 92 93 } 94 | Popular Tags |