コード例 #1
0
  /** @return ArrayList of ListItem */
  private ArrayList<ListItem> CreateServiceList() {

    ArrayList<ListItem> itemsList = null;

    try {
      /*
       * Get the list of ProcessAgent names
       */
      ProcessAgents processAgents =
          this.serviceBrokerSession.getServiceManagement().getProcessAgents();
      String[] stringArray = processAgents.GetNamesAll();
      if (stringArray != null) {
        itemsList = new ArrayList<>();
        itemsList.add(new ListItem(LabConsts.STR_MakeSelection, LabConsts.STR_MakeSelection));
        for (String string : stringArray) {
          ProcessAgentInfo processAgentInfo = processAgents.RetrieveByName(string);
          if (processAgentInfo.isSelf() == false) {
            String label =
                String.format(
                    STR_ServiceNameType_arg2,
                    processAgentInfo.getAgentType().name(),
                    processAgentInfo.getAgentName());
            itemsList.add(new ListItem(label, processAgentInfo.getAgentName()));
          }
        }
      }
    } catch (Exception ex) {
      Logfile.WriteError(ex.toString());
    }

    return itemsList;
  }
コード例 #2
0
  private void PopulateServiceInfo() {
    final String methodName = "PopulateServiceInfo";
    Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

    try {
      /*
       * Retrieve the ProcessAgentInfo for the specified service
       */
      ProcessAgents processAgents =
          this.serviceBrokerSession.getServiceManagement().getProcessAgents();
      ProcessAgentInfo processAgentInfo = processAgents.RetrieveByName(this.hsomService);
      if (processAgentInfo == null) {
        throw new Exception(String.format(STRERR_RetrieveFailed_arg, this.hsomService));
      }

      /*
       * Update information
       */
      this.hitServiceName = processAgentInfo.getAgentName();
      this.hitServiceGuid = processAgentInfo.getAgentGuid();
      this.hitServiceUrl = processAgentInfo.getServiceUrl();
      this.hitClientUrl = processAgentInfo.getClientUrl();
      this.hitServiceType = processAgentInfo.getAgentType().toString();

      SystemSupportInfo systemSupportInfo = processAgentInfo.getSystemSupportInfo();
      this.htaDescription = systemSupportInfo.getDescription();
      this.hitLocation = systemSupportInfo.getLocation();
      this.hitInfoUrl = systemSupportInfo.getInfoUrl();
      this.hitContactName = systemSupportInfo.getContactName();
      this.hitContactEmail = systemSupportInfo.getContactEmail();

      /*
       * Update controls
       */
      this.registered = true;
    } catch (Exception ex) {
      ShowMessageError(ex.getMessage());
      Logfile.WriteError(ex.toString());
    }

    Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
  }
コード例 #3
0
  /** @return String */
  public String actionRegister() {
    final String methodName = "actionRegister";
    Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

    /*
     * Parse the web page information
     */
    ProcessAgentInfo processAgentInfo = this.Parse(null);
    if (processAgentInfo != null) {
      try {
        /*
         * Get self information
         */
        ProcessAgents processAgents =
            this.serviceBrokerSession.getServiceManagement().getProcessAgents();
        ProcessAgent selfProcessAgent = processAgents.RetrieveSelf();

        /*
         * Create coupons for the ProcessAgent
         */
        TicketIssuer ticketIssuer =
            this.serviceBrokerSession.getServiceManagement().getTicketIssuer();
        Coupon inCoupon = ticketIssuer.CreateCoupon();
        Coupon outCoupon = ticketIssuer.CreateCoupon();

        ProcessAgentAPI processAgentAPI = null;

        try {
          /*
           * Pass on to ProcessAgent for processing
           */
          processAgentAPI = new ProcessAgentAPI(processAgentInfo.getServiceUrl());
          processAgentAPI.setAuthHeaderInitPasskey(processAgentInfo.getOutCoupon().getPasskey());
          ProcessAgent processAgent =
              processAgentAPI.InstallDomainCredentials(selfProcessAgent, inCoupon, outCoupon);
          if (processAgent == null) {
            throw new RuntimeException("InstallDomainCredentials() returned null");
          }

          /*
           * Create the ProcessAgentInfo for the ProcessAgent
           */
          processAgentInfo.setProcessAgent(processAgent);
          processAgentInfo.setInCoupon(outCoupon);
          processAgentInfo.setOutCoupon(inCoupon);
          processAgentInfo.setIssuerGuid(ticketIssuer.getIssuerGuid());

          /*
           * Create the ProcessAgentInfo
           */
          if (processAgents.Create(processAgentInfo) < 0) {
            throw new RuntimeException(
                String.format(STRERR_SaveFailed_arg, processAgentInfo.getAgentName()));
          }

        } catch (Exception ex) {
          /*
           * Delete the issued coupons
           */
          if (outCoupon != null) {
            ticketIssuer.DeleteCoupon(outCoupon.getCouponId());
          }
          if (inCoupon != null) {
            ticketIssuer.DeleteCoupon(inCoupon.getCouponId());
          }

          throw ex;
        }

        /*
         * Register SystemSupportInfo
         */
        SystemSupportInfo systemSupportInfo = processAgents.RetrieveSystemSupportInfoSelf();
        if (systemSupportInfo != null) {
          SystemSupportPayload systemSupportPayload = new SystemSupportPayload(systemSupportInfo);
          String serviceProviderInfo = systemSupportPayload.ToXmlString();
          ServiceDescription[] serviceDescriptions =
              new ServiceDescription[] {
                new ServiceDescription(
                    serviceProviderInfo, null, ServiceDescription.STR_RequestSystemSupport)
              };
          processAgentAPI.setAuthHeaderAgentGuid(selfProcessAgent.getAgentGuid());
          processAgentAPI.setAuthHeaderCoupon(inCoupon);
          processAgentAPI.Register(hitServiceGuid, serviceDescriptions);
        }

        /*
         * Refresh the services list and repopulate ProcessAgentInfo information
         */
        this.serviceList = this.CreateServiceList();
        this.hsomService = processAgentInfo.getAgentName();
        this.PopulateServiceInfo();

        /*
         * Information saved successfully
         */
        this.registered = true;
        this.ShowMessageInfo(
            String.format(STR_RegisterSuccessful_arg, processAgentInfo.getAgentName()));

      } catch (Exception ex) {
        String message = ex.getMessage();
        ShowMessageError(message != null ? message : ex.toString());
        Logfile.WriteError(ex.toString());
      }
    }

    Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);

    /* Navigate to the current page */
    return null;
  }