siffer 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +93 -0
- data/lib/siffer.rb +13 -16
- data/lib/siffer/agent.rb +39 -31
- data/lib/siffer/core_ext/hash.rb +15 -0
- data/lib/siffer/messages.rb +38 -4
- data/lib/siffer/messages/ack.rb +160 -35
- data/lib/siffer/messages/event.rb +20 -0
- data/lib/siffer/messages/message.rb +47 -58
- data/lib/siffer/messages/provide.rb +25 -0
- data/lib/siffer/messages/provision.rb +17 -0
- data/lib/siffer/messages/register.rb +42 -52
- data/lib/siffer/messages/request.rb +138 -0
- data/lib/siffer/messages/response.rb +48 -0
- data/lib/siffer/messages/subscribe.rb +17 -0
- data/lib/siffer/messages/system_control.rb +94 -0
- data/lib/siffer/models.rb +1 -0
- data/lib/siffer/models/address.rb +39 -0
- metadata +25 -146
- data/README.rdoc +0 -65
- data/Rakefile +0 -64
- data/bin/siffer +0 -71
- data/doc/SIF ImplementationSpecification.pdf +0 -0
- data/doc/rdoc/classes/Siffer.html +0 -259
- data/doc/rdoc/classes/Siffer/Agent.html +0 -177
- data/doc/rdoc/classes/Siffer/Container.html +0 -165
- data/doc/rdoc/classes/Siffer/Messages.html +0 -81
- data/doc/rdoc/classes/Siffer/Messages/Ack.html +0 -115
- data/doc/rdoc/classes/Siffer/Messages/Acl.html +0 -83
- data/doc/rdoc/classes/Siffer/Messages/Error.html +0 -157
- data/doc/rdoc/classes/Siffer/Messages/Message.html +0 -235
- data/doc/rdoc/classes/Siffer/Messages/Message/Header.html +0 -107
- data/doc/rdoc/classes/Siffer/Messages/Register.html +0 -154
- data/doc/rdoc/classes/Siffer/Messages/RequestBody.html +0 -185
- data/doc/rdoc/classes/Siffer/Messages/Status.html +0 -156
- data/doc/rdoc/classes/Siffer/Messaging.html +0 -212
- data/doc/rdoc/classes/Siffer/Protocol.html +0 -254
- data/doc/rdoc/classes/Siffer/Protocol/NonPostRequest.html +0 -54
- data/doc/rdoc/classes/Siffer/Protocol/UnknownPath.html +0 -54
- data/doc/rdoc/classes/Siffer/Registration.html +0 -251
- data/doc/rdoc/classes/Siffer/Request.html +0 -103
- data/doc/rdoc/classes/Siffer/RequestLogger.html +0 -109
- data/doc/rdoc/classes/Siffer/Response.html +0 -91
- data/doc/rdoc/classes/Siffer/Server.html +0 -156
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/LICENSE.html +0 -76
- data/doc/rdoc/files/README_rdoc.html +0 -131
- data/doc/rdoc/files/lib/siffer/agent_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/container_rb.html +0 -57
- data/doc/rdoc/files/lib/siffer/messages/ack_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/acl_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/error_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/message_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/register_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/request_body_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/status_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages_rb.html +0 -63
- data/doc/rdoc/files/lib/siffer/messaging_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/protocol_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/registration_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/request_logger_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/request_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/response_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/server_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer_rb.html +0 -64
- data/doc/rdoc/fr_class_index.html +0 -25
- data/doc/rdoc/fr_file_index.html +0 -39
- data/doc/rdoc/fr_method_index.html +0 -4539
- data/doc/rdoc/index.html +0 -15
- data/doc/rdoc/rdoc-style.css +0 -319
- data/lib/siffer/container.rb +0 -94
- data/lib/siffer/messages/acl.rb +0 -25
- data/lib/siffer/messages/error.rb +0 -174
- data/lib/siffer/messages/request_body.rb +0 -66
- data/lib/siffer/messages/status.rb +0 -55
- data/lib/siffer/messaging.rb +0 -99
- data/lib/siffer/protocol.rb +0 -164
- data/lib/siffer/registration.rb +0 -87
- data/lib/siffer/request.rb +0 -28
- data/lib/siffer/request_logger.rb +0 -32
- data/lib/siffer/response.rb +0 -26
- data/lib/siffer/server.rb +0 -42
- data/spec/agent_spec.rb +0 -48
- data/spec/cli_spec.rb +0 -40
- data/spec/container_spec.rb +0 -103
- data/spec/default_agent +0 -6
- data/spec/default_server +0 -5
- data/spec/message_specs/ack_spec.rb +0 -28
- data/spec/message_specs/error_spec.rb +0 -24
- data/spec/message_specs/header_spec.rb +0 -25
- data/spec/message_specs/message_spec.rb +0 -57
- data/spec/message_specs/register_spec.rb +0 -86
- data/spec/message_specs/request_body_spec.rb +0 -58
- data/spec/message_specs/status_spec.rb +0 -25
- data/spec/messaging_spec.rb +0 -85
- data/spec/protocol_spec.rb +0 -50
- data/spec/registration_spec.rb +0 -33
- data/spec/request_logger_spec.rb +0 -28
- data/spec/request_spec.rb +0 -25
- data/spec/response_spec.rb +0 -24
- data/spec/server_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -35
@@ -0,0 +1,20 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
# Message for SIF_Event, used to deliver objects defined in SIF.
|
5
|
+
# Events represent the availability of new data object, changes to
|
6
|
+
# or deletions of data object
|
7
|
+
#@see EventObject
|
8
|
+
class Event < Message
|
9
|
+
element :object_data
|
10
|
+
end
|
11
|
+
|
12
|
+
# Message Element that holds the data object that is add/change/delete
|
13
|
+
#@see Event
|
14
|
+
class EventObject < AcDc::Body
|
15
|
+
attribute :object_name
|
16
|
+
attribute :action
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -1,71 +1,60 @@
|
|
1
1
|
module Siffer
|
2
2
|
module Messages
|
3
|
+
|
4
|
+
# Security Element for the Header Element
|
5
|
+
#@see Header
|
6
|
+
class Security < SifBody
|
7
|
+
element :secure_channel
|
8
|
+
end
|
3
9
|
|
4
|
-
#
|
5
|
-
|
6
|
-
class
|
10
|
+
# SecureChannel Element for the Security Element
|
11
|
+
#@see Security
|
12
|
+
class SecureChannel < SifBody
|
13
|
+
element :encryption_level
|
14
|
+
element :authentication_level
|
15
|
+
end
|
7
16
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
# List of Contexts for the Message
|
18
|
+
class Contexts < SifBody
|
19
|
+
element :context
|
20
|
+
end
|
21
|
+
|
22
|
+
# Header for all SIF_Message types
|
23
|
+
#@see Message
|
24
|
+
class Header < SifBody
|
25
|
+
element :msg_id, :tag => "SIF_MsgId"
|
26
|
+
element :timestamp, :tag => "SIF_Timestamp"
|
27
|
+
element :security, :tag => "SIF_security"
|
28
|
+
element :source_id, :tag => "SIF_SourceId", :required => true
|
29
|
+
element :destination_id, :tag => "SIF_DestinationId"
|
30
|
+
element :contexts, :tag => "SIF_Contexts"
|
31
|
+
|
32
|
+
def initialize(values = {})
|
33
|
+
values.update(:msg_id => UUID.generate(:compact).upcase) unless values.has_key?(:msg_id)
|
34
|
+
values.update(:timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")) unless values.has_key?(:timestamp)
|
35
|
+
super(values)
|
25
36
|
end
|
26
37
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# used to remove the stack too deep issue when overridden
|
33
|
-
# there has to be a better way .... TODO: Fix the alias crap
|
34
|
-
alias :body :content
|
35
|
-
|
36
|
-
def put_header_into(xml)
|
37
|
-
xml.SIF_Header { |head|
|
38
|
-
head.SIF_MsgId(@header.msg_id)
|
39
|
-
head.SIF_Timestamp(@header.timestamp)
|
40
|
-
head.SIF_SourceId(@header.source_id)
|
41
|
-
}
|
42
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Base Message for all SIF_Message types
|
41
|
+
class Message < SifBody
|
42
|
+
element :header, Header
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
# over and over again for every read made to this
|
48
|
-
# message.
|
49
|
-
@xml ||= content
|
44
|
+
def initialize(values={})
|
45
|
+
values.update(:header => Header.new(:source_id => values[:header])) unless values[:header].nil?
|
46
|
+
super(values)
|
50
47
|
end
|
51
|
-
alias :to_str :read
|
52
|
-
|
53
|
-
# Each Message requires a Header to identify the source.
|
54
|
-
# You shouldn't need to initialize this by itself, it is
|
55
|
-
# used by Message.
|
56
|
-
class Header
|
57
|
-
|
58
|
-
attr_reader :timestamp, :msg_id, :source_id
|
59
|
-
|
60
|
-
def initialize(source)
|
61
|
-
raise ArgumentError, "Source not provided." if source.nil?
|
62
|
-
@timestamp = Time.now
|
63
|
-
@msg_id = UUID.generate(:compact).upcase
|
64
|
-
@source_id = source
|
65
|
-
end
|
66
48
|
|
49
|
+
alias_method :old_acdc, :acdc
|
50
|
+
def acdc
|
51
|
+
xml = Builder::XmlMarkup.new
|
52
|
+
attrs = { :Version => Siffer.sif_version, :xmlns => Siffer.sif_xmlns }
|
53
|
+
xml.tag!("SIF_Message", attrs){|body| body << old_acdc}
|
54
|
+
xml.target!
|
67
55
|
end
|
68
|
-
|
56
|
+
|
69
57
|
end
|
58
|
+
|
70
59
|
end
|
71
60
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
# Element used by SIF_Provide to represent the object being provided
|
5
|
+
#@see Provide
|
6
|
+
class Object < SifBody
|
7
|
+
attribute :object_name
|
8
|
+
element :extended_query_support
|
9
|
+
element :contexts
|
10
|
+
end
|
11
|
+
|
12
|
+
# Message used to attempt registering as a provider of one or more data objects
|
13
|
+
#@see Object
|
14
|
+
class Provide < Message
|
15
|
+
element :object
|
16
|
+
end
|
17
|
+
|
18
|
+
# This message performs the opposite function of SIF_Provide.
|
19
|
+
#@see Object
|
20
|
+
class UnProvide < Message
|
21
|
+
element :object
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
# This message allows an agent to announce to the ZIS the functionality the agent will provide.
|
5
|
+
#@see Object
|
6
|
+
class Provision < Message
|
7
|
+
element :provide_objects
|
8
|
+
element :subscribe_objects
|
9
|
+
element :publish_add_objects
|
10
|
+
element :publish_change_objects
|
11
|
+
element :publish_delete_objects
|
12
|
+
element :request_objects
|
13
|
+
element :respond_objects
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -1,60 +1,50 @@
|
|
1
1
|
module Siffer
|
2
2
|
module Messages
|
3
3
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(source, name, options = {})
|
10
|
-
super(source, options)
|
11
|
-
raise ArgumentError, "Agent name required" unless name
|
12
|
-
@name = name
|
13
|
-
@version = options[:version] || Siffer.sif_version
|
14
|
-
@max_buffer = options[:max_buffer] || 1024
|
15
|
-
@mode = options[:mode] || 'Pull'
|
16
|
-
@vendor = options[:vendor] || Siffer.vendor
|
17
|
-
end
|
18
|
-
|
19
|
-
def content
|
20
|
-
body do |reg|
|
21
|
-
reg.SIF_Register() { |xml|
|
22
|
-
put_header_into xml
|
23
|
-
reg.SIF_Name(@name)
|
24
|
-
reg.SIF_Version(@version)
|
25
|
-
reg.SIF_MaxBufferSize(@max_buffer)
|
26
|
-
reg.SIF_Mode(@mode)
|
27
|
-
}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Parses the body passed as a Register message and returns a
|
32
|
-
# RequestBody that provides access to Register properties.
|
33
|
-
def self.parse(body)
|
34
|
-
RegisterBody.parse(body)
|
35
|
-
end
|
36
|
-
|
37
|
-
class RegisterBody < RequestBody #:nodoc:
|
38
|
-
|
39
|
-
def name
|
40
|
-
(@doc/:SIF_Name).text
|
41
|
-
end
|
42
|
-
|
43
|
-
def version
|
44
|
-
(@doc/:SIF_Version).text
|
45
|
-
end
|
46
|
-
|
47
|
-
def max_buffer
|
48
|
-
(@doc/:SIF_MaxBufferSize).text.to_i
|
49
|
-
end
|
50
|
-
|
51
|
-
def mode
|
52
|
-
(@doc/:SIF_Mode).text
|
53
|
-
end
|
4
|
+
# Used by Protocol to describe the protocol used by the agent
|
5
|
+
DEFINED_PROTOCOLS_TYPE = {
|
6
|
+
:http => "HTTP",
|
7
|
+
:https => "HTTPS"
|
8
|
+
}
|
54
9
|
|
55
|
-
|
56
|
-
|
10
|
+
# Used by Protocl to describe any protocol settings
|
11
|
+
class Property < SifBody
|
12
|
+
element :name
|
13
|
+
element :value
|
14
|
+
end
|
15
|
+
|
16
|
+
# Contains protocol information regarding a ZIS or Agent.
|
17
|
+
class Protocol < SifBody
|
18
|
+
attribute :type, DEFINED_PROTOCOLS_TYPE[:https]
|
19
|
+
attribute :secure, true
|
20
|
+
element :url
|
21
|
+
element :property
|
22
|
+
end
|
23
|
+
|
24
|
+
# Contains information about the vendor of the product that the agent represents
|
25
|
+
class Application < SifBody
|
26
|
+
element :vendor
|
27
|
+
element :product
|
28
|
+
element :version
|
57
29
|
end
|
58
30
|
|
31
|
+
# Register is a message for registering an agent with a ZIS.
|
32
|
+
# An agent must be registered before it sends out messages.
|
33
|
+
class Register < Message
|
34
|
+
element :name
|
35
|
+
element :version
|
36
|
+
element :max_buffer_size
|
37
|
+
element :mode
|
38
|
+
element :protocol
|
39
|
+
element :node_vendor
|
40
|
+
element :node_version
|
41
|
+
element :application
|
42
|
+
element :icon
|
43
|
+
end
|
44
|
+
|
45
|
+
# This message allows an agent to remove any association it has with the ZIS.
|
46
|
+
#@see Register
|
47
|
+
class Unregister < Message; end
|
48
|
+
|
59
49
|
end
|
60
50
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
CONDITION_GROUP_TYPES = {
|
5
|
+
:and => "And",
|
6
|
+
:or => "Or",
|
7
|
+
:none => "None"
|
8
|
+
}
|
9
|
+
|
10
|
+
OPERATORS = {
|
11
|
+
:equals => "EQ",
|
12
|
+
:less_than => "LT",
|
13
|
+
:greater_than => "GT",
|
14
|
+
:less_than_or_equals => "LE",
|
15
|
+
:greater_than_or_equals => "GE",
|
16
|
+
:not_equals => "NE"
|
17
|
+
}
|
18
|
+
|
19
|
+
ORDERING = {
|
20
|
+
:asc => "Ascending",
|
21
|
+
:des => "Descending"
|
22
|
+
}
|
23
|
+
|
24
|
+
# Represents a condition used in a Query
|
25
|
+
#@see Conditions
|
26
|
+
class Condition < SifBody
|
27
|
+
element :element
|
28
|
+
element :operator
|
29
|
+
element :value
|
30
|
+
end
|
31
|
+
|
32
|
+
# List of Conditions
|
33
|
+
#@see ConditionGroup
|
34
|
+
class Conditions < SifBody
|
35
|
+
attribute :type, CONDITION_GROUP_TYPES[:none]
|
36
|
+
element :condition
|
37
|
+
end
|
38
|
+
|
39
|
+
# Represents a group conditions that the queried objects must meet.
|
40
|
+
# If conditions are not specified all objects named are returned
|
41
|
+
class ConditionGroup < SifBody
|
42
|
+
attribute :type, CONDITION_GROUP_TYPES[:none]
|
43
|
+
element :conditions
|
44
|
+
end
|
45
|
+
|
46
|
+
# The object that is being queried for
|
47
|
+
class QueryObject < SifBody
|
48
|
+
attribute :object_name
|
49
|
+
element :element
|
50
|
+
end
|
51
|
+
|
52
|
+
# SIF's default query mechanism
|
53
|
+
class Query < SifBody
|
54
|
+
element :query_object
|
55
|
+
element :condition_group
|
56
|
+
element :example
|
57
|
+
end
|
58
|
+
|
59
|
+
# Element used in Select to identify the element/attribute
|
60
|
+
#@see Select
|
61
|
+
#@see Condition
|
62
|
+
#@see OrderBy
|
63
|
+
#@see QueryObject
|
64
|
+
class Element < SifBody
|
65
|
+
attribute :alias
|
66
|
+
attribute :object_name
|
67
|
+
attribute :ordering, ORDERING[:asc]
|
68
|
+
attribute :xsi_type # need to work this out , it should be xsi:type
|
69
|
+
end
|
70
|
+
|
71
|
+
# Identifies elements to be returned as columns in a query
|
72
|
+
#@see ExtendedQuery
|
73
|
+
class Select < SifBody
|
74
|
+
attribute :distinct, false
|
75
|
+
attribute :row_count, 0 # This represents a number, 0 for all rows
|
76
|
+
element :element
|
77
|
+
end
|
78
|
+
|
79
|
+
# Specifies left join on which to constrain the join
|
80
|
+
#@see JoinOn
|
81
|
+
class LeftElement < SifBody
|
82
|
+
attribute :object_name
|
83
|
+
end
|
84
|
+
|
85
|
+
# Specifies right join on which to constrain the join
|
86
|
+
#@see JoinOn
|
87
|
+
class RightElement < SifBody
|
88
|
+
attribute :object_name
|
89
|
+
end
|
90
|
+
|
91
|
+
# Specifies conditions to limit/filter rows
|
92
|
+
#@see ExtendedQuery
|
93
|
+
class Where < SifBody
|
94
|
+
element :condition_group
|
95
|
+
end
|
96
|
+
|
97
|
+
# Optional list of elements/attributes by which to sort the resulting rows
|
98
|
+
#@see ExtendedQuery
|
99
|
+
class OrderBy < SifBody
|
100
|
+
element :element
|
101
|
+
end
|
102
|
+
|
103
|
+
# Specifies conditions for the join
|
104
|
+
#@see From
|
105
|
+
class JoinOn < SifBody
|
106
|
+
element :left_element
|
107
|
+
element :right_element
|
108
|
+
end
|
109
|
+
|
110
|
+
# Join specification for the query if more than one object is being queried
|
111
|
+
#@see ExtendedQuery
|
112
|
+
class From < SifBody
|
113
|
+
attribute :object_name
|
114
|
+
element :join
|
115
|
+
end
|
116
|
+
|
117
|
+
# A more advanced form of Query that allows for joins and retrieval of data
|
118
|
+
# in row/column form.
|
119
|
+
class ExtendedQuery < SifBody
|
120
|
+
element :destination_provider
|
121
|
+
element :select
|
122
|
+
element :from
|
123
|
+
element :where
|
124
|
+
element :order_by
|
125
|
+
end
|
126
|
+
|
127
|
+
# Message used to request information in SIF data objects from other SIF nodes.
|
128
|
+
#@see Query
|
129
|
+
#@see ExtendedQuery
|
130
|
+
class Request < Message
|
131
|
+
element :version
|
132
|
+
element :max_buffer_size
|
133
|
+
element :query
|
134
|
+
element :extended_query
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Siffer
|
2
|
+
module Messages
|
3
|
+
|
4
|
+
MORE_PACKETS = {
|
5
|
+
:yes => "Yes",
|
6
|
+
:no => "No"
|
7
|
+
}
|
8
|
+
|
9
|
+
# Provides element/attribute caption information for each column supplied in
|
10
|
+
# ExtendedQuery. The order must correspend to the order in the ExtendedQuery
|
11
|
+
#@see ExtendedQueryResults
|
12
|
+
#@see Element
|
13
|
+
class ColumnHeaders < SifBody
|
14
|
+
element :element
|
15
|
+
end
|
16
|
+
|
17
|
+
class R < SifBody
|
18
|
+
element :c
|
19
|
+
end
|
20
|
+
|
21
|
+
class Rows < SifBody
|
22
|
+
element :r
|
23
|
+
end
|
24
|
+
|
25
|
+
# Element provides a wrapper for data returned in response to
|
26
|
+
# an ExtendedQuery
|
27
|
+
#@see Response
|
28
|
+
#@see ReportObject
|
29
|
+
class ExtendedQueryResults < SifBody
|
30
|
+
element :column_headers
|
31
|
+
element :rows
|
32
|
+
end
|
33
|
+
|
34
|
+
# Used to respond to a SIF_Request message.
|
35
|
+
# May span multiple SIF_Response messages.
|
36
|
+
#@see Error
|
37
|
+
#@see ExtendedQueryResults
|
38
|
+
class Response < Message
|
39
|
+
element :request_msg_id
|
40
|
+
element :packet_number
|
41
|
+
element :more_packets
|
42
|
+
element :error
|
43
|
+
element :object_data
|
44
|
+
element :extended_query_results
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|