Search in sources :

Example 36 with RemoteException

use of java.rmi.RemoteException in project OpenAM by OpenRock.

the class RemoteServicesImpl method modifyMemberShip.

/**
     * Modify member ship for role or static group
     * 
     * @param token
     *            SSOToken
     * @param members
     *            Set of member DN to be operated
     * @param target
     *            DN of the target object to add the member
     * @param type
     *            type of the target object, AMObject.ROLE or AMObject.GROUP
     * @param operation
     *            type of operation, ADD_MEMBER or REMOVE_MEMBER
     */
public void modifyMemberShip(SSOToken token, Set members, String target, int type, int operation) throws AMException {
    try {
        String tokenID = token.getTokenID().toString();
        Object[] objs = { tokenID, members, target, new Integer(type), new Integer(operation) };
        client.send(client.encodeMessage("modifyMemberShip", objs), sessionCookies.getLBCookie(tokenID), null);
    } catch (AMRemoteException amrex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.modifyMemberShip : target" + target + ";  AMRemoteException caught exception=", amrex);
        }
        throw convertException(amrex);
    } catch (RemoteException rex) {
        getDebug().error("RemoteServicesImpl.modifyMemberShip: caught exception=", rex);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    } catch (Exception ex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.modifyMemberShip : target=" + target + ";  caught exception=", ex);
        }
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    }
}
Also used : AMException(com.iplanet.am.sdk.AMException) RemoteException(java.rmi.RemoteException) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) RemoteException(java.rmi.RemoteException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException)

Example 37 with RemoteException

use of java.rmi.RemoteException in project OpenAM by OpenRock.

the class RemoteServicesImpl method updateUserAttribute.

/**
     * Adds or remove static group DN to or from member attribute
     * 'iplanet-am-static-group-dn'
     * 
     * @param token
     *            SSOToken
     * @param members
     *            set of user DN's
     * @param staticGroupDN
     *            DN of the static group
     * @param toAdd
     *            true to add, false to remove
     * @throws AMException
     *             if there is an internal problem with AM Store.
     */
public void updateUserAttribute(SSOToken token, Set members, String staticGroupDN, boolean toAdd) throws AMException {
    try {
        String tokenID = token.getTokenID().toString();
        Object[] objs = { tokenID, members, staticGroupDN, Boolean.valueOf(toAdd) };
        client.send(client.encodeMessage("updateUserAttribute", objs), sessionCookies.getLBCookie(tokenID), null);
    } catch (AMRemoteException amrex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.updateUserAttr: staticGroupDN=" + staticGroupDN + ";  AMRemoteException caught exception=", amrex);
        }
        throw convertException(amrex);
    } catch (RemoteException rex) {
        getDebug().error("RemoteServicesImpl.updateUserAttribute: caught exception=", rex);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    } catch (Exception ex) {
        if (getDebug().messageEnabled()) {
            getDebug().message("RemoteServicesImpl.updateUserAttribute: staticGroupDN=" + staticGroupDN + ";  caught exception=", ex);
        }
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    }
}
Also used : AMException(com.iplanet.am.sdk.AMException) RemoteException(java.rmi.RemoteException) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) RemoteException(java.rmi.RemoteException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException)

Example 38 with RemoteException

use of java.rmi.RemoteException in project OpenAM by OpenRock.

the class ComplianceServicesImpl method verifyAndDeleteObject.

public void verifyAndDeleteObject(SSOToken token, String profileDN) throws AMException {
    try {
        Object[] objs = { token.getTokenID().toString(), profileDN };
        client.send(client.encodeMessage("verifyAndDeleteObject", objs), sessionCookies.getLBCookie(token.getTokenID().toString()), null);
    } catch (AMRemoteException amrex) {
        debug.error("ComplianceServicesImpl.verifyAndDeleteObject()- " + "encountered exception=", amrex);
        throw RemoteServicesImpl.convertException(amrex);
    } catch (RemoteException rex) {
        debug.error("ComplianceServicesImpl.verifyAndDeleteObject()- " + "encountered exception=", rex);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    } catch (Exception ex) {
        debug.error("ComplianceServicesImpl.verifyAndDeleteObject()- " + "encountered exception=", ex);
        throw new AMException(AMSDKBundle.getString("1000"), "1000");
    }
}
Also used : AMException(com.iplanet.am.sdk.AMException) RemoteException(java.rmi.RemoteException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) RemoteException(java.rmi.RemoteException)

Example 39 with RemoteException

use of java.rmi.RemoteException in project tdi-studio-se by Talend.

the class PartnerSamples method upsertSample.

