Search in sources :

Example 71 with Message

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

the class SchemaResourceResolver method resolveResource.

public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    Message msg = new Message("RESOLVE_SCHEMA", LOG, namespaceURI, systemId, baseURI);
    LOG.log(Level.FINE, msg.toString());
    if (NSFILEMAP.containsKey(namespaceURI)) {
        return loadLSInput(namespaceURI);
    }
    LSInput lsin = null;
    String resURL = null;
    if (systemId != null) {
        String schemaLocation = "";
        if (baseURI != null) {
            schemaLocation = baseURI.substring(0, baseURI.lastIndexOf('/') + 1);
        }
        if (systemId.indexOf("http://") < 0) {
            resURL = schemaLocation + systemId;
        } else {
            resURL = systemId;
        }
    } else if (namespaceURI != null) {
        resURL = namespaceURI;
    }
    if (resURL == null) {
        return null;
    }
    String localFile = resURL;
    if (resURL.startsWith("http://")) {
        String filename = NSFILEMAP.get(resURL);
        if (filename != null) {
            localFile = ToolConstants.CXF_SCHEMAS_DIR_INJAR + filename;
        }
    }
    try {
        msg = new Message("RESOLVE_FROM_LOCAL", LOG, localFile);
        LOG.log(Level.FINE, msg.toString());
        @SuppressWarnings("resource") final URIResolver resolver = new URIResolver(localFile);
        if (resolver.isResolved()) {
            lsin = new LSInputImpl();
            lsin.setSystemId(localFile);
            lsin.setByteStream(resolver.getInputStream());
        }
    } catch (IOException e) {
        return null;
    }
    return lsin;
}
Also used : LSInputImpl(org.apache.cxf.common.xmlschema.LSInputImpl) Message(org.apache.cxf.common.i18n.Message) LSInput(org.w3c.dom.ls.LSInput) URIResolver(org.apache.cxf.resource.URIResolver) IOException(java.io.IOException)

Example 72 with Message

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

the class UndertowHTTPServerEngine method addServant.

@Override
public void addServant(URL url, UndertowHTTPHandler handler) {
    if (shouldCheckUrl(handler.getBus())) {
        checkRegistedContext(url);
    }
    if (server == null) {
        try {
            // create a new undertow server instance if there is no server there
            String contextName = HttpUriMapper.getContextName(url.getPath());
            servletContext = buildServletContext(contextName);
            handler.setServletContext(servletContext);
            server = createServer(url, handler);
            server.start();
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "START_UP_SERVER_FAILED_MSG", new Object[] { e.getMessage(), port });
            // problem starting server
            try {
                server.stop();
            } catch (Exception ex) {
            // ignore - probably wasn't fully started anyway
            }
            server = null;
            throw new Fault(new Message("START_UP_SERVER_FAILED_MSG", LOG, e.getMessage(), port), e);
        }
    } else {
        String contextName = HttpUriMapper.getContextName(url.getPath());
        try {
            servletContext = buildServletContext(contextName);
        } catch (ServletException e) {
            throw new Fault(new Message("START_UP_SERVER_FAILED_MSG", LOG, e.getMessage(), port), e);
        }
        handler.setServletContext(servletContext);
        if (handler.isContextMatchExact()) {
            path.addExactPath(url.getPath(), handler);
        } else {
            path.addPrefixPath(url.getPath(), handler);
        }
    }
    final String smap = HttpUriMapper.getResourceBase(url.getPath());
    handler.setName(smap);
    registedPaths.put(url.getPath(), handler);
    servantCount = servantCount + 1;
}
Also used : ServletException(javax.servlet.ServletException) Message(org.apache.cxf.common.i18n.Message) Fault(org.apache.cxf.interceptor.Fault) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 73 with Message

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

the class NettyHttpServletHandler method channelRead.

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    HttpRequest request = (HttpRequest) msg;
    if (HttpUtil.is100ContinueExpected(request)) {
        ctx.write(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE));
    }
    // find the nettyHttpContextHandler by lookup the request url
    NettyHttpContextHandler nettyHttpContextHandler = pipelineFactory.getNettyHttpHandler(request.uri());
    if (nettyHttpContextHandler != null) {
        handleHttpServletRequest(ctx, request, nettyHttpContextHandler);
    } else {
        throw new RuntimeException(new Fault(new Message("NO_NETTY_SERVLET_HANDLER_FOUND", LOG, request.uri())));
    }
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) Message(org.apache.cxf.common.i18n.Message) DefaultHttpResponse(io.netty.handler.codec.http.DefaultHttpResponse) Fault(org.apache.cxf.interceptor.Fault)

Example 74 with Message

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

the class WSPolicyFeature method resolveReference.

Policy resolveReference(PolicyReference ref, PolicyBuilder builder, Bus bus, DescriptionInfo i) {
    final Policy p;
    if (!ref.getURI().startsWith("#")) {
        String base = i == null ? null : i.getBaseURI();
        p = resolveExternal(ref, base, bus);
    } else {
        p = resolveLocal(ref, bus, i);
    }
    if (null == p) {
        throw new PolicyException(new Message("UNRESOLVED_POLICY_REFERENCE_EXC", BUNDLE, ref.getURI()));
    }
    return p;
}
Also used : Policy(org.apache.neethi.Policy) Message(org.apache.cxf.common.i18n.Message)

Example 75 with Message

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

the class AbstractTokenInterceptor method policyNotAsserted.

protected void policyNotAsserted(AbstractToken assertion, String reason, SoapMessage message) {
    if (assertion == null) {
        return;
    }
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    Collection<AssertionInfo> ais = aim.get(assertion.getName());
    if (ais != null) {
        for (AssertionInfo ai : ais) {
            if (ai.getAssertion() == assertion) {
                ai.setNotAsserted(reason);
            }
        }
    }
    if (!assertion.isOptional()) {
        throw new PolicyException(new Message(reason, LOG));
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.common.i18n.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) PolicyException(org.apache.cxf.ws.policy.PolicyException) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

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