org.apache.cxf.common.util.PropertyUtils Java Examples

The following examples show how to use org.apache.cxf.common.util.PropertyUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoapOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) {
    // Yes this is ugly, but it avoids us from having to implement any kind of caching strategy
    boolean wroteStart = PropertyUtils.isTrue(message.get(WROTE_ENVELOPE_START));
    if (!wroteStart) {
        writeSoapEnvelopeStart(message);

        OutputStream os = message.getContent(OutputStream.class);
        // Unless we're caching the whole message in memory skip the envelope writing
        // if there's a fault later.
        if (!(os instanceof WriteOnCloseOutputStream) && !MessageUtils.isDOMPresent(message)) {
            message.put(WROTE_ENVELOPE_START, Boolean.TRUE);
        }
    }

    String cte = (String)message.get("soap.attachement.content.transfer.encoding");
    if (cte != null) {
        message.put(Message.CONTENT_TRANSFER_ENCODING, cte);
    }
    // Add a final interceptor to write end elements
    message.getInterceptorChain().add(new SoapOutEndingInterceptor());
}
 
Example #2
Source File: FormattedServiceListWriter.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static void writeApiSpec(String absoluteURL, Bus sb, PrintWriter writer,
        String specPath, String specName) {
    if (PropertyUtils.isTrue(sb.getProperty("swagger.service.ui.available"))) {
        URI uri = URI.create(absoluteURL);
        String schemePath = uri.getScheme() + "://" + uri.getHost()
            + (uri.getPort() == -1 ? "" : ":" + uri.getPort());
        String relPath = absoluteURL.substring(schemePath.length());
        if (!relPath.endsWith("/")) {
            relPath += "/";
        }
        specPath = "api-docs?url=" + relPath + specPath;
    }
    if (!absoluteURL.endsWith("/")) {
        specPath = "/" + specPath;
    }
    specPath = StringEscapeUtils.escapeHtml4(specPath);
    writer.write("<br/><span class=\"field\">" + specName + " :</span> " + "<a href=\"" + absoluteURL
             + specPath + "\">" + absoluteURL + specPath + "</a>");
}
 
Example #3
Source File: OSGiBeanLocator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private <T> List<T> getBeansFromOsgiService(Class<T> type) {
    List<T> list = new ArrayList<>();
    try {
        ServiceReference<?>[] refs = context.getServiceReferences(type.getName(), null);
        if (refs != null) {
            for (ServiceReference<?> r : refs) {
                if (type == ClassLoader.class
                    && checkCompatibleLocators
                    && !PropertyUtils.isTrue(r.getProperty(COMPATIBLE_LOCATOR_PROP))) {
                    continue;
                }
                list.add(type.cast(context.getService(r)));
            }
        }
    } catch (Exception ex) {
        //ignore, just don't support the OSGi services
        LOG.info("Tried to find the Bean with type:" + type
            + " from OSGi services and get error: " + ex);
    }
    return list;
}
 
Example #4
Source File: ProviderFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected static void initFactory(ProviderFactory factory) {
    // ensure to not load providers not available in a module environment if not needed
    factory.setProviders(false,
                         false,
                 new BinaryDataProvider<Object>(),
                 new SourceProvider<Object>(),
                 DATA_SOURCE_PROVIDER_CLASS.tryCreateInstance(factory.getBus()),
                 new FormEncodingProvider<Object>(),
                 new StringTextProvider(),
                 new PrimitiveTextProvider<Object>(),
                 JAXB_PROVIDER_CLASS.tryCreateInstance(factory.getBus()),
                 JAXB_ELEMENT_PROVIDER_CLASS.tryCreateInstance(factory.getBus()),
                 MULTIPART_PROVIDER_CLASS.tryCreateInstance(factory.getBus()));
    Object prop = factory.getBus().getProperty("skip.default.json.provider.registration");
    if (!PropertyUtils.isTrue(prop)) {
        factory.setProviders(false, false, createProvider(JSON_PROVIDER_NAME, factory.getBus()));
    }
}
 
