Package org.teiid.adminapi.impl

Examples of org.teiid.adminapi.impl.VDBMetaData


  }

  @Override
  protected VDBMetaData parse(VFSDeploymentUnit unit, VirtualFile file, VDBMetaData root) throws Exception {
    Unmarshaller un = VDBParserDeployer.getUnMarsheller();
    VDBMetaData vdb = (VDBMetaData)un.unmarshal(file.openStream());
   
    vdb.setUrl(unit.getRoot().toURL());
    vdb.setDynamic(true);
   
    LogManager.logDetail(LogConstants.CTX_RUNTIME,"VDB "+unit.getRoot().getName()+" has been parsed.")//$NON-NLS-1$ //$NON-NLS-2$
   
    // The loading of metadata from data sources will be done during the real deploy
    // as the resources are guaranteed to be available by that time.
View Full Code Here


      int latestVersion = 0;
        for (VDBKey key:this.vdbRepo.tailMap(new VDBKey(vdbName, 0)).keySet()) {
            if(!key.getName().equalsIgnoreCase(vdbName)) {
              break;
            }
          VDBMetaData vdb = this.vdbRepo.get(key).getVDB();
          switch (vdb.getConnectionType()) {
          case ANY:
            latestVersion = Math.max(vdb.getVersion(), latestVersion);
            break;
          case BY_VERSION:
                if (latestVersion == 0) {
                latestVersion = vdb.getVersion();
                }             
                break;
          }
        }
        if(latestVersion == 0) {
View Full Code Here

 
  @Override
  protected <U> U parse(VFSDeploymentUnit unit, Class<U> expectedType, VirtualFile file, Object root) throws Exception {
    if (expectedType.equals(VDBMetaData.class)) {
      Unmarshaller un = getUnMarsheller();
      VDBMetaData def = (VDBMetaData)un.unmarshal(file.openStream());
     
      return expectedType.cast(def);
    }
    else if (expectedType.equals(UDFMetaData.class)) {
      if (root == null) {
View Full Code Here

    return un;
  }
 
  @Override
  protected VDBMetaData mergeMetaData(VFSDeploymentUnit unit, Map<Class<?>, List<Object>> metadata) throws Exception {
    VDBMetaData vdb = getInstance(metadata, VDBMetaData.class);
    UDFMetaData udf = getInstance(metadata, UDFMetaData.class);
    IndexMetadataFactory imf = getInstance(metadata, IndexMetadataFactory.class);
   
    if (vdb == null) {
      LogManager.logError(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("invlaid_vdb_file",unit.getRoot().getName())); //$NON-NLS-1$
      return null;
    }
   
    vdb.setUrl(unit.getRoot().toURL());   
   
    // build the metadata store
    if (imf != null) {
      imf.addEntriesPlusVisibilities(unit.getRoot(), vdb);
      unit.addAttachment(IndexMetadataFactory.class, imf);
             
      // add the cached store.
      File cacheFile = VDBDeployer.buildCachedVDBFileName(this.serializer, unit, vdb);
      // check to see if the vdb has been modified when server is down; if it is then clear the old files
      if (this.serializer.isStale(cacheFile, unit.getRoot().getLastModified())) {
        this.serializer.removeAttachments(unit);
        LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB", unit.getRoot().getName(), "old cached metadata has been removed"); //$NON-NLS-1$ //$NON-NLS-2$       
      }
      MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile, MetadataStoreGroup.class);
      if (stores == null) {       
        // start to build the new metadata
        stores = new MetadataStoreGroup();
        stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
      }
      else {
        LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB", unit.getRoot().getName(), "was loaded from cached metadata"); //$NON-NLS-1$ //$NON-NLS-2$
      }
      unit.addAttachment(MetadataStoreGroup.class, stores);       
    }
   
    if (udf != null) {
      // load the UDF
      for(Model model:vdb.getModels()) {
        if (model.getModelType().equals(Model.Type.FUNCTION)) {
          String path = ((ModelMetaData)model).getPath();
          if (path == null) {
            throw new DeploymentException(RuntimePlugin.Util.getString("invalid_udf_file", model.getName())); //$NON-NLS-1$
          }
View Full Code Here

  public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
    throws DeploymentException {
           
    ManagedObject vdbMO = managedObjects.get(VDBMetaData.class.getName());
    if (vdbMO != null) {
      VDBMetaData vdb = (VDBMetaData) vdbMO.getAttachment();
      for (Model m : vdb.getModels()) {
        ManagedObject mo = this.mof.initManagedObject(m, ModelMetaData.class, m.getName(),m.getName());
        if (mo == null) {
          throw new DeploymentException("could not create managed object"); //$NON-NLS-1$
        }
        managedObjects.put(mo.getName(), mo);
      }
     
      for (Translator t: vdb.getOverrideTranslators()) {
        ManagedObject mo = this.mof.initManagedObject(t, VDBTranslatorMetaData.class, t.getName(), t.getName());
        if (mo == null) {
          throw new DeploymentException("could not create managed object"); //$NON-NLS-1$
        }
        managedObjects.put(mo.getName(), mo);       
View Full Code Here

 
  public void addChild(CompositeVDB child) {
    if (this.children == null) {
      this.children = new LinkedHashMap<VDBKey, CompositeVDB>();
    }
    VDBMetaData childVDB = child.getVDB();
    this.children.put(new VDBKey(childVDB.getName(), childVDB.getVersion()), child);
    this.mergedVDB = null;
  }
View Full Code Here

    }
    return this.mergedVDB;
  }
 
  private VDBMetaData buildVDB() {
    VDBMetaData newMergedVDB = new VDBMetaData();
    newMergedVDB.setName(this.vdb.getName());
    newMergedVDB.setVersion(this.vdb.getVersion());
    newMergedVDB.setModels(this.vdb.getModels());
    newMergedVDB.setDataPolicies(this.vdb.getDataPolicies());
    newMergedVDB.setDescription(this.vdb.getDescription());
    newMergedVDB.setStatus(this.vdb.getStatus());
    newMergedVDB.setJAXBProperties(this.vdb.getJAXBProperties());
    newMergedVDB.setConnectionType(this.vdb.getConnectionType());
    ConnectorManagerRepository mergedRepo = new ConnectorManagerRepository();
    mergedRepo.getConnectorManagers().putAll(this.cmr.getConnectorManagers());
    for (CompositeVDB child:this.children.values()) {
     
      // add models
      for (Model m:child.getVDB().getModels()) {
        newMergedVDB.addModel((ModelMetaData)m);
      }
     
      for (DataPolicy p:child.getVDB().getDataPolicies()) {
        newMergedVDB.addDataPolicy((DataPolicyMetadata)p);
      }
      mergedRepo.getConnectorManagers().putAll(child.cmr.getConnectorManagers());
    }
    newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
    return newMergedVDB;
  }
View Full Code Here

        if (adminConnection) {
          domains = this.adminSecurityDomains;
        }
       
        // Validate VDB and version if logging on to server product...
        VDBMetaData vdb = null;
        String vdbName = properties.getProperty(TeiidURL.JDBC.VDB_NAME);
        if (vdbName != null) {
          String vdbVersion = properties.getProperty(TeiidURL.JDBC.VDB_VERSION);
          vdb = getActiveVDB(vdbName, vdbVersion);
        }

        if (sessionMaxLimit > 0 && getActiveSessionsCount() >= sessionMaxLimit) {
            throw new SessionServiceException(RuntimePlugin.Util.getString("SessionServiceImpl.reached_max_sessions", new Object[] {new Long(sessionMaxLimit)})); //$NON-NLS-1$
        }
       
        if (!domains.isEmpty() && authenticate) {
          // Authenticate user...
          // if not authenticated, this method throws exception
          boolean onlyAllowPassthrough = Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, "false")); //$NON-NLS-1$
          TeiidLoginContext membership = authenticate(userName, credentials, applicationName, domains, this.securityHelper, onlyAllowPassthrough);
          loginContext = membership.getLoginContext();
          userName = membership.getUserName();
          securityDomain = membership.getSecurityDomain();
          securityContext = membership.getSecurityContext();
        }       
       
        long creationTime = System.currentTimeMillis();

        // Return a new session info object
        SessionMetadata newSession = new SessionMetadata();
        newSession.setSessionToken(new SessionToken(userName));
        newSession.setSessionId(newSession.getSessionToken().getSessionID());
        newSession.setUserName(userName);
        newSession.setCreatedTime(creationTime);
        newSession.setApplicationName(applicationName);
        newSession.setClientHostName(properties.getProperty(TeiidURL.CONNECTION.CLIENT_HOSTNAME));
        newSession.setIPAddress(properties.getProperty(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS));
        newSession.setSecurityDomain(securityDomain);
        if (vdb != null) {
          newSession.setVDBName(vdb.getName());
          newSession.setVDBVersion(vdb.getVersion());
        }
       
        // these are local no need for monitoring.
        newSession.setLoginContext(loginContext);
        newSession.setSecurityContext(securityContext);
View Full Code Here

        this.sessionCache.put(newSession.getSessionId(), newSession);
        return newSession;
  }

  VDBMetaData getActiveVDB(String vdbName, String vdbVersion) throws SessionServiceException {
    VDBMetaData vdb = null;
   
    // handle the situation when the version is part of the vdb name.
   
    int firstIndex = vdbName.indexOf('.');
    int lastIndex = vdbName.lastIndexOf('.');
    if (firstIndex != -1) {
      if (firstIndex != lastIndex || vdbVersion != null) {
        throw new SessionServiceException(RuntimePlugin.Util.getString("ambigious_name", vdbName, vdbVersion)); //$NON-NLS-1$
      }
      vdbVersion = vdbName.substring(firstIndex+1);
      vdbName = vdbName.substring(0, firstIndex);
    }
   
    try {
      if (vdbVersion == null) {
        vdbVersion = "latest"; //$NON-NLS-1$
        vdb = this.vdbRepository.getVDB(vdbName);
      }
      else {
        vdb = this.vdbRepository.getVDB(vdbName, Integer.parseInt(vdbVersion));
      }        
    } catch (NumberFormatException e) {
      throw new SessionServiceException(e, RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._3", vdbVersion)); //$NON-NLS-1$
    }
   
    if (vdb == null) {
      throw new SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._1", vdbName, vdbVersion)); //$NON-NLS-1$
    }
   
    if (vdb.getStatus() != VDB.Status.ACTIVE) {
      throw new SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, vdbVersion)); //$NON-NLS-1$
    }
    if (vdb.getConnectionType() == ConnectionType.NONE) {
      throw new SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._4", vdbName, vdbVersion)); //$NON-NLS-1$
    }
    return vdb;
  }
View Full Code Here

  }
 
  @Override
  public void updateMatViewRow(String vdbName, int vdbVersion, String schema,
      String viewName, List<?> tuple, boolean delete) {
    VDBMetaData vdb = this.vdbRepository.getVDB(vdbName, vdbVersion);
    if (vdb == null) {
      return;
    }
    TempTableStore globalStore = vdb.getAttachment(TempTableStore.class);
    if (globalStore == null) {
      return;
    }
    try {
      this.dqpCore.getDataTierManager().updateMatViewRow(globalStore, RelationalPlanner.MAT_PREFIX + (schema + '.' + viewName).toUpperCase(), tuple, delete);
View Full Code Here

TOP

Related Classes of org.teiid.adminapi.impl.VDBMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.