Search in sources :

Example 66 with RemoteException

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;
}
Also used : ApiFault(com.salesforce.soap.partner.fault.ApiFault) ServiceException(javax.xml.rpc.ServiceException) SforceServiceLocator(com.salesforce.soap.partner.SforceServiceLocator) SessionHeader(com.salesforce.soap.partner.SessionHeader) LoginFault(com.salesforce.soap.partner.fault.LoginFault) RemoteException(java.rmi.RemoteException)

Example 67 with RemoteException

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...");
}
Also used : QueryResult(com.salesforce.soap.partner.QueryResult) ApiFault(com.salesforce.soap.partner.fault.ApiFault) SObject(com.salesforce.soap.partner.sobject.SObject) SetPasswordResult(com.salesforce.soap.partner.SetPasswordResult) RemoteException(java.rmi.RemoteException)

Example 68 with RemoteException

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...");
}
Also used : QueryResult(com.salesforce.soap.partner.QueryResult) ApiFault(com.salesforce.soap.partner.fault.ApiFault) SObject(com.salesforce.soap.partner.sobject.SObject) ResetPasswordResult(com.salesforce.soap.partner.ResetPasswordResult) RemoteException(java.rmi.RemoteException)

Example 69 with RemoteException

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);
    }
}
Also used : TransferResource(org.sonatype.aether.transfer.TransferResource) RemoteException(java.rmi.RemoteException)

Example 70 with RemoteException

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);
    });
}
Also used : Future(java.util.concurrent.Future) RemoteException(java.rmi.RemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

RemoteException (java.rmi.RemoteException)368 IOException (java.io.IOException)54 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)38 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)34 SSOException (com.iplanet.sso.SSOException)32 AMException (com.iplanet.am.sdk.AMException)31 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)29 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)29 AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)29 LocateRegistry (java.rmi.registry.LocateRegistry)29 Registry (java.rmi.registry.Registry)29 UnsupportedEncodingException (java.io.UnsupportedEncodingException)27 EJBException (javax.ejb.EJBException)25 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)24 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)24 ArrayList (java.util.ArrayList)22 InvocationTargetException (java.lang.reflect.InvocationTargetException)21 ConnectException (java.net.ConnectException)20 DatastoreMO (com.cloud.hypervisor.vmware.mo.DatastoreMO)18 ExecutionException (com.cloud.utils.exception.ExecutionException)18