incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1032491 - in /incubator/deltacloud/trunk/server: lib/deltacloud/backend_capability.rb views/errors/backend_capability_failure.html.haml views/errors/backend_capability_failure.xml.haml
Date Mon, 08 Nov 2010 08:33:41 GMT
Author: mfojtik
Date: Mon Nov  8 08:33:41 2010
New Revision: 1032491

URL: http://svn.apache.org/viewvc?rev=1032491&view=rev
Log:
Add support files for capability checking.

Added:
    incubator/deltacloud/trunk/server/lib/deltacloud/backend_capability.rb
    incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.html.haml
    incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.xml.haml

Added: incubator/deltacloud/trunk/server/lib/deltacloud/backend_capability.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/backend_capability.rb?rev=1032491&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/backend_capability.rb (added)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/backend_capability.rb Mon Nov  8 08:33:41
2010
@@ -0,0 +1,21 @@
+module Deltacloud::BackendCapability
+
+  class Failure < StandardError
+    attr_reader :capability
+    def initialize(capability, msg='')
+      super(msg)
+      @capability = capability
+    end
+  end
+
+  attr_reader :capability
+  def with_capability(capability)
+    @capability = capability
+  end
+
+  def check_capability(backend)
+    if capability and !backend.respond_to?(capability)
+      raise Failure.new(capability, "#{capability} capability not supported by backend #{backend.class.name}")
+    end
+  end
+end

Added: incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.html.haml?rev=1032491&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.html.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.html.haml Mon
Nov  8 08:33:41 2010
@@ -0,0 +1,11 @@
+%h1 Backend Capability Failure
+
+%p= @error.message
+
+%dl
+  %di
+    %dt Request URL
+    %dd= request.env['REQUEST_URI']
+  %di
+    %dt Capability
+    %dd= @error.capability

Added: incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.xml.haml?rev=1032491&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.xml.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/backend_capability_failure.xml.haml Mon
Nov  8 08:33:41 2010
@@ -0,0 +1,4 @@
+%error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
+  %capability #{@error.capability}
+  %message #{@error.message}
+



Mime
View raw message