<commit_before>/*
 * This file is part of the GOsa project -  http://gosa-project.org
 *
 * Copyright:
 *    (C) 2010-2017 GONICUS GmbH, Germany, http://www.gonicus.de
 *
 * License:
 *    LGPL-2.1: http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * See the LICENSE file in the project's top-level directory for details.
 */

/**
 * Controller for actions that can be done on the object (e.g. change password).
 */
qx.Class.define("gosa.data.controller.Actions", {

  extend : qx.core.Object,
  implement: gosa.data.controller.IAction,

  /**
   * @param object {gosa.proxy.Object}
   */
  construct : function(object) {
    this.base(arguments);
    qx.core.Assert.assertInstance(object, gosa.proxy.Object);
    this.__object = object;
  },

  members : {
    __object : null,

    // overridden
    allowMethodSelection: function() {
      return true;
    },

    /**
     * Returns the dn of the object.
     *
     * @return {String | null}
     */
    getDn : function() {
      return this.__object.dn;
    },

    /**
     * Returns the uuid of the object.
     *
     * @return {String | null}
     */
    getUuid : function() {
      return this.__object.uuid;
    },

    /**
     * Returns the value of the attribute of the object.
     *
     * @param attributeName {String} Name of the desired attribute
     * @return {qx.data.Array | null}
     */
    getAttributeValue : function(attributeName) {
      qx.core.Assert.assertString(attributeName);

      if (qx.Class.hasProperty(this.__object.constructor, attributeName)) {
        return this.__object.get(attributeName);
      }
      return null;
    },

    /**
     * Returns the value of a property of the object.
     *
     * @param property {String} Name of the desired property
     * @return {Var | null} The value of the property; null if not found
     */
    getProperty : function(property) {
      qx.core.Assert.assertString(property);
      var result;
      if (this.__object.hasOwnProperty(property)) {
        result = this.__object[property];
      } else {
        result = this.__object.get(property);
      }
      return result === undefined ? null : result;
    },

    /**
     * Calls the given method on the object.
     *
     * @param methodName {String} Name of the method
     * @return {qx.Promise}
     */
    callMethod : function(methodName) {
      qx.core.Assert.assertString(methodName);
      return this.__object.callMethod.apply(this.__object, arguments);
    },

    /**
     * Checks if the method is available on the object.
     *
     * @param methodName {String} Name of the Method
     * @return {Boolean}
     */
    hasMethod : function(methodName) {
      return qx.lang.Type.isFunction(this.__object[methodName]);
    },

    /**
     * Find the current password method saved in the object.
     *
     * @return {String | null} The current password method
     */
    getPasswordMethod : function() {
      if (!this.__object) {
        return null;
      }

      var methods = this.__object.getPasswordMethod();
      if (methods.getLength() > 0) {
        return methods.getItem(0);
      }
      return null;
    },

    /**
     * Getter for the internal object.
     *
     * @return {gosa.proxy.Object}
     */
    getObject: function() {
      return this.__object;
    },

    /**
     * Move the object to a new DN
     *
     * @param newDn {String} new dn the object should be moved to
     * @return {qx.Promise}
     */
    move: function(newDn) {
      qx.core.Assert.assertString(newDn);
      return this.__object.move(newDn);
    },

    /**
     * Set the new password.
     *
     * @param method {String} The method to store the password (e.g. "MD5")
     * @param password {String} The password to save (not encoded)
     * @return {qx.Promise}
     */
    setPassword : function(method, password) {
      qx.core.Assert.assertString(method);
      qx.core.Assert.assertString(password);
      return this.__object.changePasswordMethod(method, password);<commit_msg>move recursively<commit_after>/*
 * This file is part of the GOsa project -  http://gosa-project.org
 *
 * Copyright:
 *    (C) 2010-2017 GONICUS GmbH, Germany, http://www.gonicus.de
 *
 * License:
 *    LGPL-2.1: http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * See the LICENSE file in the project's top-level directory for details.
 */

/**
 * Controller for actions that can be done on the object (e.g. change password).
 */
qx.Class.define("gosa.data.controller.Actions", {

  extend : qx.core.Object,
  implement: gosa.data.controller.IAction,

  /**
   * @param object {gosa.proxy.Object}
   */
  construct : function(object) {
    this.base(arguments);
    qx.core.Assert.assertInstance(object, gosa.proxy.Object);
    this.__object = object;
  },

  members : {
    __object : null,

    // overridden
    allowMethodSelection: function() {
      return true;
    },

    /**
     * Returns the dn of the object.
     *
     * @return {String | null}
     */
    getDn : function() {
      return this.__object.dn;
    },

    /**
     * Returns the uuid of the object.
     *
     * @return {String | null}
     */
    getUuid : function() {
      return this.__object.uuid;
    },

    /**
     * Returns the value of the attribute of the object.
     *
     * @param attributeName {String} Name of the desired attribute
     * @return {qx.data.Array | null}
     */
    getAttributeValue : function(attributeName) {
      qx.core.Assert.assertString(attributeName);

      if (qx.Class.hasProperty(this.__object.constructor, attributeName)) {
        return this.__object.get(attributeName);
      }
      return null;
    },

    /**
     * Returns the value of a property of the object.
     *
     * @param property {String} Name of the desired property
     * @return {Var | null} The value of the property; null if not found
     */
    getProperty : function(property) {
      qx.core.Assert.assertString(property);
      var result;
      if (this.__object.hasOwnProperty(property)) {
        result = this.__object[property];
      } else {
        result = this.__object.get(property);
      }
      return result === undefined ? null : result;
    },

    /**
     * Calls the given method on the object.
     *
     * @param methodName {String} Name of the method
     * @return {qx.Promise}
     */
    callMethod : function(methodName) {
      qx.core.Assert.assertString(methodName);
      return this.__object.callMethod.apply(this.__object, arguments);
    },

    /**
     * Checks if the method is available on the object.
     *
     * @param methodName {String} Name of the Method
     * @return {Boolean}
     */
    hasMethod : function(methodName) {
      return qx.lang.Type.isFunction(this.__object[methodName]);
    },

    /**
     * Find the current password method saved in the object.
     *
     * @return {String | null} The current password method
     */
    getPasswordMethod : function() {
      if (!this.__object) {
        return null;
      }

      var methods = this.__object.getPasswordMethod();
      if (methods.getLength() > 0) {
        return methods.getItem(0);
      }
      return null;
    },

    /**
     * Getter for the internal object.
     *
     * @return {gosa.proxy.Object}
     */
    getObject: function() {
      return this.__object;
    },

    /**
     * Move the object to a new DN
     *
     * @param newDn {String} new dn the object should be moved to
     * @return {qx.Promise}
     */
    move: function(newDn) {
      qx.core.Assert.assertString(newDn);
      return this.__object.move(newDn, true);
    },

    /**
     * Set the new password.
     *
     * @param method {String} The method to store the password (e.g. "MD5")
     * @param password {String} The password to save (not encoded)
     * @return {qx.Promise}
     */
    setPassword : function(method, password) {
      qx.core.Assert.assertString(method);
      qx.core.Assert.assertString(password);
      return this.__object.changePasswordMethod(method, password);
{'fraction_non_alphanumeric': 0.12373831775700934, 'fraction_numerical': 0.003738317757009346, 'mean_word_length': 2.2533441426834213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1220130', 'n_tokens_mistral': 2469, 'n_tokens_neox': 2418, 'n_words': 631}