use of java.rmi.RemoteException in project tdi-studio-se by Talend.
the class PartnerSamples method login.
/*
* login sample Prompts for username and password, set class variable binding resets the url for the binding and
* adds the session header to the binding class variable
*/
private boolean login() {
un = getUserInput("Enter user name: ");
if (un.length() == 0) {
return false;
}
pw = getUserInput("Enter password: ");
if (pw.length() == 0) {
return false;
}
// Provide feed back while we create the web service binding
System.out.println("Creating the binding to the web service...");
/*
* There are 2 ways to get the binding, one by passing a url to the getSoap() method of the
* SforceServiceLocator, the other by not passing a url. In the second case the binding will use the url
* contained in the wsdl file when the proxy was generated.
*/
try {
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
} catch (ServiceException ex) {
System.out.println("ERROR: createing binding to soap service, error was: \n" + ex.getMessage());
System.out.print("Hit return to continue...");
return false;
}
// Time out after a minute
binding.setTimeout(60000);
// binding._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/services/Soap/u/8.0");
// Attempt the login giving the user feedback
System.out.println("LOGGING IN NOW....");
try {
loginResult = binding.login(un, pw);
} catch (LoginFault lf) {
System.out.println(lf.getExceptionMessage());
// lf.printStackTrace();
getUserInput("\nHit return to continue...");
return false;
} catch (ApiFault af) {
System.out.println(af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (RemoteException re) {
System.out.println(re.getMessage());
re.printStackTrace();
getUserInput("\nHit return to continue...");
return false;
}
System.out.println("\nThe session id is: " + loginResult.getSessionId());
System.out.println("\nThe new server url is: " + loginResult.getServerUrl());
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
// binding._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/services/Soap/u/8.0");
// Create a new session header object and set the session id to that
// returned by the login
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);
loggedIn = true;
// call the getServerTimestamp method
getServerTimestampSample();
// call the getUserInfo method
getUserInfoSample();
return true;
}
use of java.rmi.RemoteException in project tdi-studio-se by Talend.
the class PartnerSamples method setPasswordSample.
private void setPasswordSample() {
if (!loggedIn) {
if (!login()) {
return;
}
}
try {
QueryResult qr = binding.query("select UserName, LastName, FirstName, Id from User");
if (qr.getSize() > 0) {
SObject[] users = qr.getRecords();
if (users != null) {
System.out.println("\nUser List: ");
for (int i = 0; i < users.length; i++) {
int printInd = i + 1;
SObject user = users[i];
System.out.println(printInd + ". " + user.get_any()[0].getValue() + " - " + user.get_any()[2].getValue() + " " + user.get_any()[1].getValue());
}
}
String idToReset = getUserInput("\nEnter user to set password for: ");
if (idToReset != null) {
int userIndex = new Integer(idToReset).intValue() - 1;
String newPassword = getUserInput("Enter the new password: ");
if (newPassword != null) {
String verify = getUserInput("Please verify that you want to reset the password for \n" + users[userIndex].get_any()[2] + " " + users[userIndex].get_any()[1] + "\n to " + newPassword + " by entering OK.");
if (verify.equals("OK")) {
SetPasswordResult setPasswordResult = binding.setPassword(users[userIndex].getId(), newPassword);
if (setPasswordResult != null) {
System.out.println("\nThe password for user " + users[userIndex].get_any()[2].getValue() + " " + users[userIndex].get_any()[1].getValue() + " has been reset to " + newPassword);
getUserInput("\nHit enter to continue...");
return;
}
}
}
}
}
} catch (ApiFault af) {
System.out.println("\nFailed to succesfully set password, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (RemoteException ex) {
System.out.println("\nFailed to succesfully set password, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
getUserInput("No password was set....\nHit return to continue...");
}
use of java.rmi.RemoteException in project tdi-studio-se by Talend.
the class PartnerSamples method resetPasswordSample.
private void resetPasswordSample() {
if (!loggedIn) {
if (!login()) {
return;
}
}
try {
QueryResult qr = binding.query("select UserName, LastName, FirstName, Id from User");
if (qr.getSize() > 0) {
SObject[] users = qr.getRecords();
if (users != null) {
System.out.println("\nUser List: ");
for (int i = 0; i < users.length; i++) {
int printInd = i + 1;
SObject user = users[i];
System.out.println(printInd + ". " + user.get_any()[0].getValue() + " - " + user.get_any()[2].getValue() + " " + user.get_any()[1].getValue());
}
}
String idToReset = getUserInput("\nEnter user to reset: ");
if (idToReset != null) {
int userIndex = new Integer(idToReset).intValue() - 1;
String verify = getUserInput("Please verify that you want to reset the password for \n" + users[userIndex].get_any()[2] + " " + users[userIndex].get_any()[1] + "\nby entering OK.");
if (verify.equals("OK")) {
ResetPasswordResult resetPasswordResult = binding.resetPassword(users[userIndex].getId());
if (resetPasswordResult != null) {
System.out.println("\nThe password for user " + users[userIndex].get_any()[2].getValue() + " " + users[userIndex].get_any()[1].getValue() + " has been reset to " + resetPasswordResult.getPassword());
getUserInput("\nHit enter to continue...");
return;
}
}
}
}
} catch (ApiFault af) {
System.out.println("\nFailed to succesfully reset password, error message was: \n" + af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (RemoteException ex) {
System.out.println("\nFailed to succesfully reset password, error message was: \n" + ex.getMessage());
getUserInput("\nHit return to continue...");
}
getUserInput("No password was reset....\nHit return to continue...");
}
use of java.rmi.RemoteException in project intellij-community by JetBrains.
the class Maven30TransferListenerAdapter method transferProgressed.
@Override
public void transferProgressed(TransferEvent event) throws TransferCancelledException {
checkCanceled();
TransferResource r = event.getResource();
long totalLength = r.getContentLength();
String sizeInfo;
if (totalLength <= 0) {
sizeInfo = StringUtil.formatFileSize(event.getTransferredBytes()) + " / ?";
} else {
sizeInfo = StringUtil.formatFileSize(event.getTransferredBytes()) + " / " + StringUtil.formatFileSize(totalLength);
}
try {
myIndicator.setText2(formatResourceName(event) + " (" + sizeInfo + ')');
if (totalLength <= 0) {
myIndicator.setIndeterminate(true);
} else {
myIndicator.setIndeterminate(false);
myIndicator.setFraction((double) event.getTransferredBytes() / totalLength);
}
} catch (RemoteException e) {
throw new RuntimeRemoteException(e);
}
}
use of java.rmi.RemoteException in project intellij-community by JetBrains.
the class MavenServerManagerTest method testInitializingDoesntTakeReadAction.
public void testInitializingDoesntTakeReadAction() throws Exception {
//make sure all components are initialized to prevent deadlocks
MavenServerManager.getInstance().getOrCreateWrappee();
ApplicationManager.getApplication().runWriteAction(() -> {
Future result = ApplicationManager.getApplication().executeOnPooledThread(() -> {
MavenServerManager.getInstance().shutdown(true);
try {
MavenServerManager.getInstance().getOrCreateWrappee();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
});
try {
result.get(10, TimeUnit.SECONDS);
} catch (InterruptedException | java.util.concurrent.ExecutionException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
printThreadDump();
throw new RuntimeException(e);
}
result.cancel(true);
});
}
Aggregations