Package org.apache.axis2.deployment

Examples of org.apache.axis2.deployment.DeploymentException


    protected SynapseEnvironment getSynapseEnvironment() throws DeploymentException {
        Parameter synCfgParam =
                cfgCtx.getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_ENV);
        if (synCfgParam == null) {
            throw new DeploymentException("SynapseEnvironment not found. " +
                    "Are you sure that you are running Synapse?");
        }
        return (SynapseEnvironment) synCfgParam.getValue();
    }
View Full Code Here


            throws DeploymentException {
        Parameter serverCfgParam =
                cfgCtx.getAxisConfiguration().getParameter(
                        SynapseConstants.SYNAPSE_SERVER_CONFIG_INFO);
        if (serverCfgParam == null) {
            throw new DeploymentException("SynapseConfigurationInformation not found. " +
                    "Are you sure that you are running Synapse?");
        }
        return (ServerConfigurationInformation) serverCfgParam.getValue();
    }
View Full Code Here

            throws DeploymentException {
        Parameter serverCtxParam =
                cfgCtx.getAxisConfiguration().getParameter(
                        SynapseConstants.SYNAPSE_SERVER_CTX_INFO);
        if (serverCtxParam == null) {
            throw new DeploymentException("ServerContextInformation not found. " +
                    "Are you sure that you are running Synapse?");
        }
        return (ServerContextInformation) serverCtxParam.getValue();
    }