Example #5
Source File: AbstractHTTPDestination.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param b the associated Bus
 * @param registry the destination registry
 * @param ei the endpoint info of the destination
 * @param path the path
 * @param dp true for adding the default port if it is missing
 * @throws IOException
 */
public AbstractHTTPDestination(Bus b,
                               DestinationRegistry registry,
                               EndpointInfo ei,
                               String path,
                               boolean dp)
    throws IOException {
    super(b, getTargetReference(getAddressValue(ei, dp), b), ei);
    this.bus = b;
    this.registry = registry;
    this.path = path;
    try {
        ServletRequest.class.getMethod("isAsyncSupported");
        isServlet3 = true;
    } catch (Throwable t) {
        //servlet 2.5 or earlier, no async support
    }
    decodeBasicAuthWithIso8859 = PropertyUtils.isTrue(bus.getProperty(DECODE_BASIC_AUTH_WITH_ISO8859));

    initConfig();
}
 
Example #6
Source File: FailoverTargetSelector.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Check if the exchange is suitable for a failover.
 *
 * @param exchange the current Exchange
 * @return boolean true if a failover should be attempted
 */
protected boolean requiresFailover(Exchange exchange, Exception ex) {
    getLogger().log(Level.FINE,
                    "CHECK_LAST_INVOKE_FAILED",
                    new Object[] {ex != null});
    Throwable curr = ex;
    boolean failover = false;
    while (curr != null) {
        failover = curr instanceof java.io.IOException;
        curr = curr.getCause();
    }
    if (ex != null) {
        getLogger().log(Level.INFO,
                        "CHECK_FAILURE_IN_TRANSPORT",
                        new Object[] {ex, failover});
    }

    if (isSupportNotAvailableErrorsOnly() && exchange.get(Message.RESPONSE_CODE) != null) {
        failover = PropertyUtils.isTrue(exchange.get("org.apache.cxf.transport.service_not_available"));
    }

    return failover;
}
 
Example #7
Source File: AbstractClient.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void checkClientException(Message outMessage, Exception ex) throws Exception {
    Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex;

    Exchange exchange = outMessage.getExchange();
    Integer responseCode = getResponseCode(exchange);
    if (actualEx instanceof ResponseProcessingException) {
        throw (ResponseProcessingException)actualEx;
    } else if (responseCode == null
        || responseCode < 300 && !(actualEx instanceof IOException)
        || actualEx instanceof IOException && exchange.get("client.redirect.exception") != null) {
        if (actualEx instanceof ProcessingException) {
            throw (RuntimeException)actualEx;
        } else if (actualEx != null) {
            Object useProcExProp = exchange.get("wrap.in.processing.exception");
            if (actualEx instanceof RuntimeException
                && useProcExProp != null && PropertyUtils.isFalse(useProcExProp)) {
                throw (Exception)actualEx;
            }
            throw new ProcessingException(actualEx);
        } else if (!exchange.isOneWay() || cfg.isResponseExpectedForOneway()) {
            waitForResponseCode(exchange);
        }
    }
}
 
Example #8
Source File: JAXRSOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean checkBufferingMode(Message m, List<WriterInterceptor> writers, boolean firstTry) {
    if (!firstTry) {
        return false;
    }
    WriterInterceptor last = writers.get(writers.size() - 1);
    MessageBodyWriter<Object> w = ((WriterInterceptorMBW)last).getMBW();
    Object outBuf = m.getContextualProperty(OUT_BUFFERING);
    boolean enabled = PropertyUtils.isTrue(outBuf);
    boolean configurableProvider = w instanceof AbstractConfigurableProvider;
    if (!enabled && outBuf == null && configurableProvider) {
        enabled = ((AbstractConfigurableProvider)w).getEnableBuffering();
    }
    if (enabled) {
        boolean streamingOn = configurableProvider
            && ((AbstractConfigurableProvider)w).getEnableStreaming();
        if (streamingOn) {
            m.setContent(XMLStreamWriter.class, new CachingXmlEventWriter());
        } else {
            m.setContent(OutputStream.class, new CachedOutputStream());
        }
    }
    return enabled;
}
 
