1 31 32 package org.opencms.workplace.tools.searchindex; 33 34 import org.opencms.configuration.CmsSearchConfiguration; 35 import org.opencms.i18n.CmsMessageContainer; 36 import org.opencms.jsp.CmsJspActionElement; 37 import org.opencms.main.CmsIllegalStateException; 38 import org.opencms.main.OpenCms; 39 import org.opencms.search.CmsSearchIndexSource; 40 import org.opencms.search.CmsSearchManager; 41 import org.opencms.workplace.list.CmsListColumnAlignEnum; 42 import org.opencms.workplace.list.CmsListColumnDefinition; 43 import org.opencms.workplace.list.CmsListDirectAction; 44 import org.opencms.workplace.list.CmsListItem; 45 import org.opencms.workplace.list.CmsListMetadata; 46 import org.opencms.workplace.list.CmsListOrderEnum; 47 48 import java.util.ArrayList ; 49 import java.util.Iterator ; 50 import java.util.List ; 51 52 import javax.servlet.http.HttpServletRequest ; 53 import javax.servlet.http.HttpServletResponse ; 54 import javax.servlet.jsp.PageContext ; 55 56 69 public class CmsSearchResourcesList extends A_CmsEmbeddedListDialog { 70 71 72 public static final String LIST_ACTION_NONE = "an"; 73 74 75 public static final String LIST_COLUMN_ICON = "ci"; 76 77 78 public static final String LIST_COLUMN_PATH = "cp"; 79 80 81 public static final String LIST_ID = "lssr"; 82 83 84 private String m_paramIndexsource; 85 86 91 public CmsSearchResourcesList(CmsJspActionElement jsp) { 92 93 this(jsp, LIST_ID, Messages.get().container(Messages.GUI_LIST_SEARCHRESOURCES_NAME_0)); 94 } 95 96 103 public CmsSearchResourcesList(CmsJspActionElement jsp, String listId, CmsMessageContainer listName) { 104 105 this(jsp, listId, listName, LIST_COLUMN_PATH, CmsListOrderEnum.ORDER_ASCENDING, null); 106 } 107 108 118 public CmsSearchResourcesList( 119 CmsJspActionElement jsp, 120 String listId, 121 CmsMessageContainer listName, 122 String sortedColId, 123 CmsListOrderEnum sortOrder, 124 String searchableColId) { 125 126 super(jsp, listId, listName, sortedColId, sortOrder, searchableColId); 127 128 } 129 130 139 public CmsSearchResourcesList(PageContext context, HttpServletRequest req, HttpServletResponse res) { 140 141 this(new CmsJspActionElement(context, req, res)); 142 } 143 144 147 public void executeListMultiActions() { 148 149 } 151 152 155 public void executeListSingleActions() { 156 157 } 159 160 165 public String getParamIndexsource() { 166 167 return m_paramIndexsource; 168 } 169 170 178 public void setParamIndexsource(String indexsource) { 179 180 m_paramIndexsource = indexsource; 181 } 182 183 186 protected void fillDetails(String detailId) { 187 188 } 190 191 194 protected List getListItems() { 195 196 List result = new ArrayList (); 197 List resources = resources(); 199 Iterator itResources = resources.iterator(); 200 String path; 201 while (itResources.hasNext()) { 202 path = (String )itResources.next(); 203 CmsListItem item = getList().newItem(path); 204 item.set(LIST_COLUMN_PATH, path); 205 result.add(item); 206 } 207 return result; 208 } 209 210 213 protected void initMessages() { 214 215 addMessages(Messages.get().getBundleName()); 217 super.initMessages(); 219 } 220 221 224 protected void setColumns(CmsListMetadata metadata) { 225 226 CmsListColumnDefinition dummyCol = new CmsListColumnDefinition(LIST_COLUMN_ICON); 228 dummyCol.setName(Messages.get().container(Messages.GUI_LIST_RESOURCES_NAME_0)); 229 dummyCol.setHelpText(Messages.get().container(Messages.GUI_LIST_RESOURCES_NAME_HELP_0)); 230 dummyCol.setWidth("20"); 231 dummyCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT); 232 dummyCol.setSorteable(false); 233 CmsListDirectAction dummyAction = new CmsListDirectAction(LIST_ACTION_NONE); 235 dummyAction.setName(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_ICON_NAME_0)); 236 dummyAction.setHelpText(Messages.get().container(Messages.GUI_LIST_INDEXSOURCE_COL_ICON_NAME_HELP_0)); 237 dummyAction.setIconPath(CmsSearchIndexSourceControlList.ICON_FOLDER); 238 dummyCol.addDirectAction(dummyAction); 239 metadata.addColumn(dummyCol); 241 242 CmsListColumnDefinition pathCol = new CmsListColumnDefinition(LIST_COLUMN_PATH); 244 pathCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT); 245 pathCol.setName(Messages.get().container(Messages.GUI_LIST_SEARCHINDEX_COL_NAME_0)); 246 pathCol.setWidth("100%"); 247 metadata.addColumn(pathCol); 248 249 } 250 251 254 protected void setIndependentActions(CmsListMetadata metadata) { 255 256 258 } 259 260 263 protected void setMultiActions(CmsListMetadata metadata) { 264 265 } 267 268 271 protected void validateParamaters() throws Exception { 272 273 if (getParamIndexsource() == null) { 275 throw new CmsIllegalStateException(Messages.get().container( 276 Messages.ERR_SEARCHINDEX_EDIT_MISSING_PARAM_1, 277 A_CmsEditIndexSourceDialog.PARAM_INDEXSOURCE)); 278 } 279 } 280 281 287 protected void writeConfiguration(boolean refresh) { 288 289 OpenCms.writeConfiguration(CmsSearchConfiguration.class); 291 if (refresh) { 292 refreshList(); 293 } 294 } 295 296 301 private List resources() { 302 303 CmsSearchManager manager = OpenCms.getSearchManager(); 304 CmsSearchIndexSource indexsource = manager.getIndexSource(getParamIndexsource()); 305 List result = indexsource.getResourcesNames(); 306 return result; 307 } 308 309 } 310 | Popular Tags |