Changeset 1424 for raptor-client


Ignore:
Timestamp:
08/09/12 16:57:51 (8 years ago)
Author:
philsmart
Message:
 
Location:
raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/registry/Endpoint.java

    r1176 r1424  
    2626 
    2727import uk.ac.cardiff.model.event.Event; 
     28import uk.ac.cardiff.model.wsmodel.StatisticParameters.ResourceCategory; 
    2829import uk.ac.cardiff.raptor.attribute.filtering.AttributeFilterPolicy; 
    2930import uk.ac.cardiff.raptor.remoting.policy.PushPolicy; 
     
    5758    /** Which event types can be sent to this endpoint. */ 
    5859    private Class<?>[] supportedEvents; 
     60 
     61    /** 
     62     * The resource category this endpoint supports, e.g. internal, external or all. 
     63     */ 
     64    private ResourceCategory supportedResourceCategory; 
    5965 
    6066    /** 
     
    165171    } 
    166172 
     173    /** 
     174     * @param supportedResourceCategory the supportedResourceCategory to set 
     175     */ 
     176    public void setSupportedResourceCategory(ResourceCategory supportedResourceCategory) { 
     177        this.supportedResourceCategory = supportedResourceCategory; 
     178    } 
     179 
     180    /** 
     181     * @return the supportedResourceCategory 
     182     */ 
     183    public ResourceCategory getSupportedResourceCategory() { 
     184        return supportedResourceCategory; 
     185    } 
     186 
    167187} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/remoting/client/EventReleaseEngine.java

    r1176 r1424  
    3131import uk.ac.cardiff.model.event.auxiliary.EventMetadata; 
    3232import uk.ac.cardiff.model.wsmodel.EventPushMessage; 
     33import uk.ac.cardiff.model.wsmodel.StatisticParameters.ResourceCategory; 
    3334import uk.ac.cardiff.raptor.attribute.filtering.AttrributeFilterEngine; 
    3435import uk.ac.cardiff.raptor.registry.Endpoint; 
     
    6566            List<Event> applicableEvents = chronologicalFilter(endpoint, events); 
    6667            applicableEvents = eventTypeFilter(endpoint, applicableEvents); 
     68            applicableEvents = eventResourceCategoryFilter(endpoint, applicableEvents); 
    6769            boolean shouldRelease = shouldRelease(endpoint, applicableEvents); 
    6870            log.debug("Endpoint {}, should release {}", endpoint.getServiceEndpoint(), shouldRelease); 
     
    100102 
    101103    /** 
    102      * Method that returns those events that are supported by the <code>endpoint</code parameter. 
     104     * Method that returns those events that are supported by the <code>endpoint</code>. For example, if the endpoint on 
     105     * supports Shibboleth Events, only Shibboleth events are returned by this method. If no supported event types are 
     106     * configured on the endpoint, ALL events are removed. 
    103107     *  
    104108     * @param endpoint 
     
    132136    } 
    133137 
     138    /** 
     139     * Method that returns those events that are of a resource category supported by the <code>endpoint</code>. For 
     140     * example, if the endpoint only supports EXTERNAL Events, only EXTERNAL events are returned by this method. If the 
     141     * endpoint has not specified a resource category type, no events are filtered, so the input is equal to the output. 
     142     *  
     143     * @param endpoint 
     144     * @param events 
     145     * @return 
     146     */ 
     147    private List<Event> eventResourceCategoryFilter(Endpoint endpoint, List<Event> events) { 
     148        if (endpoint.getSupportedResourceCategory() == null) { 
     149            log.info( 
     150                    "There are {} events to send to the endpoint [{}] after resource category type filtering. No filtering performed, has the endpoint been set" 
     151                            + " with a supported resource category type?", events.size(), endpoint.getServiceEndpoint()); 
     152            return new ArrayList<Event>(); 
     153        } 
     154        ArrayList<Event> applicableEvents = new ArrayList<Event>(); 
     155        for (Event event : events) { 
     156            boolean supported = false; 
     157            ResourceCategory resourceCategory = endpoint.getSupportedResourceCategory(); 
     158            for (int category : resourceCategory.getResourceIdCategory()) { 
     159                if (event.getResourceIdCategory() == category) { 
     160                    supported = true; 
     161                } 
     162            } 
     163            if (supported) { 
     164                applicableEvents.add(event); 
     165            } 
     166 
     167        } 
     168        log.info("There are {} events to send to the endpoint [{}] after resource category type filtering", 
     169                applicableEvents.size(), endpoint.getServiceEndpoint()); 
     170        return applicableEvents; 
     171    } 
     172 
    134173    private void appendMetadata(List<Event> events, ServiceMetadata metadata) { 
    135174        for (Event event : events) { 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/runtimeutils/ReflectionHelper.java

    r1364 r1424  
    7979    public static void nullAttribute(Object object, String attributeID) { 
    8080        try { 
    81             // log.debug("Setting {} to null on object {}",attributeID,object); 
    82             Class id = object.getClass(); 
     81            log.trace("Setting {} to null on object {}", attributeID, object); 
     82            Class<?> id = object.getClass(); 
    8383            String fieldAsMethod = prepareMethodNameSet(attributeID); 
    8484            Method[] methods = id.getMethods(); 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/store/DefaultEventStorageEngine.java

    r1355 r1424  
    102102 
    103103    /** {@inheritDoc} */ 
    104     public List<Event> getEventsOnOrAfter(DateTime earliestReleaseTime) { 
    105         List<Event> query = 
    106                 (List<Event>) eventHandler.query("from Event where eventTime >= ?", new Object[] {earliestReleaseTime}); 
     104    public List<Event> getEventsOnOrAfter(Class<? extends Event> eventType, DateTime earliestReleaseTime) { 
     105        @SuppressWarnings("unchecked") List<Event> query = 
     106                (List<Event>) eventHandler.query("from " + eventType.getCanonicalName() + " where eventTime >= ?", 
     107                        new Object[] {earliestReleaseTime}); 
    107108        return query; 
    108109    } 
    109110 
    110111    /** {@inheritDoc} */ 
    111     public List<Event> getEventsOnOrAfter(DateTime earliestReleaseTime, int maxNoResults) { 
    112         List<Event> query = 
    113                 (List<Event>) eventHandler.query("from Event where eventTime >= ? order by eventTime asc", 
    114                         new Object[] {earliestReleaseTime}, maxNoResults); 
     112    public List<Event> getEventsOnOrAfter(Class<? extends Event> eventType, DateTime earliestReleaseTime, 
     113            int maxNoResults) { 
     114        @SuppressWarnings("unchecked") List<Event> query = 
     115                (List<Event>) eventHandler.query("from " + eventType.getCanonicalName() 
     116                        + " where eventTime >= ? order by eventTime asc", new Object[] {earliestReleaseTime}, 
     117                        maxNoResults); 
    115118        return query; 
    116119    } 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/store/EventStorageEngine.java

    r1355 r1424  
    5252     * @return 
    5353     */ 
    54     public List<Event> getEventsOnOrAfter(DateTime earliestReleaseTime); 
     54    public List<Event> getEventsOnOrAfter(Class<? extends Event> eventType, DateTime earliestReleaseTime); 
    5555 
    5656    /** 
     
    6262     * @return 
    6363     */ 
    64     public List<Event> getEventsOnOrAfter(DateTime earliestReleaseTime, int maxNoResults); 
     64    public List<Event> getEventsOnOrAfter(Class<? extends Event> eventType, DateTime earliestReleaseTime, 
     65            int maxNoResults); 
    6566 
    6667    /** 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/store/impl/PersistantEventHandler.java

    r1202 r1424  
    114114 
    115115    public List query(String query, Object[] parameters, int maxNoResults) { 
     116        log.debug("Running query [{}]", query); 
    116117        return dataConnection.runQuery(query, parameters, maxNoResults); 
    117118    } 
Note: See TracChangeset for help on using the changeset viewer.