public int doStartTag() throws JspException {
try {
Application currentAppli = (Application) pageContext.getSession()
.getAttribute(ConsoleCst.CURRENT_APPLICATION);
Resource currentRes = (Resource) pageContext.getSession()
.getAttribute(ConsoleCst.CURRENT_RESOURCE);
if (currentAppli != null && currentRes != null) {
if (currentRes.getBaseDn() != null) {
ApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(pageContext
.getServletContext());
LdapTreeBuilder ldapTreeBuilder = (LdapTreeBuilder) ctx
.getBean("ldapTreeBuilder");
ldapTreeBuilder.setConnection(currentAppli.getConnection());
Set s = ldapTreeBuilder.getMandatoryAttributes(currentRes
.getBaseDn());
if (s == null) {
for (Iterator it2 = currentRes.getAttributes()
.iterator(); it2.hasNext();) {
Attribute a = (Attribute) it2.next();
a.setMandatory(ConsoleCst.UNKNOWN_STATUS);
}
} else {
if(ConsoleCst.ADD_MAPPER_TYPE.equals(currentRes.getType())) {
for (Iterator it2 = currentRes.getAttributes()
.iterator(); it2.hasNext();) {
Attribute a = (Attribute) it2.next();
a
.setMandatory(s.contains(a
.getAttributeLDAP()) ? ConsoleCst.MANDATORY_STATUS
: ConsoleCst.NOT_MANDATORY_STATUS);
}
} else {
for (Iterator it2 = currentRes.getAttributes()
.iterator(); it2.hasNext();) {
Attribute a = (Attribute) it2.next();
a
.setMandatory(ConsoleCst.NOT_MANDATORY_STATUS);
}
}
}
} else {
for (Iterator it2 = currentRes.getAttributes().iterator(); it2
.hasNext();) {
Attribute a = (Attribute) it2.next();
a.setMandatory(ConsoleCst.UNKNOWN_STATUS);
}
}