Changeset 1049 for raptor-client


Ignore:
Timestamp:
07/19/11 22:55:36 (9 years ago)
Author:
philsmart
Message:
 
Location:
raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor
Files:
1 added
12 edited
1 moved

Legend:

Unmodified
Added
Removed
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/attribute/filtering/AttrributeFilterEngine.java

    r1025 r1049  
    6464     * @param metadata 
    6565     */ 
    66     private void filterAttributes(final Event event, final BaseAttributeRule attributeRule, final ServiceMetadata metadata) { 
     66    private void filterAttributes(final Event event, final BaseAttributeRule attributeRule, 
     67            final ServiceMetadata metadata) { 
    6768        try { 
    6869            if (attributeRule.shouldApply(event.getClass())) { 
     
    7475    } 
    7576 
    76     private List<Event> clone(final List<Event> events) { 
     77    /** 
     78     * Clones the list <code>events</code> 
     79     *  
     80     * @param events the events to clone 
     81     * @return a deep cloned set of <code>Event</code>s 
     82     */ 
     83    private final List<Event> clone(final List<Event> events) { 
    7784        final List<Event> clonedSet = new ArrayList<Event>(); 
    7885        for (final Event event : events) { 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/attribute/filtering/HashAttributeRule.java

    r1025 r1049  
    3232 
    3333/** 
     34 * The Class HashAttributeRule. 
     35 *  
    3436 * @author philsmart 
    35  *  
    3637 */ 
    3738public final class HashAttributeRule extends BaseAttributeRule { 
     
    4041    private final Logger log = LoggerFactory.getLogger(HashAttributeRule.class); 
    4142 
     43    /** The attribute id. */ 
    4244    private String attributeId; 
    4345 
    44     /** The hashing algorithm used, this property is not user definable, its fixed to SHA-256 */ 
     46    /** The hashing algorithm used, this property is not user definable, its fixed to SHA-256. */ 
    4547    private final String HASH_ALGORITHM = "SHA-256"; 
    4648 
     
    4850     * Hash the attribute defined by the <code>attributeId</code> tag, with the entityId name of this service. 
    4951     *  
    50      * @throws AttributeFilterException 
     52     * @param event the event 
     53     * @param metadata the metadata 
     54     * @throws AttributeFilterException the attribute filter exception 
    5155     */ 
    5256    public void filterAttribute(final Event event, final ServiceMetadata metadata) throws AttributeFilterException { 
     
    7781 
    7882    /** 
     83     * Sets the attribute id. 
     84     *  
    7985     * @param attributeId the attributeId to set 
    8086     */ 
     
    8490 
    8591    /** 
     92     * Gets the attribute id. 
     93     *  
    8694     * @return the attributeId 
    8795     */ 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/attribute/filtering/NullAttributeRule.java

    r1025 r1049  
    2222 
    2323/** 
     24 * The Class NullAttributeRule. 
     25 *  
    2426 * @author philsmart 
    25  *  
    2627 */ 
    2728public final class NullAttributeRule extends BaseAttributeRule { 
    2829 
     30    /** The attribute id. */ 
    2931    private String attributeId; 
    3032 
     33    /** 
     34     *  
     35     *  
     36     * @see uk.ac.cardiff.raptor.attribute.filtering.BaseAttributeRule#filterAttribute(uk.ac.cardiff.model.event.Event, 
     37     *      uk.ac.cardiff.model.ServiceMetadata) 
     38     */ 
    3139    public void filterAttribute(final Event event, final ServiceMetadata metadata) { 
    3240        final String attributeID = getAttributeId(); 
     
    3745 
    3846    /** 
    39      * Null the attribute specified by the parameter <code>attributeID</code>. 
     47     * Null the attribute (using reflection) specified by the parameter <code>attributeID</code>. 
    4048     *  
    4149     * @param event the event 
     
    4654    } 
    4755 
     56    /** 
     57     * Sets the attribute id. 
     58     *  
     59     * @param attributeId the new attribute id 
     60     */ 
    4861    public void setAttributeId(final String attributeId) { 
    4962        this.attributeId = attributeId; 
    5063    } 
    5164 
     65    /** 
     66     * Gets the attribute id. 
     67     *  
     68     * @return the attribute id 
     69     */ 
    5270    public String getAttributeId() { 
    5371        return attributeId; 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/attribute/filtering/match/MatchRule.java

    r595 r1049  
    1717 * 
    1818 */ 
     19 
    1920package uk.ac.cardiff.raptor.attribute.filtering.match; 
    2021 
    2122/** 
     23 * The Class MatchRule. 
     24 *  
    2225 * @author philsmart 
    23  * 
    2426 */ 
    2527public class MatchRule { 
    2628 
     29    /** The enabled. */ 
    2730    private boolean enabled; 
    2831 
    29     public void setEnabled(boolean enabled) { 
    30         this.enabled = enabled; 
     32    /** 
     33     * Sets whether this rule is enabled. 
     34     *  
     35     * @param enabled the new enabled 
     36     */ 
     37    public void setEnabled(final boolean enabled) { 
     38        this.enabled = enabled; 
    3139    } 
    3240 
     41    /** 
     42     * Checks if this rule is enabled. 
     43     *  
     44     * @return true, if is enabled 
     45     */ 
    3346    public boolean isEnabled() { 
    34         return enabled; 
     47        return enabled; 
    3548    } 
    3649 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/event/expansion/AttributeAssociationEngine.java

    r817 r1049  
    3838 
    3939    /** Defines which attributes to add, and what principal to attach to*/ 
    40     private List<AttributeAssociationDefinition> attributeAssociationDefinitions; 
     40    private List<BaseAttributeAssociationDefinition> attributeAssociationDefinitions; 
    4141 
    4242    /** 
     
    5151     */ 
    5252    public void associateAttributes(List<Event> events) throws AttributeAssociationException{ 
    53         for (AttributeAssociationDefinition attributeAssociationDefinition: attributeAssociationDefinitions){ 
     53        for (BaseAttributeAssociationDefinition attributeAssociationDefinition: attributeAssociationDefinitions){ 
    5454            log.info("Attribute Association Definition [{}], is enabled [{}]",attributeAssociationDefinition.getDefiniationName(), attributeAssociationDefinition.isEnabled()); 
    5555 
     
    9797     * @param attributeAssociationDefinitions the attributeAssociationDefinitions to set 
    9898     */ 
    99     public void setAttributeAssociationDefinitions(List<AttributeAssociationDefinition> attributeAssociationDefinitions) { 
     99    public void setAttributeAssociationDefinitions(List<BaseAttributeAssociationDefinition> attributeAssociationDefinitions) { 
    100100        this.attributeAssociationDefinitions = attributeAssociationDefinitions; 
    101         for (AttributeAssociationDefinition definition : attributeAssociationDefinitions){ 
     101        for (BaseAttributeAssociationDefinition definition : attributeAssociationDefinitions){ 
    102102              definition.initialise(); 
    103103        } 
     
    107107     * @return the attributeAssociationDefinitions 
    108108     */ 
    109     public List<AttributeAssociationDefinition> getAttributeAssociationDefinitions() { 
     109    public List<BaseAttributeAssociationDefinition> getAttributeAssociationDefinitions() { 
    110110        return attributeAssociationDefinitions; 
    111111    } 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/event/expansion/BaseAttributeAssociationDefinition.java

    r1045 r1049  
    1717 * 
    1818 */ 
     19 
    1920package uk.ac.cardiff.raptor.event.expansion; 
    2021 
     
    2425import uk.ac.cardiff.model.event.Event; 
    2526 
    26  
    2727/** 
     28 * The Class AttributeAssociationDefinition. 
     29 *  
    2830 * @author philsmart 
    29  * 
    3031 */ 
    31 public abstract class AttributeAssociationDefinition { 
     32public abstract class BaseAttributeAssociationDefinition { 
    3233 
    3334    /** Class logger. */ 
    34     private final Logger log = LoggerFactory.getLogger(AttributeAssociationDefinition.class); 
     35    private final Logger log = LoggerFactory.getLogger(BaseAttributeAssociationDefinition.class); 
    3536 
    36     /** Human readable name for this definition*/ 
    37     private String definiationName; 
     37    /** Human readable name for this definition. */ 
     38    private String definitionName; 
    3839 
    39     /** Whether to apply the attribute association*/ 
     40    /** Whether to apply the attribute association. */ 
    4041    private boolean enabled; 
    4142 
    42     /** The class type that these attribute definitions are attached to*/ 
     43    /** The class type that these attribute definitions are attached to. */ 
    4344    protected Class<?> classToAdd; 
    4445 
    45     /** The class type that this attribute association is applicable for */ 
     46    /** The class type that this attribute association is applicable for. */ 
    4647    protected String associateWithClass; 
    4748 
     49    /** 
     50     * Associate additional attributes to the <code>event</code> 
     51     *  
     52     * @param event the event 
     53     * @return true, if successful, false otherwise 
     54     */ 
    4855    public abstract boolean associate(Event event); 
    4956 
     57    /** 
     58     * Initialise this definition. 
     59     */ 
    5060    public abstract void initialise(); 
    5161 
    52  
    5362    /** 
     63     * Sets whether this definition is enabled. 
     64     *  
    5465     * @param enabled the enabled to set 
    5566     */ 
     
    5869    } 
    5970 
    60  
    61  
    6271    /** 
     72     * Checks if this definition is enabled. 
     73     *  
    6374     * @return the enabled 
    6475     */ 
     
    6778    } 
    6879 
    69  
    7080    /** 
     81     * Sets the definition name. 
     82     *  
    7183     * @param definiationName the definiationName to set 
    7284     */ 
    7385    public void setDefiniationName(String definiationName) { 
    74         this.definiationName = definiationName; 
     86        this.definitionName = definiationName; 
    7587    } 
    7688 
    77  
    78  
    7989    /** 
     90     * Gets the definition name. 
     91     *  
    8092     * @return the definiationName 
    8193     */ 
    8294    public String getDefiniationName() { 
    83         return definiationName; 
     95        return definitionName; 
    8496    } 
    8597 
    8698    /** 
     99     * Sets the class to add. 
     100     *  
    87101     * @param classToAdd the classToAdd to set 
    88102     */ 
     
    92106 
    93107    /** 
     108     * Gets the class to add. 
     109     *  
    94110     * @return the classToAdd 
    95111     */ 
     
    99115 
    100116    /** 
     117     * Sets the associate with class. 
     118     *  
    101119     * @param associateWithClass the associateWithClass to set 
    102120     */ 
     
    106124 
    107125    /** 
     126     * Gets the associate with class. 
     127     *  
    108128     * @return the associateWithClass 
    109129     */ 
     
    112132    } 
    113133 
    114  
    115  
    116134} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/event/expansion/PrincipalAttributeAssociationDefinition.java

    r1002 r1049  
    1414 * limitations under the License. 
    1515 */ 
    16 /** 
    17  * 
    18  */ 
     16 
    1917package uk.ac.cardiff.raptor.event.expansion; 
    2018 
     
    3129 
    3230/** 
     31 * The Class PrincipalAttributeAssociationDefinition. 
     32 *  
    3333 * @author philsmart 
    34  * 
    3534 */ 
    36 public class PrincipalAttributeAssociationDefinition extends AttributeAssociationDefinition{ 
     35public class PrincipalAttributeAssociationDefinition extends BaseAttributeAssociationDefinition { 
    3736 
    3837    /** Class logger. */ 
    3938    private final Logger log = LoggerFactory.getLogger(ResourceCategoryAttributeAssociationDefinition.class); 
    4039 
    41     /** The name of the field the subject's principal should be extracted from*/ 
     40    /** The name of the field the subject's principal should be extracted from. */ 
    4241    private String subjectPrincipalField; 
    4342 
     43    /** The list of lookup attributes. */ 
    4444    private List<AttributeLookup> lookupAttributes; 
    4545 
    46     /** The data connector used to acquire the attributes*/ 
     46    /** The data connector used to acquire the attributes. */ 
    4747    private DataConnector dataConnector; 
    4848 
    49     /** The ldap search filter template*/ 
     49    /** The ldap search filter template. */ 
    5050    private String searchFilterTemplate; 
    5151 
    5252    /** 
    53      * @return 
     53     * Gets the source attributes as an array. 
     54     *  
     55     * @return the source attributes as array 
    5456     */ 
    5557    public String[] getSourceAttributesAsArray() { 
    5658        String[] sourceAttributes = new String[lookupAttributes.size()]; 
    57         int i=0; 
    58         for (AttributeLookup lookupAttribute : lookupAttributes){ 
     59        int i = 0; 
     60        for (AttributeLookup lookupAttribute : lookupAttributes) { 
    5961            sourceAttributes[i++] = lookupAttribute.getSourceAttributeName(); 
    6062        } 
     
    6264    } 
    6365 
    64     public void initialise(){ 
     66    /** 
     67     *  
     68     * @see uk.ac.cardiff.raptor.event.expansion.BaseAttributeAssociationDefinition#initialise() 
     69     */ 
     70    public void initialise() { 
    6571        dataConnector.initialise(); 
    6672 
    6773    } 
    6874 
    69  
    70     /** 
    71      * @param attributeSourceName 
    72      * @return 
    73      */ 
    74     public String getInternalAttributeName(String attributeSourceName) throws AttributeAssociationException{ 
    75         for (AttributeLookup lookupAttribute : lookupAttributes){ 
    76                if (lookupAttribute.getSourceAttributeName().equals(attributeSourceName)) 
    77                    return lookupAttribute.getInternalAttributeName(); 
    78         } 
    79         throw new AttributeAssociationException("Source attribute "+attributeSourceName+" was not found in the attribute association mappings"); 
    80     } 
    81  
    82  
    83     private void populate(Map<String,String> attributes, Event event) throws InstantiationException, IllegalAccessException{ 
     75    /** 
     76     * Gets the internal attribute name. 
     77     *  
     78     * @param attributeSourceName the attribute source name 
     79     * @return the internal attribute name 
     80     * @throws AttributeAssociationException the attribute association exception 
     81     */ 
     82    public String getInternalAttributeName(String attributeSourceName) throws AttributeAssociationException { 
     83        for (AttributeLookup lookupAttribute : lookupAttributes) { 
     84            if (lookupAttribute.getSourceAttributeName().equals(attributeSourceName)) { 
     85                return lookupAttribute.getInternalAttributeName(); 
     86            } 
     87        } 
     88        throw new AttributeAssociationException("Source attribute " + attributeSourceName 
     89                + " was not found in the attribute association mappings"); 
     90    } 
     91 
     92    /** 
     93     * Populates fields in the <code>event</code> from the values in <code>attributes</code> 
     94     *  
     95     * @param attributes the attributes 
     96     * @param event the event 
     97     * @throws InstantiationException the instantiation exception 
     98     * @throws IllegalAccessException the illegal access exception 
     99     */ 
     100    private void populate(Map<String, String> attributes, Event event) throws InstantiationException, 
     101            IllegalAccessException { 
    84102 
    85103        Object classToPopulate = getClassToAdd().newInstance(); 
    86104 
    87         for (Map.Entry<String,String> entry : attributes.entrySet()){ 
     105        for (Map.Entry<String, String> entry : attributes.entrySet()) { 
    88106            String attributeSourceName = entry.getKey(); 
    89107            String attributeValue = entry.getValue(); 
    90             log.trace("source [{}], value [{}]",attributeSourceName,attributeValue); 
    91             try{ 
     108            log.trace("source [{}], value [{}]", attributeSourceName, attributeValue); 
     109            try { 
    92110                String internalFieldName = getInternalAttributeName(attributeSourceName); 
    93111                ReflectionHelper.setValueOnObject(internalFieldName, attributeValue, classToPopulate); 
     112            } catch (AttributeAssociationException e) { 
     113                log.warn("Error trying to populate internal model. {}", e.getMessage()); 
    94114            } 
    95             catch(AttributeAssociationException e){ 
    96                 log.warn("Error trying to populate internal model. {}",e.getMessage()); 
    97             } 
    98         } 
    99  
    100         //now attach the object where appropriate on the current <code>Event</code> object 
    101         ReflectionHelper.attachObjectTo(classToPopulate,event); 
    102  
    103        // log.debug("{}",event); 
    104     } 
    105  
    106     /** 
    107      * @param event 
    108      */ 
     115        } 
     116 
     117        // now attach the object where appropriate on the current <code>Event</code> object 
     118        ReflectionHelper.attachObjectTo(classToPopulate, event); 
     119 
     120    } 
     121 
     122    @Override 
    109123    public boolean associate(Event event) { 
    110        // log.debug("{},v {}",event.getClass().getCanonicalName(),associateWithClass.getClass().getCanonicalName()); 
    111         if (!event.getClass().getCanonicalName().equals(associateWithClass)){ 
     124 
     125        if (!event.getClass().getCanonicalName().equals(associateWithClass)) { 
    112126            return false; 
    113127        } 
     
    115129        Object principalObject = ReflectionHelper.getValueFromObject(getSubjectPrincipalField(), event); 
    116130        String principal = null; 
    117         if (principalObject instanceof String){ 
    118             principal = (String)principalObject; 
    119         } 
    120         if (principal!=null){ 
     131        if (principalObject instanceof String) { 
     132            principal = (String) principalObject; 
     133        } 
     134        if (principal != null) { 
    121135            try { 
    122                  dataConnector.setReturnAttributes(getSourceAttributesAsArray()); 
    123                  dataConnector.setSearchFilterTemplate(searchFilterTemplate); 
    124                  Map<String, String> attributes = dataConnector.lookup(principal); 
    125                  populate(attributes,event); 
    126  
    127                  return true; 
     136                dataConnector.setReturnAttributes(getSourceAttributesAsArray()); 
     137                dataConnector.setSearchFilterTemplate(searchFilterTemplate); 
     138                Map<String, String> attributes = dataConnector.lookup(principal); 
     139                populate(attributes, event); 
     140                return true; 
    128141            } catch (AttributeAssociationException e) { 
    129                 log.error("Association error for principal [{}], {}",principal,e.getMessage()); 
     142                log.error("Association error for principal [{}], {}", principal, e.getMessage()); 
    130143            } catch (InstantiationException e) { 
    131                 log.warn("Could not populate event [{}], {}",event,e.getMessage()); 
     144                log.warn("Could not populate event [{}], {}", event, e.getMessage()); 
    132145            } catch (IllegalAccessException e) { 
    133                 log.warn("Could not populate event [{}], {}",event,e.getMessage()); 
     146                log.warn("Could not populate event [{}], {}", event, e.getMessage()); 
    134147            } 
    135148        } 
     
    138151    } 
    139152 
    140  
    141  
    142     /** 
     153    /** 
     154     * Sets the subject principal field. 
     155     *  
    143156     * @param subjectPrincipalField the subjectPrincipalField to set 
    144157     */ 
     
    148161 
    149162    /** 
     163     * Gets the subject principal field. 
     164     *  
    150165     * @return the subjectPrincipalField 
    151166     */ 
     
    155170 
    156171    /** 
     172     * Sets the lookup attributes. 
     173     *  
    157174     * @param lookupAttributes the lookupAttributes to set 
    158175     */ 
     
    162179 
    163180    /** 
     181     * Gets the lookup attributes. 
     182     *  
    164183     * @return the lookupAttributes 
    165184     */ 
     
    168187    } 
    169188 
    170  
    171     /** 
     189    /** 
     190     * Sets the data connector. 
     191     *  
    172192     * @param dataConnector the dataConnector to set 
    173193     */ 
     
    176196    } 
    177197 
    178  
    179  
    180     /** 
     198    /** 
     199     * Gets the data connector. 
     200     *  
    181201     * @return the dataConnector 
    182202     */ 
     
    185205    } 
    186206 
    187  
    188  
    189     /** 
     207    /** 
     208     * Sets the search filter template. 
     209     *  
    190210     * @param searchFilterTemplate the searchFilterTemplate to set 
    191211     */ 
    192212    public void setSearchFilterTemplate(String searchFilterTemplate) { 
    193         log.debug("Attribute Association Search Filter Template Set To [{}]",searchFilterTemplate); 
     213        log.debug("Attribute Association Search Filter Template Set To [{}]", searchFilterTemplate); 
    194214        this.searchFilterTemplate = searchFilterTemplate; 
    195215    } 
    196216 
    197  
    198  
    199     /** 
     217    /** 
     218     * Gets the search filter template. 
     219     *  
    200220     * @return the searchFilterTemplate 
    201221     */ 
     
    205225 
    206226    /** 
     227     * Sets the class to add. 
     228     *  
    207229     * @param classToAdd the classToAdd to set 
    208230     */ 
     
    212234 
    213235    /** 
     236     * Gets the class to add. 
     237     *  
    214238     * @return the classToAdd 
    215239     */ 
     
    219243 
    220244    /** 
     245     * Sets the associate with class. 
     246     *  
    221247     * @param associateWithClass the associateWithClass to set 
    222248     */ 
     
    226252 
    227253    /** 
     254     * Gets the associate with class. 
     255     *  
    228256     * @return the associateWithClass 
    229257     */ 
     
    232260    } 
    233261 
    234  
    235  
    236262} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/event/expansion/ResourceCategoryAttributeAssociationDefinition.java

    r828 r1049  
    1717 * 
    1818 */ 
     19 
    1920package uk.ac.cardiff.raptor.event.expansion; 
    20  
    2121 
    2222import org.slf4j.Logger; 
     
    2929 
    3030/** 
     31 * The Class ResourceCategoryAttributeAssociationDefinition. 
     32 *  
    3133 * @author philsmart 
    32  * 
    3334 */ 
    34 public class ResourceCategoryAttributeAssociationDefinition extends AttributeAssociationDefinition{ 
    35  
     35public class ResourceCategoryAttributeAssociationDefinition extends BaseAttributeAssociationDefinition { 
    3636 
    3737    /** Class logger. */ 
    3838    private final Logger log = LoggerFactory.getLogger(ResourceCategoryAttributeAssociationDefinition.class); 
    3939 
    40     /** The data connector used to acquire the attributes*/ 
     40    /** The data connector used to acquire the attributes. */ 
    4141    private RaptorDataConnection dataConnection; 
    4242 
    43  
    44     public void initialise(){ 
     43    /** 
     44     * @see uk.ac.cardiff.raptor.event.expansion.BaseAttributeAssociationDefinition#initialise() 
     45     */ 
     46    public void initialise() { 
    4547    } 
    4648 
    47  
    48  
    49     /** 
    50      * @param event 
    51      */ 
     49    @Override 
    5250    public boolean associate(Event event) { 
    5351 
    54        ResourceMetadata resourceMetadata = null; 
    55        Object result =  dataConnection.runQueryUnique("from ResourceMetadata where resourceId=?", new Object[]{event.getResourceId()}); 
    56        if (result !=null && result instanceof ResourceMetadata){ 
    57            resourceMetadata = (ResourceMetadata) result; 
    58            if (resourceMetadata.isExternal()){ 
    59                event.setResourceIdCategory(2); 
    60            } 
    61            else if (resourceMetadata.isInternal()){ 
    62                event.setResourceIdCategory(1); 
    63            } 
    64            return true; 
    65        } 
    66        else{ 
    67            ResourceMetadata resourceNew = new ResourceMetadata(); 
    68            resourceNew.setExternal(true); 
    69            resourceNew.setInternal(false); 
    70            resourceNew.setResourceId(event.getResourceId()); 
    71            event.setResourceIdCategory(2); 
    72            try{ 
    73                dataConnection.save(resourceNew); 
    74            } 
    75            catch(DataAccessException e){ 
    76                log.error("Could not save new resource metadata {}",e.getMessage()); 
    77                return false; 
    78            } 
    79            return true; 
    80        } 
     52        ResourceMetadata resourceMetadata = null; 
     53        Object result = 
     54                dataConnection.runQueryUnique("from ResourceMetadata where resourceId=?", 
     55                        new Object[] {event.getResourceId()}); 
     56        if (result != null && result instanceof ResourceMetadata) { 
     57            resourceMetadata = (ResourceMetadata) result; 
     58            if (resourceMetadata.isExternal()) { 
     59                event.setResourceIdCategory(2); 
     60            } else if (resourceMetadata.isInternal()) { 
     61                event.setResourceIdCategory(1); 
     62            } 
     63            return true; 
     64        } else { 
     65            ResourceMetadata resourceNew = new ResourceMetadata(); 
     66            resourceNew.setExternal(true); 
     67            resourceNew.setInternal(false); 
     68            resourceNew.setResourceId(event.getResourceId()); 
     69            event.setResourceIdCategory(2); 
     70            try { 
     71                dataConnection.save(resourceNew); 
     72            } catch (DataAccessException e) { 
     73                log.error("Could not save new resource metadata {}", e.getMessage()); 
     74                return false; 
     75            } 
     76            return true; 
     77        } 
    8178 
    8279    } 
    8380 
    84  
    8581    /** 
     82     * Sets the class to add. 
     83     *  
    8684     * @param classToAdd the classToAdd to set 
    8785     */ 
     
    9189 
    9290    /** 
     91     * Gets the class to add. 
     92     *  
    9393     * @return the classToAdd 
    9494     */ 
     
    9898 
    9999    /** 
     100     * Sets the associate with class. 
     101     *  
    100102     * @param associateWithClass the associateWithClass to set 
    101103     */ 
     
    105107 
    106108    /** 
     109     * Gets the associate with class. 
     110     *  
    107111     * @return the associateWithClass 
    108112     */ 
     
    111115    } 
    112116 
    113  
    114  
    115117    /** 
     118     * Sets the data connection. 
     119     *  
    116120     * @param dataConnection the dataConnection to set 
    117121     */ 
     
    120124    } 
    121125 
    122  
    123  
    124126    /** 
     127     * Gets the data connection. 
     128     *  
    125129     * @return the dataConnection 
    126130     */ 
     
    129133    } 
    130134 
    131  
    132  
    133  
    134135} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/registry/Endpoint.java

    r1043 r1049  
    1717 * 
    1818 */ 
     19 
    1920package uk.ac.cardiff.raptor.registry; 
    2021 
     
    2930 
    3031/** 
    31  * 
    32  * Stores information about an endpoint that a client can send events to. Also includes the Push Policy 
    33  * to determine if events should be sent, an attribute filter policy for determining which attributes 
    34  * of each event should be sent, and information about previous event releases. 
    35  * 
     32 *  
     33 * Stores information about an endpoint that a client can send events to. Also includes the Push Policy to determine if 
     34 * events should be sent, an attribute filter policy for determining which attributes of each event should be sent, and 
     35 * information about previous event releases. 
     36 *  
    3637 * This class could be subclassed if additional functionality is required. 
    37  * 
    38  * @author philsmart 
    39  * 
     38 *  
    4039 */ 
    4140public class Endpoint { 
    4241 
    43         /** class logger */ 
    44         private final Logger log = LoggerFactory.getLogger(Endpoint.class); 
     42    /** class logger. */ 
     43    private final Logger log = LoggerFactory.getLogger(Endpoint.class); 
    4544 
     45    /** The URL of the service endpoint. */ 
     46    private String serviceEndpoint; 
    4647 
    47         /** The URL of the service endpoint */ 
    48         private String serviceEndpoint; 
     48    /** A List of the PushPolicies defined for this endpoint. */ 
     49    private List<AbstractPushPolicy> pushPolicies; 
    4950 
    50         /** A List of the PushPolicies defined for this endpoint */ 
    51         private List<AbstractPushPolicy> pushPolicies; 
     51    /** The filter policy defined for this endpoint *. */ 
     52    private AttributeFilterPolicy attributeFilterPolicy; 
    5253 
    53         /** The filter policy defined for this endpoint **/ 
    54         private AttributeFilterPolicy attributeFilterPolicy; 
     54    /** Information about what information has been released to this endpoint. */ 
     55    private ReleaseInformation releaseInformation; 
    5556 
    56         /** Information about what information has been released to this endpoint */ 
    57         private ReleaseInformation releaseInformation; 
    58  
    59         /** Which event types can be sent to this endpoint */ 
    60         private Class<?>[] supportedEvents; 
    61  
    62  
    63         /** 
    64          * Default constructor. Instantiate <code>releaseInformation</code> 
    65          */ 
    66         public Endpoint(){ 
    67                 releaseInformation = new ReleaseInformation(); 
    68         } 
    69  
    70  
    71         /** 
    72          * Actions the <code>releasedPerformed</code> on the <code>releaseInformation</code> object. 
    73          * 
    74          * @param filteredEntries 
    75          */ 
    76         public void releasePerformed(List<Event> filteredEntries) { 
    77                 releaseInformation.releasePerformed(filteredEntries); 
    78         } 
    79  
    80         public void setServiceEndpoint(String serviceEndpoint) { 
    81                 this.serviceEndpoint = serviceEndpoint; 
    82                 releaseInformation.setServiceEndpoint(serviceEndpoint); 
    83         } 
    84  
    85         public String getServiceEndpoint() { 
    86                 return serviceEndpoint; 
    87         } 
    88  
    89         public void setAttributeFilterPolicy(AttributeFilterPolicy attributeFilterPolicy) { 
    90                 this.attributeFilterPolicy = attributeFilterPolicy; 
    91         } 
    92  
    93         public AttributeFilterPolicy getAttributeFilterPolicy() { 
    94                 return attributeFilterPolicy; 
    95         } 
    96  
    97         public void setPushPolicies(List<AbstractPushPolicy> pushPolicies) { 
    98                 this.pushPolicies = pushPolicies; 
    99         } 
    100  
    101         public List<AbstractPushPolicy> getPushPolicies() { 
    102                 return pushPolicies; 
    103         } 
    104  
    105         /** 
    106          * @return the releaseInformation 
    107          */ 
    108         public ReleaseInformation getReleaseInformation() { 
    109                 return releaseInformation; 
    110         } 
    111  
    112  
    113         /** 
    114          * Sets the releaseInformation 
    115          * 
    116          * @param releaseInformation 
    117          */ 
    118         public void setReleaseInformation(ReleaseInformation releaseInformation) { 
    119                 this.releaseInformation = releaseInformation; 
    120         } 
    121  
     57    /** Which event types can be sent to this endpoint. */ 
     58    private Class<?>[] supportedEvents; 
    12259 
    12360    /** 
     61     * Default constructor. Instantiate <code>releaseInformation</code> 
     62     */ 
     63    public Endpoint() { 
     64        releaseInformation = new ReleaseInformation(); 
     65    } 
     66 
     67    /** 
     68     * Actions the <code>releasedPerformed</code> on the <code>releaseInformation</code> object. 
     69     *  
     70     * @param filteredEntries the filtered entries 
     71     */ 
     72    public void releasePerformed(List<Event> filteredEntries) { 
     73        releaseInformation.releasePerformed(filteredEntries); 
     74    } 
     75 
     76    /** 
     77     * Sets the service endpoint. 
     78     *  
     79     * @param serviceEndpoint the new service endpoint 
     80     */ 
     81    public void setServiceEndpoint(String serviceEndpoint) { 
     82        this.serviceEndpoint = serviceEndpoint; 
     83        releaseInformation.setServiceEndpoint(serviceEndpoint); 
     84    } 
     85 
     86    /** 
     87     * Gets the service endpoint. 
     88     *  
     89     * @return the service endpoint 
     90     */ 
     91    public String getServiceEndpoint() { 
     92        return serviceEndpoint; 
     93    } 
     94 
     95    /** 
     96     * Sets the attribute filter policy. 
     97     *  
     98     * @param attributeFilterPolicy the new attribute filter policy 
     99     */ 
     100    public void setAttributeFilterPolicy(AttributeFilterPolicy attributeFilterPolicy) { 
     101        this.attributeFilterPolicy = attributeFilterPolicy; 
     102    } 
     103 
     104    /** 
     105     * Gets the attribute filter policy. 
     106     *  
     107     * @return the attribute filter policy 
     108     */ 
     109    public AttributeFilterPolicy getAttributeFilterPolicy() { 
     110        return attributeFilterPolicy; 
     111    } 
     112 
     113    /** 
     114     * Sets the push policies. 
     115     *  
     116     * @param pushPolicies the new push policies 
     117     */ 
     118    public void setPushPolicies(List<AbstractPushPolicy> pushPolicies) { 
     119        this.pushPolicies = pushPolicies; 
     120    } 
     121 
     122    /** 
     123     * Gets the push policies. 
     124     *  
     125     * @return the push policies 
     126     */ 
     127    public List<AbstractPushPolicy> getPushPolicies() { 
     128        return pushPolicies; 
     129    } 
     130 
     131    /** 
     132     * Gets the release information. 
     133     *  
     134     * @return the releaseInformation 
     135     */ 
     136    public ReleaseInformation getReleaseInformation() { 
     137        return releaseInformation; 
     138    } 
     139 
     140    /** 
     141     * Sets the releaseInformation. 
     142     *  
     143     * @param releaseInformation the new release information 
     144     */ 
     145    public void setReleaseInformation(ReleaseInformation releaseInformation) { 
     146        this.releaseInformation = releaseInformation; 
     147    } 
     148 
     149    /** 
     150     * Sets the supported events. 
     151     *  
    124152     * @param supportedEvents the supportedEvents to set 
    125153     */ 
     
    128156    } 
    129157 
    130  
    131158    /** 
     159     * Gets the supported events. 
     160     *  
    132161     * @return the supportedEvents 
    133162     */ 
     
    136165    } 
    137166 
    138  
    139  
    140167} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/registry/EndpointRegistry.java

    r817 r1049  
    2626 
    2727/** 
    28  * @author philsmart handles the list of attached ICAs as injected by Spring 
     28 * handles the list of attached endpoints as injected by Spring. 
    2929 */ 
    3030public class EndpointRegistry { 
    3131 
    32         /** Class logger. */ 
    33         private final Logger log = LoggerFactory.getLogger(EndpointRegistry.class); 
     32    /** Class logger. */ 
     33    private final Logger log = LoggerFactory.getLogger(EndpointRegistry.class); 
    3434 
    35         /** List of endpoints for invoking methods on */ 
    36         private List<Endpoint> endpoints; 
     35    /** List of endpoints for invoking methods on. */ 
     36    private List<Endpoint> endpoints; 
    3737 
    38         /** Whether release information should be persisted. */ 
    39         private boolean persistReleaseInformation; 
     38    /** Whether release information should be persisted. */ 
     39    private boolean persistReleaseInformation; 
    4040 
    41         /** The data connection class to use for persisting 
    42          * release information 
    43          */ 
    44         private RaptorDataConnection dataConnection; 
     41    /** The data connection class to use for persisting release information. */ 
     42    private RaptorDataConnection dataConnection; 
    4543 
    46         public EndpointRegistry() { 
    47                 setEndpoints(new ArrayList<Endpoint>()); 
    48         } 
     44    /** 
     45     * Instantiates a new endpoint registry. 
     46     */ 
     47    public EndpointRegistry() { 
     48        setEndpoints(new ArrayList<Endpoint>()); 
     49    } 
    4950 
    50         public void setEndpoints(List<Endpoint> endpoints) { 
    51                 for (Endpoint endpoint : endpoints){ 
    52                         log.info("Registering Service Endpoint: {}, persisting event release information {}", endpoint.getServiceEndpoint(),isPersistReleaseInformation()); 
    53                         if (isPersistReleaseInformation()){ 
    54                                 ReleaseInformation releaseInformation = loadReleaseInformation(endpoint); 
    55                                 if (releaseInformation!=null){ 
    56                                         endpoint.setReleaseInformation(releaseInformation); 
    57                                 } 
    58                         } 
     51    /** 
     52     * Sets the endpoints and loads {@link ReleaseInformation} for those endpoints where 
     53     * <code>persistReleaseInformation</code> is true. 
     54     *  
     55     * @param endpoints the new endpoints 
     56     */ 
     57    public void setEndpoints(List<Endpoint> endpoints) { 
     58        for (Endpoint endpoint : endpoints) { 
     59            log.info("Registering Service Endpoint: {}, persisting event release information {}", 
     60                    endpoint.getServiceEndpoint(), isPersistReleaseInformation()); 
     61            if (isPersistReleaseInformation()) { 
     62                ReleaseInformation releaseInformation = loadReleaseInformation(endpoint); 
     63                if (releaseInformation != null) { 
     64                    endpoint.setReleaseInformation(releaseInformation); 
     65                } 
     66            } 
    5967 
    60                 } 
    61                 this.endpoints = endpoints; 
    62         } 
     68        } 
     69        this.endpoints = endpoints; 
     70    } 
    6371 
    64         public List<Endpoint> getEndpoints() { 
    65                 return endpoints; 
    66         } 
     72    /** 
     73     * Gets the endpoints. 
     74     *  
     75     * @return the endpoints 
     76     */ 
     77    public List<Endpoint> getEndpoints() { 
     78        return endpoints; 
     79    } 
    6780 
     81    /** 
     82     * Persists release information through the configured data connection if enabled. 
     83     */ 
     84    public void storeReleaseInformationIfEnabled() { 
     85        if (!isPersistReleaseInformation()) { 
     86            return; 
     87        } 
     88        for (Endpoint entry : endpoints) { 
     89            log.debug( 
     90                    "Saving release information for the endpoint [{}], has persistentId {} and {} latestEqualEntrie(s)", 
     91                    new Object[] {entry.getServiceEndpoint(), entry.getReleaseInformation().getPersistantId(), 
     92                            entry.getReleaseInformation().getLatestEqualEntries().size()}); 
     93            dataConnection.save(entry.getReleaseInformation()); 
     94        } 
    6895 
    69         public void storeReleaseInformationIfEnabled() { 
    70                 if (!isPersistReleaseInformation()) 
    71                         return; 
     96    } 
    7297 
    73                 for (Endpoint entry : endpoints){ 
    74                     log.debug("Saving release information for the endpoint [{}], has persistentId {} and {} latestEqualEntrie(s)", 
    75                             new Object[]{entry.getServiceEndpoint(),entry.getReleaseInformation().getPersistantId(), entry.getReleaseInformation().getLatestEqualEntries().size()}); 
    76                         dataConnection.save(entry.getReleaseInformation()); 
    77                 } 
     98    /** 
     99     * Loads release information for this endpoint from the configured data connection. 
     100     *  
     101     * @param endpoint the endpoint to load release information for 
     102     * @return the release information 
     103     */ 
     104    public ReleaseInformation loadReleaseInformation(Endpoint endpoint) { 
     105        List<?> releaseInfoResults = 
     106                dataConnection.runQuery("from ReleaseInformation where serviceEndpoint=?", 
     107                        new Object[] {endpoint.getServiceEndpoint()}); 
     108        if (releaseInfoResults == null) { 
     109            log.warn("Loading error...no release information found, new release information used"); 
     110        } 
     111        if (releaseInfoResults.size() > 1) { 
     112            log.error("Loading error...ambiguity in the persisted release information, too many results"); 
     113        } 
     114        if (releaseInfoResults.size() == 1) { 
     115            ReleaseInformation releaseInformaiton = (ReleaseInformation) releaseInfoResults.get(0); 
     116            log.info( 
     117                    "Loaded ReleaseInformation for {}, with latest event released time of {}, and {} latest equal entrie(s)", 
     118                    new Object[] {releaseInformaiton.getServiceEndpoint(), 
     119                            releaseInformaiton.getLastReleasedEventTime(), 
     120                            releaseInformaiton.getLatestEqualEntries().size()}); 
     121            if (releaseInformaiton.getLatestEqualEntries().size() > 0) { 
     122                log.debug("Latest Equal Entry Is {}", releaseInformaiton.getLatestEqualEntries().iterator().next()); 
     123            } 
     124            return releaseInformaiton; 
     125        } 
     126        return null; 
    78127 
    79         } 
     128    } 
    80129 
     130    /** 
     131     * Sets the persist release information. 
     132     *  
     133     * @param persistReleaseInformation the persistReleaseInformation to set 
     134     */ 
     135    public void setPersistReleaseInformation(boolean persistReleaseInformation) { 
     136        this.persistReleaseInformation = persistReleaseInformation; 
     137    } 
    81138 
    82         public ReleaseInformation loadReleaseInformation(Endpoint endpoint){ 
    83                 List<?> releaseInfoResults = dataConnection.runQuery("from ReleaseInformation where serviceEndpoint=?",new Object[]{endpoint.getServiceEndpoint()}); 
    84                 if (releaseInfoResults==null){ 
    85                         log.warn("Loading error...no release information found, blank release information used"); 
    86                 } 
    87                 if (releaseInfoResults.size()>1){ 
    88                         log.error("Loading error...ambiguity in the persisted release information, too many results"); 
    89                 } 
    90                 if (releaseInfoResults.size()==1){ 
    91                         ReleaseInformation releaseInformaiton = (ReleaseInformation) releaseInfoResults.get(0); 
    92                         log.info("Loaded ReleaseInformation for {}, with latest event released time of {}, and {} latest equal entrie(s)", 
    93                                 new Object[]{releaseInformaiton.getServiceEndpoint(),releaseInformaiton.getLastReleasedEventTime(), 
    94                                 releaseInformaiton.getLatestEqualEntries().size()}); 
    95                         if (releaseInformaiton.getLatestEqualEntries().size()>0){ 
    96                             log.debug("Latest Equal Entry Is {}",releaseInformaiton.getLatestEqualEntries().iterator().next()); 
    97                         } 
    98                         return releaseInformaiton; 
    99                 } 
    100                 return null; 
     139    /** 
     140     * Checks if is persist release information. 
     141     *  
     142     * @return the persistReleaseInformation 
     143     */ 
     144    public boolean isPersistReleaseInformation() { 
     145        return persistReleaseInformation; 
     146    } 
    101147 
    102         } 
     148    /** 
     149     * Sets the data connection. 
     150     *  
     151     * @param dataConnection the dataConnection to set 
     152     */ 
     153    public void setDataConnection(RaptorDataConnection dataConnection) { 
     154        this.dataConnection = dataConnection; 
     155    } 
    103156 
    104  
    105         /** 
    106          * @param persistReleaseInformation the persistReleaseInformation to set 
    107          */ 
    108         public void setPersistReleaseInformation(boolean persistReleaseInformation) { 
    109                 this.persistReleaseInformation = persistReleaseInformation; 
    110         } 
    111  
    112         /** 
    113          * @return the persistReleaseInformation 
    114          */ 
    115         public boolean isPersistReleaseInformation() { 
    116                 return persistReleaseInformation; 
    117         } 
    118  
    119         /** 
    120          * @param dataConnection the dataConnection to set 
    121          */ 
    122         public void setDataConnection(RaptorDataConnection dataConnection) { 
    123                 this.dataConnection = dataConnection; 
    124         } 
    125  
    126         /** 
    127          * @return the dataConnection 
    128          */ 
    129         public RaptorDataConnection getDataConnection() { 
    130                 return dataConnection; 
    131         } 
     157    /** 
     158     * Gets the data connection. 
     159     *  
     160     * @return the dataConnection 
     161     */ 
     162    public RaptorDataConnection getDataConnection() { 
     163        return dataConnection; 
     164    } 
    132165 
    133166} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/registry/ReleaseInformation.java

    r817 r1049  
    1414 * limitations under the License. 
    1515 */ 
     16 
    1617package uk.ac.cardiff.raptor.registry; 
    1718 
     
    3132    private final Logger log = LoggerFactory.getLogger(ReleaseInformation.class); 
    3233 
    33     /** Unique identifier for the persistance layer*/ 
     34    /** Unique identifier for the persistence layer. */ 
    3435    private long persistantId; 
    3536 
    36         /** The date and time of the last entry sent to this client */ 
    37         private DateTime lastReleasedEventTime; 
    38  
    39         /** 
    40          * Stores a set of the latest equal entries hashcodes. That is, those with the latest 
    41          * and same DateTime, but different state (attribute values). 
    42          */ 
    43         private Set<Integer> latestEqualEntries; 
    44  
    45         /** 
    46          * This field is the primary key of this releaseInformation instance 
    47          * that is used to store and retrieve this object. 
    48          */ 
    49         private String serviceEndpoint; 
    50  
    51  
    52  
    53         /** 
    54          * Default constructor. Instantiate <code>latestEqualEntries</code> 
    55          */ 
    56         public ReleaseInformation(){ 
    57             latestEqualEntries = new HashSet<Integer>(); 
    58  
    59         } 
     37    /** The date and time of the last entry sent to this client. */ 
     38    private DateTime lastReleasedEventTime; 
    6039 
    6140    /** 
    62      * After a release has been performed, this method is called with the events that 
    63      * were released. The <code>lastReleasedEventTime</code> and <code>latestEqualEntries</code> are then set 
    64      * accordingly. The latest events are selected chronologically by the <code>eventTime</code> field of 
    65      * each <code>releasedEvents</code>. 
    66      * 
    67      * @param latestEvent 
     41     * Stores a set of the latest equal entries hashcodes. That is, those with the latest and same DateTime, but 
     42     * different state (field values). 
     43     */ 
     44    private Set<Integer> latestEqualEntries; 
     45 
     46    /** 
     47     * This field is the primary key of this releaseInformation instance that is used to store and retrieve this object. 
     48     */ 
     49    private String serviceEndpoint; 
     50 
     51    /** 
     52     * Default constructor. Instantiate the <code>Set</code> <code>latestEqualEntries</code> 
     53     */ 
     54    public ReleaseInformation() { 
     55        latestEqualEntries = new HashSet<Integer>(); 
     56 
     57    } 
     58 
     59    /** 
     60     * After a release has been performed, this method is called with the events that were released. The 
     61     * <code>lastReleasedEventTime</code> and <code>latestEqualEntries</code> are then set accordingly. The latest 
     62     * events are selected chronologically by the <code>eventTime</code> field of each <code>event</code> from the 
     63     * <code>releasedEvents</code>. 
     64     *  
     65     * @param releasedEvents 
    6866     */ 
    6967    public void releasePerformed(List<Event> releasedEvents) { 
    7068 
    71         for (Event event : releasedEvents){ 
    72                 if (lastReleasedEventTime==null) 
    73                     lastReleasedEventTime=event.getEventTime(); 
    74                 else{ 
    75                         if (event.getEventTime().isAfter(lastReleasedEventTime)){ 
    76                                 lastReleasedEventTime = event.getEventTime(); 
    77                                 latestEqualEntries.clear(); 
    78                                 latestEqualEntries.add(event.getEventId()); 
    79                         } 
    80                         else if (event.getEventTime().isEqual(lastReleasedEventTime)){ 
    81                             latestEqualEntries.add(event.getEventId()); 
    82                         } 
     69        for (Event event : releasedEvents) { 
     70            if (lastReleasedEventTime == null) { 
     71                lastReleasedEventTime = event.getEventTime(); 
     72            } else { 
     73                if (event.getEventTime().isAfter(lastReleasedEventTime)) { 
     74                    lastReleasedEventTime = event.getEventTime(); 
     75                    latestEqualEntries.clear(); 
     76                    latestEqualEntries.add(event.getEventId()); 
     77                } else if (event.getEventTime().isEqual(lastReleasedEventTime)) { 
     78                    latestEqualEntries.add(event.getEventId()); 
    8379                } 
     80            } 
    8481        } 
    85  
    8682 
    8783    } 
    8884 
    89  
    9085    /** 
    91      * Returns true if the event is either: 
    92      * 1. Chronologically after the lastReleasedEventTime 
    93      * 2. Is equal to the lastReleasedEventTime but is not in the set <code>latestEqualEntries</code> 
    94      * 
    95      * In effect, the event can be released if it occurred after all other events that have already 
    96      * been released to this endpoint, or occurred at the same time but was not an event that was 
    97      * already sent. 
    98      * 
     86     * Returns true if the event is either: 1. Chronologically after the lastReleasedEventTime 2. Is equal to the 
     87     * lastReleasedEventTime but is not in the set <code>latestEqualEntries</code> 
     88     *  
     89     * In effect, the event can be released if it occurred after all other events that have already been released to 
     90     * this endpoint, or occurred at the same time but was not an event that was already sent. 
     91     *  
    9992     * @param event the event to check for release 
    10093     * @return true if the event has not been released before, false otherwise 
    10194     */ 
    10295    public boolean hasNotBeenReleased(Event event) { 
    103         if (event.getEventTime().isAfter(getLastReleasedEventTime())) 
     96        if (event.getEventTime().isAfter(getLastReleasedEventTime())) { 
    10497            return true; 
    105  
    106         else if (event.getEventTime().isEqual(getLastReleasedEventTime())){ 
     98        } else if (event.getEventTime().isEqual(getLastReleasedEventTime())) { 
    10799            return !latestEqualEntries.contains(event.getEventId()); 
    108100        } 
     
    111103    } 
    112104 
    113  
    114105    /** 
    115      * @param lastPublishedEntryTime the lastPublishedEntryTime to set 
     106     * @param lastReleasedEventTime the lastReleasedEventTime to set 
    116107     */ 
    117108    public void setLastReleasedEventTime(DateTime lastReleasedEventTime) { 
    118             this.lastReleasedEventTime = lastReleasedEventTime; 
     109        this.lastReleasedEventTime = lastReleasedEventTime; 
    119110    } 
    120111 
    121112    /** 
    122      * @return the lastPublishedEntryTime if its not null, otherwise a new datetime set 
    123      * to EPOCH is returned (1970-01-01T00:00) 
     113     * @return the lastPublishedEntryTime if its not null, otherwise a new datetime set to EPOCH is returned 
     114     *         (1970-01-01T00:00) 
    124115     */ 
    125116    public DateTime getLastReleasedEventTime() { 
    126             if (lastReleasedEventTime==null) 
    127                     return new DateTime(0); 
    128             return lastReleasedEventTime; 
     117        if (lastReleasedEventTime == null) { 
     118            return new DateTime(0); 
     119        } 
     120        return lastReleasedEventTime; 
    129121    } 
    130122 
     
    133125     */ 
    134126    public void setLatestEqualEntries(Set<Integer> latestEqualEntries) { 
    135             this.latestEqualEntries = latestEqualEntries; 
     127        this.latestEqualEntries = latestEqualEntries; 
    136128    } 
    137129 
     
    140132     */ 
    141133    public Set<Integer> getLatestEqualEntries() { 
    142             return latestEqualEntries; 
     134        return latestEqualEntries; 
    143135    } 
    144136 
    145         /** 
    146         * @param serviceEndpoint the serviceEndpoint to set 
    147         */ 
    148         public void setServiceEndpoint(String serviceEndpoint) { 
    149                 this.serviceEndpoint = serviceEndpoint; 
    150         } 
     137    /** 
     138    * @param serviceEndpoint the serviceEndpoint to set 
     139    */ 
     140    public void setServiceEndpoint(String serviceEndpoint) { 
     141        this.serviceEndpoint = serviceEndpoint; 
     142    } 
    151143 
    152         /** 
    153         * @return the serviceEndpoint 
    154         */ 
    155         public String getServiceEndpoint() { 
    156                 return serviceEndpoint; 
    157         } 
     144    /** 
     145    * @return the serviceEndpoint 
     146    */ 
     147    public String getServiceEndpoint() { 
     148        return serviceEndpoint; 
     149    } 
    158150 
    159         /** 
    160         * @param persistantId the persistantId to set 
    161         */ 
    162         public void setPersistantId(long persistantId) { 
    163                 this.persistantId = persistantId; 
    164         } 
     151    /** 
     152    * @param persistantId the persistantId to set 
     153    */ 
     154    public void setPersistantId(long persistantId) { 
     155        this.persistantId = persistantId; 
     156    } 
    165157 
    166         /** 
    167         * @return the persistantId 
    168         */ 
    169         public long getPersistantId() { 
    170                 return persistantId; 
    171         } 
     158    /** 
     159    * @return the persistantId 
     160    */ 
     161    public long getPersistantId() { 
     162        return persistantId; 
     163    } 
    172164 
    173165} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/remoting/client/DefaultEventReleaseClient.java

    r1028 r1049  
    2424import uk.ac.cardiff.model.ServiceMetadata; 
    2525import uk.ac.cardiff.model.event.Event; 
    26 import uk.ac.cardiff.raptor.registry.Endpoint; 
    27 import uk.ac.cardiff.raptor.registry.EndpointRegistry; 
    2826 
    2927/** 
    3028 * The Class DefaultEventReleaseClient. 
    3129 */ 
    32 public class DefaultEventReleaseClient implements EventReleaseClient { 
     30public class DefaultEventReleaseClient extends AbstractEventReleaseClient { 
    3331 
    3432    /** Class logger. */ 
    3533    private final Logger log = LoggerFactory.getLogger(DefaultEventReleaseClient.class); 
    3634 
    37     /** Encapsulation of all endpoints this client can communication with. */ 
    38     private EndpointRegistry endpointRegistry; 
    39  
    40     /** The engine that performs event release to a client endpoint. */ 
     35    /** The engine that releases events to a client endpoint. */ 
    4136    private EventReleaseEngine eventReleaseEngine; 
    42  
    43     /** Whether events should be released. Defaults to true. */ 
    44     private boolean enableEventRelease; 
    4537 
    4638    /** 
     
    7062    } 
    7163 
    72     /* 
    73      * (non-Javadoc) 
    74      *  
    75      * @see uk.ac.cardiff.raptor.remoting.client.EventReleaseClient#getEndpoints() 
    76      */ 
    77     public List<Endpoint> getEndpoints() { 
    78         return endpointRegistry.getEndpoints(); 
    79     } 
    80  
    81     /** 
    82      * Sets the endpoint registry. 
    83      *  
    84      * @param endpointRegistry the new endpoint registry 
    85      */ 
    86     public void setEndpointRegistry(EndpointRegistry endpointRegistry) { 
    87         this.endpointRegistry = endpointRegistry; 
    88     } 
    89  
    90     /** 
    91      * Gets the endpoint registry. 
    92      *  
    93      * @return the endpoint registry 
    94      */ 
    95     public EndpointRegistry getEndpointRegistry() { 
    96         return endpointRegistry; 
    97     } 
    98  
    9964    /** 
    10065     * Sets the event release engine. 
     
    11580    } 
    11681 
    117     /** 
    118      * Sets the enable event release. 
    119      *  
    120      * @param enableEventRelease the enableEventRelease to set 
    121      */ 
    122     public void setEnableEventRelease(boolean enableEventRelease) { 
    123         this.enableEventRelease = enableEventRelease; 
    124     } 
    125  
    126     /** 
    127      * Checks if is enable event release. 
    128      *  
    129      * @return the enableEventRelease 
    130      */ 
    131     public boolean isEnableEventRelease() { 
    132         return enableEventRelease; 
    133     } 
    134  
    135     /* 
    136      * (non-Javadoc) 
    137      *  
    138      * @see uk.ac.cardiff.raptor.remoting.client.EventReleaseClient#isEnabled() 
    139      */ 
    140     public boolean isEnabled() { 
    141         return isEnableEventRelease(); 
    142     } 
    143  
    14482} 
  • raptor-client/trunk/src/main/java/uk/ac/cardiff/raptor/remoting/client/EventReleaseClient.java

    r817 r1049  
    1717 * 
    1818 */ 
     19 
    1920package uk.ac.cardiff.raptor.remoting.client; 
    2021 
     
    2627 
    2728/** 
    28  * Sends event records using the CXF SOAP libraries 
    29  * @author philsmart 
    30  * 
     29 * Sends event records to a client endpoint 
     30 *  
    3131 */ 
    3232public interface EventReleaseClient { 
     
    3434    /** 
    3535     * Release the <code>events</code> to the endpoint specified in this clients implementation 
    36      * 
     36     *  
    3737     * @param events the <code>List</code> of events that are to be released 
    38      * @param ServiceMetadata 
     38     * @param ServiceMetadata the metadata associated to the sending service 
    3939     * @return true of the release was successful and false otherwise 
    4040     * @throws ReleaseFailureException 
    4141     */ 
    42         public boolean release(List<Event> events, ServiceMetadata serviceMetadata) throws ReleaseFailureException; 
     42    public boolean release(List<Event> events, ServiceMetadata serviceMetadata) throws ReleaseFailureException; 
    4343 
    44         /** All concrete implementations of the <code>EventReleaseClient</code> must 
    45          * provide a way of accessing the list of endpoints it is communicating with 
    46          * 
    47          * @return a list of endpoints 
    48          */ 
    49         public List<Endpoint> getEndpoints(); 
     44    /** Used to determine if the event release client has been enabled */ 
     45    public boolean isEnabled(); 
    5046 
    51         /** Used to determine if the event release client has been enabled*/ 
    52         public boolean isEnabled(); 
    53  
    54  
     47    /** 
     48     * A way of accessing the list of endpoints it is communicating with 
     49     *  
     50     * @return a list of endpoints 
     51     */ 
     52    public List<Endpoint> getEndpoints(); 
    5553 
    5654} 
Note: See TracChangeset for help on using the changeset viewer.