private void upsertSample() {
    // call the login function to do so
    if (!loggedIn) {
        if (!login()) {
            return;
        }
    }
    try {
        DescribeSObjectResult dsr = binding.describeSObject("Account");
        HashMap fieldMap = makeFieldMap(dsr.getFields());
        if (!fieldMap.containsKey("External_Id__c")) {
            System.out.println("\n\nATTENTION: To run this sample you need to \ncreate a custom text field on the Account object \nnamed External_Id with a length of 8 characters \nand with the 'external id' checkbox checked.");
        } else {
            // First, we need to make sure the test accounts do not exist.
            QueryResult qr = binding.query("Select Id From Account Where External_Id__c = '11111111' or External_Id__c = '22222222'");
            if (qr.getSize() > 0) {
                SObject[] accounts = qr.getRecords();
                // Get the ids
                String[] ids = new String[accounts.length];
                for (int i = 0; i < ids.length; i++) {
                    ids[i] = accounts[i].getId();
                }
                // Delete the accounts
                binding.delete(ids);
            }
            // Create a new account using create, we wil use this to update via upsert
            // We will set the external id to be ones so that we can use that value for the upsert
            SObject newAccount = new SObject();
            newAccount.setType("Account");
            MessageElement acctName = newMessageElement("Name", "Account to update");
            MessageElement extId = newMessageElement("External_Id__c", "11111111");
            newAccount.set_any(new MessageElement[] { acctName, extId });
            binding.create(new SObject[] { newAccount });
            // Now we will create an account that should be updated on insert based
            // on the external id field.
            SObject updateAccount = new SObject();
            updateAccount.setType("Account");
            MessageElement webSite = newMessageElement("Website", "http://www.website.com");
            MessageElement extId1 = newMessageElement("External_Id__c", "11111111");
            updateAccount.set_any(new MessageElement[] { webSite, extId1 });
            // This account is meant to be new
            SObject createAccount = new SObject();
            createAccount.setType("Account");
            MessageElement cacctName = newMessageElement("Name", "My Company, Inc");
            MessageElement extId3 = newMessageElement("External_Id__c", "22222222");
            createAccount.set_any(new MessageElement[] { cacctName, extId3 });
            // We have our two accounts, one should be new, the other should be updated.
            try {
                // Invoke the upsert call and save the results.
                // Use External_Id custom field for matching records
                UpsertResult[] upsertResults = binding.upsert("External_Id__c", new SObject[] { createAccount, updateAccount });
                for (UpsertResult result : upsertResults) {
                    if (result.isSuccess()) {
                        System.out.println("\nUpsert succeeded.");
                        System.out.println((result.isCreated() ? "Inserted" : "Updated") + " account, id is " + result.getId().toString());
                    } else {
                        System.out.println("The Upsert failed because: " + result.getErrors(0).getMessage());
                    }
                }
            } catch (RemoteException ex) {
                System.out.println("An unexpected error has occurred." + ex.getMessage());
            }
        }
        getUserInput("\nPress the RETURN key to continue...");
    } catch (ApiFault e) {
        System.out.println("Error merging account: " + e.getExceptionMessage());
        getUserInput("\nHit return to continue...");
    } catch (RemoteException e) {
        System.out.println("Error from the server on the merge sample: " + e.getMessage());
        getUserInput("\nHit return to continue...");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HashMap(java.util.HashMap) DescribeSObjectResult(com.salesforce.soap.partner.DescribeSObjectResult) MessageElement(org.apache.axis.message.MessageElement) RemoteException(java.rmi.RemoteException) ServiceException(javax.xml.rpc.ServiceException) IOException(java.io.IOException) QueryResult(com.salesforce.soap.partner.QueryResult) ApiFault(com.salesforce.soap.partner.fault.ApiFault) SObject(com.salesforce.soap.partner.sobject.SObject) RemoteException(java.rmi.RemoteException) UpsertResult(com.salesforce.soap.partner.UpsertResult)

Example 40 with RemoteException

use of java.rmi.RemoteException in project tdi-studio-se by Talend.

the class PartnerSamples method createAndDeleteAnAccount.

private String createAndDeleteAnAccount(String accountName) {
    String returnId = null;
    SObject acct = new SObject();
    acct.setType("Account");
    String acctName = (accountName == null) ? "QueryAll Sample" : accountName;
    try {
        MessageElement nameField = newMessageElement("Name", acctName);
        acct.set_any(new MessageElement[] { nameField });
        // We are only creating one account so we can index the return array directly
        SaveResult sr = binding.create(new SObject[] { acct })[0];
        if (sr.isSuccess()) {
            acct.setId(sr.getId());
            // Ok, now we will delete that account
            DeleteResult dr = binding.delete(new String[] { acct.getId() })[0];
            if (!dr.isSuccess()) {
                System.out.println("The web service would not let us delete the account: \n" + dr.getErrors(0).getMessage());
                getUserInput("\nHit return to continue...");
            } else {
                returnId = acct.getId();
            }
        } else {
            System.out.println("The web service would not let us create the account: \n" + sr.getErrors(0).getMessage());
            getUserInput("\nHit return to continue...");
        }
    } catch (ApiFault e) {
        System.out.println("Error creating test account: " + e.getExceptionMessage());
        getUserInput("\nHit return to continue...");
    } catch (RemoteException e) {
        System.out.println("Error from the server on create test account: " + e.getMessage());
        getUserInput("\nHit return to continue...");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return returnId;
}
Also used : ApiFault(com.salesforce.soap.partner.fault.ApiFault) SObject(com.salesforce.soap.partner.sobject.SObject) MessageElement(org.apache.axis.message.MessageElement) SaveResult(com.salesforce.soap.partner.SaveResult) RemoteException(java.rmi.RemoteException) DeleteResult(com.salesforce.soap.partner.DeleteResult) RemoteException(java.rmi.RemoteException) ServiceException(javax.xml.rpc.ServiceException) IOException(java.io.IOException)

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