コード例 #1
0
  @Override
  public BaseResult asyncCreateInstance(InstanceRequest request, User requestingUser) {
    logger.info(
        "Create instance for organization {} for subscription {}.",
        request.getOrganizationId(),
        request.getSubscriptionId());
    ServiceInstance instance = null;
    try {
      final InstanceDescription descr = getInstanceDescription(request, requestingUser);
      instance = createPersistentServiceInstance(request, descr);
      timerService.initTimers();

      List<LocalizedText> descriptions = descr.getDescription();

      String successMsg = null;
      if (descriptions != null) {
        for (LocalizedText description : descriptions) {
          if (description.getLocale().equals(getLocale(requestingUser))) {
            successMsg = description.getText();
          }
        }
      }

      return provResult.getSuccesfulResult(BaseResult.class, successMsg);

    } catch (Exception e) {
      logger.warn(e.getMessage(), e);
      return provResult.getErrorResult(
          BaseResult.class, e, getLocale(requestingUser), instance, null);
    }
  }
コード例 #2
0
  InstanceDescription getInstanceDescription(InstanceRequest request, User requestingUser)
      throws APPlatformException, BadResultException {
    final HashMap<String, String> parameters = createParameterMap(request.getParameterValue());
    String controllerId = parameters.get(InstanceParameter.CONTROLLER_ID);
    if (controllerId == null) {
      logger.warn("The technical service does not define a controller implementation");
      throw new BadResultException(Messages.get(request.getDefaultLocale(), "error_configuration"));
    }

    HashMap<String, String> controllerSettings =
        configService.getControllerConfigurationSettings(controllerId);
    final ProvisioningSettings settings =
        new ProvisioningSettings(parameters, controllerSettings, request.getDefaultLocale());
    settings.setOrganizationId(request.getOrganizationId());
    settings.setOrganizationName(request.getOrganizationName());
    settings.setSubscriptionId(request.getSubscriptionId());
    settings.setBesLoginUrl(request.getLoginUrl());

    ServiceInstance si = new ServiceInstance();
    si.setInstanceParameters(createParameters(si, parameters));
    si.setControllerId(controllerId);

    settings.setAuthentication(
        configService.getAuthenticationForBESTechnologyManager(controllerId, si, null));
    configService.copyCredentialsFromControllerSettings(settings, controllerSettings);
    settings.setRequestingUser(UserMapper.toServiceUser(requestingUser));

    final APPlatformController controller = APPlatformControllerFactory.getInstance(controllerId);

    final InstanceDescription descr = controller.createInstance(settings);

    // Check whether instanceId is filled and unique
    if (Strings.isEmpty(descr.getInstanceId())) {
      logger.error("Instance ID not specified by controller.");
      throw new BadResultException(
          Messages.get(request.getDefaultLocale(), "error_instanceid_empty"));
    }
    if (instanceDAO.exists(descr.getInstanceId())) {
      logger.error("Instance ID " + descr.getInstanceId() + " already used by another instance.");
      throw new BadResultException(
          Messages.get(
              request.getDefaultLocale(), "error_instanceid_exists", descr.getInstanceId()));
    }
    return descr;
  }
コード例 #3
0
 ServiceInstance createPersistentServiceInstance(
     InstanceRequest request, InstanceDescription descr) throws BadResultException {
   final HashMap<String, String> parameters = createParameterMap(request.getParameterValue());
   String controllerId = parameters.get(InstanceParameter.CONTROLLER_ID);
   ServiceInstance si = new ServiceInstance();
   si.setOrganizationId(request.getOrganizationId());
   si.setOrganizationName(request.getOrganizationName());
   si.setSubscriptionId(request.getSubscriptionId());
   si.setDefaultLocale(request.getDefaultLocale());
   si.setProvisioningStatus(ProvisioningStatus.WAITING_FOR_SYSTEM_CREATION);
   si.setControllerId(controllerId);
   si.setBesLoginURL(request.getLoginUrl());
   si.setRequestTime(System.currentTimeMillis());
   si.setInstanceParameters(createParameters(si, descr.getChangedParameters()));
   si.setServiceBaseURL(descr.getBaseUrl());
   si.setInstanceId(descr.getInstanceId());
   em.persist(si);
   return si;
 }