Example #9
Source File: HTTPConduit.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void handleHeadersTrustCaching() throws IOException {
    // Need to set the headers before the trust decision
    // because they are set before the connect().
    setProtocolHeaders();

    //
    // This point is where the trust decision is made because the
    // Sun implementation of URLConnection will not let us
    // set/addRequestProperty after a connect() call, and
    // makeTrustDecision needs to make a connect() call to
    // make sure the proper information is available.
    //
    makeTrustDecision();

    // Trust is okay, set up for writing the request.

    String method = getMethod();
    if (KNOWN_HTTP_VERBS_WITH_NO_CONTENT.contains(method)
        || PropertyUtils.isTrue(outMessage.get(Headers.EMPTY_REQUEST_PROPERTY))) {
        handleNoOutput();
        return;
    }
    setupWrappedStream();
}
 
Example #10
Source File: OAuthUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static Response handleException(MessageContext mc,
                                       Exception e,
                                       int status) {
    ResponseBuilder builder = Response.status(status);
    if (PropertyUtils.isTrue(mc.getContextualProperty(REPORT_FAILURE_DETAILS))) {
        boolean asHeader = PropertyUtils.isTrue(
            mc.getContextualProperty(REPORT_FAILURE_DETAILS_AS_HEADER));
        String text = null;
        if (e instanceof OAuthProblemException) {
            OAuthProblemException problem = (OAuthProblemException)e;
            if (asHeader && problem.getProblem() != null) {
                text = problem.getProblem();
            }
        }
        if (text == null) {
            text = e.getMessage();
        }
        if (asHeader) {
            builder.header("oauth_problem", text);
        } else {
            builder.entity(e.getMessage());
        }
    }
    return builder.build();
}
 
Example #11
Source File: AbstractConduitSelector.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Called on completion of the MEP for which the Conduit was required.
 *
 * @param exchange represents the completed MEP
 */
public void complete(Exchange exchange) {
    // Clients expecting explicit InputStream responses
    // will need to keep low level conduits operating on InputStreams open
    // and will be responsible for closing the streams

    if (PropertyUtils.isTrue(exchange.get(KEEP_CONDUIT_ALIVE))) {
        return;
    }
    try {
        if (exchange.getInMessage() != null) {
            Conduit c = exchange.getOutMessage().get(Conduit.class);
            if (c == null) {
                getSelectedConduit(exchange.getInMessage()).close(exchange.getInMessage());
            } else {
                c.close(exchange.getInMessage());
            }
        }
    } catch (IOException e) {
        //IGNORE
    }
}
 
Example #12
Source File: ClientImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void waitResponse(Exchange exchange) throws IOException {
    synchronized (exchange) {
        long remaining = synchronousTimeout;
        Long o = PropertyUtils.getLong(exchange.getOutMessage(), SYNC_TIMEOUT);
        if (o != null) {
            remaining = o;
        }
        while (!Boolean.TRUE.equals(exchange.get(FINISHED)) && remaining > 0) {
            long start = System.currentTimeMillis();
            try {
                exchange.wait(remaining);
            } catch (InterruptedException ex) {
                // ignore
            }
            long end = System.currentTimeMillis();
            remaining -= (int)(end - start);
        }
        if (!Boolean.TRUE.equals(exchange.get(FINISHED))) {
            LogUtils.log(LOG, Level.WARNING, "RESPONSE_TIMEOUT",
                exchange.getBindingOperationInfo().getOperationInfo().getName().toString());
            String msg = new org.apache.cxf.common.i18n.Message("RESPONSE_TIMEOUT", LOG, exchange
                .getBindingOperationInfo().getOperationInfo().getName().toString()).toString();
            throw new IOException(msg);
        }
    }
}
 
Example #13
Source File: AbstractSearchConditionParser.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected TypeInfo getTypeInfo(String setter, String value)
    throws SearchParseException, PropertyNotFoundException {

    String name = getSetter(setter);

    TypeInfo typeInfo = null;
    try {
        typeInfo = beanspector != null ? beanspector.getAccessorTypeInfo(name)
                : new TypeInfo(String.class, String.class);
    } catch (Exception e) {
        // continue
    }
    if (typeInfo == null && !PropertyUtils.isTrue(contextProperties.get(SearchUtils.LAX_PROPERTY_MATCH))) {
        throw new PropertyNotFoundException(name, value);
    }
    return typeInfo;
}
 