View Full Code Here

        Object operationNameObject = function.get(JSConstants.OPERATION_NAME_ANNOTATION,
                                                  function);
        if (operationNameObject instanceof String) {
            String operationNameString = ((String) operationNameObject).trim();
            if (operationNameString.indexOf(' ') > -1) {
                throw new DeploymentException("Value of the operationName annotation ('"
                        + operationNameString + "') should be a single word.");
            }
            operationName = (String) operationNameObject;
        } else {
            operationName = functionName;
        }

        // Check weather the user provided inputTypes
        inputTypesNameObject = function.get(JSConstants.INPUT_TYPES_ANNOTATION, function);

        // Check weather the user provided a outputType
        outputTypeNameObject = function.get(JSConstants.OUTPUT_TYPE_ANNOTATION, function);

        // Check weather the user marked this operation as been safe
        Object safeObject = function.get(JSConstants.SAFE_ANNOTATION, function);
        if (safeObject == null || safeObject instanceof Undefined ||
                safeObject instanceof UniqueTag) {
            safe = null;
        } else {
            safe = JSUtils.isJSObjectTrue(true, safeObject);
        }

        // Check weather the user provided some operation level documentation. If the documentation
        // is a String we wrap it as a OMText. Else if its an E4X XML object we get the axiom from
        // it and set that as the documentation.
        Object documentationObject = function.get(JSConstants.DOCUMENTATION_ANNOTATION,
                                                  function);
        if (documentationObject instanceof String) {
            String documentationString = (String) documentationObject;
            //todo
//            String s = JSUtils.sanitizeHtml(documentationString);
            this.documentation =
                    omFactory.createOMText(documentationString);
        } else if (documentationObject instanceof XML) {
            XML xml = (XML) documentationObject;
            OMNode axiom = xml.getAxiomFromXML();
            this.documentation = axiom;
            //todo
            /*try {
                OMNode node = JSUtils.getSanizedHTMLAsOMNode(axiom.toString());
                this.documentation = node;
            } catch (XMLStreamException e) {
                throw new DeploymentException("The documentation for the operation " + operationName +
                        " is not well formed. Please make sure that the documentation is a " +
                        "String or valid XML");
            }*/
        }

        // Check weather the user provided a httpMethod
        Object httpMethodObject = function.get(JSConstants.HTTP_METHOD_ANNOTATION, function);
        if (httpMethodObject instanceof String) {
            String httpMethodString = ((String) httpMethodObject).trim();
            if (!(HTTPConstants.HEADER_GET.equalsIgnoreCase(httpMethodString) ||
                    HTTPConstants.HEADER_POST.equalsIgnoreCase(httpMethodString)
                    || HTTPConstants.HEADER_PUT.equalsIgnoreCase(httpMethodString) ||
                    HTTPConstants.HEADER_DELETE.equalsIgnoreCase(httpMethodString))) {
                throw new DeploymentException(
                        "Invalid httpMethod annotation on operation " + operationName
                                + ". The httpMthod annotation can accept only the values " +
                                "GET, POST, PUT or DELETE");
            }
            httpMethod = httpMethodString;
View Full Code Here

        String jsPathRelative = getJSPathRelative(jsFilePath, jsRepository);

        StringTokenizer tokenizer = new StringTokenizer(jsPathRelative, File.separator);

        if (tokenizer.countTokens() < 2) {
            throw new DeploymentException("*.js files cannot be place at " + jsPathRelative +
                    " and should be placed as jsservices/foo/bar.js");
        } else if (tokenizer.countTokens() > 2) {
            return;
        }

        String username = tokenizer.nextToken();

        //state variable kept to check if the service was successfully deployed at the end
        boolean successfullyDeployed = false;
        String serviceStatus = null;
        String jsFileName = deploymentFileData.getName();
        try {
            deploymentFileData.setClassLoader(axisConfig.getServiceClassLoader());
            AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig);
            serviceGroup.setServiceGroupClassLoader(deploymentFileData.getClassLoader());

            ArrayList serviceList =
                    processService(deploymentFileData, serviceGroup, configCtx, username);

            DeploymentEngine.addServiceGroup(serviceGroup, serviceList,
                    deploymentFileData.getFile().toURI().toURL(), deploymentFileData, axisConfig);

            log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, jsFileName,
                    deploymentFileData.getFile().toURI().toURL().toString()));

            super.deploy(deploymentFileData);
            successfullyDeployed = true;
        } catch (DeploymentException deploymentException) {
            log.error("The service " + jsFileName + " is not valid.", deploymentException);
            serviceStatus = "Error:\n" + deploymentException.getMessage();

            throw deploymentException;
        } catch (Throwable t) {
            /*
            Even though catching Throwable is not recommended, we do not want
            the server to fail on errors like NoClassDefFoundError
            */
            log.error("The service " + jsFileName + " is not valid.", t);
            serviceStatus = "Error:\n" + t.getMessage();

            throw new DeploymentException(t);
        } finally {
            /*
            Now if the service was not deployed successfully we need to update the registry saying
            that this service was faulty
            */
 
View Full Code Here

            configCtx.removeServiceGroupContext(group);
            super.undeploy(jsFilePath);
            log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED, serviceGroupName));

        } catch (AxisFault axisFault) {
            throw new DeploymentException(axisFault);
        }
    }
