Search in sources :

Example 66 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class AbstractToolContainer method getBus.

public Bus getBus() {
    Bus bus = BusFactory.getDefaultBus();
    OASISCatalogManager catalogManager = bus.getExtension(OASISCatalogManager.class);
    String catalogLocation = getCatalogURL();
    if (!StringUtils.isEmpty(catalogLocation)) {
        try {
            catalogManager.loadCatalog(new URI(catalogLocation).toURL());
        } catch (Exception e) {
            e.printStackTrace(err);
            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG, catalogLocation));
        }
    }
    return bus;
}
Also used : Bus(org.apache.cxf.Bus) Message(org.apache.cxf.common.i18n.Message) OASISCatalogManager(org.apache.cxf.catalog.OASISCatalogManager) ToolException(org.apache.cxf.tools.common.ToolException) URI(java.net.URI) IOException(java.io.IOException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 67 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class AbstractToolContainer method init.

public void init() throws ToolException {
    // initialize
    if (toolspec == null) {
        Message message = new Message("TOOLSPEC_NOT_INITIALIZED", LOG);
        LOG.log(Level.SEVERE, message.toString());
        throw new ToolException(message);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) ToolException(org.apache.cxf.tools.common.ToolException)

Example 68 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class VelocityGenerator method parseOutputName.

public File parseOutputName(String packageName, String filename, String ext) throws ToolException {
    FileUtils.mkDir(new File(this.baseDir));
    FileWriterUtil fw = new FileWriterUtil(this.baseDir, null);
    try {
        return fw.getFileToWrite(packageName, filename + ext);
    } catch (IOException ioe) {
        Message msg = new Message("FAIL_TO_WRITE_FILE", LOG, packageName + "." + filename + ext);
        throw new ToolException(msg, ioe);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) FileWriterUtil(org.apache.cxf.tools.util.FileWriterUtil) IOException(java.io.IOException) File(java.io.File)

Example 69 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WSDLRefValidator method collectValidationPointsForMessages.

private void collectValidationPointsForMessages() {
    for (QName msgName : messageRefNames) {
        javax.wsdl.Message message = getMessage(msgName);
        for (Iterator<?> iter = message.getParts().values().iterator(); iter.hasNext(); ) {
            Part part = (Part) iter.next();
            QName elementName = part.getElementName();
            QName typeName = part.getTypeName();
            if (elementName == null && typeName == null) {
                vResults.addError(new Message("PART_NO_TYPES", LOG));
                continue;
            }
            if (elementName != null && typeName != null) {
                vResults.addError(new Message("PART_NOT_UNIQUE", LOG));
                continue;
            }
            if (elementName != null && typeName == null) {
                boolean valid = validatePartType(elementName.getNamespaceURI(), elementName.getLocalPart(), true);
                if (!valid) {
                    vResults.addError(new Message("TYPE_REF_NOT_FOUND", LOG, message.getQName(), part.getName(), elementName));
                }
            }
            if (typeName != null && elementName == null) {
                boolean valid = validatePartType(typeName.getNamespaceURI(), typeName.getLocalPart(), false);
                if (!valid) {
                    vResults.addError(new Message("TYPE_REF_NOT_FOUND", LOG, message.getQName(), part.getName(), typeName));
                }
            }
        }
    }
}
Also used : XMessage(org.apache.cxf.tools.validator.internal.model.XMessage) Message(org.apache.cxf.common.i18n.Message) QName(javax.xml.namespace.QName) Part(javax.wsdl.Part)

Example 70 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WSDLRefValidator method collectValidationPointsForPortTypes.

private void collectValidationPointsForPortTypes() {
    for (QName ptName : portTypeRefNames) {
        PortType portType = getPortType(ptName);
        if (portType == null) {
            vResults.addError(new Message("NO_PORTTYPE", LOG, ptName));
            continue;
        }
        XNode vPortTypeNode = getXNode(portType);
        for (Operation operation : getOperations(portType).values()) {
            XNode vOperationNode = getOperationXNode(vPortTypeNode, operation.getName());
            if (operation.getInput() == null) {
                vResults.addError(new Message("WRONG_MEP", LOG, operation.getName(), portType.getQName()));
                continue;
            }
            javax.wsdl.Message inMsg = operation.getInput().getMessage();
            if (inMsg == null) {
                addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no input message");
            } else {
                XNode vInMsgNode = getXNode(inMsg);
                vInMsgNode.setFailurePoint(getInputXNode(vOperationNode, operation.getInput().getName()));
                vNodes.add(vInMsgNode);
                messageRefNames.add(inMsg.getQName());
            }
            if (operation.getOutput() != null) {
                javax.wsdl.Message outMsg = operation.getOutput().getMessage();
                if (outMsg == null) {
                    addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no output message");
                } else {
                    XNode vOutMsgNode = getXNode(outMsg);
                    vOutMsgNode.setFailurePoint(getOutputXNode(vOperationNode, operation.getOutput().getName()));
                    vNodes.add(vOutMsgNode);
                    messageRefNames.add(outMsg.getQName());
                }
            }
            for (Iterator<?> iter = operation.getFaults().values().iterator(); iter.hasNext(); ) {
                Fault fault = (Fault) iter.next();
                javax.wsdl.Message faultMsg = fault.getMessage();
                XNode vFaultMsgNode = getXNode(faultMsg);
                vFaultMsgNode.setFailurePoint(getFaultXNode(vOperationNode, fault.getName()));
                vNodes.add(vFaultMsgNode);
                messageRefNames.add(faultMsg.getQName());
            }
        }
    }
}
Also used : XMessage(org.apache.cxf.tools.validator.internal.model.XMessage) Message(org.apache.cxf.common.i18n.Message) QName(javax.xml.namespace.QName) XNode(org.apache.cxf.tools.validator.internal.model.XNode) Fault(javax.wsdl.Fault) XFault(org.apache.cxf.tools.validator.internal.model.XFault) Operation(javax.wsdl.Operation) XOperation(org.apache.cxf.tools.validator.internal.model.XOperation) BindingOperation(javax.wsdl.BindingOperation) PortType(javax.wsdl.PortType) XPortType(org.apache.cxf.tools.validator.internal.model.XPortType)

Aggregations

Message (org.apache.cxf.common.i18n.Message)201 ToolException (org.apache.cxf.tools.common.ToolException)69 IOException (java.io.IOException)45 QName (javax.xml.namespace.QName)42 Fault (org.apache.cxf.interceptor.Fault)34 XMLStreamException (javax.xml.stream.XMLStreamException)27 JAXBException (javax.xml.bind.JAXBException)23 ArrayList (java.util.ArrayList)19 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)17 Element (org.w3c.dom.Element)17 File (java.io.File)16 WSDLException (javax.wsdl.WSDLException)15 Method (java.lang.reflect.Method)14 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)13 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)12 InputStream (java.io.InputStream)11 HashMap (java.util.HashMap)11 List (java.util.List)11 Map (java.util.Map)11 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)11