1 24 25 package org.infoglue.cms.controllers.kernel.impl.simple; 26 27 import java.util.ArrayList ; 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Map ; 32 33 import org.apache.log4j.Logger; 34 import org.dom4j.Document; 35 import org.dom4j.Node; 36 import org.infoglue.cms.entities.kernel.BaseEntityVO; 37 import org.infoglue.cms.entities.mydesktop.ShortcutVO; 38 import org.infoglue.cms.exception.SystemException; 39 import org.infoglue.cms.security.InfoGluePrincipal; 40 import org.infoglue.cms.util.dom.DOMBuilder; 41 42 import com.opensymphony.module.propertyset.PropertySet; 43 import com.opensymphony.module.propertyset.PropertySetManager; 44 45 50 51 public class ShortcutController extends BaseController 52 { 53 private final static Logger logger = Logger.getLogger(ShortcutController.class.getName()); 54 55 private static final ShortcutController controller = new ShortcutController(); 56 57 61 public static ShortcutController getController() 62 { 63 return controller; 64 } 65 66 private ShortcutController() {} 67 68 73 public List getAvailableShortcutVOList(InfoGluePrincipal userPrincipal) throws SystemException 74 { 75 List availableShortcutVOList = new ArrayList (); 76 77 try 78 { 79 Map args = new HashMap (); 80 args.put("globalKey", "infoglue"); 81 PropertySet propertySet = PropertySetManager.getInstance("jdbc", args); 82 83 String xml = getDataPropertyValue(propertySet, "serverNode_-1_shortcuts"); 84 logger.info("xml:" + xml); 85 86 if(xml != null) 87 { 88 DOMBuilder domBuilder = new DOMBuilder(); 89 90 Document document = domBuilder.getDocument(xml); 91 92 List nodes = document.getRootElement().selectNodes("shortcut"); 93 logger.info("nodes:" + nodes.size()); 94 95 Iterator nodesIterator = nodes.iterator(); 96 while(nodesIterator.hasNext()) 97 { 98 Node node = (Node)nodesIterator.next(); 99 logger.info("Node:" + node.asXML()); 100 101 Node nameNode = node.selectSingleNode("name"); 102 Node urlNode = node.selectSingleNode("url"); 103 Node popupNode = node.selectSingleNode("popup"); 104 105 String name = nameNode.getStringValue(); 106 String url = urlNode.getStringValue(); 107 String popup = popupNode.getStringValue(); 108 109 ShortcutVO shortcut = new ShortcutVO(name, url, Boolean.valueOf(popup).booleanValue()); 110 111 availableShortcutVOList.add(shortcut);} 112 } 113 114 } 115 catch(Exception e) 116 { 117 logger.error("An error occurred when reading shortcuts:" + e.getMessage(), e); 118 } 119 120 return availableShortcutVOList; 121 } 122 123 public String getDataPropertyValue(PropertySet propertySet, String key) throws Exception 124 { 125 byte[] valueBytes = propertySet.getData(key); 126 if(valueBytes != null) 127 return new String (valueBytes, "utf-8"); 128 else 129 return null; 130 } 131 132 137 public BaseEntityVO getNewVO() 138 { 139 return null; 140 } 141 } 142 | Popular Tags |