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);
}
}
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;
}
}
}
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);
}
}
}
}
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);
}
}
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);
}
}
}
}
}
}
Aggregations