Mailinglist Archive: yast-commit (1535 mails)
| < Previous | Next > |
[yast-commit] <rest-service> master : read and render registration configuration, remove debug output
- From: J.Daniel Schmidt <jdsn@xxxxxxx>
- Date: Wed, 14 Oct 2009 15:10:15 +0200
- Message-id: <E1My3cx-0001a8-JR@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 959381aeac16a17d1ed5880431938f316950776c
Author: J. Daniel Schmidt <jdsn@xxxxxxx>
Date: Wed Oct 14 15:10:15 2009 +0200
read and render registration configuration, remove debug output
---
.../app/controllers/configuration_controller.rb | 5 +-
.../app/controllers/registration_controller.rb | 17 +------
plugins/registration/app/models/registration.rb | 44 ++++++++++++++------
.../app/views/configuration/show.html.erb | 12 +-----
.../app/views/configuration/show.xml.erb | 2 +-
.../app/views/registration/status.html.erb | 1 +
.../app/views/registration/status.json.erb | 1 +
.../app/views/registration/status.xml.erb | 1 +
8 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/plugins/registration/app/controllers/configuration_controller.rb
b/plugins/registration/app/controllers/configuration_controller.rb
index 77315bb..38e0929 100644
--- a/plugins/registration/app/controllers/configuration_controller.rb
+++ b/plugins/registration/app/controllers/configuration_controller.rb
@@ -12,11 +12,12 @@ class ConfigurationController < ApplicationController
end
def show
- @registration = Registration.new( { } )
# do not run registration
# only get the server url and certificate -> to be done in YSR.pm
- # @registration = "GET to /registration/configuration"
+ @registration = Registration.new( { } )
+ puts @registration.get_config.inspect
+
end
def index
diff --git a/plugins/registration/app/controllers/registration_controller.rb
b/plugins/registration/app/controllers/registration_controller.rb
index 0362770..bb80661 100644
--- a/plugins/registration/app/controllers/registration_controller.rb
+++ b/plugins/registration/app/controllers/registration_controller.rb
@@ -5,35 +5,24 @@ class RegistrationController < ApplicationController
before_filter :login_required
- def update
- end
-
def create
- puts "-> REGISTRATION CREATE"
# POST to registration => run registration
@registration = Registration.new({})
- puts "-> NEW registration"
- puts @registration.inspect
+
# TODO: parse post data and set context data
#@registration.set_context( { } )
ret = @registration.register
- puts "-> RAN register"
- puts ret.inspect
- puts "-> PUT inpect ^"
end
def show
# getRegistrationServerDetails
- #@registration = @@registration
- #@registration = Registration.new( getRegistrationServerDetails.to_s )
-
@registration = Registration.new( { } )
+ puts @registration.get_config.inspect
+ render :status
# do not run registration
# only get the uuid, server url and certificate -> to be done in YSR.pm
- #@registration.register
- #@registration = "GET to /registration/"
end
def index
diff --git a/plugins/registration/app/models/registration.rb
b/plugins/registration/app/models/registration.rb
index 268af4b..8c5e2b0 100644
--- a/plugins/registration/app/models/registration.rb
+++ b/plugins/registration/app/models/registration.rb
@@ -9,6 +9,7 @@ class Registration
@context = { }
@arguments = { }
+ @config = { }
@reg = ''
def initialize(hash)
@@ -34,9 +35,9 @@ class Registration
end
- def find
- # Fixme: get the uuid, server url and certificate -> to be done in YSR.pm
- return {}
+ def find
+ @config = YastService.Call("YSR::getregistrationconfig")
+ return @config
end
def set_context(hash)
@@ -58,26 +59,43 @@ class Registration
# return @reg.inspect
end
- def get_registration_config
- # return @reg.inspect
+ def get_config
+ @config = YastService.Call("YSR::getregistrationconfig")
+ return @config
end
- def set_registration_config(url, ca)
+ def set_config(url, ca)
# TODO: write registration config
# return @reg.inspect
end
+ def status_to_xml( options = {} )
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
- def to_xml
- return @reg if @reg.class.to_s == String
- return "<regtest>#{ @reg.to_s }</regtest>"
+ xml.registration do
+ xml.tag!(:guid, @config['guid']) if @config['guid'] &&
@config['guid'].size > 0
+ end
end
- def to_xml( options = {} )
- #return "This function outputs XML :)"
+ def config_to_xml( options = {} )
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
- # FIXME only for testing!!
- return @reg.inspect
+ xml.registrationconfig do
+ xml.server do
+ xml.tag!(:url, @config['regserverurl'] )
+ end
+ xml.certificate do
+ xml.data do
+ xml.cdata!(@config['regserverca']) if @config['regserverca'].size > 0
+ end
+ end
+ end
+ end
+
+
+ def to_xml( options = {} )
xml = options[:builder] ||= Builder::XmlMarkup.new(options)
xml.instruct! unless options[:skip_instruct]
diff --git a/plugins/registration/app/views/configuration/show.html.erb
b/plugins/registration/app/views/configuration/show.html.erb
index 6ed6334..61ac18e 100644
--- a/plugins/registration/app/views/configuration/show.html.erb
+++ b/plugins/registration/app/views/configuration/show.html.erb
@@ -1,11 +1 @@
-<%= # @registration == nil ? "@registration is nil - FIXME" :
@registration.to_xml
- -%>
-<%= case @registration.class.to_s
- when 'NilClass'
- "@registration is nil"
- when 'String'
- @registration.to_s
- when 'Registration'
- @registration.to_xml
- end
- -%>
+<%= @registration.config_to_xml if @registration -%>
\ No newline at end of file
diff --git a/plugins/registration/app/views/configuration/show.xml.erb
b/plugins/registration/app/views/configuration/show.xml.erb
index c1a1254..14cfa7a 100644
--- a/plugins/registration/app/views/configuration/show.xml.erb
+++ b/plugins/registration/app/views/configuration/show.xml.erb
@@ -1 +1 @@
-<%= @registration == nil ? "@registration is nil - FIXME" :
@registration.to_xml -%>
+<%= @registration.config_to_xml if @registration -%>
diff --git a/plugins/registration/app/views/registration/status.html.erb
b/plugins/registration/app/views/registration/status.html.erb
new file mode 100644
index 0000000..de74d8e
--- /dev/null
+++ b/plugins/registration/app/views/registration/status.html.erb
@@ -0,0 +1 @@
+<%= @registration.status_to_xml if @registration -%>
\ No newline at end of file
diff --git a/plugins/registration/app/views/registration/status.json.erb
b/plugins/registration/app/views/registration/status.json.erb
new file mode 100644
index 0000000..de74d8e
--- /dev/null
+++ b/plugins/registration/app/views/registration/status.json.erb
@@ -0,0 +1 @@
+<%= @registration.status_to_xml if @registration -%>
\ No newline at end of file
diff --git a/plugins/registration/app/views/registration/status.xml.erb
b/plugins/registration/app/views/registration/status.xml.erb
new file mode 100644
index 0000000..de74d8e
--- /dev/null
+++ b/plugins/registration/app/views/registration/status.xml.erb
@@ -0,0 +1 @@
+<%= @registration.status_to_xml if @registration -%>
\ No newline at end of file
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
commit 959381aeac16a17d1ed5880431938f316950776c
Author: J. Daniel Schmidt <jdsn@xxxxxxx>
Date: Wed Oct 14 15:10:15 2009 +0200
read and render registration configuration, remove debug output
---
.../app/controllers/configuration_controller.rb | 5 +-
.../app/controllers/registration_controller.rb | 17 +------
plugins/registration/app/models/registration.rb | 44 ++++++++++++++------
.../app/views/configuration/show.html.erb | 12 +-----
.../app/views/configuration/show.xml.erb | 2 +-
.../app/views/registration/status.html.erb | 1 +
.../app/views/registration/status.json.erb | 1 +
.../app/views/registration/status.xml.erb | 1 +
8 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/plugins/registration/app/controllers/configuration_controller.rb
b/plugins/registration/app/controllers/configuration_controller.rb
index 77315bb..38e0929 100644
--- a/plugins/registration/app/controllers/configuration_controller.rb
+++ b/plugins/registration/app/controllers/configuration_controller.rb
@@ -12,11 +12,12 @@ class ConfigurationController < ApplicationController
end
def show
- @registration = Registration.new( { } )
# do not run registration
# only get the server url and certificate -> to be done in YSR.pm
- # @registration = "GET to /registration/configuration"
+ @registration = Registration.new( { } )
+ puts @registration.get_config.inspect
+
end
def index
diff --git a/plugins/registration/app/controllers/registration_controller.rb
b/plugins/registration/app/controllers/registration_controller.rb
index 0362770..bb80661 100644
--- a/plugins/registration/app/controllers/registration_controller.rb
+++ b/plugins/registration/app/controllers/registration_controller.rb
@@ -5,35 +5,24 @@ class RegistrationController < ApplicationController
before_filter :login_required
- def update
- end
-
def create
- puts "-> REGISTRATION CREATE"
# POST to registration => run registration
@registration = Registration.new({})
- puts "-> NEW registration"
- puts @registration.inspect
+
# TODO: parse post data and set context data
#@registration.set_context( { } )
ret = @registration.register
- puts "-> RAN register"
- puts ret.inspect
- puts "-> PUT inpect ^"
end
def show
# getRegistrationServerDetails
- #@registration = @@registration
- #@registration = Registration.new( getRegistrationServerDetails.to_s )
-
@registration = Registration.new( { } )
+ puts @registration.get_config.inspect
+ render :status
# do not run registration
# only get the uuid, server url and certificate -> to be done in YSR.pm
- #@registration.register
- #@registration = "GET to /registration/"
end
def index
diff --git a/plugins/registration/app/models/registration.rb
b/plugins/registration/app/models/registration.rb
index 268af4b..8c5e2b0 100644
--- a/plugins/registration/app/models/registration.rb
+++ b/plugins/registration/app/models/registration.rb
@@ -9,6 +9,7 @@ class Registration
@context = { }
@arguments = { }
+ @config = { }
@reg = ''
def initialize(hash)
@@ -34,9 +35,9 @@ class Registration
end
- def find
- # Fixme: get the uuid, server url and certificate -> to be done in YSR.pm
- return {}
+ def find
+ @config = YastService.Call("YSR::getregistrationconfig")
+ return @config
end
def set_context(hash)
@@ -58,26 +59,43 @@ class Registration
# return @reg.inspect
end
- def get_registration_config
- # return @reg.inspect
+ def get_config
+ @config = YastService.Call("YSR::getregistrationconfig")
+ return @config
end
- def set_registration_config(url, ca)
+ def set_config(url, ca)
# TODO: write registration config
# return @reg.inspect
end
+ def status_to_xml( options = {} )
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
- def to_xml
- return @reg if @reg.class.to_s == String
- return "<regtest>#{ @reg.to_s }</regtest>"
+ xml.registration do
+ xml.tag!(:guid, @config['guid']) if @config['guid'] &&
@config['guid'].size > 0
+ end
end
- def to_xml( options = {} )
- #return "This function outputs XML :)"
+ def config_to_xml( options = {} )
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
- # FIXME only for testing!!
- return @reg.inspect
+ xml.registrationconfig do
+ xml.server do
+ xml.tag!(:url, @config['regserverurl'] )
+ end
+ xml.certificate do
+ xml.data do
+ xml.cdata!(@config['regserverca']) if @config['regserverca'].size > 0
+ end
+ end
+ end
+ end
+
+
+ def to_xml( options = {} )
xml = options[:builder] ||= Builder::XmlMarkup.new(options)
xml.instruct! unless options[:skip_instruct]
diff --git a/plugins/registration/app/views/configuration/show.html.erb
b/plugins/registration/app/views/configuration/show.html.erb
index 6ed6334..61ac18e 100644
--- a/plugins/registration/app/views/configuration/show.html.erb
+++ b/plugins/registration/app/views/configuration/show.html.erb
@@ -1,11 +1 @@
-<%= # @registration == nil ? "@registration is nil - FIXME" :
@registration.to_xml
- -%>
-<%= case @registration.class.to_s
- when 'NilClass'
- "@registration is nil"
- when 'String'
- @registration.to_s
- when 'Registration'
- @registration.to_xml
- end
- -%>
+<%= @registration.config_to_xml if @registration -%>
\ No newline at end of file
diff --git a/plugins/registration/app/views/configuration/show.xml.erb
b/plugins/registration/app/views/configuration/show.xml.erb
index c1a1254..14cfa7a 100644
--- a/plugins/registration/app/views/configuration/show.xml.erb
+++ b/plugins/registration/app/views/configuration/show.xml.erb
@@ -1 +1 @@
-<%= @registration == nil ? "@registration is nil - FIXME" :
@registration.to_xml -%>
+<%= @registration.config_to_xml if @registration -%>
diff --git a/plugins/registration/app/views/registration/status.html.erb
b/plugins/registration/app/views/registration/status.html.erb
new file mode 100644
index 0000000..de74d8e
--- /dev/null
+++ b/plugins/registration/app/views/registration/status.html.erb
@@ -0,0 +1 @@
+<%= @registration.status_to_xml if @registration -%>
\ No newline at end of file
diff --git a/plugins/registration/app/views/registration/status.json.erb
b/plugins/registration/app/views/registration/status.json.erb
new file mode 100644
index 0000000..de74d8e
--- /dev/null
+++ b/plugins/registration/app/views/registration/status.json.erb
@@ -0,0 +1 @@
+<%= @registration.status_to_xml if @registration -%>
\ No newline at end of file
diff --git a/plugins/registration/app/views/registration/status.xml.erb
b/plugins/registration/app/views/registration/status.xml.erb
new file mode 100644
index 0000000..de74d8e
--- /dev/null
+++ b/plugins/registration/app/views/registration/status.xml.erb
@@ -0,0 +1 @@
+<%= @registration.status_to_xml if @registration -%>
\ No newline at end of file
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
| < Previous | Next > |