Search in sources :

Example 1 with CmsModuleDependency

use of org.opencms.module.CmsModuleDependency in project opencms-core by alkacon.

the class CmsDependenciesEdit method initModule.

/**
 * Initializes the module  to work with depending on the dialog state and request parameters.<p>
 */
protected void initModule() {
    Object o;
    CmsModule module;
    // first get the correct module
    if (CmsStringUtil.isNotEmpty(m_paramModule)) {
        module = (CmsModule) OpenCms.getModuleManager().getModule(m_paramModule).clone();
    } else {
        // create a new module
        module = new CmsModule();
    }
    // now try to get the dependency
    if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
        o = null;
    } else {
        // this is not the initial call, get module dependency from session
        o = getDialogObject();
    }
    if (!(o instanceof CmsModuleDependency)) {
        if (m_paramDependency == null) {
            // there was no parameter given, so create a new, empty dependency
            m_dependency = new CmsModuleDependency();
        } else {
            // create a new module dependency by reading it from the module
            List dependencies = module.getDependencies();
            m_dependency = new CmsModuleDependency();
            if ((dependencies != null) && (dependencies.size() > 0)) {
                Iterator i = dependencies.iterator();
                while (i.hasNext()) {
                    CmsModuleDependency dependency = (CmsModuleDependency) i.next();
                    if (dependency.getName().equals(m_paramDependency)) {
                        m_dependency = dependency;
                    }
                }
            }
        }
    } else {
        // reuse module dependency stored in session
        m_dependency = (CmsModuleDependency) o;
    }
}
Also used : CmsModule(org.opencms.module.CmsModule) CmsModuleDependency(org.opencms.module.CmsModuleDependency) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with CmsModuleDependency

use of org.opencms.module.CmsModuleDependency in project opencms-core by alkacon.

the class CmsModulesDependenciesList method getListItems.

/**
 * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
 */
@Override
protected List getListItems() {
    List ret = new ArrayList();
    String moduleName = getParamModule();
    CmsModule module = OpenCms.getModuleManager().getModule(moduleName);
    // get dependencies
    List dependencies = module.getDependencies();
    Iterator i = dependencies.iterator();
    while (i.hasNext()) {
        CmsModuleDependency dependency = (CmsModuleDependency) i.next();
        CmsListItem item = getList().newItem(dependency.getName());
        // name
        item.set(LIST_COLUMN_NAME, dependency.getName());
        // version
        item.set(LIST_COLUMN_VERSION, dependency.getVersion());
        ret.add(item);
    }
    return ret;
}
Also used : CmsListItem(org.opencms.workplace.list.CmsListItem) CmsModule(org.opencms.module.CmsModule) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CmsModuleDependency(org.opencms.module.CmsModuleDependency) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with CmsModuleDependency

use of org.opencms.module.CmsModuleDependency in project opencms-core by alkacon.

the class CmsModulesUploadFromServer method actionCommit.

/**
 * @see org.opencms.workplace.CmsWidgetDialog#actionCommit()
 */
@Override
public void actionCommit() throws IOException, ServletException {
    List errors = new ArrayList();
    CmsModule module = null;
    try {
        String importpath = OpenCms.getSystemInfo().getPackagesRfsPath();
        importpath = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(importpath + "modules/" + m_moduleupload);
        module = CmsModuleImportExportHandler.readModuleFromImport(importpath);
        // check if all dependencies are fulfilled
        List dependencies = OpenCms.getModuleManager().checkDependencies(module, CmsModuleManager.DEPENDENCY_MODE_IMPORT);
        if (!dependencies.isEmpty()) {
            StringBuffer dep = new StringBuffer(32);
            for (int i = 0; i < dependencies.size(); i++) {
                CmsModuleDependency dependency = (CmsModuleDependency) dependencies.get(i);
                dep.append("\n - ");
                dep.append(dependency.getName());
                dep.append(" (Version: ");
                dep.append(dependency.getVersion());
                dep.append(")");
            }
            errors.add(new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTION_MODULE_DEPENDENCY_2, m_moduleupload, new String(dep))));
        }
    } catch (CmsConfigurationException e) {
        errors.add(new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTION_MODULE_UPLOAD_1, m_moduleupload), e));
    }
    if ((module != null) && errors.isEmpty()) {
        // refresh the list
        Map objects = (Map) getSettings().getListObject();
        if (objects != null) {
            objects.remove(CmsModulesList.class.getName());
        }
        // redirect
        Map param = new HashMap();
        param.put(CmsModulesList.PARAM_MODULE, m_moduleupload);
        param.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
        param.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(getJsp(), "/modules"));
        if (OpenCms.getModuleManager().hasModule(module.getName())) {
            param.put(PARAM_MODULENAME, module.getName());
            getToolManager().jspForwardPage(this, REPLACE_ACTION_REPORT, param);
        } else {
            getToolManager().jspForwardPage(this, IMPORT_ACTION_REPORT, param);
        }
    }
    // set the list of errors to display when saving failed
    setCommitErrors(errors);
}
Also used : CmsConfigurationException(org.opencms.configuration.CmsConfigurationException) CmsModule(org.opencms.module.CmsModule) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CmsModuleDependency(org.opencms.module.CmsModuleDependency) CmsRuntimeException(org.opencms.main.CmsRuntimeException) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with CmsModuleDependency

