/**
   * Constructor used for testing purposes only.
   *
   * @param admin the associated Teiid Admin API (never <code>null</code>)
   * @param teiidServer the server this admin belongs to (never <code>null</code>)
   * @throws Exception if there is a problem connecting the server
   */
  ExecutionAdmin(Admin admin, ITeiidServer teiidServer) throws Exception {
    ArgCheck.isNotNull(admin, "admin"); // $NON-NLS-1$
    ArgCheck.isNotNull(teiidServer, "server"); // $NON-NLS-1$

    this.admin = admin;
    this.teiidServer = teiidServer;
    this.eventManager = teiidServer.getEventManager();
    this.connectionMatcher = new ModelConnectionMatcher();

    init();
  }
 /**
  * @param translator the translator whose property is being changed (never <code>null</code>)
  * @param propName the name of the property being changed (never <code>null</code> or empty)
  * @param value the new value
  * @throws Exception if there is a problem setting the property
  * @since 7.0
  */
 public void setPropertyValue(ITeiidTranslator translator, String propName, String value)
     throws Exception {
   ArgCheck.isNotNull(translator, "translator"); // $NON-NLS-1$
   ArgCheck.isNotEmpty(propName, "propName"); // $NON-NLS-1$
   ArgCheck.isNotEmpty(value, "value"); // $NON-NLS-1$
   internalSetPropertyValue(translator, propName, value, true);
 }
  /**
   * @param translator the translator whose properties are being changed (never <code>null</code>)
   * @param changedProperties a collection of properties that have changed (never <code>null</code>
   *     or empty)
   * @throws Exception if there is a problem changing the properties
   * @since 7.0
   */
  public void setProperties(ITeiidTranslator translator, Properties changedProperties)
      throws Exception {
    ArgCheck.isNotNull(translator, "translator"); // $NON-NLS-1$
    ArgCheck.isNotNull(changedProperties, "changedProperties"); // $NON-NLS-1$
    ArgCheck.isNotEmpty(changedProperties.entrySet(), "changedProperties"); // $NON-NLS-1$

    if (changedProperties.size() == 1) {
      String name = changedProperties.stringPropertyNames().iterator().next();
      setPropertyValue(translator, name, changedProperties.getProperty(name));
    } else {

      for (String name : changedProperties.stringPropertyNames()) {
        internalSetPropertyValue(translator, name, changedProperties.getProperty(name), false);
      }
      // this.eventManager.notifyListeners(ExecutionConfigurationEvent.createUpdateConnectorEvent(translator));
    }
  }
  /**
   * Default Constructor
   *
   * @param teiidServer the server this admin belongs to (never <code>null</code>)
   * @throws Exception if there is a problem connecting the server
   */
  public ExecutionAdmin(ITeiidServer teiidServer) throws Exception {
    ArgCheck.isNotNull(teiidServer, "server"); // $NON-NLS-1$

    ITeiidAdminInfo teiidAdminInfo = teiidServer.getTeiidAdminInfo();
    char[] passwordArray = null;
    if (teiidAdminInfo.getPassword() != null) {
      passwordArray = teiidAdminInfo.getPassword().toCharArray();
    }

    this.admin =
        AdminFactory.getInstance()
            .createAdmin(teiidAdminInfo.getUsername(), passwordArray, teiidAdminInfo.getUrl());

    this.teiidServer = teiidServer;
    this.eventManager = teiidServer.getEventManager();
    this.connectionMatcher = new ModelConnectionMatcher();

    init();
  }
  @Override
  public void deployVdb(IFile vdbFile) throws Exception {
    ArgCheck.isNotNull(vdbFile, "vdbFile"); // $NON-NLS-1$

    String vdbName = vdbFile.getFullPath().lastSegment();
    String vdbNameNoExt = vdbFile.getFullPath().removeFileExtension().lastSegment();

    admin.deployVDB(vdbName, vdbFile.getContents());

    // Refresh VDBs list
    refreshVDBs();

    // TODO should get version from vdbFile
    VDB vdb = admin.getVDB(vdbNameNoExt, 1);

    // If the VDB is still loading, refresh again and potentially start refresh job
    if (!vdb.getStatus().equals(VDB.Status.ACTIVE) && vdb.getValidityErrors().isEmpty()) {
      // Give a 0.5 sec pause for the VDB to finish loading metadata.
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
      }
      // Refresh again to update vdb states
      refreshVDBs();
      vdb = admin.getVDB(vdbNameNoExt, 1);
      // Determine if still loading, if so start refresh job.  User will get dialog that the
      // vdb is still loading - and try again in a few seconds
      if (!vdb.getStatus().equals(VDB.Status.ACTIVE) && vdb.getValidityErrors().isEmpty()) {
        final Job refreshVDBsJob = new RefreshVDBsJob(vdbNameNoExt);
        refreshVDBsJob.schedule();
      }
    }

    this.eventManager.notifyListeners(
        ExecutionConfigurationEvent.createDeployVDBEvent(vdb.getName()));
  }
