/**
 * @license
 * Copyright 2018 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  package: 'foam.nanos.auth',
  name: 'ServiceProvider',

  implements: ['foam.nanos.auth.EnabledAware'],

  documentation: 'Service Provider',

  tableColumns: ['id', 'description'],

  properties: [
    {
      class: 'String',
      name: 'id',
      documentation: 'Service provider name',
      validationPredicates: [
        {
          args: ['id'],
          predicateFactory: function(e) {
            return e.REG_EXP(foam.nanos.auth.ServiceProvider.ID, /^[a-z0-9]+$/);
          },
          errorString: 'Invalid character(s) in id.'
        }
      ]
    },
    {
      class: 'Boolean',
      name: 'enabled'
    },
    {
      class: 'String',
      name: 'description',
      documentation: 'Service provider description'
    }
  ]
});

@@ -126,13 +126,14 @@
 oam.
-CLASS
+SCRIPT
 (%7B%0A 
@@ -189,27 +189,120 @@
 ider
-',%0A%0A  implements
+Fixer',%0A  code: function () %7B%0A    foam.lookup('foam.nanos.crunch.Capability');%0A  %7D%0A%7D);%0A%0Afoam.CLASS(%7B%0A  package
 : 
-%5B
 'foa
@@ -317,101 +317,128 @@
 auth
-.EnabledAware'%5D,%0A%0A  documentation: 'Service Provider',%0A%0A  tableColumns: %5B'id', 'description'%5D
+',%0A  name: 'ServiceProvider',%0A  extends: 'foam.nanos.crunch.Capability',%0A%0A  documentation: 'Service Provider Capability'
 ,%0A%0A 
@@ -847,15 +847,14 @@
 s: '
-Boolean
+String
 ',%0A 
@@ -869,110 +869,70 @@
 e: '
-e
 na
-bled'%0A    %7D,%0A    %7B%0A      class: 'String',%0A      name: 'description',%0A      documentation: '
+me',%0A      javaFactory: %60%0A        return getId() + %22
 Service 
 prov
@@ -927,25 +927,25 @@
 Service 
-p
+P
 rovider 
 descript
@@ -940,20 +940,28 @@
 der 
-description'
+Capability%22;%0A      %60
 %0A   

make spid extend capability