use of org.opencms.module.CmsModuleDependency in project opencms-core by alkacon.

the class CmsModuleImportFile method loadAndValidate.

/**
 * Loads the module data from the zip file and validates whether the module is importable, throwing an exception otherwise.<p>
 *
 * @throws CmsConfigurationException if the module is not importable for some reason
 */
public void loadAndValidate() throws CmsConfigurationException {
    CmsModule module = CmsModuleImportExportHandler.readModuleFromImport(m_path);
    m_module = module;
    List<CmsModuleDependency> dependencies = OpenCms.getModuleManager().checkDependencies(module, CmsModuleManager.DEPENDENCY_MODE_IMPORT);
    if (!dependencies.isEmpty()) {
        StringBuffer dep = new StringBuffer(32);
        for (int i = 0; i < dependencies.size(); i++) {
            CmsModuleDependency dependency = dependencies.get(i);
            dep.append("\n - ");
            dep.append(dependency.getName());
            dep.append(" (Version: ");
            dep.append(dependency.getVersion());
            dep.append(")");
        }
        throw new CmsConfigurationException(org.opencms.ui.apps.Messages.get().container(org.opencms.ui.apps.Messages.ERR_MODULEMANAGER_ACTION_MODULE_DEPENDENCY_2, m_path, new String(dep)));
    }
}
Also used : CmsConfigurationException(org.opencms.configuration.CmsConfigurationException) CmsModule(org.opencms.module.CmsModule) CmsModuleDependency(org.opencms.module.CmsModuleDependency)

Example 5 with CmsModuleDependency

use of org.opencms.module.CmsModuleDependency in project opencms-core by alkacon.

the class CmsImportFile method loadAndValidate.

/**
 *Class to load and validate import module file.<p>
 *
 * @throws CmsConfigurationException gets thrown when validation fails
 */
public void loadAndValidate() throws CmsConfigurationException {
    CmsModule module = CmsModuleImportExportHandler.readModuleFromImport(m_path);
    m_module = module;
    List<CmsModuleDependency> dependencies = OpenCms.getModuleManager().checkDependencies(module, CmsModuleManager.DEPENDENCY_MODE_IMPORT);
    if (!dependencies.isEmpty()) {
        StringBuffer dep = new StringBuffer(32);
        for (int i = 0; i < dependencies.size(); i++) {
            CmsModuleDependency dependency = dependencies.get(i);
            dep.append("\n - ");
            dep.append(dependency.getName());
            dep.append(" (Version: ");
            dep.append(dependency.getVersion());
            dep.append(")");
        }
    // throw new CmsConfigurationException(
    // org.opencms.ui.apps.Messages.get().container(
    // org.opencms.ui.apps.Messages.ERR_MODULEMANAGER_ACTION_MODULE_DEPENDENCY_2,
    // m_path,
    // new String(dep)));
    }
}
Also used : CmsModule(org.opencms.module.CmsModule) CmsModuleDependency(org.opencms.module.CmsModuleDependency)

Aggregations

CmsModuleDependency (org.opencms.module.CmsModuleDependency)13 CmsModule (org.opencms.module.CmsModule)11 Iterator (java.util.Iterator)8 List (java.util.List)8 ArrayList (java.util.ArrayList)6 CmsConfigurationException (org.opencms.configuration.CmsConfigurationException)6 Map (java.util.Map)3 CmsRuntimeException (org.opencms.main.CmsRuntimeException)3 HashMap (java.util.HashMap)2 CmsException (org.opencms.main.CmsException)2 CmsSecurityException (org.opencms.security.CmsSecurityException)2 CmsListItem (org.opencms.workplace.list.CmsListItem)2 BeanFieldGroup (com.vaadin.v7.data.fieldgroup.BeanFieldGroup)1 FieldGroup (com.vaadin.v7.data.fieldgroup.FieldGroup)1 CommitException (com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException)1 AbstractField (com.vaadin.v7.ui.AbstractField)1 Field (com.vaadin.v7.ui.Field)1 TextField (com.vaadin.v7.ui.TextField)1 CmsExportPoint (org.opencms.db.CmsExportPoint)1 CmsObject (org.opencms.file.CmsObject)1