1 19 20 package com.sslexplorer.properties; 21 22 import com.sslexplorer.core.CoreEvent; 23 import com.sslexplorer.core.CoreEventConstants; 24 import com.sslexplorer.core.CoreServlet; 25 import com.sslexplorer.policyframework.DefaultResourceType; 26 import com.sslexplorer.policyframework.Resource; 27 import com.sslexplorer.policyframework.ResourceChangeEvent; 28 import com.sslexplorer.security.SessionInfo; 29 30 31 37 public class PropertyProfileResourceType extends DefaultResourceType { 38 39 45 public PropertyProfileResourceType(int id, String permissionClass) { 46 super(id, "policyframework", permissionClass); 47 } 48 49 52 public Resource getResourceById(int resourceId) throws Exception { 53 return ProfilesFactory.getInstance().getPropertyProfile(resourceId); 54 } 55 56 59 public Resource getResourceByName(String resourceName, SessionInfo session) throws Exception { 60 return ProfilesFactory.getInstance().getPropertyProfile(null, resourceName, session.getUser().getRealm().getResourceId()); 61 } 62 63 64 67 public Resource removeResource(int resourceId, SessionInfo session) throws Exception { 68 try { 69 PropertyProfile resource = 70 ProfilesFactory.getInstance().deletePropertyProfile(resourceId); 71 CoreServlet.getServlet().fireCoreEvent( 72 new ResourceChangeEvent(this, CoreEventConstants.DELETE_PROPERTY_PROFILE, resource, session, 73 CoreEvent.STATE_SUCCESSFUL)); 74 return resource; 75 } catch (Exception e) { 76 CoreServlet.getServlet().fireCoreEvent( 77 new ResourceChangeEvent(this, CoreEventConstants.DELETE_PROPERTY_PROFILE, null, session, 78 CoreEvent.STATE_UNSUCCESSFUL)); 79 throw e; 80 } 81 } 82 83 86 public void updateResource(Resource resource, SessionInfo session) throws Exception { 87 try { 88 PropertyProfile profile = (PropertyProfile)resource; 89 ProfilesFactory.getInstance().updatePropertyProfile( 90 profile.getResourceId(), 91 profile.getResourceName(), 92 profile.getResourceDescription()); 93 CoreServlet.getServlet().fireCoreEvent( 94 new ResourceChangeEvent(this, CoreEventConstants.UPDATE_PROPERTY_PROFILE, resource, session, 95 CoreEvent.STATE_SUCCESSFUL)); 96 } catch (Exception e) { 97 CoreServlet.getServlet().fireCoreEvent( 98 new ResourceChangeEvent(this, CoreEventConstants.UPDATE_PROPERTY_PROFILE, session, e)); 99 throw e; 100 } 101 } 102 } 103 | Popular Tags |