@Override public T runAndWait(CloudFoundryOperations client, SubMonitor monitor) throws CoreException { CloudFoundryServer cloudServer = getCloudServer(); if (cloudServer.getUsername() == null || cloudServer.getUsername().length() == 0 || cloudServer.getPassword() == null || cloudServer.getPassword().length() == 0) { CloudFoundryPlugin.getCallback().getCredentials(cloudServer); } Server server = (Server) cloudServer.getServer(); // Any Server request will require the server to be connected, so update // the server state if (server.getServerState() == IServer.STATE_STOPPED || server.getServerState() == IServer.STATE_STOPPING) { server.setServerState(IServer.STATE_STARTING); } try { T result = super.runAndWait(client, monitor); // No errors at this stage, therefore assume operation was completed // successfully, and update // server state accordingly if (server.getServerState() != IServer.STATE_STARTED) { server.setServerState(IServer.STATE_STARTED); } return result; } catch (CoreException ce) { // If the server state was starting and the error is related when // the operation was // attempted, but the operation failed // set the server state back to stopped. if (CloudErrorUtil.isConnectionError(ce) && server.getServerState() == IServer.STATE_STARTING) { server.setServerState(IServer.STATE_STOPPED); } // server.setServerPublishState(IServer.PUBLISH_STATE_NONE); throw ce; } }
@Override protected String getTokenAccessErrorLabel() { if (accessTokenErrorLabel == null) { String label = super.getRequestLabel(); String serverName = null; try { CloudFoundryServer cloudServer = getCloudServer(); if (cloudServer != null && cloudServer.getServer() != null) { serverName = NLS.bind(Messages.LocalServerRequest_SERVER_LABEL, cloudServer.getServer().getId()); } } catch (Throwable e) { // Don't log. If the // server failed to resolve, the request itself // will fail and will log the error accordingly } if (serverName != null) { accessTokenErrorLabel = label + " - " + serverName; // $NON-NLS-1$ } else { accessTokenErrorLabel = label; } } return accessTokenErrorLabel; }