Example #14
Source File: SseEventSinkContextProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public SseEventSink createContext(Message message) {
    final HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
    if (request == null) {
        throw new IllegalStateException("Unable to retrieve HTTP request from the context");
    }

    final MessageBodyWriter<OutboundSseEvent> writer = new OutboundSseEventBodyWriter(
        ServerProviderFactory.getInstance(message), message.getExchange());

    final AsyncResponse async = new AsyncResponseImpl(message);
    final Integer bufferSize = PropertyUtils.getInteger(message, SseEventSinkImpl.BUFFER_SIZE_PROPERTY);
    
    final SseEventSink sink = createSseEventSink(request, writer, async, bufferSize);
    message.put(SseEventSink.class, sink);
    
    return sink;
}
 
Example #15
Source File: MultipartProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
private String getRootMediaType(Annotation[] anns, MediaType mt) {
    String mimeType = mt.getParameters().get("type");
    if (mimeType != null) {
        return mimeType;
    }
    Multipart id = AnnotationUtils.getAnnotation(anns, Multipart.class);
    if (id != null && !MediaType.WILDCARD.equals(id.type())) {
        mimeType = id.type();
    }
    if (mimeType == null) {
        if (PropertyUtils.isTrue(mc.getContextualProperty(Message.MTOM_ENABLED))) {
            mimeType = "text/xml";
        } else {
            mimeType = MediaType.APPLICATION_OCTET_STREAM;
        }
    }
    return mimeType;
}
 
Example #16
Source File: UndertowHTTPServerEngine.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean shouldEnableHttp2(Bus bus) {

        Object prop = null;
        if (bus != null) {
            prop = bus.getProperty(ENABLE_HTTP2_PROP);
        }
        if (prop == null) {
            prop = SystemPropertyAction.getPropertyOrNull(ENABLE_HTTP2_PROP);
        }
        return PropertyUtils.isTrue(prop);
    }
 
Example #17
Source File: OSGiBeanLocator.java    From cxf with Apache License 2.0 5 votes vote down vote up
public OSGiBeanLocator(ConfiguredBeanLocator c, BundleContext ctx) {
    cbl = c;
    context = ctx;

    Object checkProp = context.getProperty(COMPATIBLE_LOCATOR_PROP_CHECK);
    checkCompatibleLocators = checkProp == null || PropertyUtils.isTrue(checkProp);
}
 
Example #18
Source File: Servlet3ContinuationProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Servlet3Continuation() {
    req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
                     inMessage.getExchange().getInMessage());
    callback = inMessage.getExchange().get(ContinuationCallback.class);
    blockRestart = PropertyUtils.isTrue(inMessage.getContextualProperty(BLOCK_RESTART));
    context = req.startAsync();
    context.addListener(this);
}
 
Example #19
Source File: JettyHTTPServerEngine.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean shouldCheckUrl(Bus bus) {

        Object prop = null;
        if (bus != null) {
            prop = bus.getProperty(DO_NOT_CHECK_URL_PROP);
        }
        if (prop == null) {
            prop = SystemPropertyAction.getPropertyOrNull(DO_NOT_CHECK_URL_PROP);
        }
        return !PropertyUtils.isTrue(prop);
    }
 
Example #20
Source File: UndertowHTTPServerEngine.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean shouldCheckUrl(Bus bus) {

        Object prop = null;
        if (bus != null) {
            prop = bus.getProperty(DO_NOT_CHECK_URL_PROP);
        }
        if (prop == null) {
            prop = SystemPropertyAction.getPropertyOrNull(DO_NOT_CHECK_URL_PROP);
        }
        return !PropertyUtils.isTrue(prop);
    }
 
