Examples of ModuleMgtException


Examples of org.wso2.carbon.module.mgt.ModuleMgtException

                                               String operationName) throws ModuleMgtException {

        AxisService service = axisConfig.getServiceForActivation(serviceName);
        if (service == null) {
            log.error("Service  " + serviceName + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.SERVICE_NOT_FOUND);
        }

        AxisOperation operation = service.getOperation(new QName(operationName));
        if (operation == null) {
            log.error("Operation  " + operationName + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.OPERATION_NOT_FOUND);
        }

        AxisModule module = axisConfig.getModule(moduleId);
        if (module == null) {
            log.error("Module  " + moduleId + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.OPERATION_NOT_FOUND);
        }

        if (operation.isEngaged(module)) {
            if (RAMPART_MODULE_NAME.equalsIgnoreCase(module.getName())) {
                // Check whether it is possible to disengage Rampart
                AxisModule rahasModule = axisConfig.getModule(RAHAS_MODULE_NAME);
                if (operation.isEngaged(rahasModule)) {
                    throw new ModuleMgtException(ModuleMgtException.WARNING, ModuleMgtMessageKeys.RAHAS_RAMPART_DISENGAGE);
                }
            }

            try {
                pf.getOperationPM().disengageModuleForOperation(module, operation);
                operation.disengageModule(module);

            } catch (Exception e) {
                String msg = "Error occured while disengaging the module " + moduleId
                        + " from operation " + operationName;
                log.error(msg, e);
                throw new ModuleMgtException(e, ModuleMgtException.ERROR, ModuleMgtMessageKeys.ERROR_DISENGAGE);
            }
        }

        return true;
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

    }

    public boolean globallyDisengageModule(String moduleId) throws ModuleMgtException {

        if (moduleId.startsWith("addressing")) {
            throw new ModuleMgtException(ModuleMgtException.WARNING, ModuleMgtMessageKeys.DISENGAGE_ADDRESSING_GLOBALLY);
        }

        AxisModule module = axisConfig.getModule(moduleId);
        if (module == null) {
            log.error("Module  " + moduleId + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }

        try {
            disengageModuleFromSystem(moduleId);
        } catch (ModuleMgtException e) {
            throw e;
        } catch (Exception e) {
            String msg = "Error occured while globally disengaging the module " + moduleId;
            log.error(msg, e);
            throw new ModuleMgtException(e, ModuleMgtException.ERROR, ModuleMgtMessageKeys.ERROR_DISENGAGE);
        }

        return true;
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

    private AxisModule getAxisModule(String moduleId, String moduleVersion) throws ModuleMgtException {
        AxisModule module = this.axisConfig.getModule(moduleId, moduleVersion);

        if (module == null) {
            log.error("Module  " + moduleId + "-" + moduleVersion + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }

        return module;
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

    private AxisModule getAxisModule(String moduleId) throws ModuleMgtException {
        AxisModule module = this.axisConfig.getModule(moduleId);
        if (module == null) {
            log.error("Module  " + moduleId + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }
        return module;
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

    public String[] getModuleParameters(String moduleName, String moduleVersion) throws ModuleMgtException {

        AxisModule module = getAxisModule(moduleName, moduleVersion);
        if (module == null) {
            log.error("Module  " + module + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }

        ArrayList<String> parameters = new ArrayList<String>();

        ArrayList moduleParams = module.getParameters();
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

    private String setModuleParameter(String moduleName, String moduleVersion, String parameterStr) throws ModuleMgtException {

        AxisModule module = getAxisModule(moduleName, moduleVersion);
        if (module == null) {
            log.error("Module  " + module + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }

        OMElement paramEle;
        try {
            XMLStreamReader xmlSR = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(
                    parameterStr.getBytes()));
            paramEle = new StAXOMBuilder(xmlSR).getDocumentElement();
        } catch (XMLStreamException e) {
            String msg = "Cannot create OMElement from parameter: " + parameterStr;
            log.error(msg, e);
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.ERROR_PARAM_REMOVE);
        }

        try {
            Parameter parameter = ParameterUtil.createParameter(paramEle);
            if (module.getParameter(parameter.getName()) == null || !module.getParameter(parameter.getName()).isLocked()) {
                module.addParameter(parameter);
                pf.getModulePM().updateModuleParameter(module, parameter);
            }
        } catch (Exception e) {
            String msg = "Cannot persist module parameter for operation " + module.getName();
            log.error(msg, e);
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.ERROR_PARAM_REMOVE);
        }

        return "Succesfully updated service parameters";
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

    public String removeModuleParameter(String moduleName, String moduleVersion, String parameterName) throws ModuleMgtException {

        AxisModule module = getAxisModule(moduleName, moduleVersion);
        if (module == null) {
            log.error("Module  " + module + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }

       try {
            Parameter parameter = ParameterUtil.createParameter(parameterName, null);
            module.removeParameter(parameter);
            pf.getModulePM().removeModuleParameter(module, parameter);
        } catch (Exception e) {
            String msg = "Cannot persist parameter removal from module  " + module.getName();
            log.error(msg, e);
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.ERROR_PARAM_REMOVE);
        }

        return "Successfully removed parameter " + parameterName + " from " + moduleName + ":" + moduleVersion + " module";
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

        // We cannot delete items from a URL repo
        // First lets filter for jar resources
        String repo = getAxisConfig().getRepository().getPath();

        if (CarbonUtils.isURL(repo)) {
            throw new ModuleMgtException(ModuleMgtException.WARNING, ModuleMgtMessageKeys.URL_REPO);
        }

        // We cannot remove the addressing module if at least one service is
        // deployed in soapsession scope
        if (moduleId.startsWith("addressing")) {
            throw new ModuleMgtException(ModuleMgtException.WARNING,
                                         ModuleMgtMessageKeys.DISENGAGE_ADDRESSING_GLOBALLY);
        }

        // Check whether this file can be deleted.
        // We should proceed only if this file can be deleted.
        AxisModule module = axisConfig.getModule(moduleId);
        if (module == null) {
            log.error("Module  " + moduleId + "cannnot be found!");
            throw new ModuleMgtException(ModuleMgtException.ERROR,
                                         ModuleMgtMessageKeys.MODULE_NOT_FOUND);
        }

        if (module.getFileName() != null) {
            String fileName = module.getFileName().getPath();
            File file = new File(fileName);
            if (!file.canWrite()) {
                throw new ModuleMgtException(ModuleMgtException.WARNING,
                                             ModuleMgtMessageKeys.MODULE_DELETE_ERROR);
            }

            if (isEngaged(module)) {
                throw new ModuleMgtException(ModuleMgtException.WARNING,
                                             ModuleMgtMessageKeys.ENGAGED_MODULE_REMOVE);
            }
           
            disengageModuleFromSystem(moduleId);

            // Delete the MAR file
            if (file.exists()) {
                if (!(file.isDirectory() && FileManipulator.deleteDir(file))) {
                    if (!file.delete()) {
                        throw new ModuleMgtException(ModuleMgtException.WARNING,
                                                     ModuleMgtMessageKeys.MODULE_DELETE_ERROR);
                    }
                }
            } else {
                throw new ModuleMgtException(ModuleMgtException.WARNING,
                                             ModuleMgtMessageKeys.MODULE_FILE_NOT_FOUND);
            }
        } else {
            throw new ModuleMgtException(ModuleMgtException.WARNING,
                                         ModuleMgtMessageKeys.SYSTEM_MODULE_DELETE);
        }

        try {
            pf.getModulePM().removeModule(module);
            axisConfig.removeModule(module.getName(), module.getVersion());
        } catch (Exception e) {
            log.error("Error while removing module : " + moduleId, e);
            throw new ModuleMgtException(ModuleMgtException.WARNING, ModuleMgtMessageKeys.ERROR_MODULE_REMOVE);
        }

        return "Module " + moduleId + " was successfully removed from system";
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

     * @throws ModuleMgtException if we can't disengage the module globally
     */
    public boolean disengageModuleFromSystem(String moduleId)
            throws ModuleMgtException {
        if (moduleId.startsWith("addressing")) {
            throw new ModuleMgtException(ModuleMgtException.WARNING,
                                         ModuleMgtMessageKeys.DISENGAGE_ADDRESSING_GLOBALLY);
        }
        AxisModule module = getAxisModule(moduleId);
        try {
            if (axisConfig.isEngaged(module)) {
                if (RAHAS_MODULE_NAME.equalsIgnoreCase(module.getName()) || RAMPART_MODULE_NAME.equalsIgnoreCase(module.getName())) {
                    Map services = axisConfig.getServices();
                    for (Iterator iter = services.values().iterator(); iter.hasNext();) {
                        AxisService service = (AxisService) iter.next();

                        if (isRequiredForSecurityScenario(service.getName(), moduleId)) {
                            throw new ModuleMgtException(ModuleMgtException.WARNING,
                                    ModuleMgtMessageKeys.SERVICES_WITH_SECURITY_SCENARIOS);
                        }
                    }
                }

                if (RAMPART_MODULE_NAME.equalsIgnoreCase(module.getName())) {
                    // Check whether it is possible to disengage Rampart
                    AxisModule rahasModule = axisConfig.getModule(RAHAS_MODULE_NAME);
                    if (axisConfig.isEngaged(rahasModule)) {
                        throw new ModuleMgtException(ModuleMgtException.WARNING,
                                                     ModuleMgtMessageKeys.RAHAS_RAMPART_DISENGAGE);
                    }
                }

                // store the global engagement status
                pf.getModulePM().globallyDisengageModule(module);
                axisConfig.disengageModule(module);
                Parameter param = new Parameter(GLOBALLY_ENGAGED_PARAM_NAME, Boolean.FALSE.toString());
                module.addParameter(param);
            }
        } catch (ModuleMgtException e) {
            throw e;
        } catch (Exception e) {
            log.error("Error occurred while disengaging module " + module.getName(), e);
            throw new ModuleMgtException(ModuleMgtException.ERROR, ModuleMgtMessageKeys.ERROR_GLOBAL_DISENGAGE);
        }

        return true;
    }
View Full Code Here

Examples of org.wso2.carbon.module.mgt.ModuleMgtException

                    ,axisConfig);
            requiredModules = secConfAdmin.getRequiredModules(serviceName, moduleId);
        } catch (Exception e) {
            String msg = "Error occured while getting the security scenarions for the service";
            log.error(msg);
            throw new ModuleMgtException(e, ModuleMgtException.ERROR, ModuleMgtMessageKeys.SEC_SCENARIO_ERROR);
        }

        if (requiredModules == null) {
            return false;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.