Include Page | ||||
---|---|---|---|---|
|
Hooks Introduction
Proof of Conceptconcept (A veto hook)
Hooks Example - Assign a Unix id to each new group
Instructions to get started with Grouper and hooks.
...
No Format |
---|
package test; import edu.internet2.middleware.grouper.Group; import edu.internet2.middleware.grouper.GroupType; import edu.internet2.middleware.grouper.GroupTypeFinder; import edu.internet2.middleware.grouper.hooks.beans.HooksContext; import edu.internet2.middleware.grouper.hooks.beans.HooksGroupBean; /** * add a type after a group insert */ public class GroupAddFubHook extends edu.internet2.middleware.grouper.hooks.GroupHooks { /** * * @see edu.internet2.middleware.grouper.hooks.GroupHooks#groupPostInsert(edu.internet2.middleware.grouper.hooks.beans.HooksContext, edu.internet2.middleware.grouper.hooks.beans.HooksGroupBean) */ @SuppressWarnings("unchecked") @Override public void groupPostInsert(HooksContext hooksContext, HooksGroupBean postInsertBean) { super.groupPostInsert(hooksContext, postInsertBean); try { Group group = postInsertBean.getGroup(); GroupType fubGroup = GroupTypeFinder.find("fubGroup"); group.addType(fubGroup); group.setAttribute("gid", "2"); group.store(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } } |
...
\[mchyzer@flash2 grouper\]$ ant dist
- Add this line to the hooks section in conf/grouper.properties
hooks.group.class=test.GroupAddFubHook - See hook work, see new type and new attribute: bin\gsh.sh
...
- Download or unzip grouper-ui
- Run ant - exit
- Edit the build.properties,
- set the grouper.folder if not ../grouper
- Run ant - dist
- Edit your tomcat_home/conf/server.xml, add a context for the UI
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context docBase="/home/mchyzer/grouper_v1_4/grouper-ui/dist/grouper" path="/grouper" reloadable="false"/>
</Host>
</Engine> - Add a user to your tomcat-users.xml file:
...
- If you are using mod_jk, hook up the url with the tomcat:
JkMount /grouper/* tomcat_mchyzer Stop and start apache and tomcat: \Wiki Markup
[mchyzer@flash2 grouper\]$ /home/mchyzer/apache2_0/bin/apachectl stop \
[mchyzer@flash2 grouper\]$ /home/mchyzer/apache2_0/bin/apachectl start \
[mchyzer@flash2 grouper\]$ /home/mchyzer/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /home/mchyzer/tomcat
Using CATALINA_HOME: /home/mchyzer/tomcat
Using CATALINA_TMPDIR: /home/mchyzer/tomcat/temp
Using JRE_HOME: /opt/appserv/java6 \
[mchyzer@flash2 grouper\]$ /home/mchyzer/tomcat/bin/startup.sh
Using CATALINA_BASE: /home/mchyzer/tomcat
Using CATALINA_HOME: /home/mchyzer/tomcat
Using CATALINA_TMPDIR: /home/mchyzer/tomcat/temp
Using JRE_HOME: /opt/appserv/java6 \
[mchyzer@flash2 grouper\]$- Add a group with or without the fubGroup type, and see the type and attribute when done