View Full Code Here

                                parameterElement.setText((String) propertyValueObject);
                                Parameter param = new Parameter(propertyName, propertyValueObject);
                                param.setParameterElement(parameterElement);
                                axisService.addParameter(param);
                            } catch (AxisFault axisFault) {
                                throw new DeploymentException(
                                        "Error adding service parameter : " + propertyName,
                                        axisFault);
                            }
                        } else if (propertyValueObject instanceof XML) {
                            XML xml = (XML) propertyValueObject;
                            OMNode axiom = xml.getAxiomFromXML();
                            try {
                                OMFactory factory = OMAbstractFactory.getOMFactory();
                                OMElement parameterElement = factory.createOMElement("parameter", null);
                                parameterElement.addAttribute("name", propertyName, null);
                                parameterElement.addChild(axiom);
                                Parameter param = new Parameter(propertyName, axiom);
                                param.setParameterElement(parameterElement);
                                axisService.addParameter(param);
                            } catch (AxisFault axisFault) {
                                throw new DeploymentException(
                                        "Error adding service parameter : " + propertyName,
                                        axisFault);
                            }
                        } else if (propertyValueObject instanceof XMLList) {
                            XMLList list = (XMLList) propertyValueObject;
                            OMNode[] omNodes = list.getAxiomFromXML();
                            try {
                                OMFactory factory = OMAbstractFactory.getOMFactory();
                                OMElement parameterElement = factory.createOMElement("parameter", null);
                                parameterElement.addAttribute("name", propertyName, null);
                                for (OMNode node : omNodes) {
                                    parameterElement.addChild(node);
                                }
                                Parameter param = new Parameter(propertyName, omNodes);
                                param.setParameterElement(parameterElement);
                                axisService.addParameter(param);
                            } catch (AxisFault axisFault) {
                                throw new DeploymentException(
                                        "Error adding service parameter : " + propertyName,
                                        axisFault);
                            }
                        } else {
                            throw new DeploymentException("Invalid property value specified for " +
                                    "\"serviceProperties\" annotation : " + propertyName +
                                    ". You should provide a string for property value.");
                        }
                    } else {
                        throw new DeploymentException("Invalid property name specified for " +
                                "\"serviceProperties\" annotation : " + propertyNameObject);
                    }
                }
            }

            /*
            Checks the validity of the serviceName. If the serviceName is invalid an exception is
            thrown
            */
            JSUtils.validateName(serviceName, SERVICE_NAME);

            /*
            Although Mashup Server supports only one service per *.js file at the moment, we set
            the service group name as a combination of author name and *.js file name. If the
            mashup was created manually on the file system, then the parent directory of the
            mashup will be used as the prefix.
             */
            axisServiceGroup.setServiceGroupName(
                    username + MashupConstants.SEPARATOR_CHAR + jsFileNameShort);
            /*
            All mashup services are deployed under the authors name with the help of Axis2's
            hierarchical service deployment model. So each service name is prefixed
            by author name.
             */
            axisService.setName(username + MashupConstants.SEPARATOR_CHAR + serviceName);

            // Sets the namespace map which is defined using this.targetNamespace
            String targetNamespace = serviceAnnotationParser.getTargetNamespace();
            axisService.setTargetNamespace(targetNamespace);

            /*
            Sets the scope of the service, this is defined as a service level annotation in the mashup i.e.
            this.scope = "application | soapsession | transportsession | request"
             */
            axisService.setScope(serviceAnnotationParser.getServiceScope());
            // Sets service documentation which is defined using this.documentation annotation
            axisService.setDocumentation(serviceAnnotationParser.getServiceDocumentation());
            // Sets the namespace map which is defined using this.schemaTargetNamespace
            SchemaGenerator schemaGenerator =
                    new SchemaGenerator(serviceAnnotationParser.getSchemaTargetNamespace());
            axisService.setNamespaceMap(schemaGenerator.getNamespaceMap());

            /*
            The interfaceName is used by org.apache.axis2.description.AxisService2WSDL20 to
            set the interface during ?wsdl2
            */
            String interfaceName = serviceName + WSDL2Constants.INTERFACE_PREFIX;
            axisService.addParameter(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);

            /*
            Set a comparator so tha httpLocations are stored in descending order. We want the
            HTTPLocationBasedDiapatcher to make the best match hence we need them in descending
            order
            */
            httpLocationTable = new TreeMap<String, AxisOperation>(new Comparator() {
                public int compare(Object o1, Object o2) {
                    return (-1 * ((Comparable) o1).compareTo(o2));
                }
            });

            /*
            We create the AxisBinding Hierarchy in here. In the Mashup Server we take complete
            control of the Axis2 binding hierarchy cause we need to specify some HTTPBinding
            properties such as httpMethod and httpLocation
            */
            String bindingPrefix = username.replace('/', '-') + "-" + serviceName + "-";
            // Create a default SOAP 1.1 Binding
            createDefaultSOAP11Binding(bindingPrefix, interfaceName);

            // Create a default SOAP 1.2 Binding
            createDefaultSOAP12Binding(bindingPrefix, interfaceName);

            // Create a default HTTP Binding
            createDefaultHTTPBinding(bindingPrefix, interfaceName);

            /*
            We need to get all transports from the axis2 engine and create endpoints for each of
            those in here
            */
            createDefaultEndpoints(axisService);

            // Obtain the list of functions in the java script service and process each one of them.
            Object[] ids = engine.getIds();
            for (Object id : ids) {
                String method = (String) id;
                Object object = engine.get(method, engine);
                // some id's are not functions
                if (object instanceof Function) {
                    processOperation(engine, axisService, method, (Function) object,
                            schemaGenerator, targetNamespace);
                }
            }
            axisService.addSchema(schemaGenerator.getSchema());

            Function init = serviceAnnotationParser.getInit();
            Function destroy = serviceAnnotationParser.getDestroy();

            /*
            this.init and this.destroy correspond to service lifecycle functions.
            this.init is called upon service deployment and this.destroy is called on
            undeployment.
            */
            if (init != null) {
                JavaScriptEngineUtils.loadHostObjects(engine, serviceName);
                init.call(engine.getCx(), engine, engine, new Object[0]);
            }

            if (destroy != null) {
                axisService.addParameter(JSConstants.MASHUP_DESTROY_FUNCTION, destroy);
            }

            ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
            serviceList.add(axisService);
            return serviceList;
        } catch (FileNotFoundException e) {
            throw new DeploymentException("JS Service File Not Found", e);
        } catch (IOException e) {
            throw new DeploymentException(e);
        } catch (CarbonException e) {
            throw new DeploymentException(e);
        }
    }
