Skip to content

Commit

Permalink
TEIIDDES-1518: Change TeiidServer.getAdmin to connect
Browse files Browse the repository at this point in the history
* Refactors the getAdmin method to connect in preparation for its changing
  purpose and minimising its use
  • Loading branch information
Paul Richardson committed Nov 15, 2012
1 parent 0d69d88 commit a40607f
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public static void executeAction(String id, Properties properties, boolean synch
TeiidServer teiidServer = DqpPlugin.getInstance().getServerManager().getDefaultServer();

CreateDataSourceAction action = new CreateDataSourceAction();
action.setAdmin(teiidServer.getAdmin());
action.setAdmin(teiidServer.connect());

action.setSelection(new StructuredSelection());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static VDB deployVdb(TeiidServer teiidServer, final Object vdbOrVdbFile,

Vdb vdb = ((vdbOrVdbFile instanceof IFile) ? new Vdb(
(IFile) vdbOrVdbFile, null) : (Vdb) vdbOrVdbFile);
final VdbDeployer deployer = new VdbDeployer(shell, vdb, teiidServer.getAdmin(), doCreateDataSource);
final VdbDeployer deployer = new VdbDeployer(shell, vdb, teiidServer.connect(), doCreateDataSource);
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);

IRunnableWithProgress runnable = new IRunnableWithProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void selectionChanged( SelectionChangedEvent theEvent ) {
tempAdmin = ((TeiidTranslator)obj).getAdmin();
} else if (obj instanceof TeiidServer) {
try {
tempAdmin = ((TeiidServer)obj).getAdmin();
tempAdmin = ((TeiidServer)obj).connect();
} catch (Exception e) {
UTIL.log(e);
newAdmin = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void run() {
getString("noServer.message")); //$NON-NLS-1$
return;
} else if (DqpPlugin.getInstance().getServerManager().getDefaultServer().isConnected()) {
executionAdmin = DqpPlugin.getInstance().getServerManager().getDefaultServer().getAdmin();
executionAdmin = DqpPlugin.getInstance().getServerManager().getDefaultServer().connect();
} else {
MessageDialog.openConfirm(iww.getShell(), getString("noServerConnection.title"), //$NON-NLS-1$
getString("noServerConnection.message")); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean removeDataSource( IFile modelFile ) throws Exception {
Properties properties = getConnectionProperties(modelFile);

if (properties != null && !properties.isEmpty()) {
ExecutionAdmin executionAdmin = DqpPlugin.getInstance().getServerManager().getDefaultServer().getAdmin();
ExecutionAdmin executionAdmin = DqpPlugin.getInstance().getServerManager().getDefaultServer().connect();
String name = modelFile.getFullPath().removeFileExtension().lastSegment();
String jndiName = new ConnectionInfoHelper().generateUniqueConnectionJndiName(name,
modelFile.getFullPath(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public VdbSourceConnection ensureVdbSourceConnection( String sourceModelname,

VdbSourceConnection vdbSourceConnection = null;

ExecutionAdmin defaultAdmin = getDefaultServer().getAdmin();
ExecutionAdmin defaultAdmin = getDefaultServer().connect();

String uuid = ModelerCore.workspaceUuid().toString();

Expand Down Expand Up @@ -149,7 +149,7 @@ public void run() {
TeiidServer defServer = getDefaultServer();
if (defServer != null && defServer.isConnected()) {
try {
initialSelection = defServer.getAdmin().getDataSource(jndiName);
initialSelection = defServer.connect().getDataSource(jndiName);
} catch (Exception e) {
UTIL.log(IStatus.ERROR,
e,
Expand Down Expand Up @@ -197,7 +197,7 @@ public void run() {
TeiidServer defServer = getDefaultServer();
if (defServer != null && defServer.isConnected()) {
try {
initialSelection = defServer.getAdmin().getTranslator(transName);
initialSelection = defServer.connect().getTranslator(transName);
} catch (Exception e) {
UTIL.log(IStatus.ERROR,
e,
Expand Down Expand Up @@ -231,7 +231,7 @@ public String[] getDataSourceNames() {
Collection<TeiidDataSource> dataSources = null;

try {
dataSources = defaultServer.getAdmin().getDataSources();
dataSources = defaultServer.connect().getDataSources();
} catch (Exception e) {
UTIL.log(IStatus.ERROR,
e,
Expand Down Expand Up @@ -273,7 +273,7 @@ public PropertyDefinition[] getTranslatorDefinitions( String translatorName ) {

if ((defaultServer != null) && defaultServer.isConnected()) {
try {
TeiidTranslator translator = defaultServer.getAdmin().getTranslator(translatorName);
TeiidTranslator translator = defaultServer.connect().getTranslator(translatorName);

if (translator != null) {
Collection<PropertyDefinition> props = new ArrayList<PropertyDefinition>();
Expand Down Expand Up @@ -336,7 +336,7 @@ public String[] getTranslatorTypes() {
Collection<TeiidTranslator> translators = null;

try {
translators = defaultServer.getAdmin().getTranslators();
translators = defaultServer.connect().getTranslators();
} catch (Exception e) {
UTIL.log(IStatus.ERROR,
e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void run( final EObject eObject, final boolean planOnly ) {
TeiidTranslator tt = null;

try {
tt = getServerManager().getDefaultServer().getAdmin().getTranslator(translatorName);
tt = getServerManager().getDefaultServer().connect().getTranslator(translatorName);
} catch (Exception e) {
DqpUiConstants.UTIL.log(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void internalRun(final IFile selectedVdb) {
if (teiidServer != null) {
IStatus connectStatus = teiidServer.ping();
if (connectStatus.isOK()) {
ExecutionAdmin admin = teiidServer.getAdmin();
ExecutionAdmin admin = teiidServer.connect();
if (admin != null) {
deployedVDB = admin.getVdb(selectedVdb.getFullPath().removeFileExtension().lastSegment());
if (deployedVDB == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void run() {
if (teiidServer != null && teiidServer.isConnected()) {
ExecutionAdmin admin;
try {
admin = teiidServer.getAdmin();
admin = teiidServer.connect();
} catch (Exception ex) {
DqpUiConstants.UTIL.log(ex);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public final void load() {
Collection<TeiidDataSource> dataSources;

if (provider.isShowDataSources()) {
dataSources = new ArrayList(teiidServer.getAdmin().getDataSources());
dataSources = new ArrayList(teiidServer.connect().getDataSources());

if (!dataSources.isEmpty()) {
children.add(new DataSourcesFolder(this, dataSources));
Expand All @@ -124,7 +124,7 @@ public final void load() {
Collection<TeiidVdb> vdbs;

if (provider.isShowVDBs()) {
vdbs = new ArrayList<TeiidVdb>(teiidServer.getAdmin().getVdbs());
vdbs = new ArrayList<TeiidVdb>(teiidServer.connect().getVdbs());

if (!vdbs.isEmpty()) {
children.add(new VdbsFolder(this, vdbs));
Expand All @@ -141,7 +141,7 @@ public final void load() {
Collection<TeiidTranslator> translators;

if (provider.isShowTranslators()) {
translators = teiidServer.getAdmin().getTranslators();
translators = teiidServer.connect().getTranslators();

if (!translators.isEmpty()) {
children.add(new TranslatorsFolder(this, translators));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public boolean equals(Object obj) {
*
* @throws Exception
*/
public ExecutionAdmin getAdmin() throws Exception {
public ExecutionAdmin connect() throws Exception {
if (! isParentConnected()) {
throw new Exception(DqpPlugin.Util.getString("jbossServerNotStartedMessage")); //$NON-NLS-1$
}
Expand Down Expand Up @@ -222,7 +222,7 @@ public void reconnect() {
if (isParentConnected()) {
// Refresh is implied in the getting of the admin object since it will
// automatically load and refresh.
getAdmin();
connect();
}

setConnectionError(null);
Expand Down Expand Up @@ -398,7 +398,7 @@ public void setCustomLabel( String customLabel ) {
*/
public IStatus testPing() {
try {
getAdmin();
connect();
ping();
close();
this.admin = null;
Expand All @@ -422,7 +422,7 @@ public IStatus testPing() {
*/
public IStatus testJDBCPing(String host, String port, String username, String password) {
try {
getAdmin().ping(PingType.JDBC);
connect().ping(PingType.JDBC);
close();
this.admin = null;
} catch (Exception e) {
Expand Down Expand Up @@ -454,7 +454,7 @@ public IStatus createVdbDataSource(String vdbName, String displayName, String jn
props.put("connection-url", getVdbDataSourceConnectionUrl(vdbName)); //$NON-NLS-1$

try {
getAdmin().getOrCreateDataSource(displayName, jndiName, "connector-jdbc", props); //$NON-NLS-1$
connect().getOrCreateDataSource(displayName, jndiName, "connector-jdbc", props); //$NON-NLS-1$
} catch (Exception ex) {
String msg = "Error creating data source for VDB " + vdbName; //$NON-NLS-1$
return new Status(IStatus.ERROR, PLUGIN_ID, msg, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public TeiidServer createTeiidServer(final JBoss7Server jboss7Server, final ISer

if (optionList.contains(ServerOptions.CONNECT)) {
// Initialise the ExecutionAdmin component of the teiid server
teiidServer.getAdmin();
teiidServer.connect();
}

if (optionList.contains(ServerOptions.ADD_TO_REGISTRY)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public IStatus ensureConnectionInfoIsValid( Vdb previewVdb,

if (helper.hasConnectionInfo(modelResource)) {
String jndiName = this.context.getPreviewVdbJndiName(previewVdb.getFile().getFullPath());
ExecutionAdmin execAdmin = previewServer.getAdmin();
ExecutionAdmin execAdmin = previewServer.connect();

// create data source on server if we need to
if (!execAdmin.dataSourceExists(jndiName)) {
Expand Down Expand Up @@ -1122,7 +1122,7 @@ boolean needsToBeDeployed( IFile pvdbFile ) {
// make sure server has a copy of the Preview VDB
if (getPreviewServer() != null) {
try {
ExecutionAdmin admin = getPreviewServer().getAdmin();
ExecutionAdmin admin = getPreviewServer().connect();
deploy = (admin.getVdb(getPreviewVdbDeployedName(pvdbFile)) == null);

// server does not have a copy. update status map.
Expand Down Expand Up @@ -1223,7 +1223,7 @@ public void previewSetup( final Object objectToPreview,
}
}

ExecutionAdmin admin = previewServer.getAdmin();
ExecutionAdmin admin = previewServer.connect();

// collect all the Preview VDB parent folders so that we can make sure workspace is in sync with file system
Set<IContainer> parents = new HashSet<IContainer>();
Expand Down Expand Up @@ -1600,7 +1600,7 @@ && getPreviewServer().isConnected()
&& prefs.getBoolean(PreferenceConstants.PREVIEW_TEIID_CLEANUP_ENABLED,
PreferenceConstants.PREVIEW_TEIID_CLEANUP_ENABLED_DEFAULT)) {

ExecutionAdmin admin = getPreviewServer().getAdmin();
ExecutionAdmin admin = getPreviewServer().connect();
Collection<Job> jobs = new ArrayList<Job>();

for (TeiidVdb vdb : admin.getVdbs()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ protected IStatus runImpl( IProgressMonitor monitor ) throws Exception {

// delete PVDB from server
try {
if (teiidServer.getAdmin().getVdb(this.pvdbName) != null) {
teiidServer.getAdmin().undeployVdb(this.pvdbName, this.pvdbVersion);
if (teiidServer.connect().getVdb(this.pvdbName) != null) {
teiidServer.connect().undeployVdb(this.pvdbName, this.pvdbVersion);
}
} catch (Exception e) {
++errors;
Expand All @@ -100,8 +100,8 @@ protected IStatus runImpl( IProgressMonitor monitor ) throws Exception {
IStatus deleteDataSourceErrorStatus = null;

try {
if (teiidServer.getAdmin().dataSourceExists(this.jndiName)) {
teiidServer.getAdmin().deleteDataSource(this.jndiName);
if (teiidServer.connect().dataSourceExists(this.jndiName)) {
teiidServer.connect().deleteDataSource(this.jndiName);
}
} catch (Exception e) {
++errors;
Expand Down

0 comments on commit a40607f

Please sign in to comment.