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");
}
}
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");
}
}
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");
}
}
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();
}
}
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;
}
Aggregations