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;
}
}
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;
}
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);
}
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)));
}
}
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)));
}
}
Aggregations