Example #21
Source File: Headers.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Set content type and protocol headers (Message.PROTOCOL_HEADERS) headers into the URL
 * connection.
 * Note, this does not mean they immediately get written to the output
 * stream or the wire. They just just get set on the HTTP request.
 *
 * @param connection
 * @throws IOException
 */
public void setProtocolHeadersInConnection(HttpURLConnection connection) throws IOException {
    // If no Content-Type is set for empty requests then HttpUrlConnection:
    // - sets a form Content-Type for empty POST
    // - replaces custom Accept value with */* if HTTP proxy is used
    boolean contentTypeSet = headers.containsKey(Message.CONTENT_TYPE);
    if (!contentTypeSet) {
        // if CT is not set then assume it has to be set by default
        boolean dropContentType = false;
        boolean getRequest = "GET".equals(message.get(Message.HTTP_REQUEST_METHOD));
        boolean emptyRequest = getRequest || PropertyUtils.isTrue(message.get(EMPTY_REQUEST_PROPERTY));
        // If it is an empty request (without a request body) then check further if CT still needs be set
        if (emptyRequest) {
            Object setCtForEmptyRequestProp = message.getContextualProperty(SET_EMPTY_REQUEST_CT_PROPERTY);
            if (setCtForEmptyRequestProp != null) {
                // If SET_EMPTY_REQUEST_CT_PROPERTY is set then do as a user prefers.
                // CT will be dropped if setting CT for empty requests was explicitly disabled
                dropContentType = PropertyUtils.isFalse(setCtForEmptyRequestProp);
            } else if (getRequest) {
                // otherwise if it is GET then just drop it
                dropContentType = true;
            }
        }
        if (!dropContentType) {
            String ct = emptyRequest && !contentTypeSet ? "*/*" : determineContentType();
            connection.setRequestProperty(HttpHeaderHelper.CONTENT_TYPE, ct);
        }
    } else {
        connection.setRequestProperty(HttpHeaderHelper.CONTENT_TYPE, determineContentType());
    }

    transferProtocolHeadersToURLConnection(connection);

    Map<String, List<Object>> theHeaders = CastUtils.cast(headers);
    logProtocolHeaders(LOG, Level.FINE, theHeaders, logSensitiveHeaders());
}
 
Example #22
Source File: MessageUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean getContextualBoolean(Message m, String key, boolean defaultValue) {
    if (m != null) {
        Object o = m.getContextualProperty(key);
        if (o != null) {
            return PropertyUtils.isTrue(o);
        }
    }
    return defaultValue;
}
 
Example #23
Source File: MicroProfileClientConfigurableImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
boolean isDefaultExceptionMapperDisabled() {
    Object prop = getConfiguration().getProperty(CONFIG_KEY_DISABLE_MAPPER);
    if (prop != null) {
        return PropertyUtils.isTrue(prop);
    }
    return ConfigFacade.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
                                         Boolean.class).orElse(false);
}
 
Example #24
Source File: FiqlParser.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Creates FIQL parser.
 *
 * @param tclass - class of T used to create condition objects in built syntax tree. Class T must have
 *            accessible no-arg constructor and complementary setters to these used in FIQL expressions.
 * @param contextProperties
 * @param beanProperties
 */
public FiqlParser(Class<T> tclass,
                  Map<String, String> contextProperties,
                  Map<String, String> beanProperties) {
    super(tclass, contextProperties, beanProperties);

    if (PropertyUtils.isTrue(this.contextProperties.get(SUPPORT_SINGLE_EQUALS))) {
        operatorsMap = new HashMap<>(operatorsMap);
        operatorsMap.put("=", ConditionType.EQUALS);
        comparatorsPattern = COMPARATORS_PATTERN_SINGLE_EQUALS;
    }
}
 
Example #25
Source File: ClientProxyImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Object handleResponse(Message outMessage, Class<?> serviceCls)
    throws Throwable {
    try {
        Response r = setResponseBuilder(outMessage, outMessage.getExchange()).build();
        ((ResponseImpl)r).setOutMessage(outMessage);
        getState().setResponse(r);

        Method method = outMessage.getExchange().get(Method.class);
        checkResponse(method, r, outMessage);
        if (method.getReturnType() == Void.class || method.getReturnType() == Void.TYPE) {
            return null;
        }
        if (method.getReturnType() == Response.class
            && (r.getEntity() == null || InputStream.class.isAssignableFrom(r.getEntity().getClass())
                && ((InputStream)r.getEntity()).available() == 0)) {
            return r;
        }
        if (PropertyUtils.isTrue(super.getConfiguration().getResponseContext().get(BUFFER_PROXY_RESPONSE))) {
            r.bufferEntity();
        }

        Class<?> returnType = getReturnType(method, outMessage);
        Type genericType = getGenericReturnType(serviceCls, method, returnType);
        
        returnType = InjectionUtils.updateParamClassToTypeIfNeeded(returnType, genericType);
        return readBody(r,
                        outMessage,
                        returnType,
                        genericType,
                        method.getDeclaredAnnotations());
    } finally {
        ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
    }
}
 
Example #26
Source File: AbstractClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Object[] preProcessResult(Message message) throws Exception {
    Exchange exchange = message.getExchange();

    Exception ex = message.getContent(Exception.class);
    if (ex == null) {
        ex = message.getExchange().get(Exception.class);
    }
    if (ex == null && !exchange.isOneWay()) {
        synchronized (exchange) {
            while (exchange.get("IN_CHAIN_COMPLETE") == null) {
                exchange.wait(cfg.getSynchronousTimeout());
            }
        }
    }
    if (ex == null) {
        ex = message.getContent(Exception.class);
    }
    if (ex != null
        || PropertyUtils.isTrue(exchange.get(SERVICE_NOT_AVAIL_PROPERTY))
            && PropertyUtils.isTrue(exchange.get(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY))) {
        getConfiguration().getConduitSelector().complete(exchange);
    }
    if (ex != null) {
        checkClientException(message, ex);
    }
    checkClientException(message, exchange.get(Exception.class));

    List<?> result = exchange.get(List.class);
    return result != null ? result.toArray() : null;
}
 
Example #27
Source File: WebClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setWebClientOperationProperty(Message m, String httpMethod) {
    Object prop = m.getContextualProperty(WEB_CLIENT_OPERATION_REPORTING);
    // Enable the operation reporting by default
    if (prop == null || PropertyUtils.isTrue(prop)) {
        UriBuilder absPathUri = super.getCurrentBuilder().clone();
        absPathUri.replaceQuery(null);
        setPlainOperationNameProperty(m, httpMethod + ":" + absPathUri.build().toString());
    }

}
 
Example #28
Source File: OpenApiFeature.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Boolean getOrFallback(Boolean value, Properties properties, String property) {
    Boolean fallback = value;
    if (value == null && properties != null) {
        fallback = PropertyUtils.isTrue(properties.get(PRETTY_PRINT_PROPERTY));
    }

    if (fallback == null) {
        return false;
    }

    return fallback;
}
 
Example #29
Source File: RestClientBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setFollowRedirects(CxfTypeSafeClientBuilder builder) {
    ConfigFacade.getOptionalValue(REST_FOLLOW_REDIRECTS_FORMAT, clientInterface, String.class).ifPresent(
        follows -> {
            builder.followRedirects(PropertyUtils.isTrue(follows));
            if (LOG.isLoggable(Level.FINEST)) {
                LOG.finest("followRedirect set by MP Config: " + follows);
            }
        });
}
 
Example #30
Source File: SwaggerUiSupport.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Checks the Swagger properties to determine if Swagger UI support is available or not.
 * @param props Swagger properties (usually externalized) 
 * @return
 */
default boolean checkSupportSwaggerUiProp(Properties props) {
    Boolean theSupportSwaggerUI = isSupportSwaggerUi();
    if (theSupportSwaggerUI == null && props != null && props.containsKey(SUPPORT_UI_PROPERTY)) {
        theSupportSwaggerUI = PropertyUtils.isTrue(props.get(SUPPORT_UI_PROPERTY));
    }
    if (theSupportSwaggerUI == null) {
        theSupportSwaggerUI = true;
    }
    return theSupportSwaggerUI;
}