コード例 #1
0
 public void testLookupByServer() throws Exception {
   ActivationKey k = createTestActivationKey(user);
   Server s = k.getServer();
   createTestActivationKey(user, s);
   createTestActivationKey(user, s);
   createTestActivationKey(user, s);
   List keys = ActivationKeyFactory.lookupByServer(s);
   assertTrue(keys.size() == 4);
 }
コード例 #2
0
  private void storeActivationKeyInfo() {
    // If the target system exists already, remove any existing activation keys
    // it might have associated with it.

    log.debug("** ActivationType : Existing profile..");
    if (getTargetServer() != null) {
      List oldkeys = ActivationKeyFactory.lookupByServer(getTargetServer());

      if (oldkeys != null) {
        log.debug("** Removing old tokens");
        Iterator i = oldkeys.iterator();
        while (i.hasNext()) {
          log.debug("removing key.");
          ActivationKey oldkey = (ActivationKey) i.next();
          ActivationKeyFactory.removeKey(oldkey);
        }
      }
    }

    String note = null;
    if (getTargetServer() != null) {
      note =
          LocalizationService.getInstance()
              .getMessage("kickstart.session.newtokennote", getTargetServer().getName());
    } else {
      // TODO: translate this
      note = "Automatically generated activation key.";
    }

    RegistrationType regType = getKsdata().getRegistrationType(user);

    if (regType.equals(RegistrationType.REACTIVATION)) {
      // Create a new activation key for the target system.
      boolean reactivation = RegistrationType.REACTIVATION.equals(regType);
      createKickstartActivationKey(
          this.user,
          this.ksdata,
          reactivation ? getTargetServer() : null,
          this.kickstartSession,
          1L,
          note);
    }
    this.createdProfile = processProfileType(this.profileType);
    log.debug("** profile created: " + createdProfile);
  }