text: /*!
   * Copyright 2013 Apereo Foundation (AF) Licensed under the
   * Educational Community License, Version 2.0 (the "License"); you may
   * not use this file except in compliance with the License. You may
   * obtain a copy of the License at
   *
   *     http://opensource.org/licenses/ECL-2.0
   *
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an "AS IS"
   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
   * or implied. See the License for the specific language governing
   * permissions and limitations under the License.
   */
  
  var OAE = require('oae-util/lib/oae');
  
  var UIAPI = require('./api');
  
  //////////////////
  // Global admin //
  //////////////////
  
  /**
   * Get all the aggregated widget configs
   */
  OAE.globalAdminRouter.on('get', '/api/ui/widgets', function(req, res) {
      var widgetConfigs = UIAPI.getWidgetManifests();
      res.send(200, widgetConfigs);
  });
  
  /**
   * Get the file content for a number of static files
   */
  OAE.globalAdminRouter.on('get', '/api/ui/staticbatch', function(req, res) {
      var files = req.query.files;
      if (!Array.isArray(files)) {
          files = [files];
      }
  
      UIAPI.getStaticBatch(files, function(err, results) {
          if (err) {
              return res.send(err.code, err.msg);
          }
          res.send(200, results);
      });
  });
  
  /*!
   * Returns the base skin for the global admin UI.
   */
  OAE.globalAdminRouter.on('get', '/api/ui/skin', function(req, res) {
      UIAPI.getSkin(req.ctx, function(err, css) {
          if (err) {
              return res.send(err.code, err.msg);
          }
          res.set('Content-Type', 'text/css');
          res.send(200, css);
      });
  });
  
  /*!
   * Returns all the variable names that are present in the skin file.
   */
  OAE.globalAdminRouter.on('get', '/api/ui/skin/variables', function(req, res) {
      UIAPI.getSkinVariables(req.ctx, req.query.tenant, function(err, variables) {
          if (err) {
              return res.send(err.code, err.msg);
          }
          res.send(200, {'results': variables});
      });
  });
  
  
  /////////////
  // Tenants //
  /////////////
  
  /**
   * Get all the aggregated widget configs
   */
  OAE.tenantRouter.on('get', '/api/ui/widgets', function(req, res) {
      var widgetConfigs = UIAPI.getWidgetManifests();
      res.send(200, widgetConfigs);
  });
  
  /**
   * Get the file content for a number of static files
   */
  OAE.tenantRouter.on('get', '/api/ui/staticbatch', function(req, res) {
      var files = req.query.files;
      if (!Array.isArray(files)) {
          files = [files];
      }
  
      UIAPI.getStaticBatch(files, function(err, results) {
          if (err) {
              return res.send(err.code, err.msg);
          }
          res.send(200, results);
      });
  });
  
  /*!
   * Returns the custom skin for a tenant.
   */
  OAE.tenantRouter.on('get', '/api/ui/skin', function(req, res) {
      UIAPI.getSkin(req.ctx, function(err, css) {
          if (err) {
              return res.send(err.code, err.msg);
          }
          res.set('Content-Type', 'text/css');
          res.send(200, css);
      });
  });
  
  /*!
   * Returns all the variable names that are present in the skin file.
   */
  OAE.tenantRouter.on('get', '/api/ui/skin/variables', function(req, res) {
      UIAPI.getSkinVariables(req.ctx, req.query.tenant, function(err, variables) {
          if (err) {
              return res.send(err.code, err.msg);
          }
          res.send(200, {'results': variables});
      });
  });
  