1 31 32 package org.opencms.workplace.tools.modules; 33 34 import org.opencms.db.CmsExportPoint; 35 import org.opencms.jsp.CmsJspActionElement; 36 import org.opencms.main.OpenCms; 37 import org.opencms.module.CmsModule; 38 import org.opencms.util.CmsStringUtil; 39 import org.opencms.widgets.CmsDisplayWidget; 40 import org.opencms.workplace.CmsDialog; 41 import org.opencms.workplace.CmsWidgetDialog; 42 import org.opencms.workplace.CmsWidgetDialogParameter; 43 import org.opencms.workplace.CmsWorkplaceSettings; 44 45 import java.util.Iterator ; 46 import java.util.List ; 47 48 import javax.servlet.http.HttpServletRequest ; 49 import javax.servlet.http.HttpServletResponse ; 50 import javax.servlet.jsp.PageContext ; 51 52 61 public class CmsExportpointsOverview extends CmsWidgetDialog { 62 63 64 public static final String DIALOG_TYPE = "ExportpointsOverview"; 65 66 67 public static final String [] PAGES = {"page1"}; 68 69 70 private CmsExportPoint m_exportpoint; 71 72 73 private String m_paramExportpoint; 74 75 76 private String m_paramModule; 77 78 83 public CmsExportpointsOverview(CmsJspActionElement jsp) { 84 85 super(jsp); 86 } 87 88 95 public CmsExportpointsOverview(PageContext context, HttpServletRequest req, HttpServletResponse res) { 96 97 this(new CmsJspActionElement(context, req, res)); 98 } 99 100 103 public void actionCommit() { 104 105 } 107 108 113 public String buildDialogForm() { 114 115 StringBuffer result = new StringBuffer (1024); 116 117 try { 118 119 result.append(createDialogHtml(getParamPage())); 121 122 } catch (Throwable t) { 123 } 125 return result.toString(); 126 } 127 128 131 public String getCancelAction() { 132 133 setParamPage((String )getPages().get(0)); 135 136 return DIALOG_SET; 137 } 138 139 144 public String getParamExportpoint() { 145 146 return m_paramExportpoint; 147 } 148 149 154 public String getParamModule() { 155 156 return m_paramModule; 157 } 158 159 163 public void setParamExportpoint(String paramExportpoint) { 164 165 m_paramExportpoint = paramExportpoint; 166 } 167 168 172 public void setParamModule(String paramModule) { 173 174 m_paramModule = paramModule; 175 } 176 177 183 protected String createDialogHtml(String dialog) { 184 185 StringBuffer result = new StringBuffer (1024); 186 187 result.append(createWidgetTableStart()); 189 190 result.append(createWidgetErrorHeader()); 192 193 if (dialog.equals(PAGES[0])) { 194 result.append(dialogBlockStart(key("label.exportpointinformation"))); 195 result.append(createWidgetTableStart()); 196 result.append(createDialogRowsHtml(0, 2)); 197 result.append(createWidgetTableEnd()); 198 result.append(dialogBlockEnd()); 199 } 200 201 result.append(createWidgetTableEnd()); 203 204 return result.toString(); 205 } 206 207 210 protected void defineWidgets() { 211 212 initModule(); 213 214 addWidget(new CmsWidgetDialogParameter(m_exportpoint, "uri", PAGES[0], new CmsDisplayWidget())); 215 addWidget(new CmsWidgetDialogParameter(m_exportpoint, "configuredDestination", PAGES[0], new CmsDisplayWidget())); 216 addWidget(new CmsWidgetDialogParameter(m_exportpoint, "destinationPath", PAGES[0], new CmsDisplayWidget())); 217 218 } 219 220 223 protected String [] getPageArray() { 224 225 return PAGES; 226 } 227 228 231 protected void initMessages() { 232 233 addMessages(Messages.get().getBundleName()); 235 super.initMessages(); 237 } 238 239 242 protected void initModule() { 243 244 Object o; 245 CmsModule module; 246 247 if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) { 248 if (CmsStringUtil.isNotEmpty(m_paramModule)) { 250 o = OpenCms.getModuleManager().getModule(m_paramModule); 252 } else { 253 o = null; 255 } 256 } else { 257 o = getDialogObject(); 259 } 260 261 if (!(o instanceof CmsModule)) { 262 module = new CmsModule(); 264 265 } else { 266 module = (CmsModule)((CmsModule)o).clone(); 268 } 269 270 List exportpoints = module.getExportPoints(); 271 m_exportpoint = new CmsExportPoint(); 272 if (exportpoints != null && exportpoints.size() > 0) { 273 Iterator i = exportpoints.iterator(); 274 while (i.hasNext()) { 275 CmsExportPoint exportpoint = (CmsExportPoint)i.next(); 276 if (exportpoint.getUri().equals(m_paramExportpoint)) { 277 m_exportpoint = exportpoint; 278 } 279 } 280 } 281 282 } 283 284 287 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 288 289 setParamDialogtype(DIALOG_TYPE); 291 292 super.initWorkplaceRequestValues(settings, request); 293 294 setDialogObject(m_exportpoint); 296 297 } 298 299 302 protected void validateParamaters() throws Exception { 303 304 String moduleName = getParamModule(); 305 CmsModule module = OpenCms.getModuleManager().getModule(moduleName); 307 if (module == null) { 308 throw new Exception (); 309 } 310 Iterator it = module.getExportPoints().iterator(); 312 while (it.hasNext()) { 313 CmsExportPoint ep = (CmsExportPoint)it.next(); 314 if (ep.getUri().equals(getParamExportpoint())) { 315 return; 317 } 318 } 319 throw new Exception (); 320 } 321 } 322 | Popular Tags |