View Full Code Here

            */
            JSUtils.validateName(operationName, OPERATION_NAME);

            AxisOperation operation = axisService.getOperation(new QName(operationName));
            if (operation != null) {
                throw new DeploymentException("There is a conflict in operation names. A " +
                        "function with the name (or a function containing the operationNmae " +
                        "annotation as) " + operationName + " already exists. ");
            }

            //We always assume that our operations are inout operations
            AxisOperation axisOperation = new InOutAxisOperation(new QName(operationName));

            Boolean safe = annotationParser.isSafe();
            if (safe != null) {
                Parameter safeParameter = new Parameter(WSDL2Constants.ATTR_WSDLX_SAFE, safe);
                axisOperation.addParameter(safeParameter);
            }

            String httpLocation = annotationParser.getHttpLocation();

            /*
            If the user did not specify a httpLocation default it to operationName
            cause this is the default that axis2 uses
            */
            if (httpLocation != null) {
                if (!httpLocation.startsWith("{{") && httpLocation.startsWith("{")) {
                    /*
                    We cannot extract parameters off the URL in situations such as
                    foo.httpLocation="{param}"; Rather it should be
                    foo.httpLocation="bar/{param}";
                    */
                    throw new DeploymentException(
                            "The httpLocation Annotation of operation " + operationName +
                                    " is invalid. The httpLocation found was \"" + httpLocation +
                                    "\". The httpLocation should not start with a parameter. " +
                                    "Please include a constant part at the start of the templete.");
                }
View Full Code Here

        engine.getCx().evaluateString(engine, sourceStr, "", 0, null);

        // Get the function from the scope the javascript object is in
        Object fObj = engine.get("org_wso2_mashup_ConvertToString", engine);
        if (!(fObj instanceof Function) || (fObj == Scriptable.NOT_FOUND)) {
            throw new DeploymentException("Method " + "org_wso2_mashup_ConvertToString" +
                    " is undefined or not a function");
        }

        Object functionArgs[] = {};
        Function f = (Function) fObj;
View Full Code Here

    }


    private void handleException(String msg) throws DeploymentException {
        log.error(msg);
        throw new DeploymentException(msg);
    }
View Full Code Here

TOP

Related Classes of org.apache.axis2.deployment.DeploymentException

Copyright © 2018 www.massapicom. 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.