コード例 #1
0
ファイル: KickstartData.java プロジェクト: shastah/spacewalk
  protected void updateCloneDetails(KickstartData cloned, User user, String newLabel) {

    cloned.setLabel(newLabel);
    cloned.setActive(this.isActive());
    cloned.setPostLog(this.getPostLog());
    cloned.setPreLog(this.getPreLog());
    cloned.setKsCfg(this.getKsCfg());
    cloned.setComments(this.getComments());
    cloned.setNonChrootPost(this.getNonChrootPost());
    cloned.setVerboseUp2date(this.getVerboseUp2date());
    cloned.setOrg(this.getOrg());
    cloned.setChildChannels(new HashSet<Channel>(this.getChildChannels()));
    cloned.setPartitionData(getPartitionData());
    copyKickstartCommands(getCommands(), cloned);

    // Gotta remember to create a new HashSet with
    // the other objects.  Otherwise hibernate will
    // complain that you are using the same collection
    // in two objects.
    if (this.getCryptoKeys() != null) {
      cloned.setCryptoKeys(new HashSet<CryptoKey>(this.getCryptoKeys()));
    }

    // NOTE: Make sure we *DONT* clone isOrgDefault
    cloned.setIsOrgDefault(Boolean.FALSE);
    cloned.setKernelParams(this.getKernelParams());
    if (this.getKickstartDefaults() != null) {
      cloned.setKickstartDefaults(this.getKickstartDefaults().deepCopy(cloned));
    }
    cloned.setOrg(this.getOrg());
    if (this.getKsPackages() != null) {
      for (KickstartPackage kp : this.getKsPackages()) {
        cloned.getKsPackages().add(kp.deepCopy(cloned));
      }
    }

    if (this.getPreserveFileLists() != null) {
      cloned.setPreserveFileLists(new HashSet<FileList>(this.getPreserveFileLists()));
    }

    if (this.getScripts() != null) {
      Iterator<KickstartScript> i = this.getScripts().iterator();
      while (i.hasNext()) {
        KickstartScript kss = i.next();
        KickstartScript ksscloned = kss.deepCopy(cloned);
        cloned.getScripts().add(ksscloned);
      }
    }

    // copy all of the non-session related kickstarts
    Set<Token> newTokens = new HashSet<Token>();
    if (this.getDefaultRegTokens() != null) {
      for (Token tok : this.getDefaultRegTokens()) {
        ActivationKey key = ActivationKeyFactory.lookupByToken(tok);
        if (key == null || key.getKickstartSession() == null) {
          newTokens.add(tok);
        }
      }
    }
    cloned.setDefaultRegTokens(newTokens);
    cloned.setNoBase(this.getNoBase());
    cloned.setIgnoreMissing(this.getIgnoreMissing());
  }