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 util = require('util');
  
  var AuthzUtil = require('oae-authz/lib/util');
  var TenantsAPI = require('oae-tenants');
  
  /**
   * The Group model.
   *
   * @param  {String}     tenantAlias             The alias of the tenant this group belongs to.
   * @param  {String}     id                      The globally unique principalId for this group. e.g.: g:cam:math-101
   * @param  {String}     displayName             The name of the group
   * @param  {Object}     [opts]                  Optional additional group properties
   * @param  {String}     [opts.visibility]       The visibility of this group. e.g.: loggedin
   * @param  {String}     [opts.joinable]         How this group can be joined
   * @param  {String}     [opts.description]      The description of the group
   * @param  {String}     [opts.smallPictureUri]  The uri of the small picture. It will be made available at user.picture.smallUri
   * @param  {String}     [opts.mediumPictureUri] The uri of the medium picture. It will be made available at user.picture.mediumUri
   * @param  {String}     [opts.largePictureUri]  The uri of the large picture. It will be made available at user.picture.largeUri
   */
  module.exports.Group = function(tenantAlias, id, displayName, opts) {
      opts = opts || {};
      var resourceId = AuthzUtil.getResourceFromId(id).resourceId;
  
      var that = {};
      that.id = id;
      that.displayName = displayName;
      that.tenant = TenantsAPI.getTenant(tenantAlias).compact();
      that.visibility = opts.visibility;
      that.joinable = opts.joinable;
      that.description = opts.description;
      that.profilePath = '/group/' + tenantAlias + '/' + resourceId;
      that.resourceType = 'group';
  
      that.picture = {};
      if (opts.smallPictureUri) {
          that.picture.smallUri = opts.smallPictureUri;
      }
      if (opts.mediumPictureUri) {
          that.picture.mediumUri = opts.mediumPictureUri;
      }
      if (opts.largePictureUri) {
          that.picture.largeUri = opts.largePictureUri;
      }
  
      return that;
  };
  