/** * Commits the edited module. * * <p> */ public void actionCommit() { List errors = new ArrayList(); try { // get the correct module String moduleName = getParamModule(); CmsModule module = (CmsModule) OpenCms.getModuleManager().getModule(moduleName).clone(); // get the current exportpoints from the module List oldExportpoints = module.getExportPoints(); // now loop through the exportpoints and create the new list of exportpoints List newExportpoints = new ArrayList(); Iterator i = oldExportpoints.iterator(); while (i.hasNext()) { CmsExportPoint exp = (CmsExportPoint) i.next(); if (!exp.getUri().equals(m_exportpoint.getUri())) { newExportpoints.add(exp); } } // update the exportpoints newExportpoints.add(m_exportpoint); module.setExportPoints(newExportpoints); // update the module OpenCms.getModuleManager().updateModule(getCms(), module); // refresh the list Map objects = (Map) getSettings().getListObject(); if (objects != null) { objects.remove(CmsModulesList.class.getName()); objects.remove(CmsExportpointsList.class.getName()); } } catch (CmsConfigurationException ce) { errors.add(ce); } catch (CmsSecurityException se) { errors.add(se); } // set the list of errors to display when saving failed setCommitErrors(errors); }
/** * Initializes the module to work with depending on the dialog state and request parameters. * * <p> */ protected void initModule() { Object o; CmsModule module; if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) { // this is the initial dialog call if (CmsStringUtil.isNotEmpty(m_paramModule)) { // edit an existing module, get it from manager o = OpenCms.getModuleManager().getModule(m_paramModule); } else { // create a new module o = null; } } else { // this is not the initial call, get module from session o = getDialogObject(); } if (!(o instanceof CmsModule)) { // create a new module module = new CmsModule(); } else { // reuse module stored in session module = (CmsModule) ((CmsModule) o).clone(); } List exportpoints = module.getExportPoints(); m_exportpoint = new CmsExportPoint(); if ((exportpoints != null) && (exportpoints.size() > 0)) { Iterator i = exportpoints.iterator(); while (i.hasNext()) { CmsExportPoint exportpoint = (CmsExportPoint) i.next(); if (exportpoint.getUri().equals(m_paramExportpoint)) { m_exportpoint = exportpoint; } } } }
/** @see org.opencms.workplace.CmsWidgetDialog#validateParamaters() */ protected void validateParamaters() throws Exception { String moduleName = getParamModule(); // check module CmsModule module = OpenCms.getModuleManager().getModule(moduleName); if (module == null) { throw new Exception(); } // check export point if (!isNewExportPoint()) { Iterator it = module.getExportPoints().iterator(); while (it.hasNext()) { CmsExportPoint ep = (CmsExportPoint) it.next(); if (ep.getUri().equals(getParamExportpoint())) { // export point found return; } } throw new Exception(); } }