Esempio n. 6
0
 public void addSourceNode(MappingSourceNodeImpl elem) {
   ArgCheck.isNotNull(elem);
   setRoot(elem);
 }
Esempio n. 7
0
 public void addChildElement(MappingElementImpl elem) {
   ArgCheck.isNotNull(elem);
   fixCardinality(elem);
   setRoot(elem);
 }
Esempio n. 8
0
  public <T> Dispatch<T> createDispatch(String binding, String endpoint, Class<T> type, Mode mode) {
    ArgCheck.isNotNull(binding);
    if (endpoint != null) {
      try {
        new URL(endpoint);
        // valid url, just use the endpoint
      } catch (MalformedURLException e) {
        // otherwise it should be a relative value
        // but we should still preserve the base path and query string
        String defaultEndpoint = this.mcf.getEndPoint();
        String defaultQueryString = null;
        String defaultFragment = null;
        if (defaultEndpoint == null) {
          throw new WebServiceException(
              WSManagedConnectionFactory.UTIL.getString("null_default_endpoint")); // $NON-NLS-1$
        }
        String[] parts = defaultEndpoint.split("\\?", 2); // $NON-NLS-1$
        defaultEndpoint = parts[0];
        if (parts.length > 1) {
          defaultQueryString = parts[1];
          parts = defaultQueryString.split("#"); // $NON-NLS-1$
          defaultQueryString = parts[0];
          if (parts.length > 1) {
            defaultFragment = parts[1];
          }
        }
        if (endpoint.startsWith("?") || endpoint.startsWith("/")) { // $NON-NLS-1$ //$NON-NLS-2$
          endpoint = defaultEndpoint + endpoint;
        } else {
          endpoint = defaultEndpoint + "/" + endpoint; // $NON-NLS-1$
        }
        if ((defaultQueryString != null) && (defaultQueryString.trim().length() > 0)) {
          endpoint = WSConnection.Util.appendQueryString(endpoint, defaultQueryString);
        }
        if ((defaultFragment != null) && (endpoint.indexOf('#') < 0)) {
          endpoint = endpoint + '#' + defaultFragment;
        }
      }
    } else {
      endpoint = this.mcf.getEndPoint();
      if (endpoint == null) {
        throw new WebServiceException(
            WSManagedConnectionFactory.UTIL.getString("null_endpoint")); // $NON-NLS-1$
      }
    }
    Dispatch<T> dispatch = null;
    if (HTTPBinding.HTTP_BINDING.equals(binding) && (type == DataSource.class)) {
      Bus bus = BusFactory.getThreadDefaultBus();
      BusFactory.setThreadDefaultBus(this.mcf.getBus());
      try {
        dispatch =
            (Dispatch<T>)
                new HttpDispatch(endpoint, this.mcf.getConfigFile(), this.mcf.getConfigName());
      } finally {
        BusFactory.setThreadDefaultBus(bus);
      }
    } else {
      // TODO: cache service/port/dispatch instances?
      Bus bus = BusFactory.getThreadDefaultBus();
      BusFactory.setThreadDefaultBus(this.mcf.getBus());
      Service svc;
      try {
        svc = Service.create(this.mcf.getServiceQName());
      } finally {
        BusFactory.setThreadDefaultBus(bus);
      }
      if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
        LogManager.logDetail(
            LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint); // $NON-NLS-1$
      }
      svc.addPort(this.mcf.getPortQName(), binding, endpoint);

      dispatch = svc.createDispatch(this.mcf.getPortQName(), type, mode);
      configureWSSecurity(dispatch);
    }
    setDispatchProperties(dispatch, binding);
    return dispatch;
  }