Hi,
I am trying to create a user that that will be act like a lead same as in Campaign console & want to assign this to List provided. I have created the user using UserManager api.
Session session = resourceResolver.adaptTo(Session.class); User subscriberUser = userManager.createUser(email_id, RandomStringUtils.randomAlphanumeric(20).toUpperCase()); session.save();
But these are not reflecting as Lead in Campaign console, Also want to add this user in the list created say : xyz . Any Idea how can i achieve this programmatically.
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Given that you use case is to:
"send newsletter to the list of users"
and
"need to set the email property"
Once you create the user -- you can set email using this method:
http://jackrabbit.apache.org/api/2.0/org/apache/jackrabbit/api/security/user/Authorizable.html#setPr..., javax.jcr.Value)
Notice that setPropery method is inherited from interface org.apache.jackrabbit.api.security.user.Authorizable.
Also - use JCR-SQL code to query the child profile node under user too. Then set the email on this node.
After all the email for all users is set - you can write a server-side OSGi method to email everyone.
Views
Replies
Total Likes
Write a custom OSGi service that defines a User class, and a service. You can use JackRabbit User API to perform user tasks - AEM UserManager API is deprecated:
https://helpx.adobe.com/experience-manager/using/developing-aem-osgi-bundles-jackrabbit.html
As you get user data, add the User objects to a List collection object (ie ArrayList), order the collection and then have the service return users within JSON data.
DO not try to add JSP logic to do this. Keep components thin and make use of OSGi/Java to perform business logic.
Views
Replies
Total Likes
Thanks, Actually my use-case is to send newsletter to the list of users and following the http://docs.adobe.com/docs/en/cq/5-6-1/wcm/campaigns.html I seems almost there but here i need to set the email property under profile node. With my servlet code I don't know how it will get set
Session session = resourceResolver.adaptTo(Session.class); ValueFactory valueFactory = session.getValueFactory(); User subscriberUser = userManager.createUser(email_id, RandomStringUtils.randomAlphanumeric(20).toUpperCase()); subscriberUser.setProperty("cq:authorizableCategory", valueFactory.createValue("mcm")); //subscriberUser.setProperty("email prop under profile node",email_id); Group group = resourceResolver.resolve("/home/groups/m/mygroup").adaptTo(Group.class); group.addMember(subscriberUser); session.save();
Views
Replies
Total Likes
Given that you use case is to:
"send newsletter to the list of users"
and
"need to set the email property"
Once you create the user -- you can set email using this method:
http://jackrabbit.apache.org/api/2.0/org/apache/jackrabbit/api/security/user/Authorizable.html#setPr..., javax.jcr.Value)
Notice that setPropery method is inherited from interface org.apache.jackrabbit.api.security.user.Authorizable.
Also - use JCR-SQL code to query the child profile node under user too. Then set the email on this node.
After all the email for all users is set - you can write a server-side OSGi method to email everyone.
Views
Replies
Total Likes
If you want to see an example of using JCR SQL code to get profile node for users -- see this community article:
https://helpx.adobe.com/experience-manager/using/java-swing-applications.html
You can build similar code for your service - then add a method to email users.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies