[Anthill-pro] Notify Admins when build fails

Steve Boone sbb at urbancode.com
Wed Feb 6 10:17:03 CST 2008


Gentlemen,

Here is an example of a short script, that will return all the users for a
named role.

----------

*import* com.urbancode.anthill3.domain.security.*;
*return* UserFactory.getInstance().restoreAllForRole(RoleFactory.getInstance().restoreForName("Build
Master"));







On 2/6/08, Uldis Karlovs-Karlovskis <uldisk at ctco.lv> wrote:
>
> I need similar functionality - send notifications for users which are in
> role defined in property "project builders".
>
> This is my interpretation. I still have not tested it 100%. It would be
> nice
> if support can offer some good looking script.
>
> import com.urbancode.anthill3.domain.security.Role;
> import com.urbancode.anthill3.domain.security.User;
> import com.urbancode.anthill3.domain.workflow.Workflow;
> import com.urbancode.anthill3.runtime.scripting.helpers.UserLookup;
> import com.urbancode.anthill3.runtime.scripting.helpers.WorkflowLookup;
> import com.urbancode.anthill3.runtime.scripting.helpers.PropertyLookup;
> import java.util.ArrayList;
> import java.util.Iterator;
> import ctco.anthill.custom.util.Property;
>
> org.apache.log4j.Logger logger =
> org.apache.log4j.Logger.getLogger("script");
>         logger.warn("Starting User Generator");
>         Workflow workflow = WorkflowLookup.getCurrent();
>         String matchGroup = PropertyLookup.getValue("project builders");
>         User[] users = UserLookup.getAllForProject(workflow.getProject());
>         ArrayList filtered = new ArrayList(users.length);
>         logger.warn("Searching on role " + matchGroup);
>         logger.warn("Found users on project:");
>         for(User user : users){
>             logger.warn(user.getName());
>             Role[] roles = user.getRoles();
>             for(Role role : roles){
>                 if(role.getName().equals(matchGroup)) {
>                     filtered.add(user);
>                 }
>             }
>         }
>         User[] u = new User[filtered.size()];
>         Iterator i = filtered.iterator();
>         int k = 0;
>         logger.warn("Found users on role:");
>         while (i.hasNext()) {
>             User user = (User) i.next();
>             logger.warn(user.getName());
>             u[k++] = user;
>         }
>         workflow = null;
>         users = null;
>         filtered = null;
>         i = null;
>         return u;
>
> Uldis Karlovs-Karlovskis, C. T. Co
> uldis.karlovs-karlovskis at ctco.lv
>
>
> -----Original Message-----
> From: anthill-pro-bounces at lists.urbancode.com
> [mailto:anthill-pro-bounces at lists.urbancode.com] On Behalf Of Mockel
> Frederic
> Sent: trešdiena, 2008. gada 6. februārī 13:59
> To: anthill-pro at lists.urbancode.com
> Subject: [Anthill-pro] Notify Admins when build fails
>
> Hi all,
>
> i want to build an user generator which return all users which has the
> role
> 'Build Master'.
>
> Have you got an example for me, i have no solution retreiving the right
> role
> for using in
> User.hasRole( Role r).
>
> Thanks
>
> Freddy
>
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
>
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/anthill-pro/attachments/20080206/9e95a8ab/attachment.htm


More information about the Anthill-pro mailing list