1 package com.sslexplorer.ajax; 2 3 import java.util.ArrayList ; 4 import java.util.Collection ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpServletResponse ; 10 11 import org.ajaxtags.helpers.AjaxXmlBuilder; 12 import org.apache.struts.action.ActionForm; 13 import org.apache.struts.action.ActionMapping; 14 import org.apache.struts.util.MessageResources; 15 16 import com.sslexplorer.boot.PropertyClass; 17 import com.sslexplorer.boot.PropertyClassManager; 18 import com.sslexplorer.boot.PropertyDefinition; 19 import com.sslexplorer.boot.Util; 20 import com.sslexplorer.core.CoreUtil; 21 import com.sslexplorer.properties.attributes.AttributeDefinition; 22 import com.sslexplorer.properties.attributes.AttributesPropertyClass; 23 import com.sslexplorer.security.SessionInfo; 24 25 35 public class ListAttributeCategoriesAction extends AbstractAjaxXMLAction { 36 37 45 protected void onAjaxRequest(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, 46 AjaxXmlBuilder builder) throws Exception { 47 List <String > c = new ArrayList <String >(); 48 for (PropertyClass propertyClass : PropertyClassManager.getInstance().getPropertyClasses()) { 49 if (propertyClass instanceof AttributesPropertyClass) { 50 Collection <PropertyDefinition> l = propertyClass.getDefinitions(); 51 String category = request.getParameter("category"); 52 for (PropertyDefinition d : l) { 53 AttributeDefinition def = (AttributeDefinition)d; 54 String categoryLabel = def.getCategoryLabel(); 55 MessageResources mr = CoreUtil.getMessageResources(request.getSession(), def.getMessageResourcesKey()); 56 String s = mr == null ? null : mr.getMessage("userAttributeCategory." + def.getCategory() + ".title"); 57 if (s != null && !s.equals("")) { 58 categoryLabel = Util.urlDecode(s); 59 } else { 60 categoryLabel = categoryLabel == null || categoryLabel.equals("") ? "Attributes" : categoryLabel; 61 } 62 if ((category == null || category.equals("") || categoryLabel.toLowerCase().startsWith(category.toLowerCase())) 63 && !c.contains(categoryLabel)) { 64 c.add(categoryLabel); 65 } 66 } 67 68 } 69 } 70 for (Iterator i = c.iterator(); i.hasNext();) { 71 String n = Util.encodeHTML((String ) i.next()); 72 builder.addItem(n, n); 73 } 74 } 75 76 84 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 85 return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT; 86 } 87 88 } 89 | Popular Tags |