Search in sources :

Example 41 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 42 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 43 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 44 with RemoteException

use of java.rmi.RemoteException in project yyl_example by Relucent.

the class HelloClient method main.

public static void main(String[] args) {
    try {
        // 在RMI服务注册表中查找名称为RHello的对象,并调用其上的方法
        HelloService service = (HelloService) Naming.lookup("rmi://localhost:8888/hello");
        System.out.println(service.hello());
        System.out.println(service.hello("I'm the king of the world!"));
    } catch (NotBoundException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NotBoundException(java.rmi.NotBoundException) HelloService(yyl.example.basic.rmi.api.HelloService) RemoteException(java.rmi.RemoteException)

Example 45 with RemoteException

use of java.rmi.RemoteException in project intellij-community by JetBrains.

the class Maven30ServerEmbedderImpl method resolveProject.

@NotNull
@Override
public Collection<MavenServerExecutionResult> resolveProject(@NotNull final Collection<File> files, @NotNull Collection<String> activeProfiles, @NotNull Collection<String> inactiveProfiles) throws RemoteException, MavenServerProcessCanceledException {
    final DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener(myConsoleWrapper);
    Collection<MavenExecutionResult> results = doResolveProject(files, new ArrayList<String>(activeProfiles), new ArrayList<String>(inactiveProfiles), Collections.<ResolutionListener>singletonList(listener));
    return ContainerUtil.mapNotNull(results, new Function<MavenExecutionResult, MavenServerExecutionResult>() {

        @Override
        public MavenServerExecutionResult fun(MavenExecutionResult result) {
            try {
                return createExecutionResult(result.getPomFile(), result, listener.getRootNode());
            } catch (RemoteException e) {
                ExceptionUtil.rethrowAllAsUnchecked(e);
            }
            return null;
        }
    });
}
Also used : MavenExecutionResult(org.jetbrains.idea.maven.server.embedder.MavenExecutionResult) DependencyTreeResolutionListener(org.apache.maven.shared.dependency.tree.DependencyTreeResolutionListener) RemoteException(java.rmi.RemoteException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RemoteException (java.rmi.RemoteException)396 IOException (java.io.IOException)57 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 EJBException (javax.ejb.EJBException)31 LocateRegistry (java.rmi.registry.LocateRegistry)30 Registry (java.rmi.registry.Registry)30 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)29 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)29 AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)29 UnsupportedEncodingException (java.io.UnsupportedEncodingException)27 InvocationTargetException (java.lang.reflect.InvocationTargetException)27 ArrayList (java.util.ArrayList)25 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)24 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)24 ConnectException (java.net.ConnectException)20 HashMap (java.util.HashMap)19 DatastoreMO (com.cloud.hypervisor.vmware.mo.DatastoreMO)18