Search in sources :

Example 1 with CmsExportPoint

use of org.opencms.db.CmsExportPoint in project opencms-core by alkacon.

the class CmsExportpointsEdit method initModule.

/**
 * 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;
            }
        }
    }
}
Also used : CmsModule(org.opencms.module.CmsModule) Iterator(java.util.Iterator) CmsExportPoint(org.opencms.db.CmsExportPoint) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with CmsExportPoint

use of org.opencms.db.CmsExportPoint in project opencms-core by alkacon.

the class CmsExportpointsList 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 exportpoints
    List exportpoints = module.getExportPoints();
    Iterator i = exportpoints.iterator();
    while (i.hasNext()) {
        CmsExportPoint exportpoint = (CmsExportPoint) i.next();
        CmsListItem item = getList().newItem(exportpoint.getUri());
        // name
        item.set(LIST_COLUMN_URI, exportpoint.getUri());
        // destination
        item.set(LIST_COLUMN_DESTINATION, exportpoint.getConfiguredDestination());
        // server
        item.set(LIST_COLUMN_SERVERDESTINATION, exportpoint.getDestinationPath());
        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) CmsExportPoint(org.opencms.db.CmsExportPoint) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with CmsExportPoint

use of org.opencms.db.CmsExportPoint in project opencms-core by alkacon.

the class CmsExportpointsList method deleteExportpoint.

/**
 * Deletes a module exportpoint from a module.<p>
 *
 * @param module the module to delete the dependency from
 * @param exportpoint the name of the exportpoint to delete
 */
private void deleteExportpoint(CmsModule module, String exportpoint) {
    List oldExportpoints = module.getExportPoints();
    List newExportpoints = new ArrayList();
    Iterator i = oldExportpoints.iterator();
    while (i.hasNext()) {
        CmsExportPoint exp = (CmsExportPoint) i.next();
        if (!exp.getUri().equals(exportpoint)) {
            newExportpoints.add(exp);
        }
    }
    module.setExportPoints(newExportpoints);
    // update the module information
    try {
        OpenCms.getModuleManager().updateModule(getCms(), module);
    } catch (CmsConfigurationException ce) {
        // should never happen
        throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTION_EXPORTPOINTS_DELETE_2, exportpoint, module.getName()), ce);
    } catch (CmsRoleViolationException re) {
        throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ACTION_EXPORTPOINTS_DELETE_2, exportpoint, module.getName()), re);
    }
}
Also used : CmsConfigurationException(org.opencms.configuration.CmsConfigurationException) CmsRoleViolationException(org.opencms.security.CmsRoleViolationException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CmsRuntimeException(org.opencms.main.CmsRuntimeException) CmsExportPoint(org.opencms.db.CmsExportPoint) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with CmsExportPoint

use of org.opencms.db.CmsExportPoint in project opencms-core by alkacon.

the class CmsExportpointsOverview method initModule.

/**
 * 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;
            }
        }
    }
}
Also used : CmsModule(org.opencms.module.CmsModule) Iterator(java.util.Iterator) CmsExportPoint(org.opencms.db.CmsExportPoint) List(java.util.List)

Example 5 with CmsExportPoint

use of org.opencms.db.CmsExportPoint in project opencms-core by alkacon.

the class CmsModulesEditBase method createModuleFolders.

/**
 * Creates all module folders that are selected in the input form.<p>
 *
 * @param module the module
 *
 * @return the updated module
 *
 * @throws CmsException if somehting goes wrong
 */
private CmsModule createModuleFolders(CmsModule module) throws CmsException {
    String modulePath = CmsWorkplace.VFS_PATH_MODULES + module.getName() + "/";
    List<CmsExportPoint> exportPoints = module.getExportPoints();
    List<String> resources = module.getResources();
    // set the createModuleFolder flag if any other flag is set
    if (module.isCreateClassesFolder() || module.isCreateElementsFolder() || module.isCreateLibFolder() || module.isCreateResourcesFolder() || module.isCreateSchemasFolder() || module.isCreateTemplateFolder() || module.isCreateFormattersFolder()) {
        module.setCreateModuleFolder(true);
    }
    // check if we have to create the module folder
    int folderId = CmsResourceTypeFolder.getStaticTypeId();
    if (module.isCreateModuleFolder()) {
        getCms().createResource(modulePath, folderId);
        // add the module folder to the resource list
        resources.add(modulePath);
        module.setResources(resources);
    }
    // check if we have to create the template folder
    if (module.isCreateTemplateFolder()) {
        String path = modulePath + PATH_TEMPLATES;
        getCms().createResource(path, folderId);
    }
    // check if we have to create the elements folder
    if (module.isCreateElementsFolder()) {
        String path = modulePath + PATH_ELEMENTS;
        getCms().createResource(path, folderId);
    }
    if (module.isCreateFormattersFolder()) {
        String path = modulePath + PATH_FORMATTERS;
        getCms().createResource(path, folderId);
    }
    // check if we have to create the schemas folder
    if (module.isCreateSchemasFolder()) {
        String path = modulePath + PATH_SCHEMAS;
        getCms().createResource(path, folderId);
    }
    // check if we have to create the resources folder
    if (module.isCreateResourcesFolder()) {
        String path = modulePath + PATH_RESOURCES;
        getCms().createResource(path, folderId);
    }
    // check if we have to create the lib folder
    if (module.isCreateLibFolder()) {
        String path = modulePath + PATH_LIB;
        getCms().createResource(path, folderId);
        CmsExportPoint exp = new CmsExportPoint(path, "WEB-INF/lib/");
        exportPoints.add(exp);
        module.setExportPoints(exportPoints);
    }
    // check if we have to create the classes folder
    if (module.isCreateClassesFolder()) {
        String path = modulePath + PATH_CLASSES;
        getCms().createResource(path, folderId);
        CmsExportPoint exp = new CmsExportPoint(path, "WEB-INF/classes/");
        exportPoints.add(exp);
        module.setExportPoints(exportPoints);
        // now create all subfolders for the package structure
        StringTokenizer tok = new StringTokenizer(m_module.getName(), ".");
        while (tok.hasMoreTokens()) {
            String folder = tok.nextToken();
            path += folder + "/";
            getCms().createResource(path, folderId);
        }
    }
    return module;
}
Also used : StringTokenizer(java.util.StringTokenizer) CmsExportPoint(org.opencms.db.CmsExportPoint) CmsExportPoint(org.opencms.db.CmsExportPoint)

Aggregations

CmsExportPoint (org.opencms.db.CmsExportPoint)19 ArrayList (java.util.ArrayList)8 Iterator (java.util.Iterator)7 CmsModule (org.opencms.module.CmsModule)6 List (java.util.List)5 CmsConfigurationException (org.opencms.configuration.CmsConfigurationException)4 HashSet (java.util.HashSet)3 CmsObject (org.opencms.file.CmsObject)3 I_CmsResourceType (org.opencms.file.types.I_CmsResourceType)3 CmsLockException (org.opencms.lock.CmsLockException)3 CmsExplorerTypeSettings (org.opencms.workplace.explorer.CmsExplorerTypeSettings)3 StringTokenizer (java.util.StringTokenizer)2 Element (org.dom4j.Element)2 CmsResource (org.opencms.file.CmsResource)2 CmsException (org.opencms.main.CmsException)2 CmsSecurityException (org.opencms.security.CmsSecurityException)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