Project

General

Profile

« Previous | Next » 

Revision 1406

Added by Jing Tao almost 22 years ago

Implement clone method.

View differences:

src/edu/ucsb/nceas/metacat/AccessRule.java
82 82
  /**
83 83
   * Copy a AccessRule to another accessrule object
84 84
   */
85
  public AccessRule copyAccessRule(AccessRule rule)
85
  public Object clone()
86 86
  {
87 87
    // create a new object
88 88
    AccessRule newRule = new AccessRule();
89 89
    // set permissiontype
90
    newRule.setPermissionType(rule.getPermissionType());
90
    MetaCatUtil.debugMessage("copy permission type: "+
91
                              this.getPermissionType(), 35);
92
    newRule.setPermissionType(this.getPermissionType());
91 93
    // set permission
92
    newRule.setPermission(rule.getPermission());
94
    MetaCatUtil.debugMessage("copy permission: "+
95
                              this.getPermission(), 35);
96
    newRule.setPermission(this.getPermission());
93 97
    // walk through all the principals
94
    Vector principalVector = rule.getPrincipal();
98
    Vector principalVector = this.getPrincipal();
95 99
    for (int i=0; i<principalVector.size(); i++)
96 100
    {
97 101
      String name = (String)principalVector.elementAt(i);
102
      MetaCatUtil.debugMessage("copy principle: "+ name, 35);
98 103
      // Add this name to newrules
99 104
      newRule.addPrincipal(name);
100 105
    }
101 106
    return newRule;
102 107
  }
103 108
  
104
  public Object clone()
105
  {
106
    return this.clone();
107
  }
109
 
108 110
}//AccessRule
src/edu/ucsb/nceas/metacat/AccessSection.java
80 80
      return this.accessRules;
81 81
    }
82 82
    
83
    /** Method to copy a accesssection object to a new one */
83 84
    public Object clone()
84 85
    {
85
      return this.clone();
86
      //create a new AccessSection object
87
      AccessSection newAccessSection = new AccessSection();
88
      // set parameters
89
      MetaCatUtil.debugMessage("Copy Access Section Id: " +
90
                                this.getAccessSectionId(), 35);
91
      newAccessSection.setAccessSectionId(this.getAccessSectionId());
92
      MetaCatUtil.debugMessage("Copy permission order: " +
93
                                this.getPermissionOrder(), 35);
94
      newAccessSection.setPermissionOrder(this.getPermissionOrder());
95
      Vector accessRuleVector = this.getAccessRules();
96
      // go through access rule vector
97
      for (int i=0; i< accessRuleVector.size(); i++)
98
      {
99
        AccessRule access = (AccessRule)accessRuleVector.elementAt(i);
100
        newAccessSection.addAccessRule(access);
101
      }
102
      
103
      return newAccessSection;
86 104
    }
87 105
 
88 106
}

Also available in: Unified diff