Search in sources :

Example 1 with AdminProcessingException

use of org.teiid.adminapi.AdminProcessingException in project teiid by teiid.

the class VDBService method save.

private void save() throws AdminProcessingException {
    try {
        ObjectSerializer os = getSerializer();
        VDBMetadataParser.marshell(this.vdb, os.getVdbXmlOutputStream(this.vdb));
    } catch (IOException e) {
        throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50048, e);
    } catch (XMLStreamException e) {
        throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50049, e);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) AdminProcessingException(org.teiid.adminapi.AdminProcessingException)

Example 2 with AdminProcessingException

use of org.teiid.adminapi.AdminProcessingException in project teiid by teiid.

the class RuntimeVDB method addAnyAuthenticated.

public void addAnyAuthenticated(String policyName) throws AdminProcessingException {
    synchronized (this.vdb) {
        DataPolicyMetadata policy = getPolicy(policyName);
        boolean previous = policy.isAnyAuthenticated();
        policy.setAnyAuthenticated(true);
        try {
            this.listener.dataRoleChanged(policyName);
        } catch (AdminProcessingException e) {
            policy.setAnyAuthenticated(previous);
            throw e;
        }
    }
}
Also used : DataPolicyMetadata(org.teiid.adminapi.impl.DataPolicyMetadata) AdminProcessingException(org.teiid.adminapi.AdminProcessingException)

Example 3 with AdminProcessingException

use of org.teiid.adminapi.AdminProcessingException in project teiid by teiid.

the class RuntimeVDB method removeSource.

public ReplaceResult removeSource(String modelName, String sourceName) throws AdminProcessingException {
    synchronized (this.vdb) {
        ModelMetaData model = this.vdb.getModel(modelName);
        if (model == null) {
            throw new AdminProcessingException(RuntimePlugin.Event.TEIID40090, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40090, modelName, this.vdb.getName(), this.vdb.getVersion()));
        }
        if (!model.isSupportsMultiSourceBindings()) {
            throw new AdminProcessingException(RuntimePlugin.Event.TEIID40108, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40108, modelName, this.vdb.getName(), this.vdb.getVersion()));
        }
        if (model.getSources().size() == 1) {
            throw new AdminProcessingException(RuntimePlugin.Event.TEIID40109, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40109, modelName, this.vdb.getName(), this.vdb.getVersion()));
        }
        SourceMappingMetadata source = model.getSources().remove(sourceName);
        if (source == null) {
            throw new AdminProcessingException(RuntimePlugin.Event.TEIID40091, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40091, sourceName, modelName, this.vdb.getName(), this.vdb.getVersion()));
        }
        if (model.getSources().size() == 1) {
            // we default to multi-source with multiple sources, so now we need to explicitly set to true
            model.setSupportsMultiSourceBindings(true);
        }
        String previousDsName = source.getConnectionJndiName();
        boolean success = false;
        try {
            this.listener.dataSourceChanged(modelName, sourceName, null, null);
            ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
            // detect if the ConnectorManager is still used
            boolean exists = false;
            for (ModelMetaData m : this.vdb.getModelMetaDatas().values()) {
                if (m == model) {
                    continue;
                }
                if (m.getSourceMapping(sourceName) != null) {
                    exists = true;
                    break;
                }
            }
            if (!exists) {
                cmr.removeConnectorManager(sourceName);
            }
            ReplaceResult rr = new ReplaceResult();
            if (!dsExists(previousDsName, cmr)) {
                rr.removedDs = previousDsName;
            }
            success = true;
            return rr;
        } finally {
            if (!success) {
                // TODO: this means that the order has changed
                model.addSourceMapping(source);
            }
        }
    }
}
Also used : SourceMappingMetadata(org.teiid.adminapi.impl.SourceMappingMetadata) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) AdminProcessingException(org.teiid.adminapi.AdminProcessingException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 4 with AdminProcessingException

use of org.teiid.adminapi.AdminProcessingException in project teiid by teiid.

the class EngineStatistics method executeOperation.

@Override
protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode operation) throws OperationFailedException {
    if (!operation.hasDefined(OperationsConstants.DATA_ROLE.getName())) {
        throw new OperationFailedException(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE.getName() + MISSING));
    }
    if (!operation.hasDefined(OperationsConstants.MAPPED_ROLE.getName())) {
        throw new OperationFailedException(IntegrationPlugin.Util.getString(OperationsConstants.MAPPED_ROLE.getName() + MISSING));
    }
    String policyName = operation.get(OperationsConstants.DATA_ROLE.getName()).asString();
    String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE.getName()).asString();
    try {
        vdb.addDataRole(policyName, mappedRole);
    } catch (AdminProcessingException e) {
        throw new OperationFailedException(e);
    }
}
Also used : OperationFailedException(org.jboss.as.controller.OperationFailedException) AdminProcessingException(org.teiid.adminapi.AdminProcessingException)

Example 5 with AdminProcessingException

use of org.teiid.adminapi.AdminProcessingException in project teiid by teiid.

the class RuntimeVDB method updateSource.

public ReplaceResult updateSource(String sourceName, String translatorName, String dsName) throws AdminProcessingException {
    synchronized (this.vdb) {
        ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
        ConnectorManager cr = cmr.getConnectorManager(sourceName);
        if (cr == null) {
            throw new AdminProcessingException(RuntimePlugin.Event.TEIID40091, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40091, sourceName, this.vdb.getName(), this.vdb.getVersion()));
        }
        String previousTranslatorName = cr.getTranslatorName();
        String previousDsName = cr.getConnectionName();
        // modify all source elements in all models
        for (ModelMetaData m : this.vdb.getModelMetaDatas().values()) {
            SourceMappingMetadata mapping = m.getSourceMapping(sourceName);
            if (mapping != null) {
                mapping.setTranslatorName(translatorName);
                mapping.setConnectionJndiName(dsName);
            }
        }
        boolean success = false;
        try {
            this.listener.dataSourceChanged(null, sourceName, translatorName, dsName);
            ReplaceResult rr = new ReplaceResult();
            if (dsName != null) {
                rr.isNew = !dsExists(dsName, cmr);
            }
            boolean replaced = getVDBStatusChecker().dataSourceReplaced(vdb.getName(), vdb.getVersion(), null, sourceName, translatorName, dsName);
            if (replaced && previousDsName != null && !dsExists(previousDsName, cmr)) {
                rr.removedDs = previousDsName;
            }
            success = true;
            return rr;
        } finally {
            if (!success) {
                for (ModelMetaData m : this.vdb.getModelMetaDatas().values()) {
                    SourceMappingMetadata mapping = m.getSourceMapping(sourceName);
                    if (mapping != null) {
                        mapping.setTranslatorName(previousTranslatorName);
                        mapping.setConnectionJndiName(previousDsName);
                    }
                }
            }
        }
    }
}
Also used : SourceMappingMetadata(org.teiid.adminapi.impl.SourceMappingMetadata) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) AdminProcessingException(org.teiid.adminapi.AdminProcessingException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Aggregations

AdminProcessingException (org.teiid.adminapi.AdminProcessingException)11 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)4 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)4 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)3 SourceMappingMetadata (org.teiid.adminapi.impl.SourceMappingMetadata)3 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 ConnectionType (org.teiid.adminapi.VDB.ConnectionType)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 TeiidException (org.teiid.core.TeiidException)1