createPerson has auth set to false so that new users can create themselves. It's an exception to the standard practice.

-Adrian


RolandH wrote:
Hello Pranay,

great work :)
Perfect for beginners like myself.

As I'm trying to write my first service, implemented with java, maybe you could add a few words about that in your tutorial.

Maybe someone could answer a question about that:
how do I call services which need authentication (e.g. createPartyEmailAddress from framework/party/services)?
What I'm doing:
my service requires already authentication, which works, creating persons is no problem at all (createPerson has auth="false", which i don't get why today, but i'm sure that's because of my limited knowledge of ofbiz)
calling createPartyEmailAddress throws:
[ ServiceDispatcher.java:522:ERROR] Error in Service [partyContactMechPermissionCheck]: You must be logged in to complete the [Party contact mech permission logic] process.
a snipped of my code is below.

Thanks again for this tutorial and thanks for any answers,

Roland

--- code ---
[...]
Map createPartyEmailAddressMap = UtilMisc.toMap(
   "emailAddress", context.get("emailAddress"),
   "contactMechPurposeTypeId", "PRIMARY_EMAIL",
   "login.username", context.get("login.username"),
   "login.password", context.get("login.password"));
[...]

// create Person
Map createPersonResult = dispatcher.runSync("createPerson", createPersonMap);
if (ServiceUtil.isError(createPersonResult)) {
return createPersonResult;
}

// create EmailAddress
createPartyEmailAddressMap.put("partyId", createPersonResult.get("partyId")); Map createPartyEmailAddressResult = dispatcher.runSync("createPartyEmailAddress", createPartyEmailAddressMap);
if (ServiceUtil.isError(createPartyEmailAddressResult)) {
return createPartyEmailAddressResult;
}


Reply via email to