001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.workplace.tools.scheduler; 029 030import org.opencms.configuration.CmsSchedulerConfiguration; 031import org.opencms.i18n.CmsMessageContainer; 032import org.opencms.jsp.CmsJspActionElement; 033import org.opencms.main.CmsException; 034import org.opencms.main.CmsRuntimeException; 035import org.opencms.main.OpenCms; 036import org.opencms.scheduler.CmsScheduleManager; 037import org.opencms.scheduler.CmsScheduledJobInfo; 038import org.opencms.security.CmsRoleViolationException; 039import org.opencms.workplace.CmsDialog; 040import org.opencms.workplace.list.A_CmsListDialog; 041import org.opencms.workplace.list.CmsListColumnAlignEnum; 042import org.opencms.workplace.list.CmsListColumnDefinition; 043import org.opencms.workplace.list.CmsListDateMacroFormatter; 044import org.opencms.workplace.list.CmsListDefaultAction; 045import org.opencms.workplace.list.CmsListDirectAction; 046import org.opencms.workplace.list.CmsListItem; 047import org.opencms.workplace.list.CmsListItemActionIconComparator; 048import org.opencms.workplace.list.CmsListItemDefaultComparator; 049import org.opencms.workplace.list.CmsListItemDetails; 050import org.opencms.workplace.list.CmsListItemDetailsFormatter; 051import org.opencms.workplace.list.CmsListMetadata; 052import org.opencms.workplace.list.CmsListMultiAction; 053import org.opencms.workplace.list.CmsListOrderEnum; 054 055import java.io.IOException; 056import java.util.ArrayList; 057import java.util.HashMap; 058import java.util.Iterator; 059import java.util.List; 060import java.util.Map; 061 062import javax.servlet.ServletException; 063import javax.servlet.http.HttpServletRequest; 064import javax.servlet.http.HttpServletResponse; 065import javax.servlet.jsp.PageContext; 066 067/** 068 * Main scheduled jobs management list view.<p> 069 * 070 * Defines the list columns and possible actions for scheduled jobs.<p> 071 * 072 * @since 6.0.0 073 */ 074public class CmsSchedulerList extends A_CmsListDialog { 075 076 /** List action activate. */ 077 public static final String LIST_ACTION_ACTIVATE = "aa"; 078 079 /** List action copy. */ 080 public static final String LIST_ACTION_COPY = "ac"; 081 082 /** List action deactivate. */ 083 public static final String LIST_ACTION_DEACTIVATE = "at"; 084 085 /** List action delete. */ 086 public static final String LIST_ACTION_DELETE = "ad"; 087 088 /** List action edit. */ 089 public static final String LIST_ACTION_EDIT = "ae"; 090 091 /** List action execute. */ 092 public static final String LIST_ACTION_EXECUTE = "exec"; 093 094 /** List column activate. */ 095 public static final String LIST_COLUMN_ACTIVATE = "ca"; 096 097 /** List column class. */ 098 public static final String LIST_COLUMN_ACTIVE = "cac"; 099 100 /** List column class. */ 101 public static final String LIST_COLUMN_CLASS = "cs"; 102 103 /** List column copy. */ 104 public static final String LIST_COLUMN_COPY = "cc"; 105 106 /** List column delete. */ 107 public static final String LIST_COLUMN_DELETE = "cd"; 108 109 /** List column edit. */ 110 public static final String LIST_COLUMN_EDIT = "ce"; 111 112 /** List column execute. */ 113 public static final String LIST_COLUMN_EXECUTE = "c_exec"; 114 115 /** List column last execution. */ 116 public static final String LIST_COLUMN_LASTEXE = "cl"; 117 118 /** List column name. */ 119 public static final String LIST_COLUMN_NAME = "cn"; 120 121 /** List column next execution. */ 122 public static final String LIST_COLUMN_NEXTEXE = "cx"; 123 124 /** List action edit. */ 125 public static final String LIST_DEFACTION_EDIT = "de"; 126 127 /** List detail context info. */ 128 public static final String LIST_DETAIL_CONTEXTINFO = "dc"; 129 130 /** List detail parameter. */ 131 public static final String LIST_DETAIL_PARAMETER = "dp"; 132 133 /** List ID. */ 134 public static final String LIST_ID = "lj"; 135 136 /** List action multi activate. */ 137 public static final String LIST_MACTION_ACTIVATE = "ma"; 138 139 /** List action multi deactivate. */ 140 public static final String LIST_MACTION_DEACTIVATE = "mc"; 141 142 /** List action multi delete. */ 143 public static final String LIST_MACTION_DELETE = "md"; 144 145 /** Path to the list buttons. */ 146 public static final String PATH_BUTTONS = "tools/scheduler/buttons/"; 147 148 /** 149 * Public constructor.<p> 150 * 151 * @param jsp an initialized JSP action element 152 */ 153 public CmsSchedulerList(CmsJspActionElement jsp) { 154 155 super( 156 jsp, 157 LIST_ID, 158 new CmsMessageContainer(Messages.get(), Messages.GUI_JOBS_LIST_NAME_0), 159 LIST_COLUMN_NAME, 160 CmsListOrderEnum.ORDER_ASCENDING, 161 LIST_COLUMN_NAME); 162 } 163 164 /** 165 * Public constructor with JSP variables.<p> 166 * 167 * @param context the JSP page context 168 * @param req the JSP request 169 * @param res the JSP response 170 */ 171 public CmsSchedulerList(PageContext context, HttpServletRequest req, HttpServletResponse res) { 172 173 this(new CmsJspActionElement(context, req, res)); 174 } 175 176 /** 177 * This method should handle every defined list multi action, 178 * by comparing <code>{@link #getParamListAction()}</code> with the id 179 * of the action to execute.<p> 180 * 181 * @throws CmsRuntimeException to signal that an action is not supported 182 * 183 */ 184 @Override 185 public void executeListMultiActions() throws CmsRuntimeException { 186 187 if (getParamListAction().equals(LIST_MACTION_DELETE)) { 188 // execute the delete multiaction 189 List<String> removedItems = new ArrayList<String>(); 190 Iterator<CmsListItem> itItems = getSelectedItems().iterator(); 191 while (itItems.hasNext()) { 192 CmsListItem listItem = itItems.next(); 193 try { 194 OpenCms.getScheduleManager().unscheduleJob(getCms(), listItem.getId()); 195 removedItems.add(listItem.getId()); 196 } catch (CmsException e) { 197 throw new CmsRuntimeException( 198 Messages.get().container(Messages.ERR_UNSCHEDULE_JOB_1, listItem.getId()), 199 e); 200 } 201 } 202 // update the XML configuration 203 writeConfiguration(false); 204 } else if (getParamListAction().equals(LIST_MACTION_ACTIVATE) 205 || getParamListAction().equals(LIST_MACTION_DEACTIVATE)) { 206 // execute the activate or deactivate multiaction 207 Iterator<CmsListItem> itItems = getSelectedItems().iterator(); 208 boolean activate = getParamListAction().equals(LIST_MACTION_ACTIVATE); 209 while (itItems.hasNext()) { 210 // toggle the active state of the selected item(s) 211 CmsListItem listItem = itItems.next(); 212 try { 213 CmsScheduledJobInfo job = (CmsScheduledJobInfo)OpenCms.getScheduleManager().getJob( 214 listItem.getId()).clone(); 215 job.setActive(activate); 216 OpenCms.getScheduleManager().scheduleJob(getCms(), job); 217 } catch (CmsException e) { 218 throw new CmsRuntimeException( 219 Messages.get().container(Messages.ERR_SCHEDULE_JOB_1, listItem.getId()), 220 e); 221 } 222 } 223 // update the XML configuration 224 writeConfiguration(true); 225 } else { 226 throwListUnsupportedActionException(); 227 } 228 listSave(); 229 } 230 231 /** 232 * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() 233 */ 234 @Override 235 public void executeListSingleActions() throws IOException, ServletException { 236 237 if (getParamListAction().equals(LIST_ACTION_EDIT) || getParamListAction().equals(LIST_DEFACTION_EDIT)) { 238 // edit a job from the list 239 String jobId = getSelectedItem().getId(); 240 // forward to the edit job screen with additional parameters 241 Map<String, String[]> params = new HashMap<String, String[]>(); 242 params.put(CmsEditScheduledJobInfoDialog.PARAM_JOBID, new String[] {jobId}); 243 // set action parameter to initial dialog call 244 params.put(CmsDialog.PARAM_ACTION, new String[] {CmsDialog.DIALOG_INITIAL}); 245 getToolManager().jspForwardTool(this, "/scheduler/edit", params); 246 } else if (getParamListAction().equals(LIST_ACTION_COPY)) { 247 // copy a job from the list 248 String jobId = getSelectedItem().getId(); 249 // forward to the edit job screen with additional parameters 250 Map<String, String[]> params = new HashMap<String, String[]>(); 251 params.put(CmsEditScheduledJobInfoDialog.PARAM_JOBID, new String[] {jobId}); 252 // set action parameter to copy job action 253 params.put(CmsDialog.PARAM_ACTION, new String[] {CmsEditScheduledJobInfoDialog.DIALOG_COPYJOB}); 254 getToolManager().jspForwardTool(this, "/scheduler/new", params); 255 } else if (getParamListAction().equals(LIST_ACTION_ACTIVATE)) { 256 // activate a job from the list 257 String jobId = getSelectedItem().getId(); 258 CmsScheduledJobInfo job = (CmsScheduledJobInfo)OpenCms.getScheduleManager().getJob(jobId).clone(); 259 job.setActive(true); 260 try { 261 OpenCms.getScheduleManager().scheduleJob(getCms(), job); 262 // update the XML configuration 263 writeConfiguration(true); 264 } catch (CmsException e) { 265 // should never happen 266 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_SCHEDULE_JOB_1, jobId), e); 267 } 268 } else if (getParamListAction().equals(LIST_ACTION_DEACTIVATE)) { 269 // deactivate a job from the list 270 String jobId = getSelectedItem().getId(); 271 CmsScheduledJobInfo job = (CmsScheduledJobInfo)OpenCms.getScheduleManager().getJob(jobId).clone(); 272 job.setActive(false); 273 try { 274 OpenCms.getScheduleManager().scheduleJob(getCms(), job); 275 // update the XML configuration 276 writeConfiguration(true); 277 } catch (CmsException e) { 278 // should never happen 279 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_UNSCHEDULE_JOB_1, jobId), e); 280 } 281 } else if (getParamListAction().equals(LIST_ACTION_DELETE)) { 282 // delete a job from the list 283 String jobId = getSelectedItem().getId(); 284 try { 285 OpenCms.getScheduleManager().unscheduleJob(getCms(), jobId); 286 // update the XML configuration 287 writeConfiguration(false); 288 } catch (CmsRoleViolationException e) { 289 // should never happen 290 throw new CmsRuntimeException(Messages.get().container(Messages.ERR_DELETE_JOB_1, jobId), e); 291 } 292 } else if (getParamListAction().equals(LIST_ACTION_EXECUTE)) { 293 String jobId = getSelectedItem().getId(); 294 CmsScheduleManager scheduler = OpenCms.getScheduleManager(); 295 scheduler.executeDirectly(jobId); 296 } else { 297 throwListUnsupportedActionException(); 298 } 299 listSave(); 300 } 301 302 /** 303 * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String) 304 */ 305 @Override 306 protected void fillDetails(String detailId) { 307 308 // get all scheduled jobs from manager 309 Iterator<CmsListItem> i = getList().getAllContent().iterator(); 310 while (i.hasNext()) { 311 CmsListItem item = i.next(); 312 CmsScheduledJobInfo job = OpenCms.getScheduleManager().getJob(item.getId()); 313 if (detailId.equals(LIST_DETAIL_CONTEXTINFO)) { 314 // job details: context info 315 item.set(LIST_DETAIL_CONTEXTINFO, job.getContextInfo()); 316 } else if (detailId.equals(LIST_DETAIL_PARAMETER)) { 317 // job details: parameter 318 StringBuffer params = new StringBuffer(32); 319 Iterator<String> paramIt = job.getParameters().keySet().iterator(); 320 while (paramIt.hasNext()) { 321 String param = paramIt.next(); 322 String value = job.getParameters().get(param); 323 params.append(param).append("="); 324 params.append(value).append("<br>"); 325 } 326 item.set(LIST_DETAIL_PARAMETER, params); 327 } else { 328 continue; 329 } 330 } 331 } 332 333 /** 334 * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() 335 */ 336 @Override 337 protected List<CmsListItem> getListItems() { 338 339 List<CmsListItem> items = new ArrayList<CmsListItem>(); 340 341 // get all scheduled jobs from manager 342 Iterator<CmsScheduledJobInfo> i = OpenCms.getScheduleManager().getJobs().iterator(); 343 while (i.hasNext()) { 344 CmsScheduledJobInfo job = i.next(); 345 CmsListItem item = getList().newItem(job.getId()); 346 // set the contents of the columns 347 item.set(LIST_COLUMN_NAME, job.getJobName()); 348 item.set(LIST_COLUMN_CLASS, job.getClassName()); 349 item.set(LIST_COLUMN_LASTEXE, job.getExecutionTimePrevious()); 350 item.set(LIST_COLUMN_NEXTEXE, job.getExecutionTimeNext()); 351 item.set(LIST_COLUMN_ACTIVE, Boolean.valueOf(job.isActive())); 352 items.add(item); 353 } 354 355 return items; 356 } 357 358 /** 359 * @see org.opencms.workplace.CmsWorkplace#initMessages() 360 */ 361 @Override 362 protected void initMessages() { 363 364 // add specific messages 365 addMessages(Messages.get().getBundleName()); 366 // add default messages 367 super.initMessages(); 368 } 369 370 /** 371 * @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata) 372 */ 373 @Override 374 protected void setColumns(CmsListMetadata metadata) { 375 376 // add column for edit action 377 CmsListColumnDefinition editCol = new CmsListColumnDefinition(LIST_COLUMN_EDIT); 378 editCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_EDIT_0)); 379 editCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_EDIT_HELP_0)); 380 editCol.setWidth("20"); 381 editCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 382 editCol.setSorteable(false); 383 // create default edit action for edit column: edit job 384 CmsListDirectAction editColAction = new CmsListDirectAction(LIST_ACTION_EDIT); 385 editColAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_NAME_0)); 386 editColAction.setIconPath(PATH_BUTTONS + "edit.png"); 387 editColAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_HELP_0)); 388 editColAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_CONF_0)); 389 // set action for the edit column 390 editCol.addDirectAction(editColAction); 391 metadata.addColumn(editCol); 392 393 // add column for activate/deactivate action 394 CmsListColumnDefinition activateCol = new CmsListColumnDefinition(LIST_COLUMN_ACTIVATE); 395 activateCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_ACTIVE_0)); 396 activateCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_ACTIVE_HELP_0)); 397 activateCol.setWidth("20"); 398 activateCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 399 activateCol.setListItemComparator(new CmsListItemActionIconComparator()); 400 401 // direct action: activate job 402 CmsListDirectAction jobActAction = new CmsListDirectAction(LIST_ACTION_ACTIVATE) { 403 404 /** 405 * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible() 406 */ 407 @Override 408 public boolean isVisible() { 409 410 if (getItem() != null) { 411 return !((Boolean)getItem().get(LIST_COLUMN_ACTIVE)).booleanValue(); 412 } 413 return super.isVisible(); 414 } 415 }; 416 jobActAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_ACTIVATE_NAME_0)); 417 jobActAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_ACTIVATE_CONF_0)); 418 jobActAction.setIconPath(ICON_INACTIVE); 419 jobActAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_ACTIVATE_HELP_0)); 420 activateCol.addDirectAction(jobActAction); 421 422 // direct action: deactivate job 423 CmsListDirectAction jobDeactAction = new CmsListDirectAction(LIST_ACTION_DEACTIVATE) { 424 425 /** 426 * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible() 427 */ 428 @Override 429 public boolean isVisible() { 430 431 if (getItem() != null) { 432 return ((Boolean)getItem().get(LIST_COLUMN_ACTIVE)).booleanValue(); 433 } 434 return super.isVisible(); 435 } 436 }; 437 jobDeactAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DEACTIVATE_NAME_0)); 438 jobDeactAction.setConfirmationMessage( 439 Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DEACTIVATE_CONF_0)); 440 jobDeactAction.setIconPath(ICON_ACTIVE); 441 jobDeactAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DEACTIVATE_HELP_0)); 442 activateCol.addDirectAction(jobDeactAction); 443 444 metadata.addColumn(activateCol); 445 446 // add column for copy action 447 CmsListColumnDefinition copyCol = new CmsListColumnDefinition(LIST_COLUMN_COPY); 448 copyCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_COPY_0)); 449 copyCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_COPY_HELP_0)); 450 copyCol.setWidth("20"); 451 copyCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 452 copyCol.setListItemComparator(null); 453 // direct action: copy job 454 CmsListDirectAction copyJob = new CmsListDirectAction(LIST_ACTION_COPY); 455 copyJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_COPY_NAME_0)); 456 copyJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_COPY_CONF_0)); 457 copyJob.setIconPath(PATH_BUTTONS + "copy.png"); 458 copyJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_COPY_HELP_0)); 459 copyCol.addDirectAction(copyJob); 460 metadata.addColumn(copyCol); 461 462 // add column for delete action 463 CmsListColumnDefinition delCol = new CmsListColumnDefinition(LIST_COLUMN_DELETE); 464 delCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_DELETE_0)); 465 delCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_DELETE_HELP_0)); 466 delCol.setWidth("20"); 467 delCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 468 delCol.setListItemComparator(null); 469 // direct action: delete job 470 CmsListDirectAction delJob = new CmsListDirectAction(LIST_ACTION_DELETE); 471 delJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DELETE_NAME_0)); 472 delJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DELETE_CONF_0)); 473 delJob.setIconPath(ICON_DELETE); 474 delJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_DELETE_HELP_0)); 475 delCol.addDirectAction(delJob); 476 metadata.addColumn(delCol); 477 478 // add column for delete action 479 CmsListColumnDefinition execCol = new CmsListColumnDefinition(LIST_COLUMN_EXECUTE); 480 execCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_EXECUTE_0)); 481 execCol.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_COL_EXECUTE_HELP_0)); 482 execCol.setWidth("20"); 483 execCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER); 484 execCol.setListItemComparator(null); 485 CmsListDirectAction execJob = new CmsListDirectAction(LIST_ACTION_EXECUTE); 486 execJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EXECUTE_NAME_0)); 487 execJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EXECUTE_CONF_0)); 488 execJob.setIconPath("list/rightarrow.png"); 489 execJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EXECUTE_HELP_0)); 490 execCol.addDirectAction(execJob); 491 metadata.addColumn(execCol); 492 493 // add column for name 494 CmsListColumnDefinition nameCol = new CmsListColumnDefinition(LIST_COLUMN_NAME); 495 nameCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_NAME_0)); 496 nameCol.setWidth("30%"); 497 nameCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT); 498 nameCol.setListItemComparator(new CmsListItemDefaultComparator()); 499 // create default edit action for name column: edit job 500 CmsListDefaultAction nameColAction = new CmsListDefaultAction(LIST_DEFACTION_EDIT); 501 nameColAction.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_NAME_0)); 502 nameColAction.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_HELP_0)); 503 nameColAction.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_EDIT_CONF_0)); 504 // set action for the name column 505 nameCol.addDefaultAction(nameColAction); 506 metadata.addColumn(nameCol); 507 508 // add column for class 509 CmsListColumnDefinition classCol = new CmsListColumnDefinition(LIST_COLUMN_CLASS); 510 classCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_CLASS_0)); 511 classCol.setWidth("20%"); 512 classCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT); 513 classCol.setListItemComparator(new CmsListItemDefaultComparator()); 514 metadata.addColumn(classCol); 515 516 // add column for last execution time 517 CmsListColumnDefinition lastExecCol = new CmsListColumnDefinition(LIST_COLUMN_LASTEXE); 518 lastExecCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_LASTEXE_0)); 519 lastExecCol.setWidth("25%"); 520 lastExecCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT); 521 lastExecCol.setListItemComparator(new CmsListItemDefaultComparator()); 522 // create date formatter for last execution time 523 lastExecCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter()); 524 metadata.addColumn(lastExecCol); 525 526 // add column for next execution time 527 CmsListColumnDefinition nextExecCol = new CmsListColumnDefinition(LIST_COLUMN_NEXTEXE); 528 nextExecCol.setName(Messages.get().container(Messages.GUI_JOBS_LIST_COL_NEXTEXE_0)); 529 nextExecCol.setWidth("25%"); 530 nextExecCol.setAlign(CmsListColumnAlignEnum.ALIGN_LEFT); 531 nextExecCol.setListItemComparator(new CmsListItemDefaultComparator()); 532 // add column for activation information 533 CmsListColumnDefinition actInfoCol = new CmsListColumnDefinition(LIST_COLUMN_ACTIVE); 534 actInfoCol.setVisible(false); 535 metadata.addColumn(actInfoCol); 536 537 // create date formatter for next execution time 538 nextExecCol.setFormatter(CmsListDateMacroFormatter.getDefaultDateFormatter()); 539 metadata.addColumn(nextExecCol); 540 } 541 542 /** 543 * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata) 544 */ 545 @Override 546 protected void setIndependentActions(CmsListMetadata metadata) { 547 548 // add independent job context info button 549 CmsListItemDetails jobsContextInfoDetails = new CmsListItemDetails(LIST_DETAIL_CONTEXTINFO); 550 jobsContextInfoDetails.setAtColumn(LIST_COLUMN_NAME); 551 jobsContextInfoDetails.setVisible(false); 552 jobsContextInfoDetails.setShowActionName( 553 Messages.get().container(Messages.GUI_JOBS_DETAIL_SHOW_CONTEXTINFO_NAME_0)); 554 jobsContextInfoDetails.setShowActionHelpText( 555 Messages.get().container(Messages.GUI_JOBS_DETAIL_SHOW_CONTEXTINFO_HELP_0)); 556 jobsContextInfoDetails.setHideActionName( 557 Messages.get().container(Messages.GUI_JOBS_DETAIL_HIDE_CONTEXTINFO_NAME_0)); 558 jobsContextInfoDetails.setHideActionHelpText( 559 Messages.get().container(Messages.GUI_JOBS_DETAIL_HIDE_CONTEXTINFO_HELP_0)); 560 // create formatter to display context info 561 CmsContextInfoDetailsFormatter contextFormatter = new CmsContextInfoDetailsFormatter(); 562 contextFormatter.setUserMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_USER_0)); 563 contextFormatter.setProjectMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_PROJECT_0)); 564 contextFormatter.setLocaleMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_LOCALE_0)); 565 contextFormatter.setRootSiteMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_ROOTSITE_0)); 566 contextFormatter.setEncodingMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_ENCODING_0)); 567 contextFormatter.setRemoteAddrMessage(Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_REMADR_0)); 568 contextFormatter.setRequestedURIMessage( 569 Messages.get().container(Messages.GUI_JOBS_DETAIL_CONTEXTINFO_REQURI_0)); 570 jobsContextInfoDetails.setFormatter(contextFormatter); 571 // add context info item detail to meta data 572 metadata.addItemDetails(jobsContextInfoDetails); 573 574 // add independent job parameter button 575 CmsListItemDetails jobsParameterDetails = new CmsListItemDetails(LIST_DETAIL_PARAMETER); 576 jobsParameterDetails.setAtColumn(LIST_COLUMN_NAME); 577 jobsParameterDetails.setVisible(false); 578 jobsParameterDetails.setShowActionName( 579 Messages.get().container(Messages.GUI_JOBS_DETAIL_SHOW_PARAMETER_NAME_0)); 580 jobsParameterDetails.setShowActionHelpText( 581 Messages.get().container(Messages.GUI_JOBS_DETAIL_SHOW_PARAMETER_HELP_0)); 582 jobsParameterDetails.setHideActionName( 583 Messages.get().container(Messages.GUI_JOBS_DETAIL_HIDE_PARAMETER_NAME_0)); 584 jobsParameterDetails.setHideActionHelpText( 585 Messages.get().container(Messages.GUI_JOBS_DETAIL_HIDE_PARAMETER_HELP_0)); 586 // create formatter to display parameters 587 jobsParameterDetails.setFormatter( 588 new CmsListItemDetailsFormatter(Messages.get().container(Messages.GUI_JOBS_DETAIL_PARAMETER_FORMAT_0))); 589 // add parameter item to metadata 590 metadata.addItemDetails(jobsParameterDetails); 591 } 592 593 /** 594 * @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata) 595 */ 596 @Override 597 protected void setMultiActions(CmsListMetadata metadata) { 598 599 // add the activate job multi action 600 CmsListMultiAction activateJob = new CmsListMultiAction(LIST_MACTION_ACTIVATE); 601 activateJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MACTIVATE_NAME_0)); 602 activateJob.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MACTIVATE_CONF_0)); 603 activateJob.setIconPath(ICON_MULTI_ACTIVATE); 604 activateJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MACTIVATE_HELP_0)); 605 metadata.addMultiAction(activateJob); 606 607 // add the deactivate job multi action 608 CmsListMultiAction deactivateJob = new CmsListMultiAction(LIST_MACTION_DEACTIVATE); 609 deactivateJob.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDEACTIVATE_NAME_0)); 610 deactivateJob.setConfirmationMessage( 611 Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDEACTIVATE_CONF_0)); 612 deactivateJob.setIconPath(ICON_MULTI_DEACTIVATE); 613 deactivateJob.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDEACTIVATE_HELP_0)); 614 metadata.addMultiAction(deactivateJob); 615 616 // add the delete job multi action 617 CmsListMultiAction deleteJobs = new CmsListMultiAction(LIST_MACTION_DELETE); 618 deleteJobs.setName(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDELETE_NAME_0)); 619 deleteJobs.setConfirmationMessage(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDELETE_CONF_0)); 620 deleteJobs.setIconPath(ICON_MULTI_DELETE); 621 deleteJobs.setHelpText(Messages.get().container(Messages.GUI_JOBS_LIST_ACTION_MDELETE_HELP_0)); 622 metadata.addMultiAction(deleteJobs); 623 } 624 625 /** 626 * Writes the updated scheduled job info back to the XML configuration file and refreshes the complete list.<p> 627 * 628 * @param refresh if true, the list items are refreshed 629 */ 630 protected void writeConfiguration(boolean refresh) { 631 632 // update the XML configuration 633 OpenCms.writeConfiguration(CmsSchedulerConfiguration.class); 634 if (refresh) { 635 refreshList(); 636 } 637 } 638}