@Override protected ValidationStatus validateLocally() { String userName = getCloudFoundryServer().getUsername(); String password = getCloudFoundryServer().getPassword(); String url = getCloudFoundryServer().getUrl(); String message = null; boolean valuesFilled = false; int validationEventType = ValidationEvents.VALIDATION; if (userName == null || userName.trim().length() == 0) { message = Messages.ERROR_NO_USERNAME_SPACES; } else if (password == null || password.trim().length() == 0) { message = Messages.ERROR_NO_PASSWORD_SPACES; } else if (url == null || url.trim().length() == 0) { message = Messages.ERROR_NO_URL_SPACES; } else { valuesFilled = true; message = Messages.CLONE_SERVER_WIZARD_OK_MESSAGE; } int statusType = valuesFilled ? IStatus.OK : IStatus.ERROR; IStatus status = CloudFoundryPlugin.getStatus(message, statusType); return new ValidationStatus(status, validationEventType